summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2008-11-24 18:10:36 +0000
committerStanislav Malyshev <stas@php.net>2008-11-24 18:10:36 +0000
commitfce39ed9f7799f2bc49bda2b701b8014f90ffe1d (patch)
tree86ad9fe8c766188448d41e4b8d63a07fdf390c28
parenta9282f72a87df3f6a87084ee6c7c9ed92decea76 (diff)
downloadphp-git-fce39ed9f7799f2bc49bda2b701b8014f90ffe1d.tar.gz
add object-compatible array modes
-rw-r--r--README.PARAMETER_PARSING_API2
-rw-r--r--Zend/zend_API.c18
2 files changed, 15 insertions, 5 deletions
diff --git a/README.PARAMETER_PARSING_API b/README.PARAMETER_PARSING_API
index d2e47eb421..530b2b560d 100644
--- a/README.PARAMETER_PARSING_API
+++ b/README.PARAMETER_PARSING_API
@@ -39,12 +39,14 @@ Type specifiers
instance of that class.
a - array (zval*)
+ A - array or object (zval *)
b - boolean (zend_bool)
C - class (zend_class_entry*)
d - double (double)
f - function or array containing php method call info (returned as
zend_fcall_info and zend_fcall_info_cache)
h - array (returned as HashTable*)
+ H - array or HASH_OF(object) (returned as HashTable*)
l - long (long)
o - object of any type (zval*)
O - object of specific type given by class entry (zval*, zend_class_entry)
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 23a3dbbe31..0b505d933a 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -295,7 +295,7 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
{
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 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
}
}
break;
-
+ case 'A':
+ obj_array = 1;
case 'a':
{
zval **p = va_arg(*va, zval **);
@@ -459,14 +460,15 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
*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 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
}
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 @@ static int zend_parse_va_args(int num_args, char *type_spec, va_list *va, int fl
case 'o': case 'O':
case 'z': case 'Z':
case 'C': case 'h':
- case 'f':
+ case 'f': case 'A':
+ case 'H':
max_num_args++;
break;