]> granicus.if.org Git - php/commitdiff
integrating wez's patch
authorHarald Radi <phanto@php.net>
Mon, 20 May 2002 15:35:57 +0000 (15:35 +0000)
committerHarald Radi <phanto@php.net>
Mon, 20 May 2002 15:35:57 +0000 (15:35 +0000)
ext/com/COM.c
ext/com/com.h
ext/com/conversion.c
ext/rpc/com/com_wrapper.c
ext/rpc/com/com_wrapper.h
ext/rpc/com/conversion.c

index f8149faf7cbfaf08a48e93466d3a924496662af8..2e57eb1bd6ff23810413a228cbcea17fd1f1837f 100644 (file)
@@ -1427,25 +1427,13 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
 PHPAPI zval *php_COM_object_from_dispatch(IDispatch *disp, zval *val TSRMLS_DC)
 {
        comval *obj;
-       long rid;
        zval *zobj;
        
        ALLOC_COM(obj);
-       C_DISPATCH(obj) = disp;
-       php_COM_set(obj, &C_DISPATCH(obj), FALSE TSRMLS_CC);
-       
-       /* resource */
-       rid = zend_list_insert(obj, IS_COM);
-
-       if (val == NULL)
-               MAKE_STD_ZVAL(val);
-       ZVAL_RESOURCE(val, rid);
-
-       /* now we want an object */
        MAKE_STD_ZVAL(zobj);
-       object_init_ex(zobj, &COM_class_entry);
-       zend_hash_index_update(Z_OBJPROP_P(zobj), 0, &val, sizeof(zval *), NULL);       
-
+       php_COM_set(obj, &disp, FALSE TSRMLS_CC);
+       ZVAL_COM_EX(zobj, obj, val);
+       
        return zobj;
 }
 
index 62d08c3acd9a2b9ded84b6e722051a00f40002d0..2930f86fd9285d7895546fa7dc514e6414d3413b 100644 (file)
@@ -24,13 +24,19 @@ typedef struct comval_ {
 END_EXTERN_C()
 
 #define ZVAL_COM(z,o) {                                                                                                                                \
-                       zval *handle;                                                                                                                   \
+                       zval *handle = NULL;                                                                                                    \
+                       ZVAL_COM_EX(z,o,handle)                                                                                                 \
+               }
+
+#define ZVAL_COM_EX(z,o,handle) {                                                                                                      \
                        HashTable *properties;                                                                                                  \
                                                                                                                                                                        \
                        ALLOC_HASHTABLE(properties);                                                                                    \
                        zend_hash_init(properties, 0, NULL, ZVAL_PTR_DTOR, 0);                                  \
                                                                                                                                                                        \
-                       MAKE_STD_ZVAL(handle);                                                                                                  \
+                       if (handle == NULL) {                                                                                                   \
+                               MAKE_STD_ZVAL(handle);                                                                                          \
+                       }                                                                                                                                               \
                        ZVAL_LONG(handle, zend_list_insert((o), IS_COM));                                               \
                                                                                                                                                                        \
                        zval_copy_ctor(handle);                                                                                                 \
index 130885edd95302f3954ece1cffe370fd62e37195..c9e4f894142e15dab0be4a6e514a5bfcba4f4e92 100644 (file)
@@ -56,8 +56,6 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
                case IS_OBJECT:
                        if (!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT")) {
                                type = VT_VARIANT|VT_BYREF;
-                       } else if (!strcmp(Z_OBJCE_P(pval_arg)->name, "COM")) {
-                               type = VT_DISPATCH;
                        } else {
                                type = VT_DISPATCH;
                        }
@@ -275,8 +273,9 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
                                        comval_to_variant(pval_arg, var_arg TSRMLS_CC);
                                } else {
                                        V_DISPATCH(var_arg) = php_COM_export_object(pval_arg TSRMLS_CC);
-                                       if (V_DISPATCH(var_arg))
+                                       if (V_DISPATCH(var_arg)) {
                                                V_VT(var_arg) = VT_DISPATCH;
+                                       }
                                }
                                if (V_VT(var_arg) != VT_DISPATCH) {
                                        VariantInit(var_arg);
index f8149faf7cbfaf08a48e93466d3a924496662af8..2e57eb1bd6ff23810413a228cbcea17fd1f1837f 100644 (file)
@@ -1427,25 +1427,13 @@ PHPAPI int php_COM_set_property_handler(zend_property_reference *property_refere
 PHPAPI zval *php_COM_object_from_dispatch(IDispatch *disp, zval *val TSRMLS_DC)
 {
        comval *obj;
-       long rid;
        zval *zobj;
        
        ALLOC_COM(obj);
-       C_DISPATCH(obj) = disp;
-       php_COM_set(obj, &C_DISPATCH(obj), FALSE TSRMLS_CC);
-       
-       /* resource */
-       rid = zend_list_insert(obj, IS_COM);
-
-       if (val == NULL)
-               MAKE_STD_ZVAL(val);
-       ZVAL_RESOURCE(val, rid);
-
-       /* now we want an object */
        MAKE_STD_ZVAL(zobj);
-       object_init_ex(zobj, &COM_class_entry);
-       zend_hash_index_update(Z_OBJPROP_P(zobj), 0, &val, sizeof(zval *), NULL);       
-
+       php_COM_set(obj, &disp, FALSE TSRMLS_CC);
+       ZVAL_COM_EX(zobj, obj, val);
+       
        return zobj;
 }
 
index 62d08c3acd9a2b9ded84b6e722051a00f40002d0..2930f86fd9285d7895546fa7dc514e6414d3413b 100644 (file)
@@ -24,13 +24,19 @@ typedef struct comval_ {
 END_EXTERN_C()
 
 #define ZVAL_COM(z,o) {                                                                                                                                \
-                       zval *handle;                                                                                                                   \
+                       zval *handle = NULL;                                                                                                    \
+                       ZVAL_COM_EX(z,o,handle)                                                                                                 \
+               }
+
+#define ZVAL_COM_EX(z,o,handle) {                                                                                                      \
                        HashTable *properties;                                                                                                  \
                                                                                                                                                                        \
                        ALLOC_HASHTABLE(properties);                                                                                    \
                        zend_hash_init(properties, 0, NULL, ZVAL_PTR_DTOR, 0);                                  \
                                                                                                                                                                        \
-                       MAKE_STD_ZVAL(handle);                                                                                                  \
+                       if (handle == NULL) {                                                                                                   \
+                               MAKE_STD_ZVAL(handle);                                                                                          \
+                       }                                                                                                                                               \
                        ZVAL_LONG(handle, zend_list_insert((o), IS_COM));                                               \
                                                                                                                                                                        \
                        zval_copy_ctor(handle);                                                                                                 \
index 130885edd95302f3954ece1cffe370fd62e37195..c9e4f894142e15dab0be4a6e514a5bfcba4f4e92 100644 (file)
@@ -56,8 +56,6 @@ PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage T
                case IS_OBJECT:
                        if (!strcmp(Z_OBJCE_P(pval_arg)->name, "VARIANT")) {
                                type = VT_VARIANT|VT_BYREF;
-                       } else if (!strcmp(Z_OBJCE_P(pval_arg)->name, "COM")) {
-                               type = VT_DISPATCH;
                        } else {
                                type = VT_DISPATCH;
                        }
@@ -275,8 +273,9 @@ PHPAPI void php_pval_to_variant_ex2(pval *pval_arg, VARIANT *var_arg, int type,
                                        comval_to_variant(pval_arg, var_arg TSRMLS_CC);
                                } else {
                                        V_DISPATCH(var_arg) = php_COM_export_object(pval_arg TSRMLS_CC);
-                                       if (V_DISPATCH(var_arg))
+                                       if (V_DISPATCH(var_arg)) {
                                                V_VT(var_arg) = VT_DISPATCH;
+                                       }
                                }
                                if (V_VT(var_arg) != VT_DISPATCH) {
                                        VariantInit(var_arg);