Skip to content

Commit 46fb96a

Browse files
committed
WrapDelphi.CreateVarParam with object - a small helpful overload
1 parent f5b3ed5 commit 46fb96a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Source/WrapDelphi.pas

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,8 @@ TPyDelphiWrapper = class(TEngineClient, IFreeNotificationSubscriber)
875875
out AValue : TObject) : Boolean;
876876
function CheckCallableAttribute(AAttribute : PPyObject; const AAttributeName : string) : Boolean;
877877
function CheckEnum(const AEnumName : string; AValue, AMinValue, AMaxValue : Integer) : Boolean;
878-
function CreateVarParam(PyDelphiWrapper : TPyDelphiWrapper; const AValue : Variant) : PPyObject;
878+
function CreateVarParam(PyDelphiWrapper : TPyDelphiWrapper; const AValue : Variant) : PPyObject; overload;
879+
function CreateVarParam(PyDelphiWrapper : TPyDelphiWrapper; AObject: TObject) : PPyObject; overload;
879880
function SetToPython(ATypeInfo: PTypeInfo; AValue : Integer) : PPyObject; overload;
880881
function SetToPython(APropInfo: PPropInfo; AValue : Integer) : PPyObject; overload;
881882
function SetToPython(AInstance: TObject; APropInfo: PPropInfo) : PPyObject; overload;
@@ -1304,6 +1305,16 @@ function CreateVarParam(PyDelphiWrapper : TPyDelphiWrapper; const AValue : Varia
13041305
GetPythonEngine.Py_DECREF(tmp);
13051306
end;
13061307

1308+
function CreateVarParam(PyDelphiWrapper : TPyDelphiWrapper; AObject: TObject) : PPyObject;
1309+
var
1310+
tmp: PPyObject;
1311+
begin
1312+
Result := PyDelphiWrapper.VarParamType.CreateInstance;
1313+
tmp := PyDelphiWrapper.Wrap(AObject);
1314+
(PythonToDelphi(Result) as TPyDelphiVarParameter).Value := tmp;
1315+
GetPythonEngine.Py_DECREF(tmp);
1316+
end;
1317+
13071318
function SupportsFreeNotification(AObject : TObject) : Boolean;
13081319
var
13091320
_FreeNotification : IFreeNotification;

0 commit comments

Comments
 (0)