Skip to content

Commit 7e96130

Browse files
committed
Fix two TStream issues: 1) It's not abstract anymore. Don't know since when exactly but at least in Sidney it's not abstract. 2) Read/Write(Buffer) prototype is bad and very impractical on Unicode. Make it like it really is: they accept a var of any type and this can be done in PS by using 'const' as the type and still _not_ using 'var'. Tested it to work unchanged when a string type is used in the call anyway. Also note this fix has no runtime changes so it's not surprising that it still works.
1 parent 405f27a commit 7e96130

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Source/uPSC_classes.pas

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,20 @@ procedure SIRegisterTSTREAM(Cl: TPSPascalCompiler);
134134
begin
135135
with Cl.AddClassN(cl.FindClass('TObject'), 'TStream') do
136136
begin
137+
{$IFNDEF DELPHI_SYDNEY_UP}
137138
IsAbstract := True;
138-
RegisterMethod('function Read(Buffer: string; Count: LongInt): LongInt');
139-
RegisterMethod('function Write(Buffer: string; Count: LongInt): LongInt');
139+
{$ENDIF}
140+
RegisterMethod('function Read(Buffer: const; Count: LongInt): LongInt');
141+
RegisterMethod('function Write(Buffer: const; Count: LongInt): LongInt');
140142
{$IFDEF DELPHI_TOKYO_UP}
141143
{$IFNDEF PS_NOINT64}
142144
RegisterMethod('function Seek(Offset: Int64; Origin: Word): Int64');
143145
{$ENDIF}
144146
{$ELSE}
145147
RegisterMethod('function Seek(Offset: LongInt; Origin: Word): LongInt');
146148
{$ENDIF}
147-
RegisterMethod('procedure ReadBuffer(Buffer: string; Count: LongInt)');
148-
RegisterMethod('procedure WriteBuffer(Buffer: string; Count: LongInt)');
149+
RegisterMethod('procedure ReadBuffer(Buffer: const; Count: LongInt)');
150+
RegisterMethod('procedure WriteBuffer(Buffer: const; Count: LongInt)');
149151
{$IFDEF DELPHI4UP}
150152
{$IFNDEF PS_NOINT64}
151153
RegisterMethod('function CopyFrom(Source: TStream; Count: Int64): Int64');

Source/uPSR_classes.pas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,15 @@ procedure RIRegisterTSTREAM(Cl: TPSRuntimeClassImporter);
624624
begin
625625
with Cl.Add(TSTREAM) do
626626
begin
627+
{$IFNDEF DELPHI_SYDNEY_UP}
627628
RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.READ, 'Read');
628629
RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.WRITE, 'Write');
629630
RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.SEEK, 'Seek');
631+
{$ELSE}
632+
RegisterVirtualMethod(@TStream.READ, 'Read');
633+
RegisterVirtualMethod(@TStream.WRITE, 'Write');
634+
RegisterVirtualMethod(@TStream.SEEK, 'Seek');
635+
{$ENDIF}
630636
RegisterMethod(@TSTREAM.READBUFFER, 'ReadBuffer');
631637
RegisterMethod(@TSTREAM.WRITEBUFFER, 'WriteBuffer');
632638
RegisterMethod(@TSTREAM.COPYFROM, 'CopyFrom');

0 commit comments

Comments
 (0)