]> granicus.if.org Git - php/commitdiff
removed VARIANT module and put the VARIANT class into
authorHarald Radi <phanto@php.net>
Mon, 24 Sep 2001 15:56:18 +0000 (15:56 +0000)
committerHarald Radi <phanto@php.net>
Mon, 24 Sep 2001 15:56:18 +0000 (15:56 +0000)
the COM module.
also fixed a few bugs.

12 files changed:
ext/com/COM.c
ext/com/TODO
ext/com/VARIANT.c
ext/com/conversion.c
ext/com/conversion.h
ext/com/php_VARIANT.h
ext/rpc/com/TODO
ext/rpc/com/com_wrapper.c
ext/rpc/com/conversion.c
ext/rpc/com/conversion.h
ext/rpc/com/php_variant.h
ext/rpc/com/variant.c

index b4d855242ebf1470fc8f25b4d3fcefc8ce350e03..e67084523bb73fa8daef2ba67bf73a0add767ffd 100644 (file)
@@ -554,7 +554,7 @@ PHP_FUNCTION(com_load)
                        pResults.pIID = &IID_IDispatch;
                        pResults.pItf = NULL;
                        pResults.hr = S_OK;
-                       hr=CoCreateInstanceEx(&clsid, NULL, CLSCTX_SERVER, &server_info, 1, &pResults);
+                       hr = CoCreateInstanceEx(&clsid, NULL, CLSCTX_REMOTE_SERVER, &server_info, 1, &pResults);
                        if (SUCCEEDED(hr)) {
                                hr = pResults.hr;
                                C_DISPATCH(obj) = (IDispatch *) pResults.pItf;
@@ -612,21 +612,21 @@ PHP_FUNCTION(com_load)
 int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **arguments, int arg_count TSRMLS_DC)
 {
        DISPID dispid;
+       DISPPARAMS dispparams;
        HRESULT hr;
        OLECHAR *funcname;
-       char *error_message;
+       SAFEARRAY *pSA;
+       SAFEARRAYBOUND rgsabound[1];
        VARIANT *variant_args;
+       char *error_message;
        int current_arg, current_variant;
-       DISPPARAMS dispparams;
-       SAFEARRAY *pSA;
+       unsigned long count;
 
        if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "next")) {
                /* Grab one argument off the stack, allocate enough
                 * VARIANTs
                 * Get the IEnumVariant interface and call ->Next();
                 */
-               SAFEARRAYBOUND rgsabound[1];
-               unsigned long count;
 
                switch (arg_count) {
                        case 0:
@@ -649,7 +649,6 @@ int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **
 
                if ((pSA = SafeArrayCreate(VT_VARIANT, 1, rgsabound)) == NULL) {
                        VariantInit(var_result);
-
                        return FAILURE;
                } else {
                        V_ARRAY(var_result) = pSA;
@@ -684,6 +683,25 @@ int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **
                }
 
                return SUCCESS;
+       } else if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "all")) {
+#define FETCH_BLOCKSIZE 10 /* fetch blocks of 10 elements */
+
+               count = FETCH_BLOCKSIZE;
+
+               rgsabound[0].lLbound = 0;
+               rgsabound[0].cElements = count;
+
+               if ((pSA = SafeArrayCreate(VT_VARIANT, 1, rgsabound)) == NULL) {
+                       VariantInit(var_result);
+                       return FAILURE;
+               } else {
+                       V_ARRAY(var_result) = pSA;
+                       V_VT(var_result) = VT_VARIANT|VT_ARRAY;
+               }
+
+               /* blah*/
+
+
        } else if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "reset")) {
                if (FAILED(hr = C_ENUMVARIANT_VT(obj)->Reset(C_ENUMVARIANT(obj)))) {
                        char *error_message = php_COM_error_message(hr TSRMLS_CC);
@@ -1668,6 +1686,9 @@ PHP_MINIT_FUNCTION(COM)
 {
        le_comval = zend_register_list_destructors_ex(php_comval_destructor, NULL, "COM", module_number);
        php_register_COM_class(TSRMLS_C);
+
+       php_VARIANT_init(module_number, TSRMLS_C);
+
        REGISTER_INI_ENTRIES();
        return SUCCESS;
 }
index 038df72a6420c557eff1e909397c5c6a4a9ca916..f25e91e590bfb6295c376fbce7cd6a293303904c 100644 (file)
@@ -1,5 +1,6 @@
 1) Multi-dimenstional array support
 -- done 2) IErrorInfo
+-- done 13) export VARIANT through the COM module
 3) WithEvents
 4) Documentation (internal and user) and howtos
 5) IEnumVariant::All() which would be like IEnumVariant::Next(IDispatch::Count)
 9) reduce the need for VARIANT()
 10) lets try if we are able to call non IDispatch - only Typelib components
 -- done 11) IEnumVariant::Next() without parameter should only return an object, not an array with one element
-12) VARIANT->value as lvalue
+-- done 12) VARIANT->value as lvalue
 
 
 ad 6.) check vbsample.php (new VARIANT(*, *|VT_BYREF)) GPs
 ad 4.) faq (i've collected a few questions from various lists)
+       variant attributes !!
 
 to be discussed:
 
index 5fb5760925cd0c5af03c7d42910c41dbf04558cc..4f521cdd4ceab242a3f36a29c05f513425e30661 100644 (file)
@@ -45,25 +45,7 @@ static int codepage;
 static zend_class_entry VARIANT_class_entry;
 
 
-function_entry VARIANT_functions[] = {
-       {NULL, NULL, NULL}
-};
-
-
-static PHP_MINFO_FUNCTION(VARIANT)
-{
-       php_info_print_table_start();
-       php_info_print_table_row(2, "VARIANT support", "enabled");
-       php_info_print_table_end();
-}
-
-
-zend_module_entry VARIANT_module_entry = {
-       "variant", VARIANT_functions, PHP_MINIT(VARIANT), PHP_MSHUTDOWN(VARIANT), NULL, NULL, PHP_MINFO(VARIANT), STANDARD_MODULE_PROPERTIES
-};
-
-
-PHP_MINIT_FUNCTION(VARIANT)
+void php_VARIANT_init(int module_number, TSRMLS_D)
 {
        le_variant = zend_register_list_destructors_ex(php_VARIANT_destructor, NULL, "VARIANT", module_number);
 
@@ -98,6 +80,7 @@ PHP_MINIT_FUNCTION(VARIANT)
        REGISTER_LONG_CONSTANT("CP_OEMCP", CP_OEMCP, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("CP_UTF7", CP_UTF7, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("CP_UTF8", CP_UTF8, CONST_CS | CONST_PERSISTENT);
+
 #ifdef CP_SYMBOL
        REGISTER_LONG_CONSTANT("CP_SYMBOL", CP_SYMBOL, CONST_CS | CONST_PERSISTENT);
 #else
@@ -110,13 +93,6 @@ PHP_MINIT_FUNCTION(VARIANT)
 #endif
 
        php_register_VARIANT_class(TSRMLS_C);
-       return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(VARIANT)
-{
-       return SUCCESS;
 }
 
 
@@ -252,94 +228,96 @@ static int php_VARIANT_set_property_handler(zend_property_reference *property_re
 
 static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC)
 {
-       pval type;
+       int type;
 
-       Z_TYPE(type) = IS_STRING;
+       if (!strcmp(Z_STRVAL_P(arg_property), "value")) {
+               php_pval_to_variant(value, var_arg, codepage TSRMLS_CC);
 
-       if (!strcmp(Z_STRVAL_P(arg_property), "bVal")) {
-               Z_LVAL(type) = VT_UI1;
+               return SUCCESS;
+       } else if (!strcmp(Z_STRVAL_P(arg_property), "bVal")) {
+               type = VT_UI1;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "iVal")) { 
-               Z_LVAL(type) = VT_I2;
+               type = VT_I2;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "lVal")) {
-               Z_LVAL(type) = VT_I4;
+               type = VT_I4;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "fltVal")) {
-               Z_LVAL(type) = VT_R4;
+               type = VT_R4;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "dblVal")) {
-               Z_LVAL(type) = VT_R8;
+               type = VT_R8;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "boolVal")) {
-               Z_LVAL(type) = VT_BOOL;
+               type = VT_BOOL;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "scode")) {
-               Z_LVAL(type) = VT_ERROR;
+               type = VT_ERROR;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "cyVal")) {
-               Z_LVAL(type) = VT_CY;
+               type = VT_CY;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "date")) {
-               Z_LVAL(type) = VT_DATE;
+               type = VT_DATE;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "bstrVal")) {
-               Z_LVAL(type) = VT_BSTR;
+               type = VT_BSTR;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdecVal")) {
-               Z_LVAL(type) = VT_DECIMAL|VT_BYREF;
+               type = VT_DECIMAL|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "punkVal")) {
-               Z_LVAL(type) = VT_UNKNOWN;
+               type = VT_UNKNOWN;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdispVal")) {
-               Z_LVAL(type) = VT_DISPATCH;
+               type = VT_DISPATCH;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "parray")) {
-               Z_LVAL(type) = VT_ARRAY;
+               type = VT_ARRAY;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pbVal")) {
-               Z_LVAL(type) = VT_UI1|VT_BYREF;
+               type = VT_UI1|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "piVal")) {
-               Z_LVAL(type) = VT_I2|VT_BYREF;
+               type = VT_I2|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "plVal")) {
-               Z_LVAL(type) = VT_I4|VT_BYREF;
+               type = VT_I4|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pfltVal")) {
-               Z_LVAL(type) = VT_R4|VT_BYREF;
+               type = VT_R4|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdblVal")) {
-               Z_LVAL(type) = VT_R8|VT_BYREF;
+               type = VT_R8|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pboolVal")) {
-               Z_LVAL(type) = VT_BOOL|VT_BYREF;
+               type = VT_BOOL|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pscode")) {
-               Z_LVAL(type) = VT_ERROR|VT_BYREF;
+               type = VT_ERROR|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pcyVal")) {
-               Z_LVAL(type) = VT_CY|VT_BYREF;
+               type = VT_CY|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdate")) {
-               Z_LVAL(type) = VT_DATE|VT_BYREF;
+               type = VT_DATE|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pbstrVal")) {
-               Z_LVAL(type) = VT_BSTR|VT_BYREF;
+               type = VT_BSTR|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "ppunkVal")) {
-               Z_LVAL(type) = VT_UNKNOWN|VT_BYREF;
+               type = VT_UNKNOWN|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "ppdispVal")) {
-               Z_LVAL(type) = VT_DISPATCH|VT_BYREF;
+               type = VT_DISPATCH|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pparray")) {
-               Z_LVAL(type) = VT_ARRAY|VT_BYREF;
+               type = VT_ARRAY|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pvarVal")) {
-               Z_LVAL(type) = VT_VARIANT|VT_BYREF;
+               type = VT_VARIANT|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "byref")) {
-               Z_LVAL(type) = VT_BYREF;
+               type = VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "cVal")) {
-               Z_LVAL(type) = VT_I1;
+               type = VT_I1;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "uiVal")) {
-               Z_LVAL(type) = VT_UI2;
+               type = VT_UI2;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "ulVal")) {
-               Z_LVAL(type) = VT_UI4;
+               type = VT_UI4;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "intVal")) {
-               Z_LVAL(type) = VT_INT;
+               type = VT_INT;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "uintVal")) {
-               Z_LVAL(type) = VT_UINT|VT_BYREF;
+               type = VT_UINT|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pcVal")) {
-               Z_LVAL(type) = VT_I1|VT_BYREF;
+               type = VT_I1|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "puiVal")) {
-               Z_LVAL(type) = VT_UI2|VT_BYREF;
+               type = VT_UI2|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pulVal")) {
-               Z_LVAL(type) = VT_UI4|VT_BYREF;
+               type = VT_UI4|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pintVal")) {
-               Z_LVAL(type) = VT_INT|VT_BYREF;
+               type = VT_INT|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "puintVal")) {
-               Z_LVAL(type) = VT_UINT|VT_BYREF;
+               type = VT_UINT|VT_BYREF;
        } else {
                php_error(E_WARNING, "Unknown member.");
                return FAILURE;
        }
 
-       php_pval_to_variant_ex(value, var_arg, &type, codepage TSRMLS_CC);
+       php_pval_to_variant_ex2(value, var_arg, type, codepage TSRMLS_CC);
 
        return SUCCESS;
 }
index 18ce7f17b81c32b48d83775281d14ff9d71969f7..ea5cde618830f4e895804824afb1533f564f7cd8 100644 (file)
@@ -37,7 +37,6 @@
 
 /* prototypes */
 
-static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
 static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
 
 /* implementations */
@@ -85,21 +84,17 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
                        break;
        }
 
-       if (pval_arg->is_ref) { /* deprecated, implemented for downwards compatiblity */
-//             type |= VT_BYREF;
-       }
-
-       pval_to_variant_ex(pval_arg, var_arg, type, codepage TSRMLS_CC);
+       php_pval_to_variant_ex2(pval_arg, var_arg, type, codepage TSRMLS_CC);
 }
 
 
 PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC)
 {
-       pval_to_variant_ex(pval_arg, var_arg, Z_LVAL_P(pval_type), codepage TSRMLS_CC);
+       php_pval_to_variant_ex2(pval_arg, var_arg, Z_LVAL_P(pval_type), codepage TSRMLS_CC);
 }
 
 
-static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC)
+PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC)
 {
        OLECHAR *unicode_str;
 
@@ -143,7 +138,7 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
                                                /* Add another value to the safe array */
                                                if (SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v))) {               /* Pointer to output element entry retrieved successfully */
                                                        if (type) {     /* explicit type */
-                                                          pval_to_variant_ex(*entry, v, type, codepage TSRMLS_CC);             /* Do the required conversion */
+                                                          php_pval_to_variant_ex2(*entry, v, type, codepage TSRMLS_CC);                /* Do the required conversion */
                                                        } else {
                                                                php_pval_to_variant(*entry, v, codepage TSRMLS_CC);                    /* Do the required conversion */
                                                        }
@@ -221,7 +216,9 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
                        case VT_BSTR:
                                convert_to_string_ex(&pval_arg);
                                unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
-                               V_BSTR(var_arg) = SysAllocString(unicode_str);
+                               V_BSTR(var_arg) = SysAllocStringByteLen((char *) unicode_str, Z_STRLEN_P(pval_arg));
+/*                             @todo test
+                               V_BSTR(var_arg) = SysAllocString(unicode_str); */
                                efree(unicode_str);
                                break;
 
@@ -456,7 +453,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TS
 
                /* This call has failed for everything I have tried */
                /* But best leave it to be on the safe side */
-               if (FAILED(SafeArrayGetVartype(array, &vartype))) {
+               if (FAILED(SafeArrayGetVartype(array, &vartype)) || (vartype == VT_EMPTY)) {
                        /* Fall back to what we do know */
                        /* Mask off the array bit and assume */
                        /* what is left is the type of the array */
index 20c078be795f230c89fd6abc5d8c0f37f51f8af2..f16d67306bd634ef28c77b7832339ac8ce830e0c 100644 (file)
@@ -5,6 +5,7 @@ BEGIN_EXTERN_C()
 
 PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC);
 PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC);
+PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
 PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TSRMLS_DC);
 PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC);
 PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int codepage TSRMLS_DC);
index 2447d066ad66a20ff6897af9e4955d4ed75f427a..3f829847589c79c37fdab55f97d3b405b5ab0441 100644 (file)
@@ -8,23 +8,12 @@ BEGIN_EXTERN_C()
 #include "conversion.h"
 #include "variant.h"
 
-PHP_MINIT_FUNCTION(VARIANT);
-PHP_MSHUTDOWN_FUNCTION(VARIANT);
+void php_VARIANT_init(int module_number, TSRMLS_D);
 
 PHPAPI int php_VARIANT_get_le_variant();
 
-zend_module_entry VARIANT_module_entry;
-
 END_EXTERN_C()
 
-#define VARIANT_module_ptr &VARIANT_module_entry
-
-#else
-
-#define VARIANT_module_ptr NULL
-
 #endif  /* PHP_WIN32 */
 
-#define phpext_VARIANT_ptr VARIANT_module_ptr
-
 #endif  /* PHP_TYPEDEF_VARIANT_H */
index 038df72a6420c557eff1e909397c5c6a4a9ca916..f25e91e590bfb6295c376fbce7cd6a293303904c 100644 (file)
@@ -1,5 +1,6 @@
 1) Multi-dimenstional array support
 -- done 2) IErrorInfo
+-- done 13) export VARIANT through the COM module
 3) WithEvents
 4) Documentation (internal and user) and howtos
 5) IEnumVariant::All() which would be like IEnumVariant::Next(IDispatch::Count)
 9) reduce the need for VARIANT()
 10) lets try if we are able to call non IDispatch - only Typelib components
 -- done 11) IEnumVariant::Next() without parameter should only return an object, not an array with one element
-12) VARIANT->value as lvalue
+-- done 12) VARIANT->value as lvalue
 
 
 ad 6.) check vbsample.php (new VARIANT(*, *|VT_BYREF)) GPs
 ad 4.) faq (i've collected a few questions from various lists)
+       variant attributes !!
 
 to be discussed:
 
index b4d855242ebf1470fc8f25b4d3fcefc8ce350e03..e67084523bb73fa8daef2ba67bf73a0add767ffd 100644 (file)
@@ -554,7 +554,7 @@ PHP_FUNCTION(com_load)
                        pResults.pIID = &IID_IDispatch;
                        pResults.pItf = NULL;
                        pResults.hr = S_OK;
-                       hr=CoCreateInstanceEx(&clsid, NULL, CLSCTX_SERVER, &server_info, 1, &pResults);
+                       hr = CoCreateInstanceEx(&clsid, NULL, CLSCTX_REMOTE_SERVER, &server_info, 1, &pResults);
                        if (SUCCEEDED(hr)) {
                                hr = pResults.hr;
                                C_DISPATCH(obj) = (IDispatch *) pResults.pItf;
@@ -612,21 +612,21 @@ PHP_FUNCTION(com_load)
 int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **arguments, int arg_count TSRMLS_DC)
 {
        DISPID dispid;
+       DISPPARAMS dispparams;
        HRESULT hr;
        OLECHAR *funcname;
-       char *error_message;
+       SAFEARRAY *pSA;
+       SAFEARRAYBOUND rgsabound[1];
        VARIANT *variant_args;
+       char *error_message;
        int current_arg, current_variant;
-       DISPPARAMS dispparams;
-       SAFEARRAY *pSA;
+       unsigned long count;
 
        if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "next")) {
                /* Grab one argument off the stack, allocate enough
                 * VARIANTs
                 * Get the IEnumVariant interface and call ->Next();
                 */
-               SAFEARRAYBOUND rgsabound[1];
-               unsigned long count;
 
                switch (arg_count) {
                        case 0:
@@ -649,7 +649,6 @@ int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **
 
                if ((pSA = SafeArrayCreate(VT_VARIANT, 1, rgsabound)) == NULL) {
                        VariantInit(var_result);
-
                        return FAILURE;
                } else {
                        V_ARRAY(var_result) = pSA;
@@ -684,6 +683,25 @@ int do_COM_invoke(comval *obj, pval *function_name, VARIANT *var_result, pval **
                }
 
                return SUCCESS;
+       } else if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "all")) {
+#define FETCH_BLOCKSIZE 10 /* fetch blocks of 10 elements */
+
+               count = FETCH_BLOCKSIZE;
+
+               rgsabound[0].lLbound = 0;
+               rgsabound[0].cElements = count;
+
+               if ((pSA = SafeArrayCreate(VT_VARIANT, 1, rgsabound)) == NULL) {
+                       VariantInit(var_result);
+                       return FAILURE;
+               } else {
+                       V_ARRAY(var_result) = pSA;
+                       V_VT(var_result) = VT_VARIANT|VT_ARRAY;
+               }
+
+               /* blah*/
+
+
        } else if (C_HASENUM(obj) && strstr(Z_STRVAL_P(function_name), "reset")) {
                if (FAILED(hr = C_ENUMVARIANT_VT(obj)->Reset(C_ENUMVARIANT(obj)))) {
                        char *error_message = php_COM_error_message(hr TSRMLS_CC);
@@ -1668,6 +1686,9 @@ PHP_MINIT_FUNCTION(COM)
 {
        le_comval = zend_register_list_destructors_ex(php_comval_destructor, NULL, "COM", module_number);
        php_register_COM_class(TSRMLS_C);
+
+       php_VARIANT_init(module_number, TSRMLS_C);
+
        REGISTER_INI_ENTRIES();
        return SUCCESS;
 }
index 18ce7f17b81c32b48d83775281d14ff9d71969f7..ea5cde618830f4e895804824afb1533f564f7cd8 100644 (file)
@@ -37,7 +37,6 @@
 
 /* prototypes */
 
-static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
 static void comval_to_variant(pval *pval_arg, VARIANT *var_arg TSRMLS_DC);
 
 /* implementations */
@@ -85,21 +84,17 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
                        break;
        }
 
-       if (pval_arg->is_ref) { /* deprecated, implemented for downwards compatiblity */
-//             type |= VT_BYREF;
-       }
-
-       pval_to_variant_ex(pval_arg, var_arg, type, codepage TSRMLS_CC);
+       php_pval_to_variant_ex2(pval_arg, var_arg, type, codepage TSRMLS_CC);
 }
 
 
 PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC)
 {
-       pval_to_variant_ex(pval_arg, var_arg, Z_LVAL_P(pval_type), codepage TSRMLS_CC);
+       php_pval_to_variant_ex2(pval_arg, var_arg, Z_LVAL_P(pval_type), codepage TSRMLS_CC);
 }
 
 
-static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC)
+PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC)
 {
        OLECHAR *unicode_str;
 
@@ -143,7 +138,7 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
                                                /* Add another value to the safe array */
                                                if (SUCCEEDED(SafeArrayPtrOfIndex( safeArray, &i, &v))) {               /* Pointer to output element entry retrieved successfully */
                                                        if (type) {     /* explicit type */
-                                                          pval_to_variant_ex(*entry, v, type, codepage TSRMLS_CC);             /* Do the required conversion */
+                                                          php_pval_to_variant_ex2(*entry, v, type, codepage TSRMLS_CC);                /* Do the required conversion */
                                                        } else {
                                                                php_pval_to_variant(*entry, v, codepage TSRMLS_CC);                    /* Do the required conversion */
                                                        }
@@ -221,7 +216,9 @@ static void pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, int type, int c
                        case VT_BSTR:
                                convert_to_string_ex(&pval_arg);
                                unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC);
-                               V_BSTR(var_arg) = SysAllocString(unicode_str);
+                               V_BSTR(var_arg) = SysAllocStringByteLen((char *) unicode_str, Z_STRLEN_P(pval_arg));
+/*                             @todo test
+                               V_BSTR(var_arg) = SysAllocString(unicode_str); */
                                efree(unicode_str);
                                break;
 
@@ -456,7 +453,7 @@ PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TS
 
                /* This call has failed for everything I have tried */
                /* But best leave it to be on the safe side */
-               if (FAILED(SafeArrayGetVartype(array, &vartype))) {
+               if (FAILED(SafeArrayGetVartype(array, &vartype)) || (vartype == VT_EMPTY)) {
                        /* Fall back to what we do know */
                        /* Mask off the array bit and assume */
                        /* what is left is the type of the array */
index 20c078be795f230c89fd6abc5d8c0f37f51f8af2..f16d67306bd634ef28c77b7832339ac8ce830e0c 100644 (file)
@@ -5,6 +5,7 @@ BEGIN_EXTERN_C()
 
 PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage TSRMLS_DC);
 PHPAPI void php_pval_to_variant_ex(pval *pval_arg, VARIANT *var_arg, pval *pval_type, int codepage TSRMLS_DC);
+PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type, int codepage TSRMLS_DC);
 PHPAPI int php_variant_to_pval(VARIANT *var_arg, pval *pval_arg, int codepage TSRMLS_DC);
 PHPAPI OLECHAR *php_char_to_OLECHAR(char *C_str, uint strlen, int codepage TSRMLS_DC);
 PHPAPI char *php_OLECHAR_to_char(OLECHAR *unicode_str, uint *out_length, int codepage TSRMLS_DC);
index 2447d066ad66a20ff6897af9e4955d4ed75f427a..3f829847589c79c37fdab55f97d3b405b5ab0441 100644 (file)
@@ -8,23 +8,12 @@ BEGIN_EXTERN_C()
 #include "conversion.h"
 #include "variant.h"
 
-PHP_MINIT_FUNCTION(VARIANT);
-PHP_MSHUTDOWN_FUNCTION(VARIANT);
+void php_VARIANT_init(int module_number, TSRMLS_D);
 
 PHPAPI int php_VARIANT_get_le_variant();
 
-zend_module_entry VARIANT_module_entry;
-
 END_EXTERN_C()
 
-#define VARIANT_module_ptr &VARIANT_module_entry
-
-#else
-
-#define VARIANT_module_ptr NULL
-
 #endif  /* PHP_WIN32 */
 
-#define phpext_VARIANT_ptr VARIANT_module_ptr
-
 #endif  /* PHP_TYPEDEF_VARIANT_H */
index 5fb5760925cd0c5af03c7d42910c41dbf04558cc..4f521cdd4ceab242a3f36a29c05f513425e30661 100644 (file)
@@ -45,25 +45,7 @@ static int codepage;
 static zend_class_entry VARIANT_class_entry;
 
 
-function_entry VARIANT_functions[] = {
-       {NULL, NULL, NULL}
-};
-
-
-static PHP_MINFO_FUNCTION(VARIANT)
-{
-       php_info_print_table_start();
-       php_info_print_table_row(2, "VARIANT support", "enabled");
-       php_info_print_table_end();
-}
-
-
-zend_module_entry VARIANT_module_entry = {
-       "variant", VARIANT_functions, PHP_MINIT(VARIANT), PHP_MSHUTDOWN(VARIANT), NULL, NULL, PHP_MINFO(VARIANT), STANDARD_MODULE_PROPERTIES
-};
-
-
-PHP_MINIT_FUNCTION(VARIANT)
+void php_VARIANT_init(int module_number, TSRMLS_D)
 {
        le_variant = zend_register_list_destructors_ex(php_VARIANT_destructor, NULL, "VARIANT", module_number);
 
@@ -98,6 +80,7 @@ PHP_MINIT_FUNCTION(VARIANT)
        REGISTER_LONG_CONSTANT("CP_OEMCP", CP_OEMCP, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("CP_UTF7", CP_UTF7, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("CP_UTF8", CP_UTF8, CONST_CS | CONST_PERSISTENT);
+
 #ifdef CP_SYMBOL
        REGISTER_LONG_CONSTANT("CP_SYMBOL", CP_SYMBOL, CONST_CS | CONST_PERSISTENT);
 #else
@@ -110,13 +93,6 @@ PHP_MINIT_FUNCTION(VARIANT)
 #endif
 
        php_register_VARIANT_class(TSRMLS_C);
-       return SUCCESS;
-}
-
-
-PHP_MSHUTDOWN_FUNCTION(VARIANT)
-{
-       return SUCCESS;
 }
 
 
@@ -252,94 +228,96 @@ static int php_VARIANT_set_property_handler(zend_property_reference *property_re
 
 static int do_VARIANT_propset(VARIANT *var_arg, pval *arg_property, pval *value TSRMLS_DC)
 {
-       pval type;
+       int type;
 
-       Z_TYPE(type) = IS_STRING;
+       if (!strcmp(Z_STRVAL_P(arg_property), "value")) {
+               php_pval_to_variant(value, var_arg, codepage TSRMLS_CC);
 
-       if (!strcmp(Z_STRVAL_P(arg_property), "bVal")) {
-               Z_LVAL(type) = VT_UI1;
+               return SUCCESS;
+       } else if (!strcmp(Z_STRVAL_P(arg_property), "bVal")) {
+               type = VT_UI1;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "iVal")) { 
-               Z_LVAL(type) = VT_I2;
+               type = VT_I2;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "lVal")) {
-               Z_LVAL(type) = VT_I4;
+               type = VT_I4;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "fltVal")) {
-               Z_LVAL(type) = VT_R4;
+               type = VT_R4;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "dblVal")) {
-               Z_LVAL(type) = VT_R8;
+               type = VT_R8;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "boolVal")) {
-               Z_LVAL(type) = VT_BOOL;
+               type = VT_BOOL;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "scode")) {
-               Z_LVAL(type) = VT_ERROR;
+               type = VT_ERROR;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "cyVal")) {
-               Z_LVAL(type) = VT_CY;
+               type = VT_CY;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "date")) {
-               Z_LVAL(type) = VT_DATE;
+               type = VT_DATE;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "bstrVal")) {
-               Z_LVAL(type) = VT_BSTR;
+               type = VT_BSTR;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdecVal")) {
-               Z_LVAL(type) = VT_DECIMAL|VT_BYREF;
+               type = VT_DECIMAL|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "punkVal")) {
-               Z_LVAL(type) = VT_UNKNOWN;
+               type = VT_UNKNOWN;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdispVal")) {
-               Z_LVAL(type) = VT_DISPATCH;
+               type = VT_DISPATCH;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "parray")) {
-               Z_LVAL(type) = VT_ARRAY;
+               type = VT_ARRAY;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pbVal")) {
-               Z_LVAL(type) = VT_UI1|VT_BYREF;
+               type = VT_UI1|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "piVal")) {
-               Z_LVAL(type) = VT_I2|VT_BYREF;
+               type = VT_I2|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "plVal")) {
-               Z_LVAL(type) = VT_I4|VT_BYREF;
+               type = VT_I4|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pfltVal")) {
-               Z_LVAL(type) = VT_R4|VT_BYREF;
+               type = VT_R4|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdblVal")) {
-               Z_LVAL(type) = VT_R8|VT_BYREF;
+               type = VT_R8|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pboolVal")) {
-               Z_LVAL(type) = VT_BOOL|VT_BYREF;
+               type = VT_BOOL|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pscode")) {
-               Z_LVAL(type) = VT_ERROR|VT_BYREF;
+               type = VT_ERROR|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pcyVal")) {
-               Z_LVAL(type) = VT_CY|VT_BYREF;
+               type = VT_CY|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pdate")) {
-               Z_LVAL(type) = VT_DATE|VT_BYREF;
+               type = VT_DATE|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pbstrVal")) {
-               Z_LVAL(type) = VT_BSTR|VT_BYREF;
+               type = VT_BSTR|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "ppunkVal")) {
-               Z_LVAL(type) = VT_UNKNOWN|VT_BYREF;
+               type = VT_UNKNOWN|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "ppdispVal")) {
-               Z_LVAL(type) = VT_DISPATCH|VT_BYREF;
+               type = VT_DISPATCH|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pparray")) {
-               Z_LVAL(type) = VT_ARRAY|VT_BYREF;
+               type = VT_ARRAY|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pvarVal")) {
-               Z_LVAL(type) = VT_VARIANT|VT_BYREF;
+               type = VT_VARIANT|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "byref")) {
-               Z_LVAL(type) = VT_BYREF;
+               type = VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "cVal")) {
-               Z_LVAL(type) = VT_I1;
+               type = VT_I1;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "uiVal")) {
-               Z_LVAL(type) = VT_UI2;
+               type = VT_UI2;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "ulVal")) {
-               Z_LVAL(type) = VT_UI4;
+               type = VT_UI4;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "intVal")) {
-               Z_LVAL(type) = VT_INT;
+               type = VT_INT;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "uintVal")) {
-               Z_LVAL(type) = VT_UINT|VT_BYREF;
+               type = VT_UINT|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pcVal")) {
-               Z_LVAL(type) = VT_I1|VT_BYREF;
+               type = VT_I1|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "puiVal")) {
-               Z_LVAL(type) = VT_UI2|VT_BYREF;
+               type = VT_UI2|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pulVal")) {
-               Z_LVAL(type) = VT_UI4|VT_BYREF;
+               type = VT_UI4|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "pintVal")) {
-               Z_LVAL(type) = VT_INT|VT_BYREF;
+               type = VT_INT|VT_BYREF;
        } else if (!strcmp(Z_STRVAL_P(arg_property), "puintVal")) {
-               Z_LVAL(type) = VT_UINT|VT_BYREF;
+               type = VT_UINT|VT_BYREF;
        } else {
                php_error(E_WARNING, "Unknown member.");
                return FAILURE;
        }
 
-       php_pval_to_variant_ex(value, var_arg, &type, codepage TSRMLS_CC);
+       php_pval_to_variant_ex2(value, var_arg, type, codepage TSRMLS_CC);
 
        return SUCCESS;
 }