summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Faulds <ajf@ajf.me>2014-12-15 00:51:41 +0000
committerAndrea Faulds <ajf@ajf.me>2014-12-29 12:28:28 +0000
commit41e3fdba8e3ed927ea8c90e913df06597b021a03 (patch)
tree7a3610b7fe9fef23a19350f11eb88a3f9db8fc14
parentcd5ea1619ea16d78c17cedaf870623e5ca6becc6 (diff)
downloadphp-git-41e3fdba8e3ed927ea8c90e913df06597b021a03.tar.gz
Make zend_parse_parameters share fast zpp implementation where possible
Rename shared implementation functions and build them unconditionally Don't fail on empty path for zend_parse_arg_path Update type names Fix behaviour of by-reference "z" Make 'o' use zend_parse_arg_object Fix NULL string check in zend_parse_arg_path(_str)
-rw-r--r--Zend/zend_API.c263
-rw-r--r--Zend/zend_API.h92
2 files changed, 94 insertions, 261 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 7e7cd06bf0..01d3f9a060 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -325,7 +325,7 @@ ZEND_API void zend_wrong_callback_error(int severity, int num, char *error) /* {
}
/* }}} */
-ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int check_null) /* {{{ */
+ZEND_API int zend_parse_arg_class(zval *arg, zend_class_entry **pce, int num, int check_null) /* {{{ */
{
zend_class_entry *ce_base = *pce;
@@ -387,63 +387,14 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case 'L':
{
zend_long *p = va_arg(*va, zend_long *);
+ zend_bool *is_null = NULL;
if (check_null) {
- zend_bool *p = va_arg(*va, zend_bool *);
- *p = (Z_TYPE_P(arg) == IS_NULL);
+ is_null = va_arg(*va, zend_bool *);
}
- switch (Z_TYPE_P(arg)) {
- case IS_STRING:
- {
- double d;
- int type;
-
- if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), p, &d, -1)) == 0) {
- return "integer";
- } else if (type == IS_DOUBLE) {
- if (zend_isnan(d)) {
- return "integer";
- }
- if (!ZEND_DOUBLE_FITS_LONG(d)) {
- if (c == 'L') {
- *p = (d > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
- } else {
- return "integer";
- }
- break;
- }
-
- *p = zend_dval_to_lval(d);
- }
- }
- break;
-
- case IS_DOUBLE:
- if (zend_isnan(Z_DVAL_P(arg))) {
- return "integer";
- }
- if (!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg))) {
- if (c == 'L') {
- *p = (Z_DVAL_P(arg) > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
- } else {
- return "integer";
- }
- break;
- }
- case IS_NULL:
- case IS_FALSE:
- case IS_TRUE:
- case IS_LONG:
- convert_to_long_ex(arg);
- *p = Z_LVAL_P(arg);
- break;
-
- case IS_ARRAY:
- case IS_OBJECT:
- case IS_RESOURCE:
- default:
- return "integer";
+ if (!zend_parse_arg_long(arg, p, is_null, check_null, c == 'L')) {
+ return "integer";
}
}
break;
@@ -451,123 +402,52 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case 'd':
{
double *p = va_arg(*va, double *);
+ zend_bool *is_null = NULL;
if (check_null) {
- zend_bool *p = va_arg(*va, zend_bool *);
- *p = (Z_TYPE_P(arg) == IS_NULL);
+ is_null = va_arg(*va, zend_bool *);
}
- switch (Z_TYPE_P(arg)) {
- case IS_STRING:
- {
- zend_long l;
- int type;
-
- if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &l, p, -1)) == 0) {
- return "float";
- } else if (type == IS_LONG) {
- *p = (double) l;
- }
- }
- break;
-
- case IS_NULL:
- case IS_FALSE:
- case IS_TRUE:
- case IS_LONG:
- case IS_DOUBLE:
- convert_to_double_ex(arg);
- *p = Z_DVAL_P(arg);
- break;
-
- case IS_ARRAY:
- case IS_OBJECT:
- case IS_RESOURCE:
- default:
- return "float";
+ if (!zend_parse_arg_double(arg, p, is_null, check_null)) {
+ return "float";
}
}
break;
- case 'p':
case 's':
{
char **p = va_arg(*va, char **);
size_t *pl = va_arg(*va, size_t *);
- switch (Z_TYPE_P(arg)) {
- case IS_NULL:
- if (check_null) {
- *p = NULL;
- *pl = 0;
- break;
- }
- /* break omitted intentionally */
-
- case IS_LONG:
- case IS_DOUBLE:
- case IS_FALSE:
- case IS_TRUE:
- convert_to_string_ex(arg);
- case IS_STRING:
- *p = Z_STRVAL_P(arg);
- *pl = Z_STRLEN_P(arg);
- if (c == 'p' && CHECK_ZVAL_NULL_PATH(arg)) {
- return "a valid path";
- }
- break;
-
- case IS_OBJECT:
- if (parse_arg_object_to_string(arg, p, pl, IS_STRING) == SUCCESS) {
- if (c == 'p' && CHECK_ZVAL_NULL_PATH(arg)) {
- return "a valid path";
- }
- break;
- }
-
- case IS_ARRAY:
- case IS_RESOURCE:
- default:
- return c == 's' ? "string" : "a valid path";
+ if (!zend_parse_arg_string(arg, p, pl, check_null)) {
+ return "string";
+ }
+ }
+ break;
+
+ case 'p':
+ {
+ char **p = va_arg(*va, char **);
+ size_t *pl = va_arg(*va, size_t *);
+ if (!zend_parse_arg_path(arg, p, pl, check_null)) {
+ return "a valid path";
}
}
break;
case 'P':
- case 'S':
{
zend_string **str = va_arg(*va, zend_string **);
- switch (Z_TYPE_P(arg)) {
- case IS_NULL:
- if (check_null) {
- *str = NULL;
- break;
- }
- /* break omitted intentionally */
-
- case IS_LONG:
- case IS_DOUBLE:
- case IS_FALSE:
- case IS_TRUE:
- convert_to_string_ex(arg);
- case IS_STRING:
- *str = Z_STR_P(arg);
- if (c == 'P' && CHECK_ZVAL_NULL_PATH(arg)) {
- return "a valid path";
- }
- break;
+ if (!zend_parse_arg_path_str(arg, str, check_null)) {
+ return "a valid path";
+ }
+ }
+ break;
- case IS_OBJECT: {
- if (parse_arg_object_to_str(arg, str, IS_STRING) == SUCCESS) {
- if (c == 'P' && CHECK_ZVAL_NULL_PATH(arg)) {
- return "a valid path";
- }
- break;
- }
- }
- case IS_ARRAY:
- case IS_RESOURCE:
- default:
- return c == 'S' ? "string" : "a valid path";
+ case 'S':
+ {
+ zend_string **str = va_arg(*va, zend_string **);
+ if (!zend_parse_arg_str(arg, str, check_null)) {
+ return "string";
}
}
break;
@@ -575,28 +455,14 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case 'b':
{
zend_bool *p = va_arg(*va, zend_bool *);
+ zend_bool *is_null = NULL;
if (check_null) {
- zend_bool *p = va_arg(*va, zend_bool *);
- *p = (Z_TYPE_P(arg) == IS_NULL);
+ is_null = va_arg(*va, zend_bool *);
}
- switch (Z_TYPE_P(arg)) {
- case IS_NULL:
- case IS_STRING:
- case IS_LONG:
- case IS_DOUBLE:
- case IS_FALSE:
- case IS_TRUE:
- convert_to_boolean_ex(arg);
- *p = Z_TYPE_P(arg) == IS_TRUE;
- break;
-
- case IS_ARRAY:
- case IS_OBJECT:
- case IS_RESOURCE:
- default:
- return "boolean";
+ if (!zend_parse_arg_bool(arg, p, is_null, check_null)) {
+ return "boolean";
}
}
break;
@@ -604,48 +470,30 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case 'r':
{
zval **p = va_arg(*va, zval **);
- if (check_null && Z_TYPE_P(arg) == IS_NULL) {
- *p = NULL;
- break;
- }
- if (Z_TYPE_P(arg) == IS_RESOURCE) {
- *p = arg;
- } else {
+
+ if (!zend_parse_arg_resource(arg, p, check_null)) {
return "resource";
}
}
break;
+
case 'A':
case 'a':
{
zval **p = va_arg(*va, zval **);
- if (check_null && Z_TYPE_P(arg) == IS_NULL) {
- *p = NULL;
- break;
- }
- if (Z_TYPE_P(arg) == IS_ARRAY || (c == 'A' && Z_TYPE_P(arg) == IS_OBJECT)) {
- *p = arg;
- } else {
+
+ if (!zend_parse_arg_array(arg, p, check_null, c == 'A')) {
return "array";
}
}
break;
+
case 'H':
case 'h':
{
HashTable **p = va_arg(*va, HashTable **);
- if (check_null && Z_TYPE_P(arg) == IS_NULL) {
- *p = NULL;
- break;
- }
- if (Z_TYPE_P(arg) == IS_ARRAY) {
- *p = Z_ARRVAL_P(arg);
- } else if(c == 'H' && Z_TYPE_P(arg) == IS_OBJECT) {
- *p = HASH_OF(arg);
- if(*p == NULL) {
- return "array";
- }
- } else {
+
+ if (!zend_parse_arg_array_ht(arg, p, check_null, c == 'H')) {
return "array";
}
}
@@ -654,13 +502,8 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case 'o':
{
zval **p = va_arg(*va, zval **);
- if (check_null && Z_TYPE_P(arg) == IS_NULL) {
- *p = NULL;
- break;
- }
- if (Z_TYPE_P(arg) == IS_OBJECT) {
- *p = arg;
- } else {
+
+ if (!zend_parse_arg_object(arg, p, NULL, check_null)) {
return "object";
}
}
@@ -671,14 +514,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
zval **p = va_arg(*va, zval **);
zend_class_entry *ce = va_arg(*va, zend_class_entry *);
- if (check_null && Z_TYPE_P(arg) == IS_NULL) {
- *p = NULL;
- break;
- }
- if (Z_TYPE_P(arg) == IS_OBJECT &&
- (!ce || instanceof_function(Z_OBJCE_P(arg), ce))) {
- *p = arg;
- } else {
+ if (!zend_parse_arg_object(arg, p, ce, check_null)) {
if (ce) {
return ce->name->val;
} else {
@@ -757,11 +593,8 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
case 'z':
{
zval **p = va_arg(*va, zval **);
- if (check_null && Z_TYPE_P(arg) == IS_NULL) {
- *p = NULL;
- } else {
- *p = real_arg;
- }
+
+ zend_parse_arg_zval_deref(real_arg, p, check_null);
}
break;
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 5f7b559976..ac80d208fd 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -694,12 +694,10 @@ typedef enum _zend_expected_type {
Z_EXPECTED_LAST
} zend_expected_type;
-ZEND_API int parse_arg_object_to_str(zval *arg, zend_string **str, int type);
ZEND_API void zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args);
ZEND_API void zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg);
ZEND_API void zend_wrong_paramer_class_error(int num, char *name, zval *arg);
ZEND_API void zend_wrong_callback_error(int severity, int num, char *error);
-ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int check_null);
#define ZPP_ERROR_OK 0
#define ZPP_ERROR_FAILURE 1
@@ -782,7 +780,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "a" */
#define Z_PARAM_ARRAY_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_array(_arg, &dest, check_null, 0))) { \
+ if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \
_expected_type = Z_EXPECTED_ARRAY; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -794,7 +792,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "A" */
#define Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_array(_arg, &dest, check_null, 1))) { \
+ if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 1))) { \
_expected_type = Z_EXPECTED_ARRAY; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -806,7 +804,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "b" */
#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_bool(_arg, &dest, &is_null, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null))) { \
_expected_type = Z_EXPECTED_BOOL; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -818,7 +816,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "C" */
#define Z_PARAM_CLASS_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_class(_arg, &dest, _i, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_class(_arg, &dest, _i, check_null))) { \
error_code = ZPP_ERROR_FAILURE; \
break; \
}
@@ -829,7 +827,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "d" */
#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_double(_arg, &dest, &is_null, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null))) { \
_expected_type = Z_EXPECTED_DOUBLE; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -841,7 +839,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "f" */
#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \
+ if (UNEXPECTED(!zend_parse_arg_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \
if (!_error) { \
_expected_type = Z_EXPECTED_FUNC; \
error_code = ZPP_ERROR_WRONG_ARG; \
@@ -860,7 +858,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "h" */
#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_array_ht(_arg, &dest, check_null, 0))) { \
+ if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 0))) { \
_expected_type = Z_EXPECTED_ARRAY; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -872,7 +870,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "H" */
#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_array_ht(_arg, &dest, check_null, 1))) { \
+ if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 1))) { \
_expected_type = Z_EXPECTED_ARRAY; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -884,7 +882,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "l" */
#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_long(_arg, &dest, &is_null, check_null, 0))) { \
+ if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 0))) { \
_expected_type = Z_EXPECTED_LONG; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -896,7 +894,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "L" */
#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_long(_arg, &dest, &is_null, check_null, 1))) { \
+ if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 1))) { \
_expected_type = Z_EXPECTED_LONG; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -908,7 +906,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "o" */
#define Z_PARAM_OBJECT_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_object(_arg, &dest, NULL, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, NULL, check_null))) { \
_expected_type = Z_EXPECTED_OBJECT; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -920,7 +918,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "O" */
#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_object(_arg, &dest, _ce, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, _ce, check_null))) { \
if (_ce) { \
_error = (_ce)->name->val; \
error_code = ZPP_ERROR_WRONG_CLASS; \
@@ -938,7 +936,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "p" */
#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_path(_arg, &dest, &dest_len, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_path(_arg, &dest, &dest_len, check_null))) { \
_expected_type = Z_EXPECTED_PATH; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -950,7 +948,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "P" */
#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_path_str(_arg, &dest, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_path_str(_arg, &dest, check_null))) { \
_expected_type = Z_EXPECTED_PATH; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -962,7 +960,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "r" */
#define Z_PARAM_RESOURCE_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_resource(_arg, &dest, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_resource(_arg, &dest, check_null))) { \
_expected_type = Z_EXPECTED_RESOURCE; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -974,7 +972,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "s" */
#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_string(_arg, &dest, &dest_len, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_string(_arg, &dest, &dest_len, check_null))) { \
_expected_type = Z_EXPECTED_STRING; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -986,7 +984,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "S" */
#define Z_PARAM_STR_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- if (UNEXPECTED(!_z_param_str(_arg, &dest, check_null))) { \
+ if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null))) { \
_expected_type = Z_EXPECTED_STRING; \
error_code = ZPP_ERROR_WRONG_ARG; \
break; \
@@ -999,11 +997,11 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
#define Z_PARAM_ZVAL_EX(dest, check_null, separate) \
if (separate) { \
Z_PARAM_PROLOGUE(separate); \
- _z_param_zval_deref(_arg, &dest, check_null); \
+ zend_parse_arg_zval_deref(_arg, &dest, check_null); \
} else { \
if (UNEXPECTED(++_i >_num_args)) break; \
_real_arg++; \
- _z_param_zval(_real_arg, &dest, check_null); \
+ zend_parse_arg_zval(_real_arg, &dest, check_null); \
}
#define Z_PARAM_ZVAL(dest) \
@@ -1012,7 +1010,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
/* old "z" (with dereference) */
#define Z_PARAM_ZVAL_DEREF_EX(dest, check_null, separate) \
Z_PARAM_PROLOGUE(separate); \
- _z_param_zval_deref(_arg, &dest, check_null);
+ zend_parse_arg_zval_deref(_arg, &dest, check_null);
#define Z_PARAM_ZVAL_DEREF(dest) \
Z_PARAM_ZVAL_DEREF_EX(dest, 0, 0)
@@ -1034,9 +1032,16 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
#define Z_PARAM_VARIADIC(spec, dest, dest_num) \
Z_PARAM_VARIADIC_EX(spec, dest, dest_num, 0)
-/* Private part of new parameter parsing API */
+#endif /* FAST_ZPP */
+
+/* End of new parameter parsing API */
+
+/* Inlined implementations shared by new and old parameter parsing APIs */
-static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null)
+ZEND_API int parse_arg_object_to_str(zval *arg, zend_string **str, int type);
+ZEND_API int zend_parse_arg_class(zval *arg, zend_class_entry **pce, int num, int check_null);
+
+static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, zend_bool *is_null, int check_null)
{
if (check_null) {
*is_null = 0;
@@ -1056,7 +1061,7 @@ static zend_always_inline int _z_param_bool(zval *arg, zend_bool *dest, zend_boo
return 1;
}
-static zend_always_inline int _z_param_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null, int strict)
+static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null, int strict)
{
if (check_null) {
*is_null = 0;
@@ -1112,7 +1117,7 @@ static zend_always_inline int _z_param_long(zval *arg, zend_long *dest, zend_boo
return 1;
}
-static zend_always_inline int _z_param_double(zval *arg, double *dest, zend_bool *is_null, int check_null)
+static zend_always_inline int zend_parse_arg_double(zval *arg, double *dest, zend_bool *is_null, int check_null)
{
if (check_null) {
*is_null = 0;
@@ -1145,7 +1150,7 @@ static zend_always_inline int _z_param_double(zval *arg, double *dest, zend_bool
return 1;
}
-static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int check_null)
+static zend_always_inline int zend_parse_arg_str(zval *arg, zend_string **dest, int check_null)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
*dest = Z_STR_P(arg);
@@ -1167,11 +1172,11 @@ static zend_always_inline int _z_param_str(zval *arg, zend_string **dest, int ch
return 1;
}
-static zend_always_inline int _z_param_string(zval *arg, char **dest, size_t *dest_len, int check_null)
+static zend_always_inline int zend_parse_arg_string(zval *arg, char **dest, size_t *dest_len, int check_null)
{
zend_string *str;
- if (!_z_param_str(arg, &str, check_null)) {
+ if (!zend_parse_arg_str(arg, &str, check_null)) {
return 0;
}
if (check_null && UNEXPECTED(!str)) {
@@ -1184,21 +1189,20 @@ static zend_always_inline int _z_param_string(zval *arg, char **dest, size_t *de
return 1;
}
-static zend_always_inline int _z_param_path_str(zval *arg, zend_string **dest, int check_null)
+static zend_always_inline int zend_parse_arg_path_str(zval *arg, zend_string **dest, int check_null)
{
- if (!_z_param_str(arg, dest, check_null) ||
- (check_null && UNEXPECTED(!(*dest)->val[0])) ||
- UNEXPECTED(CHECK_NULL_PATH((*dest)->val, (*dest)->len))) {
+ if (!zend_parse_arg_str(arg, dest, check_null) ||
+ (*dest && UNEXPECTED(CHECK_NULL_PATH((*dest)->val, (*dest)->len)))) {
return 0;
}
return 1;
}
-static zend_always_inline int _z_param_path(zval *arg, char **dest, size_t *dest_len, int check_null)
+static zend_always_inline int zend_parse_arg_path(zval *arg, char **dest, size_t *dest_len, int check_null)
{
zend_string *str;
- if (!_z_param_path_str(arg, &str, check_null)) {
+ if (!zend_parse_arg_path_str(arg, &str, check_null)) {
return 0;
}
if (check_null && UNEXPECTED(!str)) {
@@ -1211,7 +1215,7 @@ static zend_always_inline int _z_param_path(zval *arg, char **dest, size_t *dest
return 1;
}
-static zend_always_inline int _z_param_array(zval *arg, zval **dest, int check_null, int or_object)
+static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int check_null, int or_object)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY) ||
(or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT))) {
@@ -1224,7 +1228,7 @@ static zend_always_inline int _z_param_array(zval *arg, zval **dest, int check_n
return 1;
}
-static zend_always_inline int _z_param_array_ht(zval *arg, HashTable **dest, int check_null, int or_object)
+static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **dest, int check_null, int or_object)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) {
*dest = Z_ARRVAL_P(arg);
@@ -1238,7 +1242,7 @@ static zend_always_inline int _z_param_array_ht(zval *arg, HashTable **dest, int
return 1;
}
-static zend_always_inline int _z_param_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null)
+static zend_always_inline int zend_parse_arg_object(zval *arg, zval **dest, zend_class_entry *ce, int check_null)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) &&
(!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce) != 0))) {
@@ -1251,7 +1255,7 @@ static zend_always_inline int _z_param_object(zval *arg, zval **dest, zend_class
return 1;
}
-static zend_always_inline int _z_param_resource(zval *arg, zval **dest, int check_null)
+static zend_always_inline int zend_parse_arg_resource(zval *arg, zval **dest, int check_null)
{
if (EXPECTED(Z_TYPE_P(arg) == IS_RESOURCE)) {
*dest = arg;
@@ -1263,7 +1267,7 @@ static zend_always_inline int _z_param_resource(zval *arg, zval **dest, int chec
return 1;
}
-static zend_always_inline int _z_param_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error)
+static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *dest_fci, zend_fcall_info_cache *dest_fcc, int check_null, char **error)
{
if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
dest_fci->size = 0;
@@ -1275,7 +1279,7 @@ static zend_always_inline int _z_param_func(zval *arg, zend_fcall_info *dest_fci
return 1;
}
-static zend_always_inline void _z_param_zval(zval *arg, zval **dest, int check_null)
+static zend_always_inline void zend_parse_arg_zval(zval *arg, zval **dest, int check_null)
{
*dest = (check_null &&
(UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) ||
@@ -1283,15 +1287,11 @@ static zend_always_inline void _z_param_zval(zval *arg, zval **dest, int check_n
UNEXPECTED(Z_TYPE_P(Z_REFVAL_P(arg)) == IS_NULL)))) ? NULL : arg;
}
-static zend_always_inline void _z_param_zval_deref(zval *arg, zval **dest, int check_null)
+static zend_always_inline void zend_parse_arg_zval_deref(zval *arg, zval **dest, int check_null)
{
*dest = (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) ? NULL : arg;
}
-#endif /* FAST_ZPP */
-
-/* End of new parameter parsing API */
-
END_EXTERN_C()
#endif /* ZEND_API_H */