cvs: ZendEngine2(PHP_5_3) / zend_API.c

[email protected] ("Stanislav Malyshev")
Newsgroups php.zend-engine.cvs
Message-ID <cvsstas1227550212@cvsserver>
stas		Mon Nov 24 18:10:12 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /ZendEngine2	zend_API.c 
  Log:
  add object-compatible array modes
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.34.2.55&r2=1.296.2.27.2.34.2.56&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.34.2.55 ZendEngine2/zend_API.c:1.296.2.27.2.34.2.56
--- ZendEngine2/zend_API.c:1.296.2.27.2.34.2.55	Tue Nov  4 15:58:49 2008
+++ ZendEngine2/zend_API.c	Mon Nov 24 18:10:12 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c,v 1.296.2.27.2.34.2.55 2008/11/04 15:58:49 helly Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.34.2.56 2008/11/24 18:10:12 stas Exp $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -295,7 +295,7 @@
 {
 	char *spec_walk = *spec;
 	char c = *spec_walk++;
-	int return_null = 0;
+	int return_null = 0, obj_array = 0;
 
 	/* scan through modifiers */
 	while (1) {
@@ -451,7 +451,8 @@
 				}
 			}
 			break;
-
+		case 'A':
+				obj_array = 1;
 		case 'a':
 			{
 				zval **p = va_arg(*va, zval **);
@@ -459,14 +460,15 @@
 					*p = NULL;
 					break;
 				}
-				if (Z_TYPE_PP(arg) == IS_ARRAY) {
+				if (Z_TYPE_PP(arg) == IS_ARRAY || (Z_TYPE_PP(arg) == IS_OBJECT && obj_array != 0)) {
 					*p = *arg;
 				} else {
 					return "array";
 				}
 			}
 			break;
-
+		case 'H':
+				obj_array = 1;
 		case 'h':
 			{
 				HashTable **p = va_arg(*va, HashTable **);
@@ -476,6 +478,11 @@
 				}
 				if (Z_TYPE_PP(arg) == IS_ARRAY) {
 					*p = Z_ARRVAL_PP(arg);
+				} else if(obj_array && Z_TYPE_PP(arg) == IS_OBJECT) {
+					*p = HASH_OF(*arg);
+					if(*p == NULL) {
+						return "array";
+					}
 				} else {
 					return "array";
 				}
@@ -670,7 +677,8 @@
 			case 'o': case 'O':
 			case 'z': case 'Z':
 			case 'C': case 'h':
-			case 'f':
+			case 'f': case 'A':
+			case 'H':
 				max_num_args++;
 				break;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.