@@ -1711,6 +1711,8 @@ TPythonTraceback = class
17111711 property Limit : Integer read FLimit write FLimit;
17121712 end ;
17131713
1714+ TPythonType = class ; // forward declaration
1715+
17141716 { $IF not Defined(FPC) and (CompilerVersion >= 23)}
17151717 [ComponentPlatformsAttribute(pidWin32 or pidWin64)]
17161718 { $IFEND}
@@ -1801,6 +1803,7 @@ TPythonEngine = class(TPythonInterface)
18011803 procedure AddClient ( client : TEngineClient );
18021804 procedure RemoveClient ( client : TEngineClient );
18031805 function FindClient ( const aName : AnsiString ) : TEngineClient;
1806+ function FindPythonType ( const TypeName : AnsiString ) : TPythonType;
18041807 function TypeByName ( const aTypeName : AnsiString ) : PPyTypeObject;
18051808 function ModuleByName ( const aModuleName : AnsiString ) : PPyObject;
18061809 function MethodsByName ( const aMethodsContainer: AnsiString ) : PPyMethodDef;
@@ -2235,9 +2238,6 @@ TPythonModule = class(TMethodsContainer)
22352238// -- --
22362239// -------------------------------------------------------
22372240
2238- type
2239- TPythonType = class ; // forward declaration
2240-
22412241{
22422242 A B C
22432243 +-------------------++------------------------------------------------------+
@@ -5588,6 +5588,19 @@ function TPythonEngine.FindModule( const ModuleName : AnsiString ) : PPyObject;
55885588 Result := nil ;
55895589end ;
55905590
5591+ function TPythonEngine.FindPythonType (const TypeName: AnsiString): TPythonType;
5592+ var
5593+ i : Integer;
5594+ begin
5595+ Result := nil ;
5596+ for i := 0 to ClientCount - 1 do
5597+ if (Clients[i] is TPythonType) and (TPythonType(Clients[i]).TypeName = TypeName) then
5598+ begin
5599+ Result := TPythonType(Clients[i]);
5600+ Break;
5601+ end ;
5602+ end ;
5603+
55915604function TPythonEngine.FindFunction (ModuleName,FuncName: AnsiString): PPyObject;
55925605var
55935606 module ,func: PPyObject;
@@ -8707,22 +8720,6 @@ function pyio_GetTypesStats(self, args : PPyObject) : PPyObject;
87078720 end ;
87088721 end ;
87098722
8710- function FindType ( const TName : AnsiString ) : TPythonType;
8711- var
8712- i : Integer;
8713- begin
8714- Result := nil ;
8715- with GetPythonEngine do
8716- for i := 0 to ClientCount - 1 do
8717- if Clients[i] is TPythonType then
8718- with TPythonType(Clients[i]) do
8719- if TypeName = TName then
8720- begin
8721- Result := TPythonType(Clients[i]);
8722- Break;
8723- end ;
8724- end ;
8725-
87268723var
87278724 i : Integer;
87288725 T : TPythonType;
@@ -8736,7 +8733,7 @@ function pyio_GetTypesStats(self, args : PPyObject) : PPyObject;
87368733 for i := 0 to PyTuple_Size(args)-1 do
87378734 begin
87388735 str := AnsiString(PyObjectAsString( PyTuple_GetItem(args, i) ));
8739- T := FindType ( str );
8736+ T := FindPythonType ( str );
87408737 if Assigned(T) then
87418738 begin
87428739 obj := HandleType( T );
0 commit comments