cvs: ZendEngine2 / zend_API.c

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

  Modified files:              
    /ZendEngine2	zend_API.c 
  Log:
  add object-compatible array parameters
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.490&r2=1.491&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.490 ZendEngine2/zend_API.c:1.491
--- ZendEngine2/zend_API.c:1.490	Fri Oct 10 15:19:22 2008
+++ ZendEngine2/zend_API.c	Mon Nov 24 19:17:24 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c,v 1.490 2008/10/10 15:19:22 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.491 2008/11/24 19:17:24 stas Exp $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -319,7 +319,7 @@
 {
 	char *spec_walk = *spec;
 	char c = *spec_walk++;
-	int return_null = 0;
+	int return_null = 0, obj_array = 0;
 	int alternate_form = 0;
 	int return_orig_type = 0;
 	zend_uchar orig_type;
@@ -686,7 +686,8 @@
 				}
 			}
 			break;
-
+		case 'A':
+				obj_array = 1;
 		case 'a':
 			{
 				zval **p = va_arg(*va, zval **);
@@ -694,14 +695,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 **);
@@ -711,6 +713,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";
 				}
@@ -915,6 +922,7 @@
 			case 'C': case 'h':
 			case 'U': case 'S':
 			case 'f': case 'x':
+			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.