Thanks all
first, i will add my configuration to my signature : laz 2.06 32b + fpc 3.04 32b / Win10 64b
ok for puhlished properties. I don't want to use trunk (company policy), i changed my code that way
program rtti;
uses typinfo;
type
{ TSampleClass }
{$M+}
TSampleClass = class
private
function doSomething: string;
published
property Something: string read doSomething;
function somethingElse(Param1, Param2: integer): string;
end;
{$M-}
{ TSampleClass }
TCallFunc = function: string of object;
function TSampleClass.doSomething: string;
begin
result := 'something';
end;
function TSampleClass.somethingElse(Param1, Param2: integer): string;
begin
result := 'somethingElse';
end;
var
SampleClasse: TSampleClass;
info:PTypeInfo;
Data: PTypeData;
propInfo: PPropInfo;
CallFunc : TCallFunc;
r: string;
begin
SampleClasse := TSampleClass.Create;
info := TypeInfo(SampleClasse);
Data := GetTypeData(info);
Writeln('Type name : ', info^.Name);
Writeln('Type kind : ', GetEnumName(TypeInfo(TTypeKind), Integer(info^.Kind)));
Writeln('Properties count : ', data^.PropCount);
propInfo := GetPropInfo(SampleClasse, 'SomeThing');
if assigned(propInfo) then begin
callfunc := TCallFunc(propInfo^.GetProc^);
r := CallFunc();
end;
readln;
end.
Point 1 : how to call something() to get result in r (current code don't work, it end up at callfunc() )
Point 2 : with {$M+}, fpc 3.04 allows me to publish a function, but is there a way to found it, access it, and then call it ?
(ho btw I've made lot of php last monthes
)