Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 88c06f1

Browse filesBrowse files
committed
Compatibility with both Lazarus and (hopefully) Delphi Linux
1 parent 7788b18 commit 88c06f1
Copy full SHA for 88c06f1

File tree

13 files changed

+207
-412
lines changed
Filter options

13 files changed

+207
-412
lines changed

‎PythonForDelphi/Components/P4DFpc.lpk

Copy file name to clipboardExpand all lines: PythonForDelphi/Components/P4DFpc.lpk
-66Lines changed: 0 additions & 66 deletions
This file was deleted.

‎PythonForDelphi/Components/P4DFpc.pas

Copy file name to clipboardExpand all lines: PythonForDelphi/Components/P4DFpc.pas
-22Lines changed: 0 additions & 22 deletions
This file was deleted.

‎PythonForDelphi/Components/Sources/Core/MethodCallBack.pas

Copy file name to clipboardExpand all lines: PythonForDelphi/Components/Sources/Core/MethodCallBack.pas
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ procedure GetCodeMem(var ptr: PByte; size: integer);
179179
{$IFDEF MSWINDOWS}
180180
page:=VirtualAlloc(nil, PageSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
181181
{$ELSE}
182-
page := GetMem(PageSize);
183-
//page := mmap(Pointer($10000000), PageSize, PROT_NONE, MAP_PRIVATE or MAP_ANON, -1, 0);
182+
//page := GetMem(PageSize);
183+
page := mmap(Pointer($10000000), PageSize, PROT_NONE, MAP_PRIVATE or MAP_ANON, -1, 0);
184184
mprotect(page, PageSize, PROT_READ or PROT_WRITE or PROT_EXEC);
185-
{$ENDIF}
185+
{$ENDIF}
186186
page^.next:=CodeMemPages;
187187
CodeMemPages:=page;
188188
// init pointer to end of page

‎PythonForDelphi/Components/Sources/Core/PythonEngine.pas

Copy file name to clipboardExpand all lines: PythonForDelphi/Components/Sources/Core/PythonEngine.pas
+15-8Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,17 @@
6767
interface
6868

6969
uses
70+
Types,
7071
{$IFDEF MSWINDOWS}
7172
Windows,
72-
{$ENDIF}
73-
{$IFDEF LINUX}
74-
Types,
73+
{$ELSE}
74+
{$IFDEF FPC}
7575
dynlibs,
76+
{$ELSE}
77+
{$IFDEF LINUX}
78+
Libc,
79+
{$ENDIF}
80+
{$ENDIF}
7681
{$ENDIF}
7782
Classes,
7883
SysUtils,
@@ -3462,10 +3467,13 @@ procedure TDynamicDll.Quit;
34623467
{$IFDEF MSWINDOWS}
34633468
MessageBox( GetActiveWindow, PChar(GetQuitMessage), 'Error', MB_TASKMODAL or MB_ICONSTOP );
34643469
ExitProcess( 1 );
3465-
{$ENDIF}
3466-
{$IFDEF LINUX}
3470+
{$ELSE}
34673471
WriteLn(ErrOutput, GetQuitMessage);
3472+
{$IFDEF FPC}
34683473
Halt( 1 );
3474+
{$ELSE}
3475+
__exit(1);
3476+
{$ENDIF}
34693477
{$ENDIF}
34703478
end;
34713479
end;
@@ -3512,7 +3520,7 @@ constructor TPythonInterface.Create(AOwner: TComponent);
35123520
procedure TPythonInterface.AfterLoad;
35133521
begin
35143522
inherited;
3515-
FIsPython3000 := Pos('PYTHON3', UpperCase(DLLName)) = 1;
3523+
FIsPython3000 := Pos('PYTHON3', UpperCase(DLLName)) > 0;
35163524
FMajorVersion := StrToInt(DLLName[7 {$IFDEF LINUX}+3{$ENDIF}]);
35173525
FMinorVersion := StrToInt(DLLName[8{$IFDEF LINUX}+4{$ENDIF}]);
35183526

@@ -3529,8 +3537,7 @@ procedure TPythonInterface.AfterLoad;
35293537
if FatalMsgDlg then
35303538
{$IFDEF MSWINDOWS}
35313539
MessageBox( GetActiveWindow, PChar(E.Message), 'Error', MB_TASKMODAL or MB_ICONSTOP );
3532-
{$ENDIF}
3533-
{$IFDEF LINUX}
3540+
{$ELSE}
35343541
WriteLn( ErrOutput, E.Message );
35353542
{$ENDIF}
35363543
if FatalAbort then Quit;

‎PythonForDelphi/Components/Sources/Core/VarPyth.pas

Copy file name to clipboardExpand all lines: PythonForDelphi/Components/Sources/Core/VarPyth.pas
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ TNamedParamDesc = record
127127
{$IFDEF DELPHIXE2_OR_HIGHER}
128128
{$DEFINE USESYSTEMDISPINVOKE} //Delphi 2010 DispInvoke is buggy
129129
{$ENDIF}
130-
{$IF DEFINED(FPC_FULLVERSION) and (FPC_FULLVERSION >= 20500)}
131-
{$DEFINE USESYSTEMDISPINVOKE}
132-
{$IFEND}
130+
{$.IF DEFINED(FPC_FULLVERSION) and (FPC_FULLVERSION >= 20500)}
131+
{.$DEFINE USESYSTEMDISPINVOKE}
132+
{.$IFEND}
133133

134134
{ Python variant type handler }
135135
TPythonVariantType = class(TInvokeableVariantType, IVarInstanceReference)
@@ -146,7 +146,7 @@ TPythonVariantType = class(TInvokeableVariantType, IVarInstanceReference)
146146
procedure PythonObjectToVarData( var Dest : TVarData; AObject : PPyObject; APythonAtomCompatible : Boolean );
147147
procedure PyhonVarDataCreate( var Dest : TVarData; AObject : PPyObject );
148148
{$IFNDEF USESYSTEMDISPINVOKE}
149-
procedure DoDispInvoke(Dest: PVarData; const Source: TVarData;
149+
procedure DoDispInvoke(Dest: PVarData; var Source: TVarData;
150150
CallDesc: PCallDesc; Params: Pointer); virtual;
151151
function GetPropertyWithArg(var Dest: TVarData; const V: TVarData;
152152
const AName: AnsiString; AArg : TVarData): Boolean; virtual;
@@ -180,14 +180,14 @@ TPythonVariantType = class(TInvokeableVariantType, IVarInstanceReference)
180180
const Arguments: TVarDataArray): Boolean; override;
181181
function GetProperty(var Dest: TVarData; const V: TVarData;
182182
const AName: string): Boolean; override;
183-
function SetProperty(const V: TVarData; const AName: string;
183+
function SetProperty({$IFDEF FPC}var{$ELSE}const{$ENDIF} V: TVarData; const AName: string;
184184
const Value: TVarData): Boolean; override;
185185
{$IFDEF DELPHIXE7_OR_HIGHER}
186186
procedure DispInvoke(Dest: PVarData;
187187
[Ref] const Source: TVarData; CallDesc: PCallDesc; Params: Pointer);override;
188188
{$ELSE}
189189
procedure DispInvoke(Dest: PVarData;
190-
const Source: TVarData; CallDesc: PCallDesc; Params: Pointer);override;
190+
var Source: TVarData; CallDesc: PCallDesc; Params: Pointer);override;
191191
{$ENDIF}
192192
end;
193193

@@ -941,7 +941,7 @@ procedure TPythonVariantType.DispInvoke(Dest: PVarData;
941941
[Ref] const Source: TVarData; CallDesc: PCallDesc; Params: Pointer);
942942
{$ELSE}
943943
procedure TPythonVariantType.DispInvoke(Dest: PVarData;
944-
const Source: TVarData; CallDesc: PCallDesc; Params: Pointer);
944+
var Source: TVarData; CallDesc: PCallDesc; Params: Pointer);
945945
{$ENDIF}
946946
{$IFDEF USESYSTEMDISPINVOKE}
947947
{$IFDEF DELPHIXE2_OR_HIGHER}
@@ -1088,7 +1088,7 @@ TStringDesc = record
10881088
end;
10891089

10901090
procedure TPythonVariantType.DoDispInvoke(Dest: PVarData;
1091-
const Source: TVarData; CallDesc: PCallDesc; Params: Pointer);
1091+
var Source: TVarData; CallDesc: PCallDesc; Params: Pointer);
10921092
type
10931093
PParamRec = ^TParamRec;
10941094
TParamRec = array[0..3] of LongInt;
@@ -1863,7 +1863,7 @@ function TPythonVariantType.RightPromotion(const V: TVarData;
18631863
Result := False;
18641864
end;
18651865

1866-
function TPythonVariantType.SetProperty(const V: TVarData;
1866+
function TPythonVariantType.SetProperty({$IFDEF FPC}var{$ELSE}const{$ENDIF} V: TVarData;
18671867
const AName: string; const Value: TVarData): Boolean;
18681868
var
18691869
_newValue : PPyObject;

‎PythonForDelphi/Components/Sources/Core/WrapDelphi.pas

Copy file name to clipboardExpand all lines: PythonForDelphi/Components/Sources/Core/WrapDelphi.pas
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,12 +1106,12 @@ function PythonToSet(ASet : PPyObject; APropInfo: PPropInfo) : Integer;
11061106
{$IFDEF FPC}
11071107
function GetPropValue(Instance: TObject; PropInfo: PPropInfo): Variant;
11081108
begin
1109-
Result := Variants.GetPropValue(Instance, PropInfo^.Name);
1109+
Result := Variants.GetPropValue(Instance, PropInfo, False);
11101110
end;
11111111

11121112
procedure SetPropValue(Instance: TObject; PropInfo: PPropInfo; const Value: Variant);
11131113
begin
1114-
Variants.SetPropValue(Instance, PropInfo^.Name, Value);
1114+
Variants.SetPropValue(Instance, PropInfo, Value);
11151115
end;
11161116
{$ENDIF}
11171117

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.