summaryrefslogtreecommitdiff
path: root/Zend/zend_API.h
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_API.h')
-rw-r--r--Zend/zend_API.h138
1 files changed, 75 insertions, 63 deletions
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 3840770362..3c134f44ef 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -12,15 +12,13 @@
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
+ | Authors: Andi Gutmans <andi@php.net> |
+ | Zeev Suraski <zeev@php.net> |
| Andrei Zmievski <andrei@php.net> |
- | Dmitry Stogov <dmitry@zend.com> |
+ | Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id$ */
-
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -52,7 +50,6 @@ typedef struct _zend_fcall_info {
} zend_fcall_info;
typedef struct _zend_fcall_info_cache {
- zend_bool initialized;
zend_function *function_handler;
zend_class_entry *calling_scope;
zend_class_entry *called_scope;
@@ -63,7 +60,7 @@ typedef struct _zend_fcall_info_cache {
#define ZEND_FN(name) zif_##name
#define ZEND_MN(name) zim_##name
-#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
+#define ZEND_NAMED_FUNCTION(name) void ZEND_FASTCALL name(INTERNAL_FUNCTION_PARAMETERS)
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
#define ZEND_METHOD(classname, name) ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name))
@@ -186,20 +183,16 @@ typedef struct _zend_fcall_info_cache {
#endif
#define INIT_CLASS_ENTRY(class_container, class_name, functions) \
- INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL)
+ INIT_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions)
#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions) \
- INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, NULL, NULL, NULL, NULL, NULL)
-
-#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
{ \
- zend_string *cl_name; \
- cl_name = zend_string_init(class_name, class_name_len, 1); \
- class_container.name = zend_new_interned_string(cl_name); \
- INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
+ memset(&class_container, 0, sizeof(zend_class_entry)); \
+ class_container.name = zend_string_init_interned(class_name, class_name_len, 1); \
+ class_container.info.internal.builtin_functions = functions; \
}
-#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
+#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions) \
{ \
class_container.constructor = NULL; \
class_container.destructor = NULL; \
@@ -207,20 +200,17 @@ typedef struct _zend_fcall_info_cache {
class_container.serialize = NULL; \
class_container.unserialize = NULL; \
class_container.create_object = NULL; \
- class_container.interface_gets_implemented = NULL; \
class_container.get_static_method = NULL; \
- class_container.__call = handle_fcall; \
+ class_container.__call = NULL; \
class_container.__callstatic = NULL; \
class_container.__tostring = NULL; \
- class_container.__get = handle_propget; \
- class_container.__set = handle_propset; \
- class_container.__unset = handle_propunset; \
- class_container.__isset = handle_propisset; \
- class_container.__debugInfo = NULL; \
+ class_container.__get = NULL; \
+ class_container.__set = NULL; \
+ class_container.__unset = NULL; \
+ class_container.__isset = NULL; \
+ class_container.__debugInfo = NULL; \
class_container.serialize_func = NULL; \
class_container.unserialize_func = NULL; \
- class_container.serialize = NULL; \
- class_container.unserialize = NULL; \
class_container.parent = NULL; \
class_container.num_interfaces = 0; \
class_container.traits = NULL; \
@@ -229,20 +219,14 @@ typedef struct _zend_fcall_info_cache {
class_container.trait_precedences = NULL; \
class_container.interfaces = NULL; \
class_container.get_iterator = NULL; \
- class_container.iterator_funcs.funcs = NULL; \
+ class_container.iterator_funcs_ptr = NULL; \
class_container.info.internal.module = NULL; \
class_container.info.internal.builtin_functions = functions; \
}
-#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
- INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL)
#define INIT_NS_CLASS_ENTRY(class_container, ns, class_name, functions) \
INIT_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions)
-#define INIT_OVERLOADED_NS_CLASS_ENTRY_EX(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
- INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, ZEND_NS_NAME(ns, class_name), sizeof(ZEND_NS_NAME(ns, class_name))-1, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset)
-#define INIT_OVERLOADED_NS_CLASS_ENTRY(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset) \
- INIT_OVERLOADED_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions, handle_fcall, handle_propget, handle_propset)
#ifdef ZTS
# define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members_table:CG(static_members_table)[(zend_intptr_t)(ce)->static_members_table])
@@ -255,8 +239,6 @@ typedef struct _zend_fcall_info_cache {
ZEND_API int zend_next_free_module(void);
BEGIN_EXTERN_C()
-ZEND_API int zend_get_parameters(int ht, int param_count, ...);
-ZEND_API ZEND_ATTRIBUTE_DEPRECATED int zend_get_parameters_ex(int param_count, ...);
ZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array);
/* internal function to efficiently copy parameters when executing __call() */
@@ -267,9 +249,9 @@ ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
#define zend_get_parameters_array_ex(param_count, 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(), ""))
+ (EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_wrong_parameters_none_error())
#define zend_parse_parameters_none_throw() \
- (EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_parse_parameters_throw(ZEND_NUM_ARGS(), ""))
+ (EXPECTED(ZEND_NUM_ARGS() == 0) ? SUCCESS : zend_wrong_parameters_none_exception())
/* Parameter parsing API -- andrei */
@@ -304,12 +286,12 @@ ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *cla
ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry);
ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...);
-ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce);
+ZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, int persistent);
#define zend_register_class_alias(name, ce) \
- zend_register_class_alias_ex(name, sizeof(name)-1, ce)
+ zend_register_class_alias_ex(name, sizeof(name)-1, ce, 1)
#define zend_register_ns_class_alias(ns, name, ce) \
- zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce)
+ zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce, 1)
ZEND_API int zend_disable_function(char *function_name, size_t function_name_length);
ZEND_API int zend_disable_class(char *class_name, size_t class_name_length);
@@ -361,6 +343,7 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object,
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_length);
ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length);
+ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value);
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value);
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length);
ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
@@ -372,6 +355,7 @@ ZEND_API int zend_update_static_property_stringl(zend_class_entry *scope, const
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_ex(zend_class_entry *scope, zend_string *name, zend_bool silent);
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);
@@ -390,15 +374,11 @@ ZEND_API char *zend_get_type_by_const(int type);
#define DLEXPORT
#endif
-#define array_init(arg) _array_init((arg), 0 ZEND_FILE_LINE_CC)
-#define array_init_size(arg, size) _array_init((arg), (size) ZEND_FILE_LINE_CC)
-#define object_init(arg) _object_init((arg) ZEND_FILE_LINE_CC)
-#define object_init_ex(arg, ce) _object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
-#define object_and_properties_init(arg, ce, properties) _object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC)
-ZEND_API int _array_init(zval *arg, uint32_t size ZEND_FILE_LINE_DC);
-ZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
-ZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
-ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC);
+#define array_init(arg) ZVAL_ARR((arg), zend_new_array(0))
+#define array_init_size(arg, size) ZVAL_ARR((arg), zend_new_array(size))
+ZEND_API int object_init(zval *arg);
+ZEND_API int object_init_ex(zval *arg, zend_class_entry *ce);
+ZEND_API int object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties);
ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type);
ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties);
ZEND_API void object_properties_load(zend_object *object, HashTable *properties);
@@ -425,7 +405,7 @@ ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval
#define add_assoc_stringl(__arg, __key, __str, __length) add_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
-/* unset() functions are only suported for legacy modules and null() functions should be used */
+/* unset() functions are only supported for legacy modules and null() functions should be used */
#define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
#define add_index_unset(__arg, __key) add_index_null(__arg, __key)
#define add_next_index_unset(__arg) add_next_index_null(__arg)
@@ -570,6 +550,8 @@ ZEND_API const char *zend_get_object_type(const zend_class_entry *ce);
ZEND_API zend_bool zend_is_iterable(zval *iterable);
+ZEND_API zend_bool zend_is_countable(zval *countable);
+
#define add_method(arg, key, method) add_assoc_function((arg), (key), (method))
ZEND_API ZEND_FUNCTION(display_disabled_function);
@@ -696,8 +678,8 @@ END_EXTERN_C()
#define FAST_ZPP 1
#define Z_EXPECTED_TYPES(_) \
- _(Z_EXPECTED_LONG, "integer") \
- _(Z_EXPECTED_BOOL, "boolean") \
+ _(Z_EXPECTED_LONG, "int") \
+ _(Z_EXPECTED_BOOL, "bool") \
_(Z_EXPECTED_STRING, "string") \
_(Z_EXPECTED_ARRAY, "array") \
_(Z_EXPECTED_FUNC, "valid callback") \
@@ -714,10 +696,17 @@ typedef enum _zend_expected_type {
Z_EXPECTED_LAST
} zend_expected_type;
-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);
+ZEND_API ZEND_COLD int ZEND_FASTCALL zend_wrong_parameters_none_error(void);
+ZEND_API ZEND_COLD int ZEND_FASTCALL zend_wrong_parameters_none_exception(void);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int min_num_args, int max_num_args);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_exception(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_type_exception(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_parameter_class_exception(int num, char *name, zval *arg);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *error);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_deprecated(int num, char *error);
+ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_exception(int num, char *error);
#define ZPP_ERROR_OK 0
#define ZPP_ERROR_FAILURE 1
@@ -751,7 +740,11 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(zend_bool throw_
(UNEXPECTED(_num_args > _max_num_args) && \
EXPECTED(_max_num_args >= 0))) { \
if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
- zend_wrong_parameters_count_error(_flags & ZEND_PARSE_PARAMS_THROW, _num_args, _min_num_args, _max_num_args); \
+ if (_flags & ZEND_PARSE_PARAMS_THROW) { \
+ zend_wrong_parameters_count_exception(_min_num_args, _max_num_args); \
+ } else { \
+ zend_wrong_parameters_count_error(_min_num_args, _max_num_args); \
+ } \
} \
error_code = ZPP_ERROR_FAILURE; \
break; \
@@ -762,16 +755,35 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(zend_bool throw_
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args) \
ZEND_PARSE_PARAMETERS_START_EX(0, min_num_args, max_num_args)
+#define ZEND_PARSE_PARAMETERS_NONE() do { \
+ if (UNEXPECTED(ZEND_NUM_ARGS() != 0)) { \
+ zend_wrong_parameters_none_error(); \
+ return; \
+ } \
+ } while (0)
+
#define ZEND_PARSE_PARAMETERS_END_EX(failure) \
} while (0); \
if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \
if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \
- zend_wrong_callback_error(_flags & ZEND_PARSE_PARAMS_THROW, E_WARNING, _i, _error); \
+ if (_flags & ZEND_PARSE_PARAMS_THROW) { \
+ zend_wrong_callback_exception(_i, _error); \
+ } else { \
+ zend_wrong_callback_error(_i, _error); \
+ } \
} else if (error_code == ZPP_ERROR_WRONG_CLASS) { \
- zend_wrong_parameter_class_error(_flags & ZEND_PARSE_PARAMS_THROW, _i, _error, _arg); \
+ if (_flags & ZEND_PARSE_PARAMS_THROW) { \
+ zend_wrong_parameter_class_exception(_i, _error, _arg); \
+ } else { \
+ zend_wrong_parameter_class_error(_i, _error, _arg); \
+ } \
} else if (error_code == ZPP_ERROR_WRONG_ARG) { \
- zend_wrong_parameter_type_error(_flags & ZEND_PARSE_PARAMS_THROW, _i, _expected_type, _arg); \
+ if (_flags & ZEND_PARSE_PARAMS_THROW) { \
+ zend_wrong_parameter_type_exception(_i, _expected_type, _arg); \
+ } else { \
+ zend_wrong_parameter_type_error(_i, _expected_type, _arg); \
+ } \
} \
} \
failure; \
@@ -828,7 +840,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(zend_bool throw_
#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) \
+#define Z_PARAM_ARRAY_OR_OBJECT(dest) \
Z_PARAM_ARRAY_OR_OBJECT_EX(dest, 0, 0)
/* old "b" */
@@ -888,7 +900,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(zend_bool throw_
break; \
} \
} else if (UNEXPECTED(_error != NULL)) { \
- zend_wrong_callback_error(_flags & ZEND_PARSE_PARAMS_THROW, E_DEPRECATED, _i, _error); \
+ zend_wrong_callback_deprecated(_i, _error); \
}
#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \
@@ -1249,7 +1261,7 @@ static zend_always_inline int zend_parse_arg_array_ht(zval *arg, HashTable **des
&& 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)--;
+ GC_DELREF(Z_OBJ_P(arg)->properties);
}
Z_OBJ_P(arg)->properties = zend_array_dup(Z_OBJ_P(arg)->properties);
}
@@ -1291,7 +1303,7 @@ static zend_always_inline int zend_parse_arg_func(zval *arg, zend_fcall_info *de
{
if (check_null && UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
dest_fci->size = 0;
- dest_fcc->initialized = 0;
+ dest_fcc->function_handler = NULL;
*error = NULL;
} else if (UNEXPECTED(zend_fcall_info_init(arg, 0, dest_fci, dest_fcc, NULL, error) != SUCCESS)) {
return 0;