FScript.AddRegisteredPTRVariable('FObjects', 'TObjectList<TObject>');
or
FScript.AddRegisteredPTRVariable('TheComponents', 'TList<string>');
I get "Invalid type for variable “XXXXXXX”.
Is it possible?
FScript.AddRegisteredPTRVariable('FObjects', 'TObjectList<TObject>');
or
FScript.AddRegisteredPTRVariable('TheComponents', 'TList<string>');
I get "Invalid type for variable “XXXXXXX”.
Is it possible?
No. Generics are not supported in Pascalscript.
I worried about the Generics.
Do you think that this alternative structure y going to be possible?
Is a very simple class and a list of Objects of this class.
Thanks!
TConfigCompProps = class(TObject)
CD_COMPONENT :string;
DS_COMPONENT :string;
QTY_QUANTITY :Double;
FRONT :Integer;
DEPTH :Integer;
THICK :Integer;
CD_COLOR :string;
PACKAGE :Integer;
PROGRAM_ID :String;
PRI_UNIT :Double;
EXPLANATION :string;
end;
TConfigCompsList = class(TObjectList)
private
protected
procedure SetObject(Index :Integer; Item: TConfigCompProps);
function GetObject(Index :Integer):TConfigCompProps;
public
constructor Create; overload;
function Add(Obj :TConfigCompProps):Integer; overload;
procedure Insert(Index :Integer; Obj :TConfigCompProps);
property Controllers[Index :Integer]:TConfigCompProps read GetObject write SetObject; default;
end;
Should be fine.
I can’t compile the imp.exe because it need SynEdit and, this last, still don’t have a compilable version for DX10.
Any way, I’ve tried to compile CIMP, but it has a bug, that I think that is too a problem with the Delphi Version.
I’m trying of register this classes manually, with the example of TStringList registering methos, but, I have a lot of problems.
Do you know an example of Registering, manually a single object, like TConfigCompProps?
Well TStringList comes pretty close? You register a class like:
procedure SIRegisterTSTRINGLIST(Cl: TPSPascalCompiler);
begin
with Cl.AddClassN(cl.FindClass('TStrings'), 'TStringList') do
begin
{$IFDEF DELPHI2005UP}
RegisterMethod('constructor Create;');
{$ENDIF}
RegisterMethod('function Find(S: string; var Index: Integer): Boolean');
RegisterMethod('procedure Sort');
RegisterProperty('CaseSensitive', 'Boolean', iptrw);
RegisterProperty('Duplicates', 'TDuplicates', iptrw);
RegisterProperty('Sorted', 'Boolean', iptrw);
RegisterProperty('OnChange', 'TNotifyEvent', iptrw);
RegisterProperty('OnChanging', 'TNotifyEvent', iptrw);
end;
end;
then for the runtime end:
rocedure TSTRINGLISTCASESENSITIVE_R(Self: TSTRINGLIST; var T: BOOLEAN); begin T := Self.CASESENSITIVE; end;
procedure TSTRINGLISTCASESENSITIVE_W(Self: TSTRINGLIST; const T: BOOLEAN); begin Self.CASESENSITIVE := T; end;
procedure TSTRINGLISTDUPLICATES_R(Self: TSTRINGLIST; var T: TDUPLICATES); begin T := Self.DUPLICATES; end;
procedure TSTRINGLISTDUPLICATES_W(Self: TSTRINGLIST; const T: TDUPLICATES); begin Self.DUPLICATES := T; end;
procedure TSTRINGLISTSORTED_R(Self: TSTRINGLIST; var T: BOOLEAN); begin T := Self.SORTED; end;
procedure TSTRINGLISTSORTED_W(Self: TSTRINGLIST; const T: BOOLEAN); begin Self.SORTED := T; end;
procedure TSTRINGLISTONCHANGE_R(Self: TSTRINGLIST; var T: TNOTIFYEVENT);
begin
T := Self.ONCHANGE; end;
procedure TSTRINGLISTONCHANGE_W(Self: TSTRINGLIST; const T: TNOTIFYEVENT);
begin
Self.ONCHANGE := T; end;
procedure TSTRINGLISTONCHANGING_R(Self: TSTRINGLIST; var T: TNOTIFYEVENT); begin T := Self.ONCHANGING; end;
procedure TSTRINGLISTONCHANGING_W(Self: TSTRINGLIST; const T: TNOTIFYEVENT); begin Self.ONCHANGING := T; end;
procedure RIRegisterTSTRINGLIST(Cl: TPSRuntimeClassImporter);
begin
with Cl.Add(TSTRINGLIST) do
begin
{$IFDEF DELPHI2005UP}
RegisterConstructor(@TStringList.CREATE, 'Create');
{$ENDIF}
RegisterVirtualMethod(@TSTRINGLIST.FIND, 'Find');
RegisterVirtualMethod(@TSTRINGLIST.SORT, 'Sort');
RegisterPropertyHelper(@TSTRINGLISTCASESENSITIVE_R, @TSTRINGLISTCASESENSITIVE_W, 'CaseSensitive');
RegisterPropertyHelper(@TSTRINGLISTDUPLICATES_R, @TSTRINGLISTDUPLICATES_W, 'Duplicates');
RegisterPropertyHelper(@TSTRINGLISTSORTED_R, @TSTRINGLISTSORTED_W, 'Sorted');
RegisterEventPropertyHelper(@TSTRINGLISTONCHANGE_R, @TSTRINGLISTONCHANGE_W, 'OnChange');
RegisterEventPropertyHelper(@TSTRINGLISTONCHANGING_R, @TSTRINGLISTONCHANGING_W, 'OnChanging');
end;
end;
those helper methods are read/write accessors. you can do the same for fields.
Ok, but… when should I call the register procedures?