php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch ffi-0.3-compile_with_php-5.3.13.patch for ffi Bug #62028

Patch version 2012-05-14 15:22 UTC

Return to Bug #62028 | Download this patch
Patch Revisions:

Developer: ogenez@optilian.com

diff -urB ffi-0.3/ffi_library.c ffi-0.3-patched/ffi_library.c
--- ffi-0.3/ffi_library.c	2004-01-20 16:38:09.000000000 +0100
+++ ffi-0.3-patched/ffi_library.c	2012-05-14 17:10:56.943289672 +0200
@@ -26,7 +26,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_ffi.h"
-#include "Zend/zend_default_classes.h"
+#include "Zend/zend_exceptions.h"
 #include "Zend/zend_object_handlers.h"
 
 #include "php_ffi_internal.h"
@@ -279,7 +279,7 @@
 	}
 }
 
-static zval *php_ffi_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC)
+static zval *php_ffi_property_read(zval *object, zval *member, int type TSRMLS_DC)
 {
 	zval *return_value;
 	php_ffi_context *obj;
@@ -299,7 +299,7 @@
 	PHP_FFI_THROW("ffi_libraries have no properties");
 }
 
-static zval *php_ffi_read_dimension(zval *object, zval *offset TSRMLS_DC)
+static zval *php_ffi_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
 {
 	zval *return_value;
 
@@ -326,7 +326,7 @@
 	return NULL;
 }
 
-static int php_ffi_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
+static int php_ffi_property_exists(zval *object, zval *member, int has_set_exists TSRMLS_DC)
 {
 	return 0;
 }
@@ -395,13 +395,13 @@
 	return func;
 }
 
-static union _zend_function *php_ffi_method_get(zval *object, char *name, int len TSRMLS_DC)
+static union _zend_function *php_ffi_method_get(zval **object, char *name, int len TSRMLS_DC)
 {
 	zend_internal_function *f;
 	php_ffi_context *obj;
 	php_ffi_function *func;
 	
-	obj = CTX_FETCH(object);
+	obj = CTX_FETCH(*object);
 
 	func = bind_func(obj, name, len TSRMLS_CC);
 
@@ -540,7 +540,7 @@
 	}
 }
 
-static zend_class_entry *php_ffi_class_entry_get(zval *object TSRMLS_DC)
+static zend_class_entry *php_ffi_class_entry_get(const zval *object TSRMLS_DC)
 {
 	php_ffi_context *obj;
 	obj = CTX_FETCH(object);
@@ -548,7 +548,7 @@
 	return obj->ce;
 }
 
-static int php_ffi_class_name_get(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
+static int php_ffi_class_name_get(const zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
 {
 	php_ffi_context *obj;
 	obj = CTX_FETCH(object);
@@ -565,11 +565,9 @@
 	return -1;
 }
 
-static int php_ffi_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC)
+static int php_ffi_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
 {
-	if (should_free) {
-		zval_dtor(writeobj);
-	}
+	zval_dtor(writeobj);
 
 	ZVAL_NULL(writeobj);
 
@@ -637,7 +635,7 @@
 	zend_hash_init(&obj->types, 2, NULL, php_ffi_type_dtor, 0);
 	obj->ce = ce;
 	
-	retval.handle = zend_objects_store_put(obj, php_ffi_context_dtor, php_ffi_object_clone TSRMLS_CC);
+	retval.handle = zend_objects_store_put(obj, php_ffi_context_dtor, NULL, php_ffi_object_clone TSRMLS_CC);
 	retval.handlers = &php_ffi_object_handlers;
 
 	return retval;
diff -urB ffi-0.3/ffi_struct.c ffi-0.3-patched/ffi_struct.c
--- ffi-0.3/ffi_struct.c	2004-01-20 20:29:01.000000000 +0100
+++ ffi-0.3-patched/ffi_struct.c	2012-05-14 17:10:47.559968564 +0200
@@ -26,7 +26,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_ffi.h"
-#include "Zend/zend_default_classes.h"
+#include "Zend/zend_exceptions.h"
 
 #include "php_ffi_internal.h"
 
@@ -69,7 +69,7 @@
 	}
 }
 
-static zval *php_ffi_struct_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC)
+static zval *php_ffi_struct_property_read(zval *object, zval *member, int type TSRMLS_DC)
 {
 	zval *return_value;
 	php_ffi_struct *obj;
@@ -77,8 +77,8 @@
 
 	MAKE_STD_ZVAL(return_value);
 	ZVAL_NULL(return_value);
-	return_value->refcount = 0;
-	return_value->is_ref = 0;
+	Z_SET_REFCOUNT_P(return_value, 0);
+	Z_UNSET_ISREF_P(return_value);
 
 	obj = STRUCT_FETCH(object);
 
@@ -147,14 +147,14 @@
 	PHP_FFI_THROW("no such property");
 }
 
-static zval *php_ffi_struct_read_dimension(zval *object, zval *offset TSRMLS_DC)
+static zval *php_ffi_struct_read_dimension(zval *object, zval *offset, int type TSRMLS_DC)
 {
 	zval *return_value;
 
 	MAKE_STD_ZVAL(return_value);
 	ZVAL_NULL(return_value);
-	return_value->refcount = 0;
-	return_value->is_ref = 0;
+	Z_SET_REFCOUNT_P(return_value, 0);
+	Z_UNSET_ISREF_P(return_value);
 
 	PHP_FFI_THROW("no dimension support yet");
 	return return_value;
@@ -176,9 +176,8 @@
 	return NULL;
 }
 
-static int php_ffi_struct_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
+static int php_ffi_struct_property_exists(zval *object, zval *member, int has_set_exists TSRMLS_DC)
 {
-	zval *return_value;
 	php_ffi_struct *obj;
 	int i;
 
@@ -215,13 +214,11 @@
 	return NULL;
 }
 
-static union _zend_function *php_ffi_struct_method_get(zval *object, char *name, int len TSRMLS_DC)
+static union _zend_function *php_ffi_struct_method_get(zval **object, char *name, int len TSRMLS_DC)
 {
-	zend_internal_function *f;
 	php_ffi_struct *obj;
-	php_ffi_function *func;
 	
-	obj = STRUCT_FETCH(object);
+	obj = STRUCT_FETCH(*object);
 
 	/* TODO: worry about pointers to functions? */
 	
@@ -254,12 +251,12 @@
 	return (union _zend_function*)&f;
 }
 
-static zend_class_entry *php_ffi_struct_class_entry_get(zval *object TSRMLS_DC)
+static zend_class_entry *php_ffi_struct_class_entry_get(const zval *object TSRMLS_DC)
 {
 	return php_ffi_struct_class_entry;
 }
 
-static int php_ffi_struct_class_name_get(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
+static int php_ffi_struct_class_name_get(const zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
 {
 	php_ffi_struct *obj;
 	obj = STRUCT_FETCH(object);
@@ -275,11 +272,9 @@
 	return -1;
 }
 
-static int php_ffi_struct_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC)
+static int php_ffi_struct_object_cast(zval *readobj, zval *writeobj, int type TSRMLS_DC)
 {
-	if (should_free) {
-		zval_dtor(writeobj);
-	}
+	zval_dtor(writeobj);
 
 	ZVAL_NULL(writeobj);
 
@@ -344,7 +339,7 @@
 
 	obj = ecalloc(1, sizeof(*obj));
 	
-	retval.handle = zend_objects_store_put(obj, php_ffi_struct_dtor, php_ffi_struct_object_clone TSRMLS_CC);
+	retval.handle = zend_objects_store_put(obj, php_ffi_struct_dtor, NULL, php_ffi_struct_object_clone TSRMLS_CC);
 	retval.handlers = &php_ffi_struct_object_handlers;
 
 	return retval;
@@ -489,7 +484,7 @@
 
 			Z_TYPE_P(val) = IS_OBJECT;
 			Z_OBJ_HANDLE_P(val) = zend_objects_store_put(str,
-					php_ffi_struct_dtor, php_ffi_struct_object_clone TSRMLS_CC);
+					php_ffi_struct_dtor, NULL, php_ffi_struct_object_clone TSRMLS_CC);
 			Z_OBJ_HT_P(val) = &php_ffi_struct_object_handlers;
 			return 1;
 		}
Only in ffi-0.3-patched/libffi/include: ffi.h
diff -urB ffi-0.3/php_ffi_internal.h ffi-0.3-patched/php_ffi_internal.h
--- ffi-0.3/php_ffi_internal.h	2004-01-12 14:51:44.000000000 +0100
+++ ffi-0.3-patched/php_ffi_internal.h	2012-05-14 11:45:01.000000000 +0200
@@ -21,10 +21,6 @@
 
 #include "ffi.h"
 
-#ifdef PHP_WIN32
-# define SINT64	INT64
-#endif
-
 typedef struct {
 	DL_HANDLE handle;		/* handle to the library */
 	char *libname;			/* name of the library (for error messages) */
@@ -146,7 +142,7 @@
 
 #define CTX_FETCH(x)	(php_ffi_context*)zend_object_store_get_object(x TSRMLS_CC)
 #define STRUCT_FETCH(x)	(php_ffi_struct*)zend_object_store_get_object(x TSRMLS_CC)
-#define PHP_FFI_THROW(msg)	zend_throw_exception(zend_exception_get_default(), msg, 0 TSRMLS_CC)
+#define PHP_FFI_THROW(msg)	zend_throw_exception(zend_exception_get_default(TSRMLS_C), msg, 0 TSRMLS_CC)
 
 int php_ffi_zval_to_native(void **mem, int *need_free, zval *val, struct php_ffi_typed_arg *argtype TSRMLS_DC);
 int php_ffi_native_to_zval(void *mem, struct php_ffi_typed_arg *argtype, zval *val TSRMLS_DC);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 07:01:28 2024 UTC