@@ -180,7 +180,16 @@ TPythonVersionProp = record
180180type
181181 // Delphi equivalent used by TPyObject
182182 TRichComparisonOpcode = (pyLT, pyLE, pyEQ, pyNE, pyGT, pyGE);
183- const
183+
184+ { $IFDEF MSWINDOWS}
185+ C_Long = Integer;
186+ C_ULong = Cardinal;
187+ { $ELSE}
188+ C_Long= NativeInt;
189+ C_ULong = NativeUInt;
190+ { $ENDIF}
191+
192+ const
184193{
185194Type flags (tp_flags)
186195
@@ -202,42 +211,42 @@ TPythonVersionProp = record
202211}
203212
204213// Set if the type object is dynamically allocated
205- Py_TPFLAGS_HEAPTYPE = (1 shl 9 );
214+ Py_TPFLAGS_HEAPTYPE = (C_ULong( 1 ) shl 9 );
206215
207216// Set if the type allows subclassing
208- Py_TPFLAGS_BASETYPE = (1 shl 10 );
217+ Py_TPFLAGS_BASETYPE = (C_ULong( 1 ) shl 10 );
209218
210219// Set if the type is 'ready' -- fully initialized
211- Py_TPFLAGS_READY = (1 shl 12 );
220+ Py_TPFLAGS_READY = (C_ULong( 1 ) shl 12 );
212221
213222// Set while the type is being 'readied', to prevent recursive ready calls
214- Py_TPFLAGS_READYING = (1 shl 13 );
223+ Py_TPFLAGS_READYING = (C_ULong( 1 ) shl 13 );
215224
216225// Objects support garbage collection (see objimp.h)
217- Py_TPFLAGS_HAVE_GC = (1 shl 14 );
226+ Py_TPFLAGS_HAVE_GC = (C_ULong( 1 ) shl 14 );
218227
219228// Set if the type implements the vectorcall protocol (PEP 590) */
220- _Py_TPFLAGS_HAVE_VECTORCALL = (1 shl 11 );
229+ _Py_TPFLAGS_HAVE_VECTORCALL = (C_ULong( 1 ) shl 11 );
221230
222231// Objects behave like an unbound method
223- Py_TPFLAGS_METHOD_DESCRIPTOR = (1 shl 17 );
232+ Py_TPFLAGS_METHOD_DESCRIPTOR = (C_ULong( 1 ) shl 17 );
224233
225234// Objects support type attribute cache
226- Py_TPFLAGS_HAVE_VERSION_TAG = (1 shl 18 );
227- Py_TPFLAGS_VALID_VERSION_TAG = (1 shl 19 );
235+ Py_TPFLAGS_HAVE_VERSION_TAG = (C_ULong( 1 ) shl 18 );
236+ Py_TPFLAGS_VALID_VERSION_TAG = (C_ULong( 1 ) shl 19 );
228237
229238// Type is abstract and cannot be instantiated
230- Py_TPFLAGS_IS_ABSTRACT = (1 shl 20 );
239+ Py_TPFLAGS_IS_ABSTRACT = (C_ULong( 1 ) shl 20 );
231240
232241// These flags are used to determine if a type is a subclass.
233- Py_TPFLAGS_LONG_SUBCLASS = (1 shl 24 );
234- Py_TPFLAGS_LIST_SUBCLASS = (1 shl 25 );
235- Py_TPFLAGS_TUPLE_SUBCLASS = (1 shl 26 );
236- Py_TPFLAGS_BYTES_SUBCLASS = (1 shl 27 );
237- Py_TPFLAGS_UNICODE_SUBCLASS = (1 shl 28 );
238- Py_TPFLAGS_DICT_SUBCLASS = (1 shl 29 );
239- Py_TPFLAGS_BASE_EXC_SUBCLASS = (1 shl 30 );
240- Py_TPFLAGS_TYPE_SUBCLASS = (1 shl 31 );
242+ Py_TPFLAGS_LONG_SUBCLASS = (C_ULong( 1 ) shl 24 );
243+ Py_TPFLAGS_LIST_SUBCLASS = (C_ULong( 1 ) shl 25 );
244+ Py_TPFLAGS_TUPLE_SUBCLASS = (C_ULong( 1 ) shl 26 );
245+ Py_TPFLAGS_BYTES_SUBCLASS = (C_ULong( 1 ) shl 27 );
246+ Py_TPFLAGS_UNICODE_SUBCLASS = (C_ULong( 1 ) shl 28 );
247+ Py_TPFLAGS_DICT_SUBCLASS = (C_ULong( 1 ) shl 29 );
248+ Py_TPFLAGS_BASE_EXC_SUBCLASS = (C_ULong( 1 ) shl 30 );
249+ Py_TPFLAGS_TYPE_SUBCLASS = (C_ULong( 1 ) shl 31 );
241250
242251 Py_TPFLAGS_DEFAULT = Py_TPFLAGS_BASETYPE or Py_TPFLAGS_HAVE_VERSION_TAG;
243252
@@ -339,7 +348,6 @@ TPythonVersionProp = record
339348 PPyObject = ^PyObject;
340349 PPPyObject = ^PPyObject;
341350 PPPPyObject = ^PPPyObject;
342- PPyIntObject = ^PyIntObject;
343351 PPyTypeObject = ^PyTypeObject;
344352 PPySliceObject = ^PySliceObject;
345353
@@ -450,12 +458,6 @@ TPythonVersionProp = record
450458 ob_type: PPyTypeObject;
451459 end ;
452460
453- PyIntObject = { $IFNDEF CPUX64} packed { $ENDIF} record
454- ob_refcnt : NativeInt;
455- ob_type : PPyTypeObject;
456- ob_ival : LongInt;
457- end ;
458-
459461 _frozen = { $IFNDEF CPUX64} packed { $ENDIF} record
460462 name : PAnsiChar;
461463 code : PByte;
@@ -641,7 +643,7 @@ TPythonVersionProp = record
641643 // Functions to access object as input/output buffer
642644 tp_as_buffer: Pointer; // PPyBufferProcs - not implemented
643645 // Flags to define presence of optional/expanded features
644- tp_flags: LongInt ;
646+ tp_flags: C_ULong ;
645647
646648 tp_doc: PAnsiChar; // Documentation string
647649
@@ -1233,8 +1235,8 @@ TPythonInterface=class(TDynamicDll)
12331235
12341236 Py_None: PPyObject;
12351237 Py_Ellipsis: PPyObject;
1236- Py_False: PPyIntObject ;
1237- Py_True: PPyIntObject ;
1238+ Py_False: PPyObject ;
1239+ Py_True: PPyObject ;
12381240 Py_NotImplemented: PPyObject;
12391241
12401242 PyExc_AttributeError: PPPyObject;
@@ -1401,7 +1403,7 @@ TPythonInterface=class(TDynamicDll)
14011403 PyFunction_GetGlobals:function (ob:PPyObject):PPyObject; cdecl;
14021404 PyFunction_New:function (ob1,ob2:PPyObject):PPyObject; cdecl;
14031405 PyImport_AddModule:function (name :PAnsiChar):PPyObject; cdecl;
1404- PyImport_GetMagicNumber:function :LongInt ; cdecl;
1406+ PyImport_GetMagicNumber:function :C_Long ; cdecl;
14051407 PyImport_ImportFrozenModule:function (key:PAnsiChar):integer; cdecl;
14061408 PyImport_ImportModule:function (name :PAnsiChar):PPyObject; cdecl;
14071409 PyImport_Import:function (name :PPyObject):PPyObject; cdecl;
@@ -1418,12 +1420,12 @@ TPythonInterface=class(TDynamicDll)
14181420 PyList_Size:function (ob:PPyObject):NativeInt; cdecl;
14191421 PyList_Sort:function (ob:PPyObject):integer; cdecl;
14201422 PyLong_AsDouble:function (ob:PPyObject):DOUBLE; cdecl;
1421- PyLong_AsLong:function (ob:PPyObject):LongInt ; cdecl;
1423+ PyLong_AsLong:function (ob:PPyObject):C_Long ; cdecl;
14221424 PyLong_FromDouble:function (db:double):PPyObject; cdecl;
1423- PyLong_FromLong:function (l:LongInt ):PPyObject; cdecl;
1425+ PyLong_FromLong:function (l:C_Long ):PPyObject; cdecl;
14241426 PyLong_FromString:function (pc:PAnsiChar;var ppc:PAnsiChar;i:integer):PPyObject; cdecl;
1425- PyLong_FromUnsignedLong:function(val:LongWord ): PPyObject; cdecl;
1426- PyLong_AsUnsignedLong:function(ob:PPyObject): LongWord ; cdecl;
1427+ PyLong_FromUnsignedLong:function(val:C_ULong ): PPyObject; cdecl;
1428+ PyLong_AsUnsignedLong:function(ob:PPyObject): C_ULong ; cdecl;
14271429 PyLong_FromUnicodeObject:function(ob:PPyObject; base : integer): PPyObject; cdecl;
14281430 PyLong_FromLongLong:function(val:Int64): PPyObject; cdecl;
14291431 PyLong_FromUnsignedLongLong:function(val:UInt64) : PPyObject; cdecl;
@@ -1553,7 +1555,7 @@ TPythonInterface=class(TDynamicDll)
15531555 PyWeakref_NewRef: function ( ob, callback : PPyObject) : PPyObject; cdecl;
15541556 PyWrapper_New: function ( ob1, ob2 : PPyObject) : PPyObject; cdecl;
15551557 PyBool_FromLong: function ( ok : Integer) : PPyObject; cdecl;
1556- PyThreadState_SetAsyncExc: function(t_id :LongInt ; exc :PPyObject) : Integer; cdecl;
1558+ PyThreadState_SetAsyncExc: function(t_id:C_ULong ; exc:PPyObject) : Integer; cdecl;
15571559 Py_AtExit:function (proc: AtExitProc):integer; cdecl;
15581560 Py_CompileStringExFlags:function (str,filename:PAnsiChar;start:integer;flags:PPyCompilerFlags;optimize:integer):PPyObject; cdecl;
15591561 Py_FatalError:procedure(s:PAnsiChar); cdecl;
@@ -2495,7 +2497,7 @@ TPythonType = class(TGetSetContainer)
24952497 function CreateMethod ( pSelf, args : PPyObject ) : PPyObject; cdecl;
24962498 procedure InitServices ;
24972499 procedure SetDocString ( value : TStringList );
2498- function TypeFlagsAsInt : LongInt ;
2500+ function TypeFlagsAsInt : C_ULong ;
24992501 function GetMembersStartOffset : Integer; override;
25002502 procedure ModuleReady (Sender : TObject); override;
25012503 procedure ReallocMethods ; override;
@@ -3352,7 +3354,6 @@ procedure TPythonInterface.MapDll;
33523354 PyImport_ImportModule := Import (' PyImport_ImportModule' );
33533355 PyImport_Import := Import (' PyImport_Import' );
33543356 PyImport_ReloadModule := Import (' PyImport_ReloadModule' );
3355- PyLong_AsLong := Import (' PyLong_AsLong' );
33563357 PyList_Append := Import (' PyList_Append' );
33573358 PyList_AsTuple := Import (' PyList_AsTuple' );
33583359 PyList_GetItem := Import (' PyList_GetItem' );
@@ -7520,7 +7521,7 @@ procedure TPythonType.SetDocString( value : TStringList );
75207521 FDocString.Assign( value );
75217522end ;
75227523
7523- function TPythonType.TypeFlagsAsInt : LongInt ;
7524+ function TPythonType.TypeFlagsAsInt : C_ULong ;
75247525begin
75257526 Result := 0 ;
75267527 if tpfHeapType in TypeFlags then
0 commit comments