Is it possible to pass a PHP userland function as a callbak in a COM interface.
| From: | Richard Quadling | Date: | Mon, 07 Sep 2009 10:47:20 +0000 |
| Subject: | Is it possible to pass a PHP userland function as a callbak in a COM interface. | ||
| Groups: | php.windows php.internals.win | ||
| Request: | Send a blank email to php-windows+get-29596@lists.php.net to get a copy of this message | ||
Hi.
I'm playing with a COM exposed OCR tool.
One of the methods of the COM interface requires a callback.
The VB and C++ examples simply supply the address of the function to
the method ...
(VB) ret = objOCR.OCRSetOutputHandlerX(AddressOf myOutputHandler)
(C++) OCRSetOutputHandler(myOutputHandler);
(NOTE: that is a straight cut'n'paste from their dox - I don't think
the C++ example is complete, but you get the idea).
So, in PHP, create_function() creates a "lambda_n" and function()
creates a "closure".
Trying to pass the either of these (with or without &) results in an
exception. Pretty much as expected.
Is there any way of passing this?
At the moment I don't think so, but I may be wrong.
I think we need a more direct way of exposing the PHP function, OR to
have a callback type which proxies the callback from the COM layer to
the php userland code.
As I understand things, a function call essentially puts the params on
a stack/heap, switches execution point to the function. The function
retrieves the params from the stack/heap and carries on executing.
As the PHP userland "function" isn't available in the same way, a
proxy seems to be the only way I could think of.
But, this is WAY out of my skill set (I'm remembering my c coding from
over 25 years ago - eek!).
Any ideas, suggestions, etc.
Regards,
Richard Quadling.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling