PerlCtrl, COM objects and callbacks

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
G'day everyone

I have a VB application (though it could easily be any other 3GL)
which calls a PerlCtrl'd COM object. What I'd like to be able to do is
to create a real (or ersatz) callback mechanism. The idea would be to
pass to the Perl object a long containing the address of a function or
procedure and have Perl call that address. IIRC, the COM object would
run in-process so the address would be meaningful within that

I can generate the address and pass it in to the COM. What I don't
know is how to have Perl either call or jump to that address.

Any ideas? Should I give up now, before I do any damage?

Kind regards,

Re: PerlCtrl, COM objects and callbacks

Quoted text here. Click to load it

Better would be if you could pass some sort of COM object with a single
method Perl can invoke (the Java 'functor' pattern, commonly used in OO
languages as a poor substitute for closures). I've no idea how you might
do this from VB, but I would have thought it's possible.

Quoted text here. Click to load it

You can't call a function by machine address from Perl. If you have a
compiler you can write a tiny bit of XS to do this, trivially (assuming
you know the prototype/calling convention at compile time). If you
don't, but the called functions use the __stdcall calling convention
(likely if they're not C functions) then you ought to be able to fake up
a Win32::API object using the address given and then invoke that.

Quoted text here. Click to load it

Just be aware that poking about in memory like this undercuts the safety
of a high-level language like Perl or VB: you need to be as careful as
you would be in C or assembler. If you get segfaults or random memory
corruption, they're your fault :).


Site Timeline