source upload
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
TTimeLog Vizualizer for Delphi IDE debugger
|
||||
===========================================
|
||||
|
||||
By TPrami.
|
||||
|
||||
# Presentation
|
||||
|
||||
It'll visualize
|
||||
* TTimeLog
|
||||
* TModTime
|
||||
* TCreateTime
|
||||
|
||||
C++ support isn't there (Just code structure to write the Support later).
|
||||
|
||||
Helped me to track some bugs in my project.
|
||||
|
||||
-Tee-
|
||||
|
||||
# Installation
|
||||
|
||||
Ensure your *mORMot* source code folders is in your general IDE settings, or add them in package `mORMotDebuggerVisualizer.dpk`, compile and install.
|
||||
|
||||
# Forum Thread
|
||||
|
||||
See http://synopse.info/forum/viewtopic.php?id=2642
|
||||
|
||||
# License
|
||||
|
||||
Feel free to use and/or append to Lib and extend if needed.
|
@@ -0,0 +1,143 @@
|
||||
unit TimeLogVisualizer;
|
||||
|
||||
// http://edn.embarcadero.com/article/40268
|
||||
|
||||
interface
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
{ Standard Stuff }
|
||||
System.SysUtils, System.DateUtils, SysTem.Math,
|
||||
{ OTA }
|
||||
ToolsAPI,
|
||||
{ mORMot }
|
||||
SynCommons;
|
||||
|
||||
|
||||
type
|
||||
TTimeLogVisualizer = class(TInterfacedObject, IOTADebuggerVisualizer, IOTADebuggerVisualizerValueReplacer)
|
||||
public
|
||||
function GetReplacementValue(const Expression: string; const TypeName: string; const EvalResult: string): string;
|
||||
procedure GetSupportedType(Index: Integer; var TypeName: string; var AllDescendents: Boolean);
|
||||
function GetSupportedTypeCount: Integer;
|
||||
function GetVisualizerDescription: string;
|
||||
function GetVisualizerIdentifier: string;
|
||||
function GetVisualizerName: string;
|
||||
end;
|
||||
|
||||
|
||||
type
|
||||
TTypeLang = (tlDelphi, tlCpp);
|
||||
|
||||
TDateTimeVisualizerType = record
|
||||
TypeName: string;
|
||||
TypeLang: TTypeLang;
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
// If later need CPP support
|
||||
TimeLogVisualizerTypes: array[0..5] of TDateTimeVisualizerType =
|
||||
(
|
||||
(TypeName: 'TTimeLog'; TypeLang: tlDelphi),
|
||||
(TypeName: 'TModTime'; TypeLang: tlDelphi),
|
||||
(TypeName: 'TCreateTime'; TypeLang: tlDelphi),
|
||||
(TypeName: 'function: TTimeLog'; TypeLang: tlDelphi),
|
||||
(TypeName: 'function: TModTime'; TypeLang: tlDelphi),
|
||||
(TypeName: 'function: TCreateTime'; TypeLang: tlDelphi)
|
||||
);
|
||||
|
||||
|
||||
{ TTimeLogVisualizer }
|
||||
|
||||
function TTimeLogVisualizer.GetReplacementValue(const Expression, TypeName, EvalResult: string): string;
|
||||
var
|
||||
I : Integer;
|
||||
LLang: TTypeLang;
|
||||
LValue: TTimeLog;
|
||||
LDateTime: TDateTime;
|
||||
begin
|
||||
LLang := TTypeLang(-1);
|
||||
for I := Low(TimeLogVisualizerTypes) to High(TimeLogVisualizerTypes) do
|
||||
begin
|
||||
if TypeName = TimeLogVisualizerTypes[I].TypeName then
|
||||
begin
|
||||
LLang := TimeLogVisualizerTypes[I].TypeLang;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
||||
if LLang = tlDelphi then
|
||||
begin
|
||||
LValue := StrToInt64Def(EvalResult, 0);
|
||||
|
||||
LDateTime := PTimeLogBits(@LValue)^.ToDateTime;
|
||||
|
||||
// Only time
|
||||
if IsZero(Trunc(LDateTime)) then
|
||||
Result := TimeToStr(LDateTime)
|
||||
else if not IsZero(LDateTime) then
|
||||
Result := DateTimeToStr(LDateTime);
|
||||
end
|
||||
else if LLang = tlCpp then
|
||||
begin
|
||||
Result := EvalResult;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTimeLogVisualizer.GetSupportedType(Index: Integer; var TypeName: string; var AllDescendents: Boolean);
|
||||
begin
|
||||
AllDescendents := False;
|
||||
TypeName := TimeLogVisualizerTypes[Index].TypeName;
|
||||
end;
|
||||
|
||||
function TTimeLogVisualizer.GetSupportedTypeCount: Integer;
|
||||
begin
|
||||
Result := Length(TimeLogVisualizerTypes);
|
||||
end;
|
||||
|
||||
function TTimeLogVisualizer.GetVisualizerDescription: string;
|
||||
begin
|
||||
Result := 'Shows mORMot proprietary TTimeLog Date/Time format in humanreadable format';
|
||||
end;
|
||||
|
||||
function TTimeLogVisualizer.GetVisualizerIdentifier: string;
|
||||
begin
|
||||
Result := ClassName;
|
||||
end;
|
||||
|
||||
function TTimeLogVisualizer.GetVisualizerName: string;
|
||||
begin
|
||||
Result := 'mORMot TTimeLog visualizer';
|
||||
end;
|
||||
|
||||
var
|
||||
TimeLogVis: IOTADebuggerVisualizer;
|
||||
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
TimeLogVis := TTimeLogVisualizer.Create;
|
||||
(BorlandIDEServices as IOTADebuggerServices).RegisterDebugVisualizer(TimeLogVis);
|
||||
end;
|
||||
|
||||
procedure RemoveVisualizer;
|
||||
var
|
||||
DebuggerServices: IOTADebuggerServices;
|
||||
begin
|
||||
if Supports(BorlandIDEServices, IOTADebuggerServices, DebuggerServices) then
|
||||
begin
|
||||
DebuggerServices.UnregisterDebugVisualizer(TimeLogVis);
|
||||
TimeLogVis := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
finalization
|
||||
RemoveVisualizer;
|
||||
|
||||
end.
|
@@ -0,0 +1,14 @@
|
||||
program mORMotDebugVisualizerTestAppdproj;
|
||||
|
||||
uses
|
||||
Vcl.Forms,
|
||||
mORMotVisualizerTesterMainForm in 'mORMotVisualizerTesterMainForm.pas' {MainForm};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.MainFormOnTaskbar := True;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
@@ -0,0 +1,38 @@
|
||||
package mORMotDebuggerVisualizer;
|
||||
|
||||
{$R *.res}
|
||||
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
|
||||
{$ALIGN 8}
|
||||
{$ASSERTIONS ON}
|
||||
{$BOOLEVAL OFF}
|
||||
{$DEBUGINFO OFF}
|
||||
{$EXTENDEDSYNTAX ON}
|
||||
{$IMPORTEDDATA ON}
|
||||
{$IOCHECKS ON}
|
||||
{$LOCALSYMBOLS ON}
|
||||
{$LONGSTRINGS ON}
|
||||
{$OPENSTRINGS ON}
|
||||
{$OPTIMIZATION OFF}
|
||||
{$OVERFLOWCHECKS OFF}
|
||||
{$RANGECHECKS OFF}
|
||||
{$REFERENCEINFO ON}
|
||||
{$SAFEDIVIDE OFF}
|
||||
{$STACKFRAMES ON}
|
||||
{$TYPEDADDRESS OFF}
|
||||
{$VARSTRINGCHECKS ON}
|
||||
{$WRITEABLECONST OFF}
|
||||
{$MINENUMSIZE 1}
|
||||
{$IMAGEBASE $400000}
|
||||
{$DEFINE DEBUG}
|
||||
{$ENDIF IMPLICITBUILDING}
|
||||
{$IMPLICITBUILD ON}
|
||||
|
||||
requires
|
||||
rtl,
|
||||
designide;
|
||||
|
||||
contains
|
||||
TimeLogVisualizer in 'TimeLogVisualizer.pas';
|
||||
|
||||
end.
|
||||
|
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'mORMot Debug Vizualizer Test app'
|
||||
ClientHeight = 165
|
||||
ClientWidth = 291
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object Button1: TButton
|
||||
Left = 25
|
||||
Top = 20
|
||||
Width = 230
|
||||
Height = 25
|
||||
Caption = 'Button1'
|
||||
TabOrder = 0
|
||||
OnClick = Button1Click
|
||||
end
|
||||
end
|
@@ -0,0 +1,49 @@
|
||||
unit mORMotVisualizerTesterMainForm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils,
|
||||
System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
|
||||
|
||||
type
|
||||
TMainForm = class(TForm)
|
||||
Button1: TButton;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
uses
|
||||
{ mORMot }
|
||||
SynCommons;
|
||||
|
||||
procedure TMainForm.Button1Click(Sender: TObject);
|
||||
var
|
||||
LTimeLog: TTimeLog;
|
||||
LTempTimeLog: TTimeLog;
|
||||
begin
|
||||
PTimeLogBits(@LTimeLog)^.From(0, 0, 0, 0, 0, 0);
|
||||
LTempTimeLog := LTimeLog;
|
||||
|
||||
PTimeLogBits(@LTimeLog)^.From(1991, 12, 19, 19, 19, 19);
|
||||
LTempTimeLog := LTimeLog;
|
||||
|
||||
PTimeLogBits(@LTimeLog)^.From(1991, 12, 19, 0, 0, 0);
|
||||
LTempTimeLog := LTimeLog;
|
||||
|
||||
PTimeLogBits(@LTimeLog)^.From(0, 0, 0, 19, 19, 19);
|
||||
LTempTimeLog := LTimeLog;
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user