Skip to content

Commit 458b5b2

Browse files
committed
Improvement of GetterWrapper and SetterWrapper
1 parent e62bc01 commit 458b5b2

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

Source/WrapDelphi.pas

+5-13
Original file line numberDiff line numberDiff line change
@@ -1290,15 +1290,11 @@ function TExposedGetSet.GetterWrapper(AObj: PPyObject; AContext : Pointer): PPyO
12901290
LOutMsg: string;
12911291
begin
12921292
Result := nil;
1293-
if not ValidateClassProperty(AObj, FParentRtti.Handle, Obj, LOutMsg) then
1294-
begin
1295-
InvalidArguments(FRttiMember.Name, LOutMsg);
1296-
Exit;
1297-
end;
1298-
1293+
if ValidateClassProperty(AObj, FParentRtti.Handle, Obj, LOutMsg) then
12991294
// TODO: Optimize out the property/field lookup, by passing FRttiMember
13001295
// directly to a GetRttiAttr/SetRtti overload
13011296
Result := GetRttiAttr(Obj, FParentRtti, FRttiMember.Name, FPyDelphiWrapper, LOutMsg);
1297+
13021298
if not Assigned(Result) then
13031299
with GetPythonEngine do
13041300
PyErr_SetObject (PyExc_AttributeError^,
@@ -1311,13 +1307,9 @@ function TExposedGetSet.SetterWrapper(AObj, AValue: PPyObject; AContext: Pointer
13111307
LOutMsg: string;
13121308
begin
13131309
Result := -1;
1314-
if not ValidateClassProperty(AObj, FParentRtti.Handle, Obj, LOutMsg) then
1315-
begin
1316-
InvalidArguments(FRttiMember.Name, LOutMsg);
1317-
Exit;
1318-
end;
1319-
1320-
if SetRttiAttr(Obj, FParentRtti, FRttiMember.Name, AValue, FPyDelphiWrapper, LOutMsg) then
1310+
if ValidateClassProperty(AObj, FParentRtti.Handle, Obj, LOutMsg) and
1311+
SetRttiAttr(Obj, FParentRtti, FRttiMember.Name, AValue, FPyDelphiWrapper, LOutMsg)
1312+
then
13211313
Result := 0;
13221314

13231315
if Result <> 0 then

0 commit comments

Comments
 (0)