Skip to content

Commit bc0465a

Browse files
committed
Minor refactoring of SetRttiAttr.
1 parent e49d2db commit bc0465a

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

Source/WrapDelphi.pas

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,9 +2819,10 @@ function SetRttiAttr(const ParentAddr: Pointer; ParentType: TRttiStructuredType
28192819
begin
28202820
Result := False;
28212821

2822-
Prop := ParentType.GetProperty(AttrName);
2823-
if Prop <> nil then
2824-
try
2822+
try
2823+
Prop := ParentType.GetProperty(AttrName);
2824+
if Prop <> nil then
2825+
begin
28252826
if Ord(Prop.Visibility) < Ord(mvPublic) then
28262827
ErrMsg := rs_NoAccess
28272828
else if not Prop.IsWritable then
@@ -2841,17 +2842,12 @@ function SetRttiAttr(const ParentAddr: Pointer; ParentType: TRttiStructuredType
28412842
Prop.SetValue(ParentAddr, AttrValue);
28422843
Result := True;
28432844
end;
2844-
except
2845-
on E: Exception do begin
2846-
Result := False;
2847-
ErrMsg := E.Message;
2848-
end;
28492845
end
2850-
else
2851-
begin
2852-
Field := ParentType.GetField(AttrName);
2853-
if Field <> nil then
2854-
try
2846+
else
2847+
begin
2848+
Field := ParentType.GetField(AttrName);
2849+
if Field <> nil then
2850+
begin
28552851
if Ord(Field.Visibility) < Ord(mvPublic) then
28562852
ErrMsg := rs_NoAccess
28572853
else if Field.FieldType = nil then
@@ -2861,12 +2857,15 @@ function SetRttiAttr(const ParentAddr: Pointer; ParentType: TRttiStructuredType
28612857
Field.SetValue(ParentAddr, AttrValue);
28622858
Result := True;
28632859
end;
2864-
except
2865-
on E: Exception do begin
2866-
Result := False;
2867-
ErrMsg := E.Message;
2868-
end;
28692860
end
2861+
else
2862+
ErrMsg := rs_UnknownAttribute;
2863+
end;
2864+
except
2865+
on E: Exception do begin
2866+
Result := False;
2867+
ErrMsg := E.Message;
2868+
end;
28702869
end;
28712870
end;
28722871

0 commit comments

Comments
 (0)