Mit Variablen und Prozeduren klappt das hervorragend, bei Funktionen sperrt es sich etwas. Die KI hat sich da etwas zusammen halluziniert, liefert mir aber ein Mischmasch von Delphi und fpc
Kennt sich da vielleicht jmd aus ?
Lazarus 4.3, FPC 3.2.3
Code: Alles auswählen
uses
..typeinfo,rtti....
function CallBoolMethod(aForm: TObject; const MethodName: string; out
ResultValue: Boolean): Boolean;
var
ctx: TRttiContext;
rttiType: TRttiType;
method: TRttiMethod;
retval: TValue;
begin
Result := False;
ResultValue := False;
if aForm = nil then
Exit;
ctx := TRttiContext.Create;
try
rttiType := ctx.GetType(aForm.ClassType);
method := rttiType.GetMethod(MethodName);
if Assigned(method) and (method.ReturnType <> nil) and (method.ReturnType.Handle = TypeInfo(Boolean)) then
begin
retval := method.Invoke(aForm, []);
if retval.IsBoolean then //<<<Error: identifier idents no member "IsBoolean"
begin
ResultValue := retval.AsBoolean;
Result := True;
end;
end;
finally
ctx.Free;
end;
end;