Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
php-src/php-src#3780 com_dotnet fix
ext/com_dotnet/com_handlers.c | 53 ++++++++++++++++----------------
ext/com_dotnet/com_persist.c | 4 +--
ext/com_dotnet/com_saproxy.c | 45 ++++++++++++++-------------
ext/com_dotnet/php_com_dotnet_internal.h | 4 +--
4 files changed, 54 insertions(+), 52 deletions(-)
diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c
index f542bafb60..6e5cc8c4d8 100644
--- a/ext/com_dotnet/com_handlers.c
+++ b/ext/com_dotnet/com_handlers.c
@@ -27,7 +27,7 @@
#include "php_com_dotnet_internal.h"
#include "Zend/zend_exceptions.h"
-static zval *com_property_read(zval *object, zval *member, int type, void **cahce_slot, zval *rv)
+static zval *com_property_read(zend_object *object, zend_string *member, int type, void **cahce_slot, zval *rv)
{
php_com_dotnet_object *obj;
VARIANT v;
@@ -35,21 +35,22 @@ static zval *com_property_read(zval *object, zval *member, int type, void **cahc
ZVAL_NULL(rv);
- obj = CDNO_FETCH(object);
+ obj = (php_com_dotnet_object*) object;
if (V_VT(&obj->v) == VT_DISPATCH) {
VariantInit(&v);
- convert_to_string_ex(member);
-
- res = php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member),
+ res = php_com_do_invoke(obj, ZSTR_VAL(member), ZSTR_LEN(member),
DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL, 1);
if (res == SUCCESS) {
php_com_zval_from_variant(rv, &v, obj->code_page);
VariantClear(&v);
} else if (res == DISP_E_BADPARAMCOUNT) {
- php_com_saproxy_create(object, rv, member);
+ zval zv;
+
+ ZVAL_STR(&zv, member);
+ php_com_saproxy_create(object, rv, &zv);
}
} else {
php_com_throw_exception(E_INVALIDARG, "this variant has no properties");
@@ -58,18 +59,17 @@ static zval *com_property_read(zval *object, zval *member, int type, void **cahc
return rv;
}
-static zval *com_property_write(zval *object, zval *member, zval *value, void **cache_slot)
+static zval *com_property_write(zend_object *object, zend_string *member, zval *value, void **cache_slot)
{
php_com_dotnet_object *obj;
VARIANT v;
- obj = CDNO_FETCH(object);
+ obj = (php_com_dotnet_object*) object;
if (V_VT(&obj->v) == VT_DISPATCH) {
VariantInit(&v);
- convert_to_string_ex(member);
- if (SUCCESS == php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member),
+ if (SUCCESS == php_com_do_invoke(obj, ZSTR_VAL(member), ZSTR_LEN(member),
DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, &v, 1, value, 0)) {
VariantClear(&v);
}
@@ -79,14 +79,14 @@ static zval *com_property_write(zval *object, zval *member, zval *value, void **
return value;
}
-static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv)
+static zval *com_read_dimension(zend_object *object, zval *offset, int type, zval *rv)
{
php_com_dotnet_object *obj;
VARIANT v;
ZVAL_NULL(rv);
- obj = CDNO_FETCH(object);
+ obj = (php_com_dotnet_object*) object;
if (V_VT(&obj->v) == VT_DISPATCH) {
VariantInit(&v);
@@ -115,14 +115,14 @@ static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv)
return rv;
}
-static void com_write_dimension(zval *object, zval *offset, zval *value)
+static void com_write_dimension(zend_object *object, zval *offset, zval *value)
{
php_com_dotnet_object *obj;
zval args[2];
VARIANT v;
HRESULT res;
- obj = CDNO_FETCH(object);
+ obj = (php_com_dotnet_object*) object;
if (V_VT(&obj->v) == VT_DISPATCH) {
ZVAL_COPY_VALUE(&args[0], offset);
@@ -187,16 +187,15 @@ static zval *com_object_get(zval *property)
}
#endif
-static int com_property_exists(zval *object, zval *member, int check_empty, void **cache_slot)
+static int com_property_exists(zend_object *object, zend_string *member, int check_empty, void **cache_slot)
{
DISPID dispid;
php_com_dotnet_object *obj;
- obj = CDNO_FETCH(object);
+ obj = (php_com_dotnet_object*) object;
if (V_VT(&obj->v) == VT_DISPATCH) {
- convert_to_string_ex(member);
- if (SUCCEEDED(php_com_get_id_of_name(obj, Z_STRVAL_P(member), Z_STRLEN_P(member), &dispid))) {
+ if (SUCCEEDED(php_com_get_id_of_name(obj, ZSTR_VAL(member), ZSTR_LEN(member), &dispid))) {
/* TODO: distinguish between property and method! */
return 1;
}
@@ -207,23 +206,23 @@ static int com_property_exists(zval *object, zval *member, int check_empty, void
return 0;
}
-static int com_dimension_exists(zval *object, zval *member, int check_empty)
+static int com_dimension_exists(zend_object *object, zval *member, int check_empty)
{
php_error_docref(NULL, E_WARNING, "Operation not yet supported on a COM object");
return 0;
}
-static void com_property_delete(zval *object, zval *member, void **cache_slot)
+static void com_property_delete(zend_object *object, zend_string *member, void **cache_slot)
{
php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object");
}
-static void com_dimension_delete(zval *object, zval *offset)
+static void com_dimension_delete(zend_object *object, zval *offset)
{
php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object");
}
-static HashTable *com_properties_get(zval *object)
+static HashTable *com_properties_get(zend_object *object)
{
/* TODO: use type-info to get all the names and values ?
* DANGER: if we do that, there is a strong possibility for
@@ -468,7 +467,7 @@ static int com_object_cast(zend_object *readobj, zval *writeobj, int type)
VARTYPE vt = VT_EMPTY;
HRESULT res = S_OK;
- obj = CDNO_FETCH(readobj);
+ obj = (php_com_dotnet_object*) readobj;
ZVAL_NULL(writeobj);
VariantInit(&v);
@@ -518,12 +517,12 @@ static int com_object_cast(zend_object *readobj, zval *writeobj, int type)
return zend_std_cast_object_tostring(readobj, writeobj, type);
}
-static int com_object_count(zval *object, zend_long *count)
+static int com_object_count(zend_object *object, zend_long *count)
{
php_com_dotnet_object *obj;
LONG ubound = 0, lbound = 0;
- obj = CDNO_FETCH(object);
+ obj = (php_com_dotnet_object*) object;
if (!V_ISARRAY(&obj->v)) {
return FAILURE;
@@ -617,11 +616,11 @@ void php_com_object_free_storage(zend_object *object)
}
}
-zend_object* php_com_object_clone(zval *object)
+zend_object* php_com_object_clone(zend_object *object)
{
php_com_dotnet_object *cloneobj, *origobject;
- origobject = (php_com_dotnet_object*)Z_OBJ_P(object);
+ origobject = (php_com_dotnet_object*) object;
cloneobj = (php_com_dotnet_object*)emalloc(sizeof(php_com_dotnet_object));
memcpy(cloneobj, origobject, sizeof(*cloneobj));
diff --git a/ext/com_dotnet/com_persist.c b/ext/com_dotnet/com_persist.c
index 57538d2faa..ac3a638eeb 100644
--- a/ext/com_dotnet/com_persist.c
+++ b/ext/com_dotnet/com_persist.c
@@ -709,9 +709,9 @@ static void helper_free_storage(zend_object *obj)
}
-static zend_object* helper_clone(zval *obj)
+static zend_object* helper_clone(zend_object *obj)
{
- php_com_persist_helper *clone, *object = (php_com_persist_helper*)Z_OBJ_P(obj);
+ php_com_persist_helper *clone, *object = (php_com_persist_helper*) obj;
clone = emalloc(sizeof(*object));
memcpy(clone, object, sizeof(*object));
diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c
index 170f2018e2..6b17e1e003 100644
--- a/ext/com_dotnet/com_saproxy.c
+++ b/ext/com_dotnet/com_saproxy.c
@@ -69,7 +69,7 @@ static inline void clone_indices(php_com_saproxy *dest, php_com_saproxy *src, in
}
}
-static zval *saproxy_property_read(zval *object, zval *member, int type, void **cache_slot, zval *rv)
+static zval *saproxy_property_read(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
{
ZVAL_NULL(rv);
@@ -78,14 +78,14 @@ static zval *saproxy_property_read(zval *object, zval *member, int type, void **
return rv;
}
-static void saproxy_property_write(zval *object, zval *member, zval *value, void **cache_slot)
+static void saproxy_property_write(zend_object *object, zend_string *member, zval *value, void **cache_slot)
{
php_com_throw_exception(E_INVALIDARG, "safearray has no properties");
}
-static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *rv)
+static zval *saproxy_read_dimension(zend_object *object, zval *offset, int type, zval *rv)
{
- php_com_saproxy *proxy = SA_FETCH(object);
+ php_com_saproxy *proxy = (php_com_saproxy*) object;
UINT dims, i;
SAFEARRAY *sa;
LONG ubound, lbound;
@@ -201,9 +201,9 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval *
return rv;
}
-static void saproxy_write_dimension(zval *object, zval *offset, zval *value)
+static void saproxy_write_dimension(zend_object *object, zval *offset, zval *value)
{
- php_com_saproxy *proxy = SA_FETCH(object);
+ php_com_saproxy *proxy = (php_com_saproxy*) object;
UINT dims, i;
HRESULT res;
VARIANT v;
@@ -286,29 +286,29 @@ static zval *saproxy_object_get(zval *property)
}
#endif
-static int saproxy_property_exists(zval *object, zval *member, int check_empty, void **cache_slot)
+static int saproxy_property_exists(zend_object *object, zend_string *member, int check_empty, void **cache_slot)
{
/* no properties */
return 0;
}
-static int saproxy_dimension_exists(zval *object, zval *member, int check_empty)
+static int saproxy_dimension_exists(zend_object *object, zval *member, int check_empty)
{
php_error_docref(NULL, E_WARNING, "Operation not yet supported on a COM object");
return 0;
}
-static void saproxy_property_delete(zval *object, zval *member, void **cache_slot)
+static void saproxy_property_delete(zend_object *object, zend_string *member, void **cache_slot)
{
php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object");
}
-static void saproxy_dimension_delete(zval *object, zval *offset)
+static void saproxy_dimension_delete(zend_object *object, zval *offset)
{
php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object");
}
-static HashTable *saproxy_properties_get(zval *object)
+static HashTable *saproxy_properties_get(zend_object *object)
{
/* no properties */
return NULL;
@@ -341,14 +341,14 @@ static int saproxy_objects_compare(zval *object1, zval *object2)
return -1;
}
-static int saproxy_object_cast(zval *readobj, zval *writeobj, int type)
+static int saproxy_object_cast(zend_object *readobj, zval *writeobj, int type)
{
return FAILURE;
}
-static int saproxy_count_elements(zval *object, zend_long *count)
+static int saproxy_count_elements(zend_object *object, zend_long *count)
{
- php_com_saproxy *proxy = SA_FETCH(object);
+ php_com_saproxy *proxy = (php_com_saproxy*) object;
LONG ubound, lbound;
if (!V_ISARRAY(&proxy->obj->v)) {
@@ -378,9 +378,9 @@ static void saproxy_free_storage(zend_object *object)
efree(proxy->indices);
}
-static zend_object* saproxy_clone(zval *object)
+static zend_object* saproxy_clone(zend_object *object)
{
- php_com_saproxy *proxy = (php_com_saproxy *)Z_OBJ_P(object);
+ php_com_saproxy *proxy = (php_com_saproxy *) object;
php_com_saproxy *cloneproxy;
cloneproxy = emalloc(sizeof(*cloneproxy));
@@ -419,21 +419,24 @@ zend_object_handlers php_com_saproxy_handlers = {
saproxy_count_elements
};
-int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index)
+int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index)
{
php_com_saproxy *proxy, *rel = NULL;
proxy = ecalloc(1, sizeof(*proxy));
proxy->dimensions = 1;
- if (Z_OBJCE_P(com_object) == php_com_saproxy_class_entry) {
- rel = SA_FETCH(com_object);
+ if (com_object->ce == php_com_saproxy_class_entry) {
+ rel = (php_com_saproxy*) com_object;
proxy->obj = rel->obj;
proxy->zobj = rel->zobj;
proxy->dimensions += rel->dimensions;
} else {
- proxy->obj = CDNO_FETCH(com_object);
- proxy->zobj = com_object;
+ zval zv;
+
+ proxy->obj = (php_com_dotnet_object*) com_object;
+ ZVAL_OBJ(&zv, com_object);
+ proxy->zobj = &zv;
}
Z_ADDREF_P(proxy->zobj);
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index e41b7ffdd1..611220b729 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -75,14 +75,14 @@ zend_class_entry *php_com_variant_class_entry, *php_com_exception_class_entry, *
/* com_handlers.c */
zend_object* php_com_object_new(zend_class_entry *ce);
-zend_object* php_com_object_clone(zval *object);
+zend_object* php_com_object_clone(zend_object *object);
void php_com_object_free_storage(zend_object *object);
zend_object_handlers php_com_object_handlers;
void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable);
/* com_saproxy.c */
zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *object, int by_ref);
-int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index);
+int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index);
/* com_olechar.c */
PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.