Skip to content

changes to fix Lazarus and FreePascal compilation issues. #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/PythonEngine.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6066,7 +6066,8 @@ function TPythonEngine.PyUnicodeAsString(obj : PPyObject): UnicodeString;
Exit;

// The second argument is the size of the destination (Result) including #0
NewSize := Utf8ToUnicode(PChar(Result), Cardinal(Size + 1), Buffer, Cardinal(Size));
NewSize := Utf8ToUnicode(PWideChar(Result), Cardinal(Size + 1), Buffer, Cardinal(Size));

// NewSize includes #0
SetLength(Result, NewSize - 1);
end
Expand Down
2 changes: 2 additions & 0 deletions Source/WrapDelphi.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2571,12 +2571,14 @@ function TPyDelphiObject.Dir_Wrapper(args: PPyObject): PPyObject;

var
PyType: PPyTypeObject;

{$IFDEF EXTENDED_RTTI}
Context: TRttiContext;
RttiType: TRTTIType;
{$ELSE}
_PropList: PPropList;
_propCount : Integer;
i: Integer;
{$ENDIF}
begin
Adjust(@Self);
Expand Down
15 changes: 11 additions & 4 deletions Source/WrapDelphiClasses.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
interface

uses
Classes, SysUtils, PythonEngine, WrapDelphi;
Classes, SysUtils, PythonEngine, WrapDelphi
{$IFDEF FPC}, bufstream{$ENDIF};

type
{
Expand Down Expand Up @@ -367,6 +368,7 @@ implementation
uses
TypInfo {$IFNDEF FPC}, System.Rtti{$ENDIF};


{$IFNDEF FPC}
type
TPyReader = class(TReader)
Expand Down Expand Up @@ -2223,7 +2225,12 @@ TBufferedFileStreamClass = class of TBufferedFileStream;
DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LBufferSize);
end else if (LArgCount = 3) then begin
if (APythonType.Engine.PyArg_ParseTupleAndKeywords(args, kwds, 'sHI|i:Create', @LKwArgs2[0], @LFileName, @LMode, @LRights, @LBufferSize) <> 0) then
DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LRights, LBufferSize);
{$IFDEF FPC}
DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LRights);
DelphiObject.Size:= LBufferSize;
{$ELSE}
DelphiObject := TBufferedFileStreamClass(DelphiObjectClass).Create(String(LFileName), LMode, LRights, LBufferSize);
{$ENDIF}
end;

//Maybe it was created on the next attempt...
Expand Down Expand Up @@ -2385,14 +2392,14 @@ TResourceStreamClass = class of TResourceStream;
{$ELSE}
if APythonType.Engine.PyArg_ParseTuple(args, 'Iss:Create', @LHandle, @LResName, @LResType) <> 0 then
{$ENDIF}
DelphiObject := TResourceStreamClass(DelphiObjectClass).Create(LHandle, String(LResName), PWideChar(String(LResType)))
DelphiObject := TResourceStreamClass(DelphiObjectClass).Create(LHandle, String(LResName), PChar(String(LResType)))
else
{$IFDEF CPUX64}
if APythonType.Engine.PyArg_ParseTuple(args, 'Kis:Create', @LHandle, @LResId, @LResType) <> 0 then
{$ELSE}
if APythonType.Engine.PyArg_ParseTuple(args, 'Iis:Create', @LHandle, @LResId, @LResType) <> 0 then
{$ENDIF}
DelphiObject := TResourceStreamClass(DelphiObjectClass).CreateFromID(LHandle, LResId, PWideChar(String(LResType)));
DelphiObject := TResourceStreamClass(DelphiObjectClass).CreateFromID(LHandle, LResId, PChar(String(LResType)));
except
on E: Exception do
with GetPythonEngine do
Expand Down