mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Add the Z_PARAM_ARRAY_HT_OR_NULL and Z_PARAM_OBJ macros
This commit is contained in:
parent
7805b97720
commit
e50cb320b4
1 changed files with 34 additions and 0 deletions
|
@ -1527,6 +1527,9 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
|
|||
#define Z_PARAM_ARRAY_HT(dest) \
|
||||
Z_PARAM_ARRAY_HT_EX(dest, 0, 0)
|
||||
|
||||
#define Z_PARAM_ARRAY_HT_OR_NULL(dest) \
|
||||
Z_PARAM_ARRAY_HT_EX(dest, 1, 0)
|
||||
|
||||
/* old "H" */
|
||||
#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX2(dest, check_null, deref, separate) \
|
||||
Z_PARAM_PROLOGUE(deref, separate); \
|
||||
|
@ -1593,6 +1596,24 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
|
|||
#define Z_PARAM_OBJECT_OR_NULL(dest) \
|
||||
Z_PARAM_OBJECT_EX(dest, 1, 0)
|
||||
|
||||
/* The same as Z_PARAM_OBJECT_EX2 except that dest is a zend_object rather than a zval */
|
||||
#define Z_PARAM_OBJ_EX2(dest, check_null, deref, separate) \
|
||||
Z_PARAM_PROLOGUE(deref, separate); \
|
||||
if (UNEXPECTED(!zend_parse_arg_obj(_arg, &dest, NULL, check_null))) { \
|
||||
_expected_type = check_null ? Z_EXPECTED_OBJECT_OR_NULL : Z_EXPECTED_OBJECT; \
|
||||
_error_code = ZPP_ERROR_WRONG_ARG; \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define Z_PARAM_OBJ_EX(dest, check_null, separate) \
|
||||
Z_PARAM_OBJ_EX2(dest, check_null, separate, separate)
|
||||
|
||||
#define Z_PARAM_OBJ(dest) \
|
||||
Z_PARAM_OBJ_EX(dest, 0, 0)
|
||||
|
||||
#define Z_PARAM_OBJ_OR_NULL(dest) \
|
||||
Z_PARAM_OBJ_EX(dest, 1, 0)
|
||||
|
||||
/* old "O" */
|
||||
#define Z_PARAM_OBJECT_OF_CLASS_EX2(dest, _ce, check_null, deref, separate) \
|
||||
Z_PARAM_PROLOGUE(deref, separate); \
|
||||
|
@ -1983,6 +2004,19 @@ static zend_always_inline bool zend_parse_arg_object(zval *arg, zval **dest, zen
|
|||
return 1;
|
||||
}
|
||||
|
||||
static zend_always_inline bool zend_parse_arg_obj(zval *arg, zend_object **dest, zend_class_entry *ce, bool check_null)
|
||||
{
|
||||
if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT) &&
|
||||
(!ce || EXPECTED(instanceof_function(Z_OBJCE_P(arg), ce) != 0))) {
|
||||
*dest = Z_OBJ_P(arg);
|
||||
} else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
|
||||
*dest = NULL;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static zend_always_inline bool zend_parse_arg_resource(zval *arg, zval **dest, bool check_null)
|
||||
{
|
||||
if (EXPECTED(Z_TYPE_P(arg) == IS_RESOURCE)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue