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.

This commit is contained in:
Martijn Laan 2024-05-15 16:35:17 +02:00
parent 405f27a381
commit 7e96130ba6
2 changed files with 12 additions and 4 deletions

View File

@ -134,9 +134,11 @@ procedure SIRegisterTSTREAM(Cl: TPSPascalCompiler);
begin begin
with Cl.AddClassN(cl.FindClass('TObject'), 'TStream') do with Cl.AddClassN(cl.FindClass('TObject'), 'TStream') do
begin begin
{$IFNDEF DELPHI_SYDNEY_UP}
IsAbstract := True; IsAbstract := True;
RegisterMethod('function Read(Buffer: string; Count: LongInt): LongInt'); {$ENDIF}
RegisterMethod('function Write(Buffer: string; Count: LongInt): LongInt'); RegisterMethod('function Read(Buffer: const; Count: LongInt): LongInt');
RegisterMethod('function Write(Buffer: const; Count: LongInt): LongInt');
{$IFDEF DELPHI_TOKYO_UP} {$IFDEF DELPHI_TOKYO_UP}
{$IFNDEF PS_NOINT64} {$IFNDEF PS_NOINT64}
RegisterMethod('function Seek(Offset: Int64; Origin: Word): Int64'); RegisterMethod('function Seek(Offset: Int64; Origin: Word): Int64');
@ -144,8 +146,8 @@ begin
{$ELSE} {$ELSE}
RegisterMethod('function Seek(Offset: LongInt; Origin: Word): LongInt'); RegisterMethod('function Seek(Offset: LongInt; Origin: Word): LongInt');
{$ENDIF} {$ENDIF}
RegisterMethod('procedure ReadBuffer(Buffer: string; Count: LongInt)'); RegisterMethod('procedure ReadBuffer(Buffer: const; Count: LongInt)');
RegisterMethod('procedure WriteBuffer(Buffer: string; Count: LongInt)'); RegisterMethod('procedure WriteBuffer(Buffer: const; Count: LongInt)');
{$IFDEF DELPHI4UP} {$IFDEF DELPHI4UP}
{$IFNDEF PS_NOINT64} {$IFNDEF PS_NOINT64}
RegisterMethod('function CopyFrom(Source: TStream; Count: Int64): Int64'); RegisterMethod('function CopyFrom(Source: TStream; Count: Int64): Int64');

View File

@ -624,9 +624,15 @@ procedure RIRegisterTSTREAM(Cl: TPSRuntimeClassImporter);
begin begin
with Cl.Add(TSTREAM) do with Cl.Add(TSTREAM) do
begin begin
{$IFNDEF DELPHI_SYDNEY_UP}
RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.READ, 'Read'); RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.READ, 'Read');
RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.WRITE, 'Write'); RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.WRITE, 'Write');
RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.SEEK, 'Seek'); RegisterVirtualAbstractMethod(TMemoryStream, @TMemoryStream.SEEK, 'Seek');
{$ELSE}
RegisterVirtualMethod(@TStream.READ, 'Read');
RegisterVirtualMethod(@TStream.WRITE, 'Write');
RegisterVirtualMethod(@TStream.SEEK, 'Seek');
{$ENDIF}
RegisterMethod(@TSTREAM.READBUFFER, 'ReadBuffer'); RegisterMethod(@TSTREAM.READBUFFER, 'ReadBuffer');
RegisterMethod(@TSTREAM.WRITEBUFFER, 'WriteBuffer'); RegisterMethod(@TSTREAM.WRITEBUFFER, 'WriteBuffer');
RegisterMethod(@TSTREAM.COPYFROM, 'CopyFrom'); RegisterMethod(@TSTREAM.COPYFROM, 'CopyFrom');