I
I
Interface2016-03-26 16:54:40
Delphi
Interface, 2016-03-26 16:54:40

Is there an alternative to Delphi Invoke for FreePascal?

Good afternoon!
I am looking for a way to call to do the following:
There is a set of functions, procedures, methods, constructors with different set of parameters, type, etc.

// например:
function Fn1(param: Integer; param2: String): Byte;
function Fn1(param: TPoint): String;
procedure Fn1(param: Object);
//...

Then I want to call these functions, but I can't just write: I'm looking for a solution like:
byteVar := Fn1(1, 'hello');
function CallFn(FnPointer: pointer; Args: array of Variant): Variant;
// ...
ResultValue := CallFn(@MessageBox, [0, 'hello', 'world', '0']);

Those. a pointer to a function is set, a list of arguments in some form, and it is called.
As far as I understand, Invoke from enhanced RTTI (which Delphi 2010+ has) can be used for this.
Whether however me interests it is possible to turn similar on FreePascal'e? Perhaps there are ready-made libraries that cover some of the features of enhanced RTTI for FPC? Perhaps there is a lower-level or less convenient solution?
There is for example www.swissdelphicenter.ch/torry/showcode.php?id=1745 such a solution for calling functions from Dll, where the parameters are passed as an array of Pointer.
PS I'm also interested in calling constructors in a similar way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vapaamies, 2016-03-28
@vapaamies

Free Pascal: Tricks with Objects .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question