Has any performance tests been ran, to see what the runtime impact of
utilizing RTTI is? Hopefully negligent in the grand scheme...
Thanks,
Don
On 12/28/2021 2:11 PM, Michael Van Canneyt via fpc-pascal wrote:
On Tue, 28 Dec 2021, Graeme Geldenhuys via fpc-pascal wrote:
On 2021-12-28 15:25, Michael Van Canneyt via fpc-pascal wrote:
Thanks to the magic of RTTI and Invoke(), creating a JSON-RPC server
has
just become significantly easier !
That's pretty neat - nicely done Michael.
We do our best.
// Create a class that implements the interface
Type
TIntf2Impl = class(TInterfacedObject, IMyOtherInterface)
public
function Echo(args: TStringArray): String;
function SayHello: string;
end;
...snip...
// Register the class using an interface factory:
Function GetMyOtherInterface(Const aName : string) : IInterface;
begin
Result:=TIntf2Impl.Create as IInterface;
end;
Slightly off topic, and my Object Pascal is getting a bit rusty as
the years go by. <grin> ;-) In your factory above, is the "as
IInterface" part needed. Can't the FPC compiler automatically cast
the return type based on the function return type, and the fact that
the compiler should know that TIntf2Impl type implements
TInterfacedObject?
No, theoretically it probably could, but type inference is not
implemented in Pascal.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal