diff options
Diffstat (limited to 'Zend/zend_API.h')
-rw-r--r-- | Zend/zend_API.h | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 822dbb08b8..5f68b680bc 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -43,9 +43,7 @@ typedef struct _zend_function_entry { typedef struct _zend_fcall_info { size_t size; - HashTable *function_table; zval function_name; - zend_array *symbol_table; zval *retval; zval *params; zend_object *object; @@ -160,7 +158,11 @@ typedef struct _zend_fcall_info_cache { #define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \ ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor); #define ZEND_MODULE_GLOBALS_ACCESSOR(module_name, v) ZEND_TSRMG(module_name##_globals_id, zend_##module_name##_globals *, v) +#if ZEND_ENABLE_STATIC_TSRMLS_CACHE +#define ZEND_MODULE_GLOBALS_BULK(module_name) TSRMG_BULK_STATIC(module_name##_globals_id, zend_##module_name##_globals *) +#else #define ZEND_MODULE_GLOBALS_BULK(module_name) TSRMG_BULK(module_name##_globals_id, zend_##module_name##_globals *) +#endif #else @@ -324,6 +326,7 @@ ZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type); ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_len, int access_type); +ZEND_API int zend_declare_class_constant_ex(zend_class_entry *ce, zend_string *name, zval *value, int access_type, zend_string *doc_comment); ZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value); ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length); ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value); @@ -352,13 +355,14 @@ ZEND_API int zend_update_static_property_double(zend_class_entry *scope, const c ZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); +ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zval *object, zend_string *name, zend_bool silent, zval *rv); ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv); ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent); ZEND_API char *zend_get_type_by_const(int type); -#define getThis() (Z_OBJ(EX(This)) ? &EX(This) : NULL) +#define getThis() ((Z_TYPE(EX(This)) == IS_OBJECT) ? &EX(This) : NULL) #define ZEND_IS_METHOD_CALL() (EX(func)->common.scope != NULL) #define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT() @@ -468,8 +472,12 @@ ZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zv #define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value) -ZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]); -ZEND_API int call_user_function_ex(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation, zend_array *symbol_table); +ZEND_API int _call_user_function_ex(zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[], int no_separation); + +#define call_user_function(function_table, object, function_name, retval_ptr, param_count, params) \ + _call_user_function_ex(object, function_name, retval_ptr, param_count, params, 1) +#define call_user_function_ex(function_table, object, function_name, retval_ptr, param_count, params, no_separation, symbol_table) \ + _call_user_function_ex(object, function_name, retval_ptr, param_count, params, no_separation) ZEND_API extern const zend_fcall_info empty_fcall_info; ZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache; @@ -539,12 +547,15 @@ ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data); ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data); ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force); ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force); +ZEND_API int zend_forbid_dynamic_call(const char *func_name); ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name); ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f); ZEND_API const char *zend_get_object_type(const zend_class_entry *ce); +ZEND_API zend_bool zend_is_iterable(zval *iterable); + #define add_method(arg, key, method) add_assoc_function((arg), (key), (method)) ZEND_API ZEND_FUNCTION(display_disabled_function); @@ -562,7 +573,7 @@ END_EXTERN_C() #endif #define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p))) -#define CHECK_NULL_PATH(p, l) (strlen(p) != l) +#define CHECK_NULL_PATH(p, l) (strlen(p) != (size_t)(l)) #define ZVAL_STRINGL(z, s, l) do { \ ZVAL_NEW_STR(z, zend_string_init(s, l, 0)); \ @@ -691,9 +702,9 @@ typedef enum _zend_expected_type { Z_EXPECTED_LAST } zend_expected_type; -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_paramer_class_error(int num, char *name, zval *arg); +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); #define ZPP_ERROR_OK 0 @@ -728,7 +739,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_paramers_count_error(_num_args, _min_num_args, _max_num_args); \ + zend_wrong_parameters_count_error(_num_args, _min_num_args, _max_num_args); \ } \ error_code = ZPP_ERROR_FAILURE; \ break; \ @@ -746,9 +757,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \ zend_wrong_callback_error(E_WARNING, _i, _error); \ } else if (error_code == ZPP_ERROR_WRONG_CLASS) { \ - zend_wrong_paramer_class_error(_i, _error, _arg); \ + zend_wrong_parameter_class_error(_i, _error, _arg); \ } else if (error_code == ZPP_ERROR_WRONG_ARG) { \ - zend_wrong_paramer_type_error(_i, _expected_type, _arg); \ + zend_wrong_parameter_type_error(_i, _expected_type, _arg); \ } \ } \ failure; \ @@ -857,7 +868,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in /* old "h" */ #define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \ Z_PARAM_PROLOGUE(separate); \ - if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 0))) { \ + 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; \ @@ -869,7 +880,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int severity, in /* old "H" */ #define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \ Z_PARAM_PROLOGUE(separate); \ - if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 1))) { \ + 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; \ @@ -1172,11 +1183,19 @@ static zend_always_inline int zend_parse_arg_array(zval *arg, zval **dest, int c return 1; } -static zend_always_inline int zend_parse_arg_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, int separate) { if (EXPECTED(Z_TYPE_P(arg) == IS_ARRAY)) { *dest = Z_ARRVAL_P(arg); } else if (or_object && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { + if (separate + && Z_OBJ_P(arg)->properties + && UNEXPECTED(GC_REFCOUNT(Z_OBJ_P(arg)->properties) > 1)) { + if (EXPECTED(!(GC_FLAGS(Z_OBJ_P(arg)->properties) & IS_ARRAY_IMMUTABLE))) { + GC_REFCOUNT(Z_OBJ_P(arg)->properties)--; + } + Z_OBJ_P(arg)->properties = zend_array_dup(Z_OBJ_P(arg)->properties); + } *dest = Z_OBJ_HT_P(arg)->get_properties(arg); } else if (check_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) { *dest = NULL; |