mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 12:29:08 +02:00
* Some small additions to restbase (ArrayArray) and code gen (logging)
git-svn-id: trunk@30827 -
This commit is contained in:
parent
b83ff7dd27
commit
b9c0acc99d
@ -24,12 +24,15 @@ uses
|
||||
Type
|
||||
ERESTAPI = Class(Exception);
|
||||
TStringArray = Array of string;
|
||||
TStringArrayArray = Array of TStringArray;
|
||||
TUnicodeStringArray = Array of UnicodeString;
|
||||
TIntegerArray = Array of Integer;
|
||||
TInt64Array = Array of Int64;
|
||||
TInt32Array = Array of Integer;
|
||||
TFloatArray = Array of TJSONFloat;
|
||||
TFloatArrayArray = Array of TFloatArray;
|
||||
TDoubleArray = Array of TJSONFloat;
|
||||
TDoubleArrayArray = Array of TDoubleArray;
|
||||
TDateTimeArray = Array of TDateTime;
|
||||
TBooleanArray = Array of boolean;
|
||||
TChildType = (ctArray,ctObject);
|
||||
@ -115,6 +118,7 @@ Type
|
||||
end;
|
||||
TBaseObjectClass = Class of TBaseObject;
|
||||
TObjectArray = Array of TBaseObject;
|
||||
TObjectArrayArray = Array of TObjectArray;
|
||||
|
||||
{ TBaseObjectList }
|
||||
|
||||
|
@ -22,20 +22,26 @@ uses
|
||||
Classes, SysUtils;
|
||||
|
||||
Type
|
||||
|
||||
TCodegenLogType = (cltInfo);
|
||||
TCodegenLogTypes = Set of TCodegenLogType;
|
||||
TCodeGeneratorLogEvent = Procedure (Sender : TObject; LogType : TCodegenLogType; Const Msg : String) of object;
|
||||
{ TRestCodeGenerator }
|
||||
|
||||
TRestCodeGenerator = Class(TComponent)
|
||||
Private
|
||||
FAddTimeStamp: Boolean;
|
||||
FBaseClassName: String;
|
||||
FClassPrefix: String;
|
||||
FExtraUnits: String;
|
||||
FLicenseText: TStrings;
|
||||
FOnLog: TCodeGeneratorLogEvent;
|
||||
FOutputUnitName: String;
|
||||
FSource : TStrings;
|
||||
Findent : String;
|
||||
Protected
|
||||
// Source manipulation
|
||||
Procedure DoLog(Const Msg : String; AType : TCodegenLogType = cltInfo);
|
||||
Procedure DoLog(Const Fmt : String; Args : Array of const; AType : TCodegenLogType = cltInfo);
|
||||
Procedure CreateHeader; virtual;
|
||||
Procedure IncIndent;
|
||||
Procedure DecIndent;
|
||||
@ -66,6 +72,8 @@ Type
|
||||
Property ExtraUnits : String Read FExtraUnits Write FExtraUnits;
|
||||
Property ClassPrefix : String Read FClassPrefix Write FClassPrefix;
|
||||
Property LicenseText : TStrings Read FLicenseText;
|
||||
Property OnLog : TCodeGeneratorLogEvent Read FOnLog Write FOnlog;
|
||||
Property AddTimeStamp : Boolean Read FAddTimeStamp Write FAddTimeStamp;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -203,6 +211,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRestCodeGenerator.DoLog(const Msg: String; AType: TCodegenLogType);
|
||||
begin
|
||||
If Assigned(FOnLog) then
|
||||
FOnLog(Self,Atype,Msg);
|
||||
end;
|
||||
|
||||
procedure TRestCodeGenerator.DoLog(const Fmt: String; Args: array of const;
|
||||
AType: TCodegenLogType);
|
||||
begin
|
||||
DoLog(Format(Fmt,Args),AType);
|
||||
end;
|
||||
|
||||
procedure TRestCodeGenerator.CreateHeader;
|
||||
|
||||
Var
|
||||
@ -211,6 +231,8 @@ Var
|
||||
begin
|
||||
if LicenseText.Count>0 then
|
||||
Comment(LicenseText);
|
||||
if AddTimeStamp then
|
||||
Comment('Generated on: '+DateTimeToStr(Now));
|
||||
addln('{$MODE objfpc}');
|
||||
addln('{$H+}');
|
||||
addln('');
|
||||
|
Loading…
Reference in New Issue
Block a user