cvs: php-objc / extension.m

From: Date: Sun, 06 Jul 2008 04:37:18 +0000
Subject: cvs: php-objc / extension.m
Groups: php.objc 
Request: Send a blank email to php-objc+get-27@lists.php.net to get a copy of this message
wez Sun Jul 6 04:37:18 2008 UTC Modified files: /php-objc extension.m Log: fixup byref handling for objects http://cvs.php.net/viewvc.cgi/php-objc/extension.m?r1=1.2&r2=1.3&diff_format=u Index: php-objc/extension.m diff -u php-objc/extension.m:1.2 php-objc/extension.m:1.3 --- php-objc/extension.m:1.2 Sat Jul 5 19:14:40 2008 +++ php-objc/extension.m Sun Jul 6 04:37:18 2008 @@ -1727,7 +1727,7 @@ 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); @@ -1757,6 +1757,7 @@ argtype++; is_ref = 1; } + printf("arg %d is_ref=%d\n", i, is_ref); switch (*argtype) { case _C_CHARPTR: @@ -1932,11 +1933,15 @@ } 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]); @@ -2144,12 +2149,15 @@ 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); + zend_hash_index_find(byref_hash, i, (void**)&ptr); - if (*idptr) { - php_objc_wrap_id(*idptr, *args[i + first_passed]); + if (ptr) { + php_objc_wrap_id(ptr->val, *args[i + first_passed]); } else { ZVAL_NULL(*args[i + first_passed]); }

« previous php.objc (#27) next »