]> granicus.if.org Git - php/commitdiff
Implement com_create_guid().
authorWez Furlong <wez@php.net>
Tue, 18 Feb 2003 09:46:19 +0000 (09:46 +0000)
committerWez Furlong <wez@php.net>
Tue, 18 Feb 2003 09:46:19 +0000 (09:46 +0000)
Add a special case for RETVAL_VARIANT when a variant is of type VT_DISPATCH but has a NULL dispatch pointer.
This kind of variant is returned by the WindowsInstaller automation interface.

ext/rpc/com/com.c
ext/rpc/com/variant.h

index 47efe7231f687a6cf1a865f27ae4113a44eb864e..9a8e40587b450675b23c74e617c2904c8f490f80 100644 (file)
@@ -34,6 +34,7 @@
 
 
 static ZEND_FUNCTION(com_indexed_prop_set);
+static ZEND_FUNCTION(com_create_guid);
 
 /* protos */
 static int com_hash(rpc_string, rpc_string *, void *, int, char *, int);
@@ -96,6 +97,7 @@ RPC_FUNCTION_ENTRY_BEGIN(com)
        ZEND_FE(com_load_typelib,       NULL)
        ZEND_FE(com_print_typeinfo,     NULL)
        ZEND_FE(com_indexed_prop_set,   NULL)
+       ZEND_FE(com_create_guid,                NULL)
 RPC_FUNCTION_ENTRY_END()
 
 zend_module_entry com_module_entry = {
@@ -830,6 +832,27 @@ static int com_get_properties(HashTable **properties, void *data)
 
 /* custom functions */
 
+static ZEND_FUNCTION(com_create_guid)
+{
+       GUID retval;
+       OLECHAR *guid_string;
+
+       if (ZEND_NUM_ARGS() != 0) {
+               ZEND_WRONG_PARAM_COUNT();
+       }
+
+       if (CoCreateGuid(&retval) && StringFromCLSID(&retval, &guid_string)) {
+               Z_TYPE_P(return_value) = IS_STRING;
+               Z_STRVAL_P(return_value) = php_OLECHAR_to_char(guid_string, &Z_STRLEN_P(return_value), CP_ACP, 0);
+
+               CoTaskMemFree(guid_string);
+       } else {
+               RETURN_FALSE;
+       }
+}
+
+
+
 static ZEND_FUNCTION(com_indexed_prop_set)
 {
        zval *object;
index 8d7a9bc6d62c6d50497da629367f888c40b5193c..e8c3539572f908bfc2b63ce1ff3d5ff4c5d9b68f 100644 (file)
@@ -32,6 +32,9 @@
                                                        efree((v));
 
 #define ZVAL_VARIANT(z, v, cp)                                                                                                 \
+       if (V_VT(v) == VT_DISPATCH && V_DISPATCH(v) == NULL) {                                          \
+               V_VT(v) = VT_NULL;                                                      \
+       }                                                                           \
        if (V_VT(v) == VT_DISPATCH) {                                                                                           \
                comval *obj;                                                                                                                    \
                ALLOC_COM(obj);                                                                                                                 \