|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-04-10 18:09 UTC] phanto@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
I wrote a simple COM object using VC & ATL. Here a part of code HRESULT FetchValue([in, out]int* iValue, [out]int* iResult) STDMETHODIMP CSimpleCom::FetchValue(int* iValue, int* iResult) { int iTemp = *iValue + 10; *iValue = iTemp; *iResult = iTemp; return S_OK; } I wrote a PHP script to invoke this method. It can't get the new value from this function. <?php echo "Call Com Object<br>"; $instance = new COM("comtest.SimpleCom"); $value = 15; $result =10; $instance->FetchValue(&$value, &$result); echo "<b>Access function <i>void FetchValue(int*, int*): </i></b>"; echo "Output result: ".$result."<br>"; echo "Output value: ".$value."<br>"; $instance->release(); ?> After reading the source code, I found the function php_pval_to_variant in conversion.c didn't check if the variale is passed by reference. Am I right? Maybe this is the problem. By the way, this is a little bug in the COM interface function. php_VARIANT_call_function_handler (VARIANT.c) call function VariantInit(), and then call php_pval_to_variant_ex(conversion.c) --> php_pval_to_variant_ex2(conversion.c), the function VariantInit() has been called again. But in another invocation path do_COM_invoke(COM.c) -> php_pval_to_variant(conversion.c) -> php_pval_to_variant_ex2, the function VariantInit() is only invoked once.