Add TStringStream and TStrings.ValueFromIndex.

This commit is contained in:
Martijn Laan 2014-07-08 15:47:14 +02:00
parent 5e9416fd41
commit 0f3d4a14d0
2 changed files with 31 additions and 0 deletions

View File

@ -27,6 +27,7 @@ procedure SIRegisterTHANDLESTREAM(Cl: TPSPascalCompiler);
procedure SIRegisterTMEMORYSTREAM(Cl: TPSPascalCompiler);
{$ENDIF}
procedure SIRegisterTFILESTREAM(Cl: TPSPascalCompiler);
procedure SIRegisterTSTRINGSTREAM(Cl: TPSPascalCompiler);
{$IFNDEF PS_MINIVCL}
procedure SIRegisterTCUSTOMMEMORYSTREAM(Cl: TPSPascalCompiler);
procedure SIRegisterTRESOURCESTREAM(Cl: TPSPascalCompiler);
@ -83,6 +84,7 @@ begin
RegisterMethod('procedure SetText(Text: PChar); ');
RegisterProperty('Names', 'String Integer', iptr);
RegisterProperty('Values', 'String String', iptRW);
RegisterProperty('ValueFromIndex', 'String Integer', iptRW);
RegisterMethod('function AddObject(S:String;AObject:TObject):integer');
RegisterMethod('function GetText:PChar');
RegisterMethod('function IndexofObject(AObject:tObject):Integer');
@ -171,6 +173,14 @@ begin
end;
end;
procedure SIRegisterTSTRINGSTREAM(Cl: TPSPascalCompiler);
begin
with Cl.AddClassN(cl.FindClass('TSTREAM'), 'TSTRINGSTREAM') do
begin
RegisterMethod('constructor CREATE(ASTRING:STRING)');
end;
end;
{$IFNDEF PS_MINIVCL}
procedure SIRegisterTCUSTOMMEMORYSTREAM(Cl: TPSPascalCompiler);
begin
@ -306,6 +316,7 @@ begin
begin
SIRegisterTHANDLESTREAM(Cl);
SIRegisterTFILESTREAM(Cl);
SIRegisterTSTRINGSTREAM(Cl);
{$IFNDEF PS_MINIVCL}
SIRegisterTCUSTOMMEMORYSTREAM(Cl);
SIRegisterTMEMORYSTREAM(Cl);

View File

@ -15,6 +15,7 @@ procedure RIRegisterTBITS(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTSTREAM(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTHANDLESTREAM(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTFILESTREAM(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTSTRINGSTREAM(Cl: TPSRuntimeClassImporter);
{$IFNDEF PS_MINIVCL}
procedure RIRegisterTCUSTOMMEMORYSTREAM(Cl: TPSRuntimeClassImporter);
procedure RIRegisterTMEMORYSTREAM(Cl: TPSRuntimeClassImporter);
@ -72,6 +73,15 @@ begin
Self.Values[I]:= T;
end;
procedure TStringsValueFromIndexR(Self: TStrings; var T: string; const I: Longint);
begin
T := Self.ValueFromIndex[I];
end;
procedure TStringsValueFromIndexW(Self: TStrings; Const T: String; I: Longint);
begin
Self.ValueFromIndex[I]:= T;
end;
procedure RIRegisterTStrings(cl: TPSRuntimeClassImporter; Streams: Boolean); // requires TPersistent
begin
with Cl.Add(TStrings) do
@ -112,6 +122,7 @@ begin
RegisterVirtualMethod(@TStrings.SetText, 'SETTEXT');
RegisterPropertyHelper(@TStringsNamesR, nil, 'NAMES');
RegisterPropertyHelper(@TStringsValuesR, @TStringsValuesW, 'VALUES');
RegisterPropertyHelper(@TStringsValueFromIndexR, @TStringsValueFromIndexW, 'VALUEFROMINDEX');
RegisterVirtualMethod(@TSTRINGS.ADDOBJECT, 'ADDOBJECT');
RegisterVirtualMethod(@TSTRINGS.GETTEXT, 'GETTEXT');
RegisterMethod(@TSTRINGS.INDEXOFOBJECT, 'INDEXOFOBJECT');
@ -224,6 +235,14 @@ begin
end;
end;
procedure RIRegisterTSTRINGSTREAM(Cl: TPSRuntimeClassImporter);
begin
with Cl.Add(TSTRINGSTREAM) do
begin
RegisterConstructor(@TSTRINGSTREAM.CREATE, 'CREATE');
end;
end;
{$IFNDEF PS_MINIVCL}
procedure RIRegisterTCUSTOMMEMORYSTREAM(Cl: TPSRuntimeClassImporter);
begin
@ -375,6 +394,7 @@ begin
begin
RIRegisterTHANDLESTREAM(Cl);
RIRegisterTFILESTREAM(Cl);
RIRegisterTSTRINGSTREAM(Cl);
{$IFNDEF PS_MINIVCL}
RIRegisterTCUSTOMMEMORYSTREAM(Cl);
RIRegisterTMEMORYSTREAM(Cl);