diff options
author | Wez Furlong <wez@php.net> | 2004-01-07 21:00:07 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2004-01-07 21:00:07 +0000 |
commit | e10c206dac0fbd43e20f9ae9b704e76c5c564d2f (patch) | |
tree | 9675f1c8d2760ce9e7d3f6bf766d5ad434dc96c0 /ext/com_dotnet/com_variant.c | |
parent | 48b96c10d2c9efbe4ff11876c6cd9f9361073bc3 (diff) | |
download | php-git-e10c206dac0fbd43e20f9ae9b704e76c5c564d2f.tar.gz |
Port other major parts of PHP 4 COM extension into PHP 5 com_dotnet
extension.
This enables:
- iteration of SafeArray types via foreach()
- proxying of multi-dimensional SafeArray types so that multi-dimension
array accesses work (untested!)
- Fix COM exceptions, and expose them as their own class of exception
"com_exception"
- auto typelib file import (com.typelib_file ini option)
- event sinking
- wrapper to map PHP objects to COM
- fix mapping of variant values to PHP values
# Could someone please add com_saproxy.c and com_wrapper.c to the .dsp
# file?
Diffstat (limited to 'ext/com_dotnet/com_variant.c')
-rw-r--r-- | ext/com_dotnet/com_variant.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index a9b89c19ee..c848660a4c 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 4 | + | PHP Version 5 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2003 The PHP Group | +----------------------------------------------------------------------+ @@ -59,8 +59,9 @@ PHPAPI void php_com_variant_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_D V_VARIANTREF(v) = &obj->v; } } else { - /* TODO: export the object using our COM wrapper */ - V_VT(v) = VT_NULL; + /* export the PHP object using our COM wrapper */ + V_VT(v) = VT_DISPATCH; + V_DISPATCH(v) = php_com_wrapper_export(z TSRMLS_CC); } break; @@ -168,6 +169,9 @@ PHPAPI int php_com_zval_from_variant(zval *z, VARIANT *v, int codepage TSRMLS_DC break; case VT_VARIANT: + /* points to another variant */ + return php_com_zval_from_variant(z, V_VARIANTREF(v), codepage TSRMLS_CC); + default: php_com_wrap_variant(z, v, codepage TSRMLS_CC); } @@ -202,7 +206,7 @@ PHP_FUNCTION(com_variant_create_instance) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!|ll", &zvalue, &vt, &codepage)) { - php_com_throw_exception("Invalid arguments" TSRMLS_CC); + php_com_throw_exception(E_INVALIDARG, "Invalid arguments" TSRMLS_CC); return; } @@ -223,7 +227,7 @@ PHP_FUNCTION(com_variant_create_instance) spprintf(&msg, 0, "Variant type conversion failed: %s", werr); LocalFree(werr); - php_com_throw_exception(msg TSRMLS_CC); + php_com_throw_exception(res, msg TSRMLS_CC); efree(msg); } } @@ -254,6 +258,11 @@ PHP_FUNCTION(variant_set) ITypeInfo_Release(obj->typeinfo); obj->typeinfo = NULL; } + if (obj->sink_dispatch) { + php_com_object_enable_event_sink(obj, FALSE TSRMLS_CC); + IDispatch_Release(obj->sink_dispatch); + obj->sink_dispatch = NULL; + } VariantClear(&obj->v); @@ -779,7 +788,7 @@ PHP_FUNCTION(variant_set_type) spprintf(&msg, 0, "Variant type conversion failed: %s", werr); LocalFree(werr); - php_com_throw_exception(msg TSRMLS_CC); + php_com_throw_exception(res, msg TSRMLS_CC); efree(msg); } } @@ -813,7 +822,7 @@ PHP_FUNCTION(variant_cast) spprintf(&msg, 0, "Variant type conversion failed: %s", werr); LocalFree(werr); - php_com_throw_exception(msg TSRMLS_CC); + php_com_throw_exception(res, msg TSRMLS_CC); efree(msg); } |