Skip to content

Commit

Permalink
Restored FPC compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
pyscripter committed Jun 28, 2022
1 parent 2d96639 commit 6038788
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Source/PythonEngine.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,11 @@ implementation
{$ENDIF}
{$IFDEF MSWINDOWS}
Registry,
{$IFDEF FPC}
JwaPsApi,
{$ELSE}
PsAPI,
{$ENDIF}
{$ENDIF}
Math;

Expand Down
12 changes: 10 additions & 2 deletions Source/WrapDelphiClasses.pas
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ TPyDelphiComponent = class (TPyDelphiPersistent)
function CreateComponent(AOwner : TComponent) : TComponent; virtual;
procedure SubscribeToFreeNotification; override;
procedure UnSubscribeToFreeNotification; override;
{$IFNDEF FPC}
function InternalReadComponent(const AResFile: string;
const AInstance: TComponent): boolean; virtual;
{$ENDIF}
// Exposed Methods
function GetParentComponent_Wrapper(args : PPyObject) : PPyObject; cdecl;
function HasParent_Wrapper(args : PPyObject) : PPyObject; cdecl;
Expand Down Expand Up @@ -244,8 +246,9 @@ TPyDelphiBasicAction = class (TPyDelphiComponent)
implementation

uses
TypInfo, System.IOUtils, System.Rtti;
TypInfo {$IFNDEF FPC}, System.Rtti{$ENDIF};

{$IFNDEF FPC}
type
TPyReader = class(TReader)
private
Expand All @@ -258,6 +261,7 @@ TPyReader = class(TReader)
public
constructor Create(APyObject: TPyDelphiObject; Stream: TStream; BufSize: Integer);
end;
{$ENDIF}

{ Register the wrappers, the globals and the constants }
type
Expand Down Expand Up @@ -892,6 +896,7 @@ function TPyDelphiComponent.HasParent_Wrapper(args: PPyObject): PPyObject;
end;
end;

{$IFNDEF FPC}
function TPyDelphiComponent.InternalReadComponent(const AResFile: string;
const AInstance: TComponent): boolean;

Expand Down Expand Up @@ -930,7 +935,7 @@ function TPyDelphiComponent.InternalReadComponent(const AResFile: string;
LInput: TFileStream;
LOutput: TMemoryStream;
begin
if AResFile.IsEmpty or not TFile.Exists(AResFile) then
if AResFile.IsEmpty or not FileExists(AResFile) then
Exit(false);

LInput := TFileStream.Create(AResFile, fmOpenRead);
Expand All @@ -956,6 +961,7 @@ function TPyDelphiComponent.InternalReadComponent(const AResFile: string;
end;
Result := true;
end;
{$ENDIF}

function TPyDelphiComponent.GetAttrO(key: PPyObject): PPyObject;
Var
Expand Down Expand Up @@ -1655,6 +1661,7 @@ function TPyDelphiStrings.Set_Text(AValue: PPyObject;
end;
end;

{$IFNDEF FPC}
{ TPyReader }

constructor TPyReader.Create(APyObject: TPyDelphiObject; Stream: TStream;
Expand Down Expand Up @@ -1750,6 +1757,7 @@ procedure TPyReader.SetName(Component: TComponent; var Name: string);
end;
FInstance := Component;
end;
{$ENDIF}

initialization
RegisteredUnits.Add(TClassesRegistration.Create);
Expand Down

0 comments on commit 6038788

Please sign in to comment.