wharmby Fri Feb 2 08:42:32 2007 UTC Modified files: /php-src/ext/com_dotnet com_misc.c php_com_dotnet_internal.h com_variant.c com_wrapper.c Log: ADW: Fix COM extension bug #35463. Fix in/out argument processing http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_misc.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/ext/com_dotnet/com_misc.c diff -u php-src/ext/com_dotnet/com_misc.c:1.13 php-src/ext/com_dotnet/com_misc.c:1.14 --- php-src/ext/com_dotnet/com_misc.c:1.13 Thu Feb 1 18:05:10 2007 +++ php-src/ext/com_dotnet/com_misc.c Fri Feb 2 08:42:32 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: com_misc.c,v 1.13 2007/02/01 18:05:10 wharmby Exp $ */ +/* $Id: com_misc.c,v 1.14 2007/02/02 08:42:32 wharmby Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -78,6 +78,7 @@ VariantInit(&obj->v); VariantCopyInd(&obj->v, v); + obj->modified = 0; if ((V_VT(&obj->v) == VT_DISPATCH) && (V_DISPATCH(&obj->v) != NULL)) { IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &obj->typeinfo); http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/php_com_dotnet_internal.h?r1=1.21&r2=1.22&diff_format=u Index: php-src/ext/com_dotnet/php_com_dotnet_internal.h diff -u php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.21 php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.22 --- php-src/ext/com_dotnet/php_com_dotnet_internal.h:1.21 Mon Jan 1 09:29:22 2007 +++ php-src/ext/com_dotnet/php_com_dotnet_internal.h Fri Feb 2 08:42:32 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_com_dotnet_internal.h,v 1.21 2007/01/01 09:29:22 sebastian Exp $ */ +/* $Id: php_com_dotnet_internal.h,v 1.22 2007/02/02 08:42:32 wharmby Exp $ */ #ifndef PHP_COM_DOTNET_INTERNAL_H #define PHP_COM_DOTNET_INTERNAL_H @@ -36,6 +36,7 @@ zend_object zo; VARIANT v; + int modified; ITypeInfo *typeinfo; long code_page; @@ -152,6 +153,7 @@ PHPAPI void php_com_variant_from_zval_with_type(VARIANT *v, zval *z, VARTYPE type, int codepage TSRMLS_DC); PHPAPI void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC); PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC); +PHPAPI int php_com_copy_variant(VARIANT *dst, VARIANT *src TSRMLS_DC); /* com_dotnet.c */ PHP_FUNCTION(com_dotnet_create_instance); http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_variant.c?r1=1.20&r2=1.21&diff_format=u Index: php-src/ext/com_dotnet/com_variant.c diff -u php-src/ext/com_dotnet/com_variant.c:1.20 php-src/ext/com_dotnet/com_variant.c:1.21 --- php-src/ext/com_dotnet/com_variant.c:1.20 Mon Jan 1 09:29:22 2007 +++ php-src/ext/com_dotnet/com_variant.c Fri Feb 2 08:42:32 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: com_variant.c,v 1.20 2007/01/01 09:29:22 sebastian Exp $ */ +/* $Id: com_variant.c,v 1.21 2007/02/02 08:42:32 wharmby Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -264,6 +264,140 @@ return ret; } + +PHPAPI int php_com_copy_variant(VARIANT *dstvar, VARIANT *srcvar TSRMLS_DC) +{ + int ret = SUCCESS; + + switch (V_VT(dstvar) & ~VT_BYREF) { + case VT_EMPTY: + case VT_NULL: + case VT_VOID: + /* should not be possible */ + break; + + case VT_UI1: + if (V_VT(dstvar) & VT_BYREF) { + *V_UI1REF(dstvar) = V_UI1(srcvar); + } else { + V_UI1(dstvar) = V_UI1(srcvar); + } + break; + + case VT_I1: + if (V_VT(dstvar) & VT_BYREF) { + *V_I1REF(dstvar) = V_I1(srcvar); + } else { + V_I1(dstvar) = V_I1(srcvar); + } + break; + + case VT_UI2: + if (V_VT(dstvar) & VT_BYREF) { + *V_UI2REF(dstvar) = V_UI2(srcvar); + } else { + V_UI2(dstvar) = V_UI2(srcvar); + } + break; + + case VT_I2: + if (V_VT(dstvar) & VT_BYREF) { + *V_I2REF(dstvar) = V_I2(srcvar); + } else { + V_I2(dstvar) = V_I2(srcvar); + } + break; + + case VT_UI4: + if (V_VT(dstvar) & VT_BYREF) { + *V_UI4REF(dstvar) = V_UI4(srcvar); + } else { + V_UI4(dstvar) = V_UI4(srcvar); + } + break; + + case VT_I4: + if (V_VT(dstvar) & VT_BYREF) { + *V_I4REF(dstvar) = V_I4(srcvar); + } else { + V_I4(dstvar) = V_I4(srcvar); + } + break; + + case VT_INT: + if (V_VT(dstvar) & VT_BYREF) { + *V_INTREF(dstvar) = V_INT(srcvar); + } else { + V_INT(dstvar) = V_INT(srcvar); + } + break; + + case VT_UINT: + if (V_VT(dstvar) & VT_BYREF) { + *V_UINTREF(dstvar) = V_UINT(srcvar); + } else { + V_UINT(dstvar) = V_UINT(srcvar); + } + break; + + case VT_R4: + if (V_VT(dstvar) & VT_BYREF) { + *V_R4REF(dstvar) = V_R4(srcvar); + } else { + V_R4(dstvar) = V_R4(srcvar); + } + break; + + case VT_R8: + if (V_VT(dstvar) & VT_BYREF) { + *V_R8REF(dstvar) = V_R8(srcvar); + } else { + V_R8(dstvar) = V_R8(srcvar); + } + break; + + case VT_BOOL: + if (V_VT(dstvar) & VT_BYREF) { + *V_BOOLREF(dstvar) = V_BOOL(srcvar); + } else { + V_BOOL(dstvar) = V_BOOL(srcvar); + } + break; + + case VT_BSTR: + if (V_VT(dstvar) & VT_BYREF) { + *V_BSTRREF(dstvar) = V_BSTR(srcvar); + } else { + V_BSTR(dstvar) = V_BSTR(srcvar); + } + break; + + case VT_UNKNOWN: + if (V_VT(dstvar) & VT_BYREF) { + *V_UNKNOWNREF(dstvar) = V_UNKNOWN(srcvar); + } else { + V_UNKNOWN(dstvar) = V_UNKNOWN(srcvar); + } + break; + + case VT_DISPATCH: + if (V_VT(dstvar) & VT_BYREF) { + *V_DISPATCHREF(dstvar) = V_DISPATCH(srcvar); + } else { + V_DISPATCH(dstvar) = V_DISPATCH(srcvar); + } + break; + + case VT_VARIANT: + return php_com_copy_variant(V_VARIANTREF(dstvar), srcvar TSRMLS_CC); + + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "variant->variant: failed to copy from 0x%x to 0x%x", V_VT(dstvar), V_VT(srcvar)); + ret = FAILURE; + } + return ret; +} + /* {{{ com_variant_create_instance - ctor for new VARIANT() */ PHP_FUNCTION(com_variant_create_instance) { @@ -364,6 +498,8 @@ VariantClear(&obj->v); php_com_variant_from_zval(&obj->v, zvalue, obj->code_page TSRMLS_CC); + /* remember we modified this variant */ + obj->modified = 1; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/com_wrapper.c?r1=1.12&r2=1.13&diff_format=u Index: php-src/ext/com_dotnet/com_wrapper.c diff -u php-src/ext/com_dotnet/com_wrapper.c:1.12 php-src/ext/com_dotnet/com_wrapper.c:1.13 --- php-src/ext/com_dotnet/com_wrapper.c:1.12 Mon Jan 1 09:29:22 2007 +++ php-src/ext/com_dotnet/com_wrapper.c Fri Feb 2 08:42:32 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: com_wrapper.c,v 1.12 2007/01/01 09:29:22 sebastian Exp $ */ +/* $Id: com_wrapper.c,v 1.13 2007/02/02 08:42:32 wharmby Exp $ */ /* This module exports a PHP object as a COM object by wrapping it * using IDispatchEx */ @@ -298,6 +298,17 @@ &retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) { ret = S_OK; trace("function called ok\n"); + + /* Copy any modified values to callers copy of variant*/ + for (i = 0; i < pdp->cArgs; i++) { + php_com_dotnet_object *obj = CDNO_FETCH(*params[i]); + VARIANT *srcvar = &obj->v; + VARIANT *dstvar = &pdp->rgvarg[ pdp->cArgs - 1 - i]; + if ((V_VT(dstvar) & VT_BYREF) && obj->modified ) { + trace("percolate modified value for arg %d VT=%08x\n", i, V_VT(dstvar)); + php_com_copy_variant(dstvar, srcvar TSRMLS_CC); + } + } } else { trace("failed to call func\n"); ret = DISP_E_EXCEPTION;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php