Commits

Anonymous committed a2b3b0f

fixup byref handling for objects

Comments (0)

Files changed (1)

 	ffi_args[1] = &sel;
 
 NS_DURING
-//	printf("method type: %s(%s)\n", method, meth->method_types);
+	printf("method type: %s(%s)\n", method, meth->method_types);
 
 	ALLOC_HASHTABLE(byref_hash);
 	zend_hash_init(byref_hash, 2, NULL, NULL, 0);
 			argtype++;
 			is_ref = 1;
 		}
+		printf("arg %d is_ref=%d\n", i, is_ref);
 
 		switch (*argtype) {
 			case _C_CHARPTR:
 				}
 
 				if (is_ref) {
-					id *idptr = NULL;
-					zend_hash_index_update(byref_hash, i, &idptr, sizeof(idptr),
-						(void**)&idptr);
-					*idptr = idval;
-					ffi_args[2 + i] = idptr;
+					struct {
+						id val;
+						id *ptr;
+					} idref, *ptr;
+					zend_hash_index_update(byref_hash, i, &idref,
+						sizeof(idref), (void**)&ptr);
+					ptr->val = idval;
+					ptr->ptr = &ptr->val;
+					ffi_args[2+i] = &ptr->ptr;
 				} else {
 					zend_hash_index_update(byref_hash, i, &idval, sizeof(idval),
 						(void**)&ffi_args[2 + i]);
 			SEPARATE_ZVAL_IF_NOT_REF(args[i + first_passed]);
 			switch (*argtype) {
 				case _C_ID: {
-					id *idptr;
+					struct {
+						id val;
+						id *ptr;
+					} *ptr;
 					
-					zend_hash_index_find(byref_hash, i, (void**)&idptr);
-
-					if (*idptr) {
-						php_objc_wrap_id(*idptr, *args[i + first_passed]);
+					zend_hash_index_find(byref_hash, i, (void**)&ptr);
+
+					if (ptr) {
+						php_objc_wrap_id(ptr->val, *args[i + first_passed]);
 					} else {
 						ZVAL_NULL(*args[i + first_passed]);
 					}