diff options
Diffstat (limited to 'Zend/zend_API.h')
| -rw-r--r-- | Zend/zend_API.h | 216 |
1 files changed, 139 insertions, 77 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 7a0eea82e6..865f5dd291 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -35,7 +35,7 @@ BEGIN_EXTERN_C() typedef struct _zend_function_entry { const char *fname; - void (*handler)(INTERNAL_FUNCTION_PARAMETERS); + zif_handler handler; const struct _zend_internal_arg_info *arg_info; uint32_t num_args; uint32_t flags; @@ -97,24 +97,32 @@ typedef struct _zend_fcall_info_cache { #define ZEND_FE_END { NULL, NULL, NULL, 0, 0 } -#define ZEND_ARG_INFO(pass_by_ref, name) { #name, NULL, 0, pass_by_ref, 0, 0 }, -#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, NULL, 0, pass_by_ref, 0, 0 }, -#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, #classname, IS_OBJECT, pass_by_ref, allow_null, 0 }, -#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, NULL, IS_ARRAY, pass_by_ref, allow_null, 0 }, -#define ZEND_ARG_CALLABLE_INFO(pass_by_ref, name, allow_null) { #name, NULL, IS_CALLABLE, pass_by_ref, allow_null, 0 }, -#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, NULL, type_hint, pass_by_ref, allow_null, 0 }, -#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name) { #name, NULL, 0, pass_by_ref, 0, 1 }, +#define ZEND_ARG_INFO(pass_by_ref, name) { #name, 0, pass_by_ref, 0}, +#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, pass_by_ref, 0}, +#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, ZEND_TYPE_ENCODE_CLASS_CONST(#classname, allow_null), pass_by_ref, 0 }, +#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, ZEND_TYPE_ENCODE(IS_ARRAY, allow_null), pass_by_ref, 0 }, +#define ZEND_ARG_CALLABLE_INFO(pass_by_ref, name, allow_null) { #name, ZEND_TYPE_ENCODE(IS_CALLABLE, allow_null), pass_by_ref, 0 }, +#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, ZEND_TYPE_ENCODE(type_hint, allow_null), pass_by_ref, 0 }, +#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name) { #name, 0, pass_by_ref, 1 }, +#define ZEND_ARG_VARIADIC_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, ZEND_TYPE_ENCODE(type_hint, allow_null), pass_by_ref, 1 }, +#define ZEND_ARG_VARIADIC_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, ZEND_TYPE_ENCODE_CLASS_CONST(#classname, allow_null), pass_by_ref, 1 }, + +#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \ + static const zend_internal_arg_info name[] = { \ + { (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_ENCODE_CLASS_CONST(#class_name, allow_null), return_reference, 0 }, +#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(name, class_name, allow_null) \ + ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, 0, -1, class_name, allow_null) -#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, class_name, allow_null) \ +#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ static const zend_internal_arg_info name[] = { \ - { (const char*)(zend_uintptr_t)(required_num_args), class_name, type, return_reference, allow_null, 0 }, -#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(name, type, class_name, allow_null) \ - ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, 0, -1, type, class_name, allow_null) + { (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_ENCODE(type, allow_null), return_reference, 0 }, +#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(name, type, allow_null) \ + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, 0, -1, type, allow_null) #define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args) \ static const zend_internal_arg_info name[] = { \ - { (const char*)(zend_uintptr_t)(required_num_args), NULL, 0, return_reference, 0, 0 }, + { (const char*)(zend_uintptr_t)(required_num_args), 0, return_reference, 0 }, #define ZEND_BEGIN_ARG_INFO(name, _unused) \ ZEND_BEGIN_ARG_INFO_EX(name, 0, ZEND_RETURN_VALUE, -1) #define ZEND_END_ARG_INFO() }; @@ -260,6 +268,8 @@ ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array); _zend_get_parameters_array_ex(param_count, argument_array) #define zend_parse_parameters_none() \ (EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_parse_parameters(ZEND_NUM_ARGS(), "")) +#define zend_parse_parameters_none_throw() \ + (EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_parse_parameters_throw(ZEND_NUM_ARGS(), "")) /* Parameter parsing API -- andrei */ @@ -269,6 +279,7 @@ ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...); ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...); ZEND_API int zend_parse_parameters_throw(int num_args, const char *type_spec, ...); ZEND_API char *zend_zval_type_name(const zval *arg); +ZEND_API zend_string *zend_zval_get_type(const zval *arg); ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...); ZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this_ptr, const char *type_spec, ...); @@ -312,8 +323,10 @@ ZEND_API ZEND_COLD void zend_wrong_param_count(void); #define IS_CALLABLE_STRICT (IS_CALLABLE_CHECK_IS_STATIC) -ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error); -ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name); +ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object); +ZEND_API zend_string *zend_get_callable_name(zval *callable); +ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error); +ZEND_API zend_bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name); ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name); ZEND_API const char *zend_get_module_version(const char *module_name); ZEND_API int zend_get_module_started(const char *module_name); @@ -398,8 +411,8 @@ ZEND_API int add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b ZEND_API int add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r); ZEND_API int add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d); ZEND_API int add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str); -ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str); -ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, char *str, size_t length); +ZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, const char *str); +ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length); ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value); #define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n) @@ -438,8 +451,8 @@ ZEND_API int add_next_index_string(zval *arg, const char *str); ZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length); ZEND_API int add_next_index_zval(zval *arg, zval *value); -ZEND_API zval *add_get_assoc_string_ex(zval *arg, const char *key, uint key_len, const char *str); -ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, size_t length); +ZEND_API zval *add_get_assoc_string_ex(zval *arg, const char *key, uint32_t key_len, const char *str); +ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint32_t key_len, const char *str, size_t length); #define add_get_assoc_string(__arg, __key, __str) add_get_assoc_string_ex(__arg, __key, strlen(__key), __str) #define add_get_assoc_stringl(__arg, __key, __str, __length) add_get_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length) @@ -492,7 +505,7 @@ ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache; * The callable_name argument may be NULL. * Set check_flags to IS_CALLABLE_STRICT for every new usage! */ -ZEND_API int zend_fcall_info_init(zval *callable, uint check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); +ZEND_API int zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error); /** Clear arguments connected with zend_fcall_info *fci * If free_mem is not zero then the params array gets free'd as well @@ -701,10 +714,10 @@ typedef enum _zend_expected_type { Z_EXPECTED_LAST } zend_expected_type; -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int num_args, int min_num_args, int max_num_args); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, zend_expected_type expected_type, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, int num, char *error); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(zend_bool throw_, int num_args, int min_num_args, int max_num_args); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(zend_bool throw_, int num, zend_expected_type expected_type, zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(zend_bool throw_, int num, char *name, zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(zend_bool throw_, int severity, int num, char *error); #define ZPP_ERROR_OK 0 #define ZPP_ERROR_FAILURE 1 @@ -738,7 +751,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in (UNEXPECTED(_num_args > _max_num_args) && \ EXPECTED(_max_num_args >= 0))) { \ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \ - zend_wrong_parameters_count_error(_num_args, _min_num_args, _max_num_args); \ + zend_wrong_parameters_count_error(_flags & ZEND_PARSE_PARAMS_THROW, _num_args, _min_num_args, _max_num_args); \ } \ error_code = ZPP_ERROR_FAILURE; \ break; \ @@ -754,11 +767,11 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \ if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \ if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \ - zend_wrong_callback_error(E_WARNING, _i, _error); \ + zend_wrong_callback_error(_flags & ZEND_PARSE_PARAMS_THROW, E_WARNING, _i, _error); \ } else if (error_code == ZPP_ERROR_WRONG_CLASS) { \ - zend_wrong_parameter_class_error(_i, _error, _arg); \ + zend_wrong_parameter_class_error(_flags & ZEND_PARSE_PARAMS_THROW, _i, _error, _arg); \ } else if (error_code == ZPP_ERROR_WRONG_ARG) { \ - zend_wrong_parameter_type_error(_i, _expected_type, _arg); \ + zend_wrong_parameter_type_error(_flags & ZEND_PARSE_PARAMS_THROW, _i, _expected_type, _arg); \ } \ } \ failure; \ @@ -768,7 +781,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in #define ZEND_PARSE_PARAMETERS_END() \ ZEND_PARSE_PARAMETERS_END_EX(return) -#define Z_PARAM_PROLOGUE(separate) \ +#define Z_PARAM_PROLOGUE(deref, separate) \ ++_i; \ ZEND_ASSERT(_i <= _min_num_args || _optional==1); \ ZEND_ASSERT(_i > _min_num_args || _optional==0); \ @@ -777,7 +790,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in } \ _real_arg++; \ _arg = _real_arg; \ - ZVAL_DEREF(_arg); \ + if (deref) { \ + ZVAL_DEREF(_arg); \ + } \ if (separate) { \ SEPARATE_ZVAL_NOREF(_arg); \ } @@ -787,67 +802,82 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in _optional = 1; /* old "a" */ -#define Z_PARAM_ARRAY_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_ARRAY_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \ _expected_type = Z_EXPECTED_ARRAY; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_ARRAY_EX(dest, check_null, separate) \ + Z_PARAM_ARRAY_EX2(dest, check_null, separate, separate) + #define Z_PARAM_ARRAY(dest) \ Z_PARAM_ARRAY_EX(dest, 0, 0) /* old "A" */ -#define Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_ARRAY_OR_OBJECT_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 1))) { \ _expected_type = Z_EXPECTED_ARRAY; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate) \ + Z_PARAM_ARRAY_OR_OBJECT_EX2(dest, check_null, separate, separate) + #define Z_PARAM_ARRAY_OR_OBJECT(dest, check_null, separate) \ Z_PARAM_ARRAY_OR_OBJECT_EX(dest, 0, 0) /* old "b" */ -#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_BOOL_EX2(dest, is_null, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null))) { \ _expected_type = Z_EXPECTED_BOOL; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \ + Z_PARAM_BOOL_EX2(dest, is_null, check_null, separate, separate) + #define Z_PARAM_BOOL(dest) \ Z_PARAM_BOOL_EX(dest, _dummy, 0, 0) /* old "C" */ -#define Z_PARAM_CLASS_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_CLASS_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_class(_arg, &dest, _i, check_null))) { \ error_code = ZPP_ERROR_FAILURE; \ break; \ } +#define Z_PARAM_CLASS_EX(dest, check_null, separate) \ + Z_PARAM_CLASS_EX2(dest, check_null, separate, separate) + #define Z_PARAM_CLASS(dest) \ Z_PARAM_CLASS_EX(dest, 0, 0) /* old "d" */ -#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_DOUBLE_EX2(dest, is_null, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null))) { \ _expected_type = Z_EXPECTED_DOUBLE; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) \ + Z_PARAM_DOUBLE_EX2(dest, is_null, check_null, separate, separate) + #define Z_PARAM_DOUBLE(dest) \ Z_PARAM_DOUBLE_EX(dest, _dummy, 0, 0) /* old "f" */ -#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_FUNC_EX2(dest_fci, dest_fcc, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \ if (!_error) { \ _expected_type = Z_EXPECTED_FUNC; \ @@ -858,75 +888,93 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in break; \ } \ } else if (UNEXPECTED(_error != NULL)) { \ - zend_wrong_callback_error(E_DEPRECATED, _i, _error); \ + zend_wrong_callback_error(_flags & ZEND_PARSE_PARAMS_THROW, E_DEPRECATED, _i, _error); \ } +#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \ + Z_PARAM_FUNC_EX2(dest_fci, dest_fcc, check_null, separate, separate) + #define Z_PARAM_FUNC(dest_fci, dest_fcc) \ Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 0, 0) /* old "h" */ -#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_ARRAY_HT_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 0, separate))) { \ _expected_type = Z_EXPECTED_ARRAY; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \ + Z_PARAM_ARRAY_HT_EX2(dest, check_null, separate, separate) + #define Z_PARAM_ARRAY_HT(dest) \ Z_PARAM_ARRAY_HT_EX(dest, 0, 0) /* old "H" */ -#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 1, separate))) { \ _expected_type = Z_EXPECTED_ARRAY; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \ + Z_PARAM_ARRAY_OR_OBJECT_HT_EX2(dest, check_null, separate, separate) + #define Z_PARAM_ARRAY_OR_OBJECT_HT(dest) \ Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, 0, 0) /* old "l" */ -#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_LONG_EX2(dest, is_null, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ 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; \ } +#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) \ + Z_PARAM_LONG_EX2(dest, is_null, check_null, separate, separate) + #define Z_PARAM_LONG(dest) \ Z_PARAM_LONG_EX(dest, _dummy, 0, 0) /* old "L" */ -#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_STRICT_LONG_EX2(dest, is_null, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ 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; \ } +#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \ + Z_PARAM_STRICT_LONG_EX2(dest, is_null, check_null, separate, separate) + #define Z_PARAM_STRICT_LONG(dest) \ Z_PARAM_STRICT_LONG_EX(dest, _dummy, 0, 0) /* old "o" */ -#define Z_PARAM_OBJECT_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_OBJECT_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, NULL, check_null))) { \ _expected_type = Z_EXPECTED_OBJECT; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_OBJECT_EX(dest, check_null, separate) \ + Z_PARAM_OBJECT_EX2(dest, check_null, separate, separate) + #define Z_PARAM_OBJECT(dest) \ Z_PARAM_OBJECT_EX(dest, 0, 0) /* old "O" */ -#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_OBJECT_OF_CLASS_EX2(dest, _ce, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, _ce, check_null))) { \ if (_ce) { \ _error = ZSTR_VAL((_ce)->name); \ @@ -939,89 +987,101 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in } \ } +#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \ + Z_PARAM_OBJECT_OF_CLASS_EX2(dest, _ce, check_null, separate, separate) + #define Z_PARAM_OBJECT_OF_CLASS(dest, _ce) \ Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, 0, 0) /* old "p" */ -#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_PATH_EX2(dest, dest_len, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_path(_arg, &dest, &dest_len, check_null))) { \ _expected_type = Z_EXPECTED_PATH; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \ + Z_PARAM_PATH_EX2(dest, dest_len, check_null, separate, separate) + #define Z_PARAM_PATH(dest, dest_len) \ Z_PARAM_PATH_EX(dest, dest_len, 0, 0) /* old "P" */ -#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_PATH_STR_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_path_str(_arg, &dest, check_null))) { \ _expected_type = Z_EXPECTED_PATH; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \ + Z_PARAM_PATH_STR_EX2(dest, check_null, separate, separate) + #define Z_PARAM_PATH_STR(dest) \ Z_PARAM_PATH_STR_EX(dest, 0, 0) /* old "r" */ -#define Z_PARAM_RESOURCE_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_RESOURCE_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_resource(_arg, &dest, check_null))) { \ _expected_type = Z_EXPECTED_RESOURCE; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_RESOURCE_EX(dest, check_null, separate) \ + Z_PARAM_RESOURCE_EX2(dest, check_null, separate, separate) + #define Z_PARAM_RESOURCE(dest) \ Z_PARAM_RESOURCE_EX(dest, 0, 0) /* old "s" */ -#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_STRING_EX2(dest, dest_len, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_string(_arg, &dest, &dest_len, check_null))) { \ _expected_type = Z_EXPECTED_STRING; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \ + Z_PARAM_STRING_EX2(dest, dest_len, check_null, separate, separate) + #define Z_PARAM_STRING(dest, dest_len) \ Z_PARAM_STRING_EX(dest, dest_len, 0, 0) /* old "S" */ -#define Z_PARAM_STR_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ +#define Z_PARAM_STR_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null))) { \ _expected_type = Z_EXPECTED_STRING; \ error_code = ZPP_ERROR_WRONG_ARG; \ break; \ } +#define Z_PARAM_STR_EX(dest, check_null, separate) \ + Z_PARAM_STR_EX2(dest, check_null, separate, separate) + #define Z_PARAM_STR(dest) \ Z_PARAM_STR_EX(dest, 0, 0) /* old "z" */ +#define Z_PARAM_ZVAL_EX2(dest, check_null, deref, separate) \ + Z_PARAM_PROLOGUE(deref, separate); \ + zend_parse_arg_zval_deref(_arg, &dest, check_null); + #define Z_PARAM_ZVAL_EX(dest, check_null, separate) \ - if (separate) { \ - Z_PARAM_PROLOGUE(separate); \ - zend_parse_arg_zval_deref(_arg, &dest, check_null); \ - } else { \ - ++_i; \ - ZEND_ASSERT(_i <= _min_num_args || _optional==1); \ - ZEND_ASSERT(_i > _min_num_args || _optional==0); \ - if (_optional && UNEXPECTED(_i >_num_args)) break; \ - _real_arg++; \ - zend_parse_arg_zval(_real_arg, &dest, check_null); \ - } + Z_PARAM_ZVAL_EX2(dest, check_null, separate, separate) #define Z_PARAM_ZVAL(dest) \ Z_PARAM_ZVAL_EX(dest, 0, 0) /* old "z" (with dereference) */ #define Z_PARAM_ZVAL_DEREF_EX(dest, check_null, separate) \ - Z_PARAM_PROLOGUE(separate); \ + Z_PARAM_PROLOGUE(1, separate); \ zend_parse_arg_zval_deref(_arg, &dest, check_null); #define Z_PARAM_ZVAL_DEREF(dest) \ @@ -1263,4 +1323,6 @@ END_EXTERN_C() * c-basic-offset: 4 * indent-tabs-mode: t * End: + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 */ |
