Is it possible to pass a PHP userland function as a callbak in a COM

Is it possible to pass a PHP userland function as a callbak in a COM

am 07.09.2009 12:47:20 von Richard Quadling

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

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php