zend_API.h revision 3e31838d
1573b4602SAndi Gutmans/*
2573b4602SAndi Gutmans   +----------------------------------------------------------------------+
3573b4602SAndi Gutmans   | Zend Engine                                                          |
4573b4602SAndi Gutmans   +----------------------------------------------------------------------+
5fc33f52dSXinchen Hui   | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
6573b4602SAndi Gutmans   +----------------------------------------------------------------------+
7d863d52aSSebastian Bergmann   | This source file is subject to version 2.00 of the Zend license,     |
8b4892511SJani Taskinen   | that is bundled with this package in the file LICENSE, and is        |
9f68c7ff2SJames Cox   | available through the world-wide-web at the following url:           |
10d863d52aSSebastian Bergmann   | http://www.zend.com/license/2_00.txt.                                |
11b5b11177SZeev Suraski   | If you did not receive a copy of the Zend license and are unable to  |
12b5b11177SZeev Suraski   | obtain it through the world-wide-web, please send a note to          |
13b5b11177SZeev Suraski   | license@zend.com so we can mail you a copy immediately.              |
14573b4602SAndi Gutmans   +----------------------------------------------------------------------+
15573b4602SAndi Gutmans   | Authors: Andi Gutmans <andi@zend.com>                                |
16573b4602SAndi Gutmans   |          Zeev Suraski <zeev@zend.com>                                |
1758f88057SAndrei Zmievski   |          Andrei Zmievski <andrei@php.net>                            |
18573b4602SAndi Gutmans   +----------------------------------------------------------------------+
19573b4602SAndi Gutmans*/
20573b4602SAndi Gutmans
21333406bdSfoobar/* $Id$ */
22b5b11177SZeev Suraski
23b982307dSSascha Schumann#ifndef ZEND_API_H
24b982307dSSascha Schumann#define ZEND_API_H
25573b4602SAndi Gutmans
267080fa5bSAndi Gutmans#include "zend_modules.h"
27573b4602SAndi Gutmans#include "zend_list.h"
285dba4774SZeev Suraski#include "zend_operators.h"
295dba4774SZeev Suraski#include "zend_variables.h"
30df74f1dfSSascha Schumann#include "zend_execute.h"
31573b4602SAndi Gutmans
320450ab94SZeev Suraski
330450ab94SZeev SuraskiBEGIN_EXTERN_C()
34e9d126a7SAndi Gutmans
35f8bbafd6SZeev Suraskitypedef struct _zend_function_entry {
366c810b0dSDmitry Stogov	const char *fname;
37f8bbafd6SZeev Suraski	void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
385dd427eaSDmitry Stogov	const struct _zend_internal_arg_info *arg_info;
396f9f0bf2SAnatol Belski	uint32_t num_args;
406f9f0bf2SAnatol Belski	uint32_t flags;
41f8bbafd6SZeev Suraski} zend_function_entry;
42f8bbafd6SZeev Suraski
43feb85801SDmitry Stogovtypedef struct _zend_fcall_info {
44feb85801SDmitry Stogov	size_t size;
45feb85801SDmitry Stogov	HashTable *function_table;
46f4cfaf36SDmitry Stogov	zval function_name;
47aa5f5530SDmitry Stogov	zend_array *symbol_table;
48f4cfaf36SDmitry Stogov	zval *retval;
49f4cfaf36SDmitry Stogov	zval *params;
50ea85451bSDmitry Stogov	zend_object *object;
51feb85801SDmitry Stogov	zend_bool no_separation;
525d5a7020SAnatol Belski	uint32_t param_count;
53feb85801SDmitry Stogov} zend_fcall_info;
54feb85801SDmitry Stogov
55feb85801SDmitry Stogovtypedef struct _zend_fcall_info_cache {
56feb85801SDmitry Stogov	zend_bool initialized;
57feb85801SDmitry Stogov	zend_function *function_handler;
58feb85801SDmitry Stogov	zend_class_entry *calling_scope;
59feb85801SDmitry Stogov	zend_class_entry *called_scope;
60ea85451bSDmitry Stogov	zend_object *object;
61feb85801SDmitry Stogov} zend_fcall_info_cache;
62feb85801SDmitry Stogov
6386b36438SJelle Zijlstra#define ZEND_NS_NAME(ns, name)			ns "\\" name
64907fa665SDmitry Stogov
65f8bbafd6SZeev Suraski#define ZEND_FN(name) zif_##name
66637a4042SMarcus Boerger#define ZEND_MN(name) zim_##name
67f8bbafd6SZeev Suraski#define ZEND_NAMED_FUNCTION(name)		void name(INTERNAL_FUNCTION_PARAMETERS)
68f8bbafd6SZeev Suraski#define ZEND_FUNCTION(name)				ZEND_NAMED_FUNCTION(ZEND_FN(name))
69637a4042SMarcus Boerger#define ZEND_METHOD(classname, name)	ZEND_NAMED_FUNCTION(ZEND_MN(classname##_##name))
70f8bbafd6SZeev Suraski
716f9f0bf2SAnatol Belski#define ZEND_FENTRY(zend_name, name, arg_info, flags)	{ #zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
721c2512ddSMarcus Boerger
736f9f0bf2SAnatol Belski#define ZEND_RAW_FENTRY(zend_name, name, arg_info, flags)   { zend_name, name, arg_info, (uint32_t) (sizeof(arg_info)/sizeof(struct _zend_arg_info)-1), flags },
741e19ee87SHannes Magnusson#define ZEND_RAW_NAMED_FE(zend_name, name, arg_info) ZEND_RAW_FENTRY(#zend_name, name, arg_info, 0)
751e19ee87SHannes Magnusson
761c2512ddSMarcus Boerger#define ZEND_NAMED_FE(zend_name, name, arg_info)	ZEND_FENTRY(zend_name, name, arg_info, 0)
771c2512ddSMarcus Boerger#define ZEND_FE(name, arg_info)						ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0)
78941b0651SMarcus Boerger#define ZEND_DEP_FE(name, arg_info)                 ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
79cec053f7SMarcus Boerger#define ZEND_FALIAS(name, alias, arg_info)			ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0)
80941b0651SMarcus Boerger#define ZEND_DEP_FALIAS(name, alias, arg_info)		ZEND_FENTRY(name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
81637a4042SMarcus Boerger#define ZEND_NAMED_ME(zend_name, name, arg_info, flags)	ZEND_FENTRY(zend_name, name, arg_info, flags)
82637a4042SMarcus Boerger#define ZEND_ME(classname, name, arg_info, flags)	ZEND_FENTRY(name, ZEND_MN(classname##_##name), arg_info, flags)
831c2512ddSMarcus Boerger#define ZEND_ABSTRACT_ME(classname, name, arg_info)	ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
8433cdc9edSMarcus Boerger#define ZEND_MALIAS(classname, name, alias, arg_info, flags) \
85637a4042SMarcus Boerger                                                    ZEND_FENTRY(name, ZEND_MN(classname##_##alias), arg_info, flags)
86637a4042SMarcus Boerger#define ZEND_ME_MAPPING(name, func_name, arg_types, flags) ZEND_NAMED_ME(name, ZEND_FN(func_name), arg_types, flags)
87f8bbafd6SZeev Suraski
88907fa665SDmitry Stogov#define ZEND_NS_FENTRY(ns, zend_name, name, arg_info, flags)		ZEND_RAW_FENTRY(ZEND_NS_NAME(ns, #zend_name), name, arg_info, flags)
89907fa665SDmitry Stogov
90907fa665SDmitry Stogov#define ZEND_NS_RAW_FENTRY(ns, zend_name, name, arg_info, flags)	ZEND_RAW_FENTRY(ZEND_NS_NAME(ns, zend_name), name, arg_info, flags)
91907fa665SDmitry Stogov#define ZEND_NS_RAW_NAMED_FE(ns, zend_name, name, arg_info)			ZEND_NS_RAW_FENTRY(ns, #zend_name, name, arg_info, 0)
92907fa665SDmitry Stogov
932d5695cbSSara Golemon#define ZEND_NS_NAMED_FE(ns, zend_name, name, arg_info)	ZEND_NS_FENTRY(ns, zend_name, name, arg_info, 0)
94907fa665SDmitry Stogov#define ZEND_NS_FE(ns, name, arg_info)					ZEND_NS_FENTRY(ns, name, ZEND_FN(name), arg_info, 0)
95907fa665SDmitry Stogov#define ZEND_NS_DEP_FE(ns, name, arg_info)				ZEND_NS_FENTRY(ns, name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
96907fa665SDmitry Stogov#define ZEND_NS_FALIAS(ns, name, alias, arg_info)		ZEND_NS_FENTRY(ns, name, ZEND_FN(alias), arg_info, 0)
97907fa665SDmitry Stogov#define ZEND_NS_DEP_FALIAS(ns, name, alias, arg_info)	ZEND_NS_FENTRY(ns, name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
98907fa665SDmitry Stogov
99f1f2a649SFelipe Pena#define ZEND_FE_END            { NULL, NULL, NULL, 0, 0 }
100f1f2a649SFelipe Pena
1015dd427eaSDmitry Stogov#define ZEND_ARG_INFO(pass_by_ref, name)							 { #name, NULL, 0, pass_by_ref, 0, 0 },
1025dd427eaSDmitry Stogov#define ZEND_ARG_PASS_INFO(pass_by_ref)								 { NULL,  NULL, 0, pass_by_ref, 0, 0 },
1035dd427eaSDmitry Stogov#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null)  { #name, #classname, IS_OBJECT, pass_by_ref, allow_null, 0 },
1045dd427eaSDmitry Stogov#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null)           { #name, NULL, IS_ARRAY, pass_by_ref, allow_null, 0 },
1055dd427eaSDmitry Stogov#define ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, NULL, type_hint, pass_by_ref, allow_null, 0 },
1065dd427eaSDmitry Stogov#define ZEND_ARG_VARIADIC_INFO(pass_by_ref, name) 					 { #name, NULL, 0, pass_by_ref, 0, 1 },
1070d7a6388SNikita Popov
1080d7a6388SNikita Popov#define ZEND_BEGIN_ARG_INFO_EX(name, _unused, return_reference, required_num_args)	\
1095dd427eaSDmitry Stogov	static const zend_internal_arg_info name[] = {																		\
1105dd427eaSDmitry Stogov		{ (const char*)(zend_uintptr_t)(required_num_args), NULL, 0, return_reference, 0, 0 },
1110d7a6388SNikita Popov#define ZEND_BEGIN_ARG_INFO(name, _unused)	\
1120d7a6388SNikita Popov	ZEND_BEGIN_ARG_INFO_EX(name, 0, ZEND_RETURN_VALUE, -1)
113f8bbafd6SZeev Suraski#define ZEND_END_ARG_INFO()		};
114342c6e0bSZeev Suraski
1158b6f848cSAndi Gutmans/* Name macros */
1168b6f848cSAndi Gutmans#define ZEND_MODULE_STARTUP_N(module)       zm_startup_##module
1178b6f848cSAndi Gutmans#define ZEND_MODULE_SHUTDOWN_N(module)		zm_shutdown_##module
1188b6f848cSAndi Gutmans#define ZEND_MODULE_ACTIVATE_N(module)		zm_activate_##module
1198b6f848cSAndi Gutmans#define ZEND_MODULE_DEACTIVATE_N(module)	zm_deactivate_##module
1206535933fSDerick Rethans#define ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)	zm_post_zend_deactivate_##module
1218b6f848cSAndi Gutmans#define ZEND_MODULE_INFO_N(module)			zm_info_##module
122ada4e506SDmitry Stogov#define ZEND_MODULE_GLOBALS_CTOR_N(module)  zm_globals_ctor_##module
123ada4e506SDmitry Stogov#define ZEND_MODULE_GLOBALS_DTOR_N(module)  zm_globals_dtor_##module
124342c6e0bSZeev Suraski
1258b6f848cSAndi Gutmans/* Declaration macros */
1268b6f848cSAndi Gutmans#define ZEND_MODULE_STARTUP_D(module)		int ZEND_MODULE_STARTUP_N(module)(INIT_FUNC_ARGS)
1278b6f848cSAndi Gutmans#define ZEND_MODULE_SHUTDOWN_D(module)		int ZEND_MODULE_SHUTDOWN_N(module)(SHUTDOWN_FUNC_ARGS)
1288b6f848cSAndi Gutmans#define ZEND_MODULE_ACTIVATE_D(module)		int ZEND_MODULE_ACTIVATE_N(module)(INIT_FUNC_ARGS)
1298b6f848cSAndi Gutmans#define ZEND_MODULE_DEACTIVATE_D(module)	int ZEND_MODULE_DEACTIVATE_N(module)(SHUTDOWN_FUNC_ARGS)
1306535933fSDerick Rethans#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module)	int ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)(void)
1318b6f848cSAndi Gutmans#define ZEND_MODULE_INFO_D(module)			void ZEND_MODULE_INFO_N(module)(ZEND_MODULE_INFO_FUNC_ARGS)
132bdeb220fSAnatol Belski#define ZEND_MODULE_GLOBALS_CTOR_D(module)  void ZEND_MODULE_GLOBALS_CTOR_N(module)(zend_##module##_globals *module##_globals)
133bdeb220fSAnatol Belski#define ZEND_MODULE_GLOBALS_DTOR_D(module)  void ZEND_MODULE_GLOBALS_DTOR_N(module)(zend_##module##_globals *module##_globals)
134342c6e0bSZeev Suraski
1350b6d923bSSascha Schumann#define ZEND_GET_MODULE(name) \
136cb71ac03SHartmut Holzgraefe    BEGIN_EXTERN_C()\
137cb71ac03SHartmut Holzgraefe	ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }\
138cb71ac03SHartmut Holzgraefe    END_EXTERN_C()
1390d21940dSZeev Suraski
1400d21940dSZeev Suraski#define ZEND_BEGIN_MODULE_GLOBALS(module_name)		\
1410d21940dSZeev Suraski	typedef struct _zend_##module_name##_globals {
1420d21940dSZeev Suraski#define ZEND_END_MODULE_GLOBALS(module_name)		\
1430d21940dSZeev Suraski	} zend_##module_name##_globals;
1440d21940dSZeev Suraski
1450d21940dSZeev Suraski#ifdef ZTS
1460d21940dSZeev Suraski
1470d21940dSZeev Suraski#define ZEND_DECLARE_MODULE_GLOBALS(module_name)							\
14802af513cSAndi Gutmans	ts_rsrc_id module_name##_globals_id;
14902af513cSAndi Gutmans#define ZEND_EXTERN_MODULE_GLOBALS(module_name)								\
15002af513cSAndi Gutmans	extern ts_rsrc_id module_name##_globals_id;
1510d21940dSZeev Suraski#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)	\
1522c254ba7SZeev Suraski	ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
1530d21940dSZeev Suraski
1540d21940dSZeev Suraski#else
1550d21940dSZeev Suraski
1560d21940dSZeev Suraski#define ZEND_DECLARE_MODULE_GLOBALS(module_name)							\
15702af513cSAndi Gutmans	zend_##module_name##_globals module_name##_globals;
15802af513cSAndi Gutmans#define ZEND_EXTERN_MODULE_GLOBALS(module_name)								\
15902af513cSAndi Gutmans	extern zend_##module_name##_globals module_name##_globals;
1600d21940dSZeev Suraski#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor)	\
1610d21940dSZeev Suraski	globals_ctor(&module_name##_globals);
1620d21940dSZeev Suraski
1630d21940dSZeev Suraski#endif
1640d21940dSZeev Suraski
165b4892511SJani Taskinen#define INIT_CLASS_ENTRY(class_container, class_name, functions) \
166b4892511SJani Taskinen	INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL)
167741b8161SZeev Suraski
168b4892511SJani Taskinen#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions) \
169b4892511SJani Taskinen	INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, NULL, NULL, NULL, NULL, NULL)
170b4892511SJani Taskinen
171b4892511SJani Taskinen#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
172741b8161SZeev Suraski	{															\
173f4cfaf36SDmitry Stogov		zend_string *cl_name;									\
174c3e3c98eSAnatol Belski		cl_name = zend_string_init(class_name, class_name_len, 1);		\
175bdeb220fSAnatol Belski		class_container.name = zend_new_interned_string(cl_name);	\
17603a1fcabSXinchen Hui		INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
17703a1fcabSXinchen Hui	}
17803a1fcabSXinchen Hui
17903a1fcabSXinchen Hui#define INIT_CLASS_ENTRY_INIT_METHODS(class_container, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
18003a1fcabSXinchen Hui	{															\
1812eccd95cSAndi Gutmans		class_container.constructor = NULL;						\
18273b159e0SAndi Gutmans		class_container.destructor = NULL;						\
18329ea3da2SAndi Gutmans		class_container.clone = NULL;							\
184637a4042SMarcus Boerger		class_container.serialize = NULL;						\
185637a4042SMarcus Boerger		class_container.unserialize = NULL;						\
186637a4042SMarcus Boerger		class_container.create_object = NULL;					\
1873c62b3b5SMarcus Boerger		class_container.interface_gets_implemented = NULL;		\
18872d0454bSDmitry Stogov		class_container.get_static_method = NULL;				\
189637a4042SMarcus Boerger		class_container.__call = handle_fcall;					\
190b4892511SJani Taskinen		class_container.__callstatic = NULL;					\
191637a4042SMarcus Boerger		class_container.__tostring = NULL;						\
192637a4042SMarcus Boerger		class_container.__get = handle_propget;					\
193637a4042SMarcus Boerger		class_container.__set = handle_propset;					\
194637a4042SMarcus Boerger		class_container.__unset = handle_propunset;				\
195637a4042SMarcus Boerger		class_container.__isset = handle_propisset;				\
1961e752ce9SSara Golemon		class_container.__debugInfo = NULL;					\
197637a4042SMarcus Boerger		class_container.serialize_func = NULL;					\
198637a4042SMarcus Boerger		class_container.unserialize_func = NULL;				\
199637a4042SMarcus Boerger		class_container.serialize = NULL;						\
200637a4042SMarcus Boerger		class_container.unserialize = NULL;						\
201637a4042SMarcus Boerger		class_container.parent = NULL;							\
202637a4042SMarcus Boerger		class_container.num_interfaces = 0;						\
203fdb6077fSFelipe Pena		class_container.traits = NULL;							\
204fdb6077fSFelipe Pena		class_container.num_traits = 0;							\
205fdb6077fSFelipe Pena		class_container.trait_aliases = NULL;					\
206fdb6077fSFelipe Pena		class_container.trait_precedences = NULL;				\
207637a4042SMarcus Boerger		class_container.interfaces = NULL;						\
208637a4042SMarcus Boerger		class_container.get_iterator = NULL;					\
209637a4042SMarcus Boerger		class_container.iterator_funcs.funcs = NULL;			\
210f2df6a4aSDmitry Stogov		class_container.info.internal.module = NULL;			\
211f2df6a4aSDmitry Stogov		class_container.info.internal.builtin_functions = functions;	\
212741b8161SZeev Suraski	}
213741b8161SZeev Suraski
214345e0255SDmitry Stogov#define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \
215b4892511SJani Taskinen	INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL)
216345e0255SDmitry Stogov
217907fa665SDmitry Stogov#define INIT_NS_CLASS_ENTRY(class_container, ns, class_name, functions) \
218907fa665SDmitry Stogov	INIT_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions)
219907fa665SDmitry Stogov#define INIT_OVERLOADED_NS_CLASS_ENTRY_EX(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
220907fa665SDmitry Stogov	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)
221907fa665SDmitry Stogov#define INIT_OVERLOADED_NS_CLASS_ENTRY(class_container, ns, class_name, functions, handle_fcall, handle_propget, handle_propset) \
222907fa665SDmitry Stogov	INIT_OVERLOADED_CLASS_ENTRY(class_container, ZEND_NS_NAME(ns, class_name), functions, handle_fcall, handle_propget, handle_propset)
223907fa665SDmitry Stogov
2248768ab94SDmitry Stogov#ifdef ZTS
225f23e8576SDmitry Stogov#	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])
2268768ab94SDmitry Stogov#else
227c5237d82SDmitry Stogov#	define CE_STATIC_MEMBERS(ce) ((ce)->static_members_table)
2288768ab94SDmitry Stogov#endif
2298768ab94SDmitry Stogov
230b4892511SJani Taskinen#define ZEND_FCI_INITIALIZED(fci) ((fci).size != 0)
231b4892511SJani Taskinen
232c96a6b44SAnatol BelskiZEND_API int zend_next_free_module(void);
233573b4602SAndi Gutmans
2341727c6a2SHartmut HolzgraefeBEGIN_EXTERN_C()
235f77e6a44SZeev SuraskiZEND_API int zend_get_parameters(int ht, int param_count, ...);
236e59bfcffSStanislav MalyshevZEND_API ZEND_ATTRIBUTE_DEPRECATED int zend_get_parameters_ex(int param_count, ...);
237bdeb220fSAnatol BelskiZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array);
23811e5d2f2SZeev Suraski
239e39f3f3fSMarcus Boerger/* internal function to efficiently copy parameters when executing __call() */
240bdeb220fSAnatol BelskiZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
241e39f3f3fSMarcus Boerger
24211e5d2f2SZeev Suraski#define zend_get_parameters_array(ht, param_count, argument_array)			\
243bdeb220fSAnatol Belski	_zend_get_parameters_array_ex(param_count, argument_array)
24411e5d2f2SZeev Suraski#define zend_get_parameters_array_ex(param_count, argument_array)			\
245bdeb220fSAnatol Belski	_zend_get_parameters_array_ex(param_count, argument_array)
246cc2b17d5SFelipe Pena#define zend_parse_parameters_none()										\
247bdeb220fSAnatol Belski	zend_parse_parameters(ZEND_NUM_ARGS(), "")
24858f88057SAndrei Zmievski
24958f88057SAndrei Zmievski/* Parameter parsing API -- andrei */
25058f88057SAndrei Zmievski
2510ae305e6SDmitry Stogov#define ZEND_PARSE_PARAMS_QUIET (1<<1)
252bdeb220fSAnatol BelskiZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...);
253bdeb220fSAnatol BelskiZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...);
254cf7384aaSFelipe PenaZEND_API char *zend_zval_type_name(const zval *arg);
25558f88057SAndrei Zmievski
256bdeb220fSAnatol BelskiZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...);
257bdeb220fSAnatol BelskiZEND_API int zend_parse_method_parameters_ex(int flags, int num_args, zval *this_ptr, const char *type_spec, ...);
258c4528f82SHarald Radi
259bdeb220fSAnatol BelskiZEND_API int zend_parse_parameter(int flags, int arg_num, zval *arg, const char *spec, ...);
26013f1d53bSGustavo André dos Santos Lopes
261b5255495SZeev Suraski/* End of parameter parsing API -- andrei */
26239f9487eSAndi Gutmans
263bdeb220fSAnatol BelskiZEND_API int zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type);
264bdeb220fSAnatol BelskiZEND_API void zend_unregister_functions(const zend_function_entry *functions, int count, HashTable *function_table);
265bdeb220fSAnatol BelskiZEND_API int zend_startup_module(zend_module_entry *module_entry);
266bdeb220fSAnatol BelskiZEND_API zend_module_entry* zend_register_internal_module(zend_module_entry *module_entry);
267bdeb220fSAnatol BelskiZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module);
268bdeb220fSAnatol BelskiZEND_API int zend_startup_module_ex(zend_module_entry *module);
269bdeb220fSAnatol BelskiZEND_API int zend_startup_modules(void);
270bdeb220fSAnatol BelskiZEND_API void zend_collect_module_handlers(void);
2711a1178a6SDmitry StogovZEND_API void zend_destroy_modules(void);
272bdeb220fSAnatol BelskiZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, int error_type);
273eb0e6946SAndi Gutmans
274bdeb220fSAnatol BelskiZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry);
275bdeb220fSAnatol BelskiZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce);
276bdeb220fSAnatol BelskiZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry);
277bdeb220fSAnatol BelskiZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...);
278eb0e6946SAndi Gutmans
279bdeb220fSAnatol BelskiZEND_API int zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce);
280907fa665SDmitry Stogov
281907fa665SDmitry Stogov#define zend_register_class_alias(name, ce) \
282bdeb220fSAnatol Belski	zend_register_class_alias_ex(name, sizeof(name)-1, ce)
283907fa665SDmitry Stogov#define zend_register_ns_class_alias(ns, name, ce) \
284bdeb220fSAnatol Belski	zend_register_class_alias_ex(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, ce)
285907fa665SDmitry Stogov
286bdeb220fSAnatol BelskiZEND_API int zend_disable_function(char *function_name, size_t function_name_length);
287bdeb220fSAnatol BelskiZEND_API int zend_disable_class(char *class_name, size_t class_name_length);
288573b4602SAndi Gutmans
289bdeb220fSAnatol BelskiZEND_API void zend_wrong_param_count(void);
290c81db6bcSDmitry Stogov
291c81db6bcSDmitry Stogov#define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0)
292c81db6bcSDmitry Stogov#define IS_CALLABLE_CHECK_NO_ACCESS   (1<<1)
29353e52606SMarcus Boerger#define IS_CALLABLE_CHECK_IS_STATIC   (1<<2)
294af05ce0aSDmitry Stogov#define IS_CALLABLE_CHECK_SILENT      (1<<3)
295c81db6bcSDmitry Stogov
2960cd997d7SMarcus Boerger#define IS_CALLABLE_STRICT  (IS_CALLABLE_CHECK_IS_STATIC)
2970cd997d7SMarcus Boerger
298bdeb220fSAnatol BelskiZEND_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);
299bdeb220fSAnatol BelskiZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, zend_string **callable_name);
300bdeb220fSAnatol BelskiZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_name);
3016c810b0dSDmitry StogovZEND_API const char *zend_get_module_version(const char *module_name);
302cf7384aaSFelipe PenaZEND_API int zend_get_module_started(const char *module_name);
303bdeb220fSAnatol BelskiZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, zval *property, int access_type, zend_string *doc_comment);
304bdeb220fSAnatol BelskiZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, size_t name_length, zval *property, int access_type);
305bdeb220fSAnatol BelskiZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, size_t name_length, int access_type);
306bdeb220fSAnatol BelskiZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
307bdeb220fSAnatol BelskiZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value, int access_type);
308bdeb220fSAnatol BelskiZEND_API int zend_declare_property_double(zend_class_entry *ce, const char *name, size_t name_length, double value, int access_type);
309bdeb220fSAnatol BelskiZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value, int access_type);
310bdeb220fSAnatol BelskiZEND_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);
311bdeb220fSAnatol Belski
312bdeb220fSAnatol BelskiZEND_API int zend_declare_class_constant(zend_class_entry *ce, const char *name, size_t name_length, zval *value);
313bdeb220fSAnatol BelskiZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char *name, size_t name_length);
314bdeb220fSAnatol BelskiZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value);
315bdeb220fSAnatol BelskiZEND_API int zend_declare_class_constant_bool(zend_class_entry *ce, const char *name, size_t name_length, zend_bool value);
316bdeb220fSAnatol BelskiZEND_API int zend_declare_class_constant_double(zend_class_entry *ce, const char *name, size_t name_length, double value);
317bdeb220fSAnatol BelskiZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const char *name, size_t name_length, const char *value, size_t value_length);
318bdeb220fSAnatol BelskiZEND_API int zend_declare_class_constant_string(zend_class_entry *ce, const char *name, size_t name_length, const char *value);
319bdeb220fSAnatol Belski
320bdeb220fSAnatol BelskiZEND_API void zend_update_class_constants(zend_class_entry *class_type);
321bdeb220fSAnatol BelskiZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zval *value);
322bdeb220fSAnatol BelskiZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, size_t name_length);
323bdeb220fSAnatol BelskiZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
324bdeb220fSAnatol BelskiZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_long value);
325bdeb220fSAnatol BelskiZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, size_t name_length, double value);
326bdeb220fSAnatol BelskiZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_string *value);
327bdeb220fSAnatol BelskiZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value);
328bdeb220fSAnatol BelskiZEND_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);
329bdeb220fSAnatol Belski
330bdeb220fSAnatol BelskiZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value);
331bdeb220fSAnatol BelskiZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length);
332bdeb220fSAnatol BelskiZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
333bdeb220fSAnatol BelskiZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, size_t name_length, zend_long value);
334bdeb220fSAnatol BelskiZEND_API int zend_update_static_property_double(zend_class_entry *scope, const char *name, size_t name_length, double value);
335bdeb220fSAnatol BelskiZEND_API int zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value);
336bdeb220fSAnatol BelskiZEND_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);
337bdeb220fSAnatol Belski
3383e31838dSDmitry StogovZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length, zend_bool silent, zval *rv);
339bdeb220fSAnatol Belski
340bdeb220fSAnatol BelskiZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
341248345d9SDmitry Stogov
3429dd24c6dSAntony DovgalZEND_API char *zend_get_type_by_const(int type);
3436ac6cb10SHarald Radi
344bd9a2346SDmitry Stogov#define getThis()							(Z_OBJ(EX(This)) ? &EX(This) : NULL)
345cf5920e8SNikita Popov#define ZEND_IS_METHOD_CALL()				(EX(func)->common.scope != NULL)
346741b8161SZeev Suraski
347131d9cb2SZeev Suraski#define WRONG_PARAM_COUNT					ZEND_WRONG_PARAM_COUNT()
348131d9cb2SZeev Suraski#define WRONG_PARAM_COUNT_WITH_RETVAL(ret)	ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
34911384ba7SDmitry Stogov#define ARG_COUNT(dummy)					EX_NUM_ARGS()
35011384ba7SDmitry Stogov#define ZEND_NUM_ARGS()						EX_NUM_ARGS()
351bdeb220fSAnatol Belski#define ZEND_WRONG_PARAM_COUNT()					{ zend_wrong_param_count(); return; }
352bdeb220fSAnatol Belski#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)		{ zend_wrong_param_count(); return ret; }
353573b4602SAndi Gutmans
35480bdd19eSZeev Suraski#ifndef ZEND_WIN32
355573b4602SAndi Gutmans#define DLEXPORT
356573b4602SAndi Gutmans#endif
357573b4602SAndi Gutmans
3587da75d81SMatt Wilmas#define array_init(arg)			_array_init((arg), 0 ZEND_FILE_LINE_CC)
3597da75d81SMatt Wilmas#define array_init_size(arg, size) _array_init((arg), (size) ZEND_FILE_LINE_CC)
360bdeb220fSAnatol Belski#define object_init(arg)		_object_init((arg) ZEND_FILE_LINE_CC)
361bdeb220fSAnatol Belski#define object_init_ex(arg, ce)	_object_init_ex((arg), (ce) ZEND_FILE_LINE_CC)
362bdeb220fSAnatol Belski#define object_and_properties_init(arg, ce, properties)	_object_and_properties_init((arg), (ce), (properties) ZEND_FILE_LINE_CC)
3637da75d81SMatt WilmasZEND_API int _array_init(zval *arg, uint size ZEND_FILE_LINE_DC);
364bdeb220fSAnatol BelskiZEND_API int _object_init(zval *arg ZEND_FILE_LINE_DC);
365bdeb220fSAnatol BelskiZEND_API int _object_init_ex(zval *arg, zend_class_entry *ce ZEND_FILE_LINE_DC);
366bdeb220fSAnatol BelskiZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties ZEND_FILE_LINE_DC);
367c5237d82SDmitry StogovZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type);
368bdeb220fSAnatol BelskiZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties);
369bdeb220fSAnatol BelskiZEND_API void object_properties_load(zend_object *object, HashTable *properties);
3706847fefaSThies C. Arntzen
371bdeb220fSAnatol BelskiZEND_API void zend_merge_properties(zval *obj, HashTable *properties);
372047a574eSMarcus Boerger
3736847fefaSThies C. Arntzen/* no longer supported */
3746c810b0dSDmitry StogovZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr)(INTERNAL_FUNCTION_PARAMETERS));
3756847fefaSThies C. Arntzen
376f2279224SAnatol BelskiZEND_API int add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n);
377f2279224SAnatol BelskiZEND_API int add_assoc_null_ex(zval *arg, const char *key, size_t key_len);
378f2279224SAnatol BelskiZEND_API int add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, int b);
379f2279224SAnatol BelskiZEND_API int add_assoc_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
380f2279224SAnatol BelskiZEND_API int add_assoc_double_ex(zval *arg, const char *key, size_t key_len, double d);
381f2279224SAnatol BelskiZEND_API int add_assoc_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
382f2279224SAnatol BelskiZEND_API int add_assoc_string_ex(zval *arg, const char *key, size_t key_len, char *str);
383f2279224SAnatol BelskiZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, size_t key_len, char *str, size_t length);
384f2279224SAnatol BelskiZEND_API int add_assoc_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
385f2279224SAnatol Belski
386f2279224SAnatol Belski#define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key), __n)
387f2279224SAnatol Belski#define add_assoc_null(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
388f2279224SAnatol Belski#define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key), __b)
389f2279224SAnatol Belski#define add_assoc_resource(__arg, __key, __r) add_assoc_resource_ex(__arg, __key, strlen(__key), __r)
390f2279224SAnatol Belski#define add_assoc_double(__arg, __key, __d) add_assoc_double_ex(__arg, __key, strlen(__key), __d)
391f2279224SAnatol Belski#define add_assoc_str(__arg, __key, __str) add_assoc_str_ex(__arg, __key, strlen(__key), __str)
392f2279224SAnatol Belski#define add_assoc_string(__arg, __key, __str) add_assoc_string_ex(__arg, __key, strlen(__key), __str)
393f2279224SAnatol Belski#define add_assoc_stringl(__arg, __key, __str, __length) add_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
394f2279224SAnatol Belski#define add_assoc_zval(__arg, __key, __value) add_assoc_zval_ex(__arg, __key, strlen(__key), __value)
3956847fefaSThies C. Arntzen
3960611acb9SAndi Gutmans/* unset() functions are only suported for legacy modules and null() functions should be used */
397f2279224SAnatol Belski#define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key))
3980611acb9SAndi Gutmans#define add_index_unset(__arg, __key) add_index_null(__arg, __key)
3990611acb9SAndi Gutmans#define add_next_index_unset(__arg) add_next_index_null(__arg)
4000611acb9SAndi Gutmans#define add_property_unset(__arg, __key) add_property_null(__arg, __key)
4010611acb9SAndi Gutmans
402c3e3c98eSAnatol BelskiZEND_API int add_index_long(zval *arg, zend_ulong idx, zend_long n);
403c3e3c98eSAnatol BelskiZEND_API int add_index_null(zval *arg, zend_ulong idx);
404c3e3c98eSAnatol BelskiZEND_API int add_index_bool(zval *arg, zend_ulong idx, int b);
405c3e3c98eSAnatol BelskiZEND_API int add_index_resource(zval *arg, zend_ulong idx, zend_resource *r);
406c3e3c98eSAnatol BelskiZEND_API int add_index_double(zval *arg, zend_ulong idx, double d);
407c3e3c98eSAnatol BelskiZEND_API int add_index_str(zval *arg, zend_ulong idx, zend_string *str);
408c3e3c98eSAnatol BelskiZEND_API int add_index_string(zval *arg, zend_ulong idx, const char *str);
409d6faac2cSAnatol BelskiZEND_API int add_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length);
410c3e3c98eSAnatol BelskiZEND_API int add_index_zval(zval *arg, zend_ulong index, zval *value);
411c3e3c98eSAnatol Belski
412c3e3c98eSAnatol BelskiZEND_API int add_next_index_long(zval *arg, zend_long n);
4130611acb9SAndi GutmansZEND_API int add_next_index_null(zval *arg);
4146847fefaSThies C. ArntzenZEND_API int add_next_index_bool(zval *arg, int b);
415f4cfaf36SDmitry StogovZEND_API int add_next_index_resource(zval *arg, zend_resource *r);
416573b4602SAndi GutmansZEND_API int add_next_index_double(zval *arg, double d);
417f4cfaf36SDmitry StogovZEND_API int add_next_index_str(zval *arg, zend_string *str);
418050d7e38SDmitry StogovZEND_API int add_next_index_string(zval *arg, const char *str);
419d6faac2cSAnatol BelskiZEND_API int add_next_index_stringl(zval *arg, const char *str, size_t length);
420ef95a346SAndi GutmansZEND_API int add_next_index_zval(zval *arg, zval *value);
421ef95a346SAndi Gutmans
422050d7e38SDmitry StogovZEND_API zval *add_get_assoc_string_ex(zval *arg, const char *key, uint key_len, const char *str);
423d6faac2cSAnatol BelskiZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len, const char *str, size_t length);
424ef95a346SAndi Gutmans
425050d7e38SDmitry Stogov#define add_get_assoc_string(__arg, __key, __str) add_get_assoc_string_ex(__arg, __key, strlen(__key), __str)
426050d7e38SDmitry Stogov#define add_get_assoc_stringl(__arg, __key, __str, __length) add_get_assoc_stringl_ex(__arg, __key, strlen(__key), __str, __length)
427573b4602SAndi Gutmans
428c3e3c98eSAnatol BelskiZEND_API zval *add_get_index_long(zval *arg, zend_ulong idx, zend_long l);
429c3e3c98eSAnatol BelskiZEND_API zval *add_get_index_double(zval *arg, zend_ulong idx, double d);
430c3e3c98eSAnatol BelskiZEND_API zval *add_get_index_str(zval *arg, zend_ulong index, zend_string *str);
431c3e3c98eSAnatol BelskiZEND_API zval *add_get_index_string(zval *arg, zend_ulong idx, const char *str);
432d6faac2cSAnatol BelskiZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong idx, const char *str, size_t length);
433573b4602SAndi Gutmans
434bdeb220fSAnatol BelskiZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value);
435fcc6611dSNikita Popov
436bdeb220fSAnatol BelskiZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long l);
437bdeb220fSAnatol BelskiZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len);
438bdeb220fSAnatol BelskiZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b);
439bdeb220fSAnatol BelskiZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r);
440bdeb220fSAnatol BelskiZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d);
441bdeb220fSAnatol BelskiZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str);
442bdeb220fSAnatol BelskiZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str);
443bdeb220fSAnatol BelskiZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len,  const char *str, size_t length);
444bdeb220fSAnatol BelskiZEND_API int add_property_zval_ex(zval *arg, const char *key, size_t key_len, zval *value);
445f2279224SAnatol Belski
446bdeb220fSAnatol Belski#define add_property_long(__arg, __key, __n) add_property_long_ex(__arg, __key, strlen(__key), __n)
447bdeb220fSAnatol Belski#define add_property_null(__arg, __key) add_property_null_ex(__arg, __key, strlen(__key))
448bdeb220fSAnatol Belski#define add_property_bool(__arg, __key, __b) add_property_bool_ex(__arg, __key, strlen(__key), __b)
449bdeb220fSAnatol Belski#define add_property_resource(__arg, __key, __r) add_property_resource_ex(__arg, __key, strlen(__key), __r)
450bdeb220fSAnatol Belski#define add_property_double(__arg, __key, __d) add_property_double_ex(__arg, __key, strlen(__key), __d)
451bdeb220fSAnatol Belski#define add_property_str(__arg, __key, __str) add_property_str_ex(__arg, __key, strlen(__key), __str)
452bdeb220fSAnatol Belski#define add_property_string(__arg, __key, __str) add_property_string_ex(__arg, __key, strlen(__key), __str)
453bdeb220fSAnatol Belski#define add_property_stringl(__arg, __key, __str, __length) add_property_stringl_ex(__arg, __key, strlen(__key), __str, __length)
454bdeb220fSAnatol Belski#define add_property_zval(__arg, __key, __value) add_property_zval_ex(__arg, __key, strlen(__key), __value)
455ef95a346SAndi Gutmans
45692b4013eSZeev Suraski
457bdeb220fSAnatol BelskiZEND_API int call_user_function(HashTable *function_table, zval *object, zval *function_name, zval *retval_ptr, uint32_t param_count, zval params[]);
458bdeb220fSAnatol BelskiZEND_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);
45992b4013eSZeev Suraski
460f87d4530SNuno LopesZEND_API extern const zend_fcall_info empty_fcall_info;
461f87d4530SNuno LopesZEND_API extern const zend_fcall_info_cache empty_fcall_info_cache;
46292b4013eSZeev Suraski
46364c353abSMarcus Boerger/** Build zend_call_info/cache from a zval*
46464c353abSMarcus Boerger *
465b7a7b1a6SStanislav Malyshev * Caller is responsible to provide a return value, otherwise the we will crash.
46664c353abSMarcus Boerger * fci->retval_ptr_ptr = NULL;
46764c353abSMarcus Boerger * In order to pass parameters the following members need to be set:
46864c353abSMarcus Boerger * fci->param_count = 0;
46964c353abSMarcus Boerger * fci->params = NULL;
470b4892511SJani Taskinen * The callable_name argument may be NULL.
471e8a8acdfSMarcus Boerger * Set check_flags to IS_CALLABLE_STRICT for every new usage!
472b4892511SJani Taskinen */
473bdeb220fSAnatol BelskiZEND_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);
474b4892511SJani Taskinen
47504145dc2SVeres Lajos/** Clear arguments connected with zend_fcall_info *fci
476b4892511SJani Taskinen * If free_mem is not zero then the params array gets free'd as well
477b4892511SJani Taskinen */
478b4892511SJani TaskinenZEND_API void zend_fcall_info_args_clear(zend_fcall_info *fci, int free_mem);
479b4892511SJani Taskinen
480b4892511SJani Taskinen/** Save current arguments from zend_fcall_info *fci
481b4892511SJani Taskinen * params array will be set to NULL
482b4892511SJani Taskinen */
483f4cfaf36SDmitry StogovZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, int *param_count, zval **params);
484b4892511SJani Taskinen
485b4892511SJani Taskinen/** Free arguments connected with zend_fcall_info *fci andset back saved ones.
48664c353abSMarcus Boerger */
487f4cfaf36SDmitry StogovZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, int param_count, zval *params);
48864c353abSMarcus Boerger
48964c353abSMarcus Boerger/** Set or clear the arguments in the zend_call_info struct taking care of
49064c353abSMarcus Boerger * refcount. If args is NULL and arguments are set then those are cleared.
49164c353abSMarcus Boerger */
492bdeb220fSAnatol BelskiZEND_API int zend_fcall_info_args(zend_fcall_info *fci, zval *args);
493bdeb220fSAnatol BelskiZEND_API int zend_fcall_info_args_ex(zend_fcall_info *fci, zend_function *func, zval *args);
49464c353abSMarcus Boerger
495b4892511SJani Taskinen/** Set arguments in the zend_fcall_info struct taking care of refcount.
496b4892511SJani Taskinen * If argc is 0 the arguments which are set will be cleared, else pass
497b4892511SJani Taskinen * a variable amount of zval** arguments.
498b4892511SJani Taskinen */
499bdeb220fSAnatol BelskiZEND_API int zend_fcall_info_argp(zend_fcall_info *fci, int argc, zval *argv);
500b4892511SJani Taskinen
501b4892511SJani Taskinen/** Set arguments in the zend_fcall_info struct taking care of refcount.
502b4892511SJani Taskinen * If argc is 0 the arguments which are set will be cleared, else pass
503b4892511SJani Taskinen * a variable amount of zval** arguments.
504b4892511SJani Taskinen */
505bdeb220fSAnatol BelskiZEND_API int zend_fcall_info_argv(zend_fcall_info *fci, int argc, va_list *argv);
506b4892511SJani Taskinen
507b4892511SJani Taskinen/** Set arguments in the zend_fcall_info struct taking care of refcount.
508b4892511SJani Taskinen * If argc is 0 the arguments which are set will be cleared, else pass
509b4892511SJani Taskinen * a variable amount of zval** arguments.
510b4892511SJani Taskinen */
511bdeb220fSAnatol BelskiZEND_API int zend_fcall_info_argn(zend_fcall_info *fci, int argc, ...);
512b4892511SJani Taskinen
51364c353abSMarcus Boerger/** Call a function using information created by zend_fcall_info_init()/args().
51404145dc2SVeres Lajos * If args is given then those replace the argument info in fci is temporarily.
51564c353abSMarcus Boerger */
516bdeb220fSAnatol BelskiZEND_API int zend_fcall_info_call(zend_fcall_info *fci, zend_fcall_info_cache *fcc, zval *retval, zval *args);
51764c353abSMarcus Boerger
518bdeb220fSAnatol BelskiZEND_API int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache);
51992b4013eSZeev Suraski
520cf7384aaSFelipe PenaZEND_API int zend_set_hash_symbol(zval *symbol, const char *name, int name_length, zend_bool is_ref, int num_symbol_tables, ...);
521f962a35dSAndrei Zmievski
522bdeb220fSAnatol BelskiZEND_API int zend_delete_global_variable(zend_string *name);
523453b49edSDmitry Stogov
524bdeb220fSAnatol BelskiZEND_API zend_array *zend_rebuild_symbol_table(void);
525ea2e1bb1SDmitry StogovZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data);
526ea2e1bb1SDmitry StogovZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data);
527bdeb220fSAnatol BelskiZEND_API int zend_set_local_var(zend_string *name, zval *value, int force);
528bdeb220fSAnatol BelskiZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force);
5292ecf4bb0SDmitry Stogov
530f4cfaf36SDmitry StogovZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name);
531f4cfaf36SDmitry StogovZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f);
5327dce0194SXinchen Hui
533bd9a2346SDmitry StogovZEND_API void zend_ctor_make_null(zend_execute_data *execute_data);
534bd9a2346SDmitry Stogov
5354f6c95d1SZeev Suraski#define add_method(arg, key, method)	add_assoc_function((arg), (key), (method))
536573b4602SAndi Gutmans
537a35c61afSAndrei ZmievskiZEND_API ZEND_FUNCTION(display_disabled_function);
538a700180fSHarald RadiZEND_API ZEND_FUNCTION(display_disabled_class);
5391727c6a2SHartmut HolzgraefeEND_EXTERN_C()
540a35c61afSAndrei Zmievski
541bcddfd47SThies C. Arntzen#if ZEND_DEBUG
542050d7e38SDmitry Stogov#define CHECK_ZVAL_STRING(str) \
543050d7e38SDmitry Stogov	if ((str)->val[(str)->len] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s)", (str)->val); }
544050d7e38SDmitry Stogov#define CHECK_ZVAL_STRING_REL(str) \
545050d7e38SDmitry Stogov	if ((str)->val[(str)->len] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", (str)->val ZEND_FILE_LINE_RELAY_CC); }
546bcddfd47SThies C. Arntzen#else
547bcddfd47SThies C. Arntzen#define CHECK_ZVAL_STRING(z)
54843ebb868SZeev Suraski#define CHECK_ZVAL_STRING_REL(z)
549bcddfd47SThies C. Arntzen#endif
550bcddfd47SThies C. Arntzen
551c3e3c98eSAnatol Belski#define CHECK_ZVAL_NULL_PATH(p) (Z_STRLEN_P(p) != strlen(Z_STRVAL_P(p)))
55232b5f8a1SFelipe Pena#define CHECK_NULL_PATH(p, l) (strlen(p) != l)
55332b5f8a1SFelipe Pena
554f4cfaf36SDmitry Stogov#define ZVAL_STRINGL(z, s, l) do {				\
555c3e3c98eSAnatol Belski		ZVAL_NEW_STR(z, zend_string_init(s, l, 0));		\
556453b49edSDmitry Stogov	} while (0)
557bcddfd47SThies C. Arntzen
558f4cfaf36SDmitry Stogov#define ZVAL_STRING(z, s) do {					\
559f4cfaf36SDmitry Stogov		const char *_s = (s);					\
560a0fe8e5aSDmitry Stogov		ZVAL_STRINGL(z, _s, strlen(_s));		\
561453b49edSDmitry Stogov	} while (0)
562bcddfd47SThies C. Arntzen
563f4cfaf36SDmitry Stogov#define ZVAL_EMPTY_STRING(z) do {				\
5646f9f0bf2SAnatol Belski		ZVAL_INTERNED_STR(z, STR_EMPTY_ALLOC());		\
565453b49edSDmitry Stogov	} while (0)
566453b49edSDmitry Stogov
567f4cfaf36SDmitry Stogov#define ZVAL_PSTRINGL(z, s, l) do {				\
568c3e3c98eSAnatol Belski		ZVAL_NEW_STR(z, zend_string_init(s, l, 1));		\
569453b49edSDmitry Stogov	} while (0)
570453b49edSDmitry Stogov
571f4cfaf36SDmitry Stogov#define ZVAL_PSTRING(z, s) do {					\
572f4cfaf36SDmitry Stogov		const char *_s = (s);					\
573a0fe8e5aSDmitry Stogov		ZVAL_PSTRINGL(z, _s, strlen(_s));		\
574f4cfaf36SDmitry Stogov	} while (0)
575f4cfaf36SDmitry Stogov
576f4cfaf36SDmitry Stogov#define ZVAL_EMPTY_PSTRING(z) do {				\
5770e425121SDmitry Stogov		ZVAL_PSTRINGL(z, "", 0);				\
578453b49edSDmitry Stogov	} while (0)
579af22085cSThies C. Arntzen
580d18b9698SNikita Popov#define ZVAL_ZVAL(z, zv, copy, dtor) do {		\
581d18b9698SNikita Popov		zval *__z = (z);						\
582d18b9698SNikita Popov		zval *__zv = (zv);						\
583bfdaf6e8SDmitry Stogov		if (EXPECTED(!Z_ISREF_P(__zv))) {		\
584bfdaf6e8SDmitry Stogov			ZVAL_COPY_VALUE(__z, __zv);			\
585bfdaf6e8SDmitry Stogov		} else {                                \
586bfdaf6e8SDmitry Stogov			ZVAL_COPY_VALUE(__z,                \
587bfdaf6e8SDmitry Stogov				Z_REFVAL_P(__zv));				\
588bfdaf6e8SDmitry Stogov		}										\
589d90ebc65SDmitry Stogov		if (copy) {								\
59058f0f250SDmitry Stogov			zval_opt_copy_ctor(__z);			\
591d90ebc65SDmitry Stogov	    }										\
592d90ebc65SDmitry Stogov		if (dtor) {								\
593d90ebc65SDmitry Stogov			if (!copy) {						\
594d18b9698SNikita Popov				ZVAL_NULL(__zv);				\
595d90ebc65SDmitry Stogov			}									\
596f4cfaf36SDmitry Stogov			zval_ptr_dtor(__zv);				\
597d90ebc65SDmitry Stogov	    }										\
598d18b9698SNikita Popov	} while (0)
599c7d27ad9SMarcus Boerger
6004f6c95d1SZeev Suraski#define RETVAL_BOOL(b)					ZVAL_BOOL(return_value, b)
601bcddfd47SThies C. Arntzen#define RETVAL_NULL() 					ZVAL_NULL(return_value)
602c3e3c98eSAnatol Belski#define RETVAL_LONG(l) 					ZVAL_LONG(return_value, l)
6034f6c95d1SZeev Suraski#define RETVAL_DOUBLE(d) 				ZVAL_DOUBLE(return_value, d)
604f4cfaf36SDmitry Stogov#define RETVAL_STR(s)			 		ZVAL_STR(return_value, s)
6056f9f0bf2SAnatol Belski#define RETVAL_LONG_STR(s)		 		ZVAL_INTERNED_STR(return_value, s)
60676cc99feSDmitry Stogov#define RETVAL_NEW_STR(s)		 		ZVAL_NEW_STR(return_value, s)
607f4cfaf36SDmitry Stogov#define RETVAL_STRING(s)		 		ZVAL_STRING(return_value, s)
608f4cfaf36SDmitry Stogov#define RETVAL_STRINGL(s, l)		 	ZVAL_STRINGL(return_value, s, l)
609bcddfd47SThies C. Arntzen#define RETVAL_EMPTY_STRING() 			ZVAL_EMPTY_STRING(return_value)
610398256e5SDmitry Stogov#define RETVAL_RES(r)			 		ZVAL_RES(return_value, r)
6112402d6cbSXinchen Hui#define RETVAL_OBJ(r)			 		ZVAL_OBJ(return_value, r)
612c7d27ad9SMarcus Boerger#define RETVAL_ZVAL(zv, copy, dtor)		ZVAL_ZVAL(return_value, zv, copy, dtor)
613b5b61767SXinchen Hui#define RETVAL_FALSE  					ZVAL_FALSE(return_value)
614b5b61767SXinchen Hui#define RETVAL_TRUE   					ZVAL_TRUE(return_value)
615bcddfd47SThies C. Arntzen
616bcddfd47SThies C. Arntzen#define RETURN_BOOL(b) 					{ RETVAL_BOOL(b); return; }
617bcddfd47SThies C. Arntzen#define RETURN_NULL() 					{ RETVAL_NULL(); return;}
618c3e3c98eSAnatol Belski#define RETURN_LONG(l) 					{ RETVAL_LONG(l); return; }
619bcddfd47SThies C. Arntzen#define RETURN_DOUBLE(d) 				{ RETVAL_DOUBLE(d); return; }
620f4cfaf36SDmitry Stogov#define RETURN_STR(s) 					{ RETVAL_STR(s); return; }
621c3e3c98eSAnatol Belski#define RETURN_LONG_STR(s)				{ RETVAL_LONG_STR(s); return; }
62276cc99feSDmitry Stogov#define RETURN_NEW_STR(s)				{ RETVAL_NEW_STR(s); return; }
623f4cfaf36SDmitry Stogov#define RETURN_STRING(s) 				{ RETVAL_STRING(s); return; }
624f4cfaf36SDmitry Stogov#define RETURN_STRINGL(s, l) 			{ RETVAL_STRINGL(s, l); return; }
625bcddfd47SThies C. Arntzen#define RETURN_EMPTY_STRING() 			{ RETVAL_EMPTY_STRING(); return; }
626398256e5SDmitry Stogov#define RETURN_RES(r) 					{ RETVAL_RES(r); return; }
6272402d6cbSXinchen Hui#define RETURN_OBJ(r) 					{ RETVAL_OBJ(r); return; }
628c7d27ad9SMarcus Boerger#define RETURN_ZVAL(zv, copy, dtor)		{ RETVAL_ZVAL(zv, copy, dtor); return; }
629bcddfd47SThies C. Arntzen#define RETURN_FALSE  					{ RETVAL_FALSE; return; }
630bcddfd47SThies C. Arntzen#define RETURN_TRUE   					{ RETVAL_TRUE; return; }
6311f985edeSZeev Suraski
63208567145SNikita Popov#define RETVAL_ZVAL_FAST(z) do {      \
63308567145SNikita Popov	zval *_z = (z);                   \
63408567145SNikita Popov	if (Z_ISREF_P(_z)) {              \
63508567145SNikita Popov		RETVAL_ZVAL(_z, 1, 0);        \
63608567145SNikita Popov	} else {                          \
637f4cfaf36SDmitry Stogov		zval_ptr_dtor(return_value);  \
638f4cfaf36SDmitry Stogov		ZVAL_COPY(return_value, _z);  \
63908567145SNikita Popov	}                                 \
64008567145SNikita Popov} while (0)
641f4cfaf36SDmitry Stogov
6421dd07d6bSDmitry Stogov/* May be used in internal constructors to make them return NULL */
643bd9a2346SDmitry Stogov#define ZEND_CTOR_MAKE_NULL() \
644bd9a2346SDmitry Stogov	zend_ctor_make_null(execute_data)
6451dd07d6bSDmitry Stogov
64608567145SNikita Popov#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
64708567145SNikita Popov
648bdeb220fSAnatol Belski#define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties((p)) : NULL)))
649068ec75fSXinchen Hui#define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL)
65006a18f16SAndi Gutmans
6518b6f848cSAndi Gutmans/* For compatibility */
6528b6f848cSAndi Gutmans#define ZEND_MINIT			ZEND_MODULE_STARTUP_N
6538b6f848cSAndi Gutmans#define ZEND_MSHUTDOWN		ZEND_MODULE_SHUTDOWN_N
6548b6f848cSAndi Gutmans#define ZEND_RINIT			ZEND_MODULE_ACTIVATE_N
6558b6f848cSAndi Gutmans#define ZEND_RSHUTDOWN		ZEND_MODULE_DEACTIVATE_N
6568b6f848cSAndi Gutmans#define ZEND_MINFO			ZEND_MODULE_INFO_N
657bdeb220fSAnatol Belski#define ZEND_GINIT(module)		((void (*)(void*))(ZEND_MODULE_GLOBALS_CTOR_N(module)))
658bdeb220fSAnatol Belski#define ZEND_GSHUTDOWN(module)	((void (*)(void*))(ZEND_MODULE_GLOBALS_DTOR_N(module)))
6598b6f848cSAndi Gutmans
6608b6f848cSAndi Gutmans#define ZEND_MINIT_FUNCTION			ZEND_MODULE_STARTUP_D
661f5c59863SStanislav Malyshev#define ZEND_MSHUTDOWN_FUNCTION		ZEND_MODULE_SHUTDOWN_D
662f5c59863SStanislav Malyshev#define ZEND_RINIT_FUNCTION			ZEND_MODULE_ACTIVATE_D
663f5c59863SStanislav Malyshev#define ZEND_RSHUTDOWN_FUNCTION		ZEND_MODULE_DEACTIVATE_D
664f5c59863SStanislav Malyshev#define ZEND_MINFO_FUNCTION			ZEND_MODULE_INFO_D
665ada4e506SDmitry Stogov#define ZEND_GINIT_FUNCTION			ZEND_MODULE_GLOBALS_CTOR_D
666ada4e506SDmitry Stogov#define ZEND_GSHUTDOWN_FUNCTION		ZEND_MODULE_GLOBALS_DTOR_D
6678b6f848cSAndi Gutmans
66827f38798SDmitry Stogov/* Fast parameter parsing API */
66927f38798SDmitry Stogov
6706c9621c9SRasmus Lerdorf/* TODO: This API is experimental. It may be changed or removed ???
67127f38798SDmitry Stogov * It should be used only for really often used functions.
67227f38798SDmitry Stogov * (Keep the original parsing code and wrap usage with #ifndef FAST_ZPP)
67327f38798SDmitry Stogov */
67427f38798SDmitry Stogov#define FAST_ZPP 1
67527f38798SDmitry Stogov
67627f38798SDmitry Stogov#ifdef FAST_ZPP
67727f38798SDmitry Stogov
67827f38798SDmitry Stogov#define Z_EXPECTED_TYPES(_) \
679e5eb9530SAndrea Faulds	_(Z_EXPECTED_LONG,		"integer") \
68027f38798SDmitry Stogov	_(Z_EXPECTED_BOOL,		"boolean") \
68127f38798SDmitry Stogov	_(Z_EXPECTED_STRING,	"string") \
68227f38798SDmitry Stogov	_(Z_EXPECTED_ARRAY,		"array") \
68327f38798SDmitry Stogov	_(Z_EXPECTED_FUNC,		"valid callback") \
68427f38798SDmitry Stogov	_(Z_EXPECTED_RESOURCE,	"resource") \
68527f38798SDmitry Stogov	_(Z_EXPECTED_PATH,		"a valid path") \
68627f38798SDmitry Stogov	_(Z_EXPECTED_OBJECT,	"object") \
687e5eb9530SAndrea Faulds	_(Z_EXPECTED_DOUBLE,	"float")
68827f38798SDmitry Stogov
68927f38798SDmitry Stogov#define Z_EXPECTED_TYPE_ENUM(id, str) id,
69027f38798SDmitry Stogov#define Z_EXPECTED_TYPE_STR(id, str)  str,
69127f38798SDmitry Stogov
69227f38798SDmitry Stogovtypedef enum _zend_expected_type {
69327f38798SDmitry Stogov	Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_ENUM)
69427f38798SDmitry Stogov	Z_EXPECTED_LAST
69527f38798SDmitry Stogov} zend_expected_type;
69627f38798SDmitry Stogov
697bdeb220fSAnatol BelskiZEND_API void zend_wrong_paramers_count_error(int num_args, int min_num_args, int max_num_args);
698bdeb220fSAnatol BelskiZEND_API void zend_wrong_paramer_type_error(int num, zend_expected_type expected_type, zval *arg);
699bdeb220fSAnatol BelskiZEND_API void zend_wrong_paramer_class_error(int num, char *name, zval *arg);
700bdeb220fSAnatol BelskiZEND_API void zend_wrong_callback_error(int severity, int num, char *error);
70127f38798SDmitry Stogov
7020ae305e6SDmitry Stogov#define ZPP_ERROR_OK             0
7030ae305e6SDmitry Stogov#define ZPP_ERROR_FAILURE        1
7040ae305e6SDmitry Stogov#define ZPP_ERROR_WRONG_CALLBACK 2
7050ae305e6SDmitry Stogov#define ZPP_ERROR_WRONG_CLASS    3
7060ae305e6SDmitry Stogov#define ZPP_ERROR_WRONG_ARG      4
7070ae305e6SDmitry Stogov#define ZPP_ERROR_WRONG_COUNT    5
7080ae305e6SDmitry Stogov
70927f38798SDmitry Stogov#define ZEND_PARSE_PARAMETERS_START_EX(flags, min_num_args, max_num_args) do { \
71027f38798SDmitry Stogov		const int _flags = (flags); \
71127f38798SDmitry Stogov		int _min_num_args = (min_num_args); \
71227f38798SDmitry Stogov		int _max_num_args = (max_num_args); \
71311384ba7SDmitry Stogov		int _num_args = EX_NUM_ARGS(); \
71427f38798SDmitry Stogov		int _i; \
7150ae305e6SDmitry Stogov		zval *_real_arg, *_arg = NULL; \
7160ae305e6SDmitry Stogov		zend_expected_type _expected_type = IS_UNDEF; \
7170ae305e6SDmitry Stogov		char *_error = NULL; \
71827f38798SDmitry Stogov		zend_bool _dummy; \
7190ae305e6SDmitry Stogov		zend_bool _optional = 0; \
7200ae305e6SDmitry Stogov		int error_code = ZPP_ERROR_OK; \
72127f38798SDmitry Stogov		((void)_i); \
72227f38798SDmitry Stogov		((void)_real_arg); \
72327f38798SDmitry Stogov		((void)_arg); \
72427f38798SDmitry Stogov		((void)_expected_type); \
72527f38798SDmitry Stogov		((void)_error); \
72627f38798SDmitry Stogov		((void)_dummy); \
7270ae305e6SDmitry Stogov		((void)_optional); \
7280ae305e6SDmitry Stogov		\
7290ae305e6SDmitry Stogov		do { \
7300ae305e6SDmitry Stogov			if (UNEXPECTED(_num_args < _min_num_args) || \
7310ae305e6SDmitry Stogov			    (UNEXPECTED(_num_args > _max_num_args) && \
7320ae305e6SDmitry Stogov			     EXPECTED(_max_num_args >= 0))) { \
7330ae305e6SDmitry Stogov				if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
734bdeb220fSAnatol Belski					zend_wrong_paramers_count_error(_num_args, _min_num_args, _max_num_args); \
7350ae305e6SDmitry Stogov				} \
7360ae305e6SDmitry Stogov				error_code = ZPP_ERROR_FAILURE; \
7370ae305e6SDmitry Stogov				break; \
73827f38798SDmitry Stogov			} \
7390ae305e6SDmitry Stogov			_i = 0; \
740bd9a2346SDmitry Stogov			_real_arg = ZEND_CALL_ARG(execute_data, 0);
74127f38798SDmitry Stogov
74227f38798SDmitry Stogov#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args) \
74327f38798SDmitry Stogov	ZEND_PARSE_PARAMETERS_START_EX(0, min_num_args, max_num_args)
74427f38798SDmitry Stogov
74527f38798SDmitry Stogov#define ZEND_PARSE_PARAMETERS_END_EX(failure) \
7460ae305e6SDmitry Stogov		} while (0); \
7470ae305e6SDmitry Stogov		if (UNEXPECTED(error_code != ZPP_ERROR_OK)) { \
74827f38798SDmitry Stogov			if (!(_flags & ZEND_PARSE_PARAMS_QUIET)) { \
7490ae305e6SDmitry Stogov				if (error_code == ZPP_ERROR_WRONG_CALLBACK) { \
750bdeb220fSAnatol Belski					zend_wrong_callback_error(E_WARNING, _i, _error); \
7510ae305e6SDmitry Stogov				} else if (error_code == ZPP_ERROR_WRONG_CLASS) { \
752bdeb220fSAnatol Belski					zend_wrong_paramer_class_error(_i, _error, _arg); \
7530ae305e6SDmitry Stogov				} else if (error_code == ZPP_ERROR_WRONG_ARG) { \
754bdeb220fSAnatol Belski					zend_wrong_paramer_type_error(_i, _expected_type, _arg); \
7550ae305e6SDmitry Stogov				} \
75627f38798SDmitry Stogov			} \
75727f38798SDmitry Stogov			failure; \
75827f38798SDmitry Stogov		} \
75927f38798SDmitry Stogov	} while (0)
76027f38798SDmitry Stogov
76127f38798SDmitry Stogov#define ZEND_PARSE_PARAMETERS_END() \
76227f38798SDmitry Stogov	ZEND_PARSE_PARAMETERS_END_EX(return)
76327f38798SDmitry Stogov
76427f38798SDmitry Stogov#define Z_PARAM_PROLOGUE(separate) \
7650ae305e6SDmitry Stogov	++_i; \
7660ae305e6SDmitry Stogov	if (_optional) { \
7670ae305e6SDmitry Stogov		if (UNEXPECTED(_i >_num_args)) break; \
7680ae305e6SDmitry Stogov	} \
76927f38798SDmitry Stogov	_real_arg++; \
77027f38798SDmitry Stogov	_arg = _real_arg; \
77127f38798SDmitry Stogov	ZVAL_DEREF(_arg); \
77227f38798SDmitry Stogov	if (separate) { \
77327f38798SDmitry Stogov		SEPARATE_ZVAL_NOREF(_arg); \
77427f38798SDmitry Stogov	}
77527f38798SDmitry Stogov
77627f38798SDmitry Stogov/* old "|" */
7770ae305e6SDmitry Stogov#define Z_PARAM_OPTIONAL \
7780ae305e6SDmitry Stogov	_optional = 1;
77927f38798SDmitry Stogov
78027f38798SDmitry Stogov/* old "a" */
7810ae305e6SDmitry Stogov#define Z_PARAM_ARRAY_EX(dest, check_null, separate) \
78227f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
78341e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 0))) { \
78427f38798SDmitry Stogov			_expected_type = Z_EXPECTED_ARRAY; \
7850ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
7860ae305e6SDmitry Stogov			break; \
7870ae305e6SDmitry Stogov		}
78827f38798SDmitry Stogov
78927f38798SDmitry Stogov#define Z_PARAM_ARRAY(dest) \
79027f38798SDmitry Stogov	Z_PARAM_ARRAY_EX(dest, 0, 0)
79127f38798SDmitry Stogov
79227f38798SDmitry Stogov/* old "A" */
7930ae305e6SDmitry Stogov#define Z_PARAM_ARRAY_OR_OBJECT_EX(dest, check_null, separate) \
79427f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
79541e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_array(_arg, &dest, check_null, 1))) { \
79627f38798SDmitry Stogov			_expected_type = Z_EXPECTED_ARRAY; \
7970ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
7980ae305e6SDmitry Stogov			break; \
7990ae305e6SDmitry Stogov		}
80027f38798SDmitry Stogov
80127f38798SDmitry Stogov#define Z_PARAM_ARRAY_OR_OBJECT(dest, check_null, separate) \
80227f38798SDmitry Stogov	Z_PARAM_ARRAY_OR_OBJECT_EX(dest, 0, 0)
80327f38798SDmitry Stogov
80427f38798SDmitry Stogov/* old "b" */
8050ae305e6SDmitry Stogov#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \
80627f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
80741e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null))) { \
80827f38798SDmitry Stogov			_expected_type = Z_EXPECTED_BOOL; \
8090ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
8100ae305e6SDmitry Stogov			break; \
8110ae305e6SDmitry Stogov		}
81227f38798SDmitry Stogov
81327f38798SDmitry Stogov#define Z_PARAM_BOOL(dest) \
81427f38798SDmitry Stogov	Z_PARAM_BOOL_EX(dest, _dummy, 0, 0)
81527f38798SDmitry Stogov
81627f38798SDmitry Stogov/* old "C" */
8170ae305e6SDmitry Stogov#define Z_PARAM_CLASS_EX(dest, check_null, separate) \
81827f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
81941e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_class(_arg, &dest, _i, check_null))) { \
8200ae305e6SDmitry Stogov			error_code = ZPP_ERROR_FAILURE; \
8210ae305e6SDmitry Stogov			break; \
8220ae305e6SDmitry Stogov		}
82327f38798SDmitry Stogov
82427f38798SDmitry Stogov#define Z_PARAM_CLASS(dest) \
82527f38798SDmitry Stogov	Z_PARAM_CLASS_EX(dest, 0, 0)
82627f38798SDmitry Stogov
82727f38798SDmitry Stogov/* old "d" */
8280ae305e6SDmitry Stogov#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) \
82927f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
83041e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null))) { \
83127f38798SDmitry Stogov			_expected_type = Z_EXPECTED_DOUBLE; \
8320ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
8330ae305e6SDmitry Stogov			break; \
8340ae305e6SDmitry Stogov		}
83527f38798SDmitry Stogov
83627f38798SDmitry Stogov#define Z_PARAM_DOUBLE(dest) \
83727f38798SDmitry Stogov	Z_PARAM_DOUBLE_EX(dest, _dummy, 0, 0)
83827f38798SDmitry Stogov
83927f38798SDmitry Stogov/* old "f" */
8400ae305e6SDmitry Stogov#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \
84127f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
84241e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \
84327f38798SDmitry Stogov			if (!_error) { \
84427f38798SDmitry Stogov				_expected_type = Z_EXPECTED_FUNC; \
8450ae305e6SDmitry Stogov				error_code = ZPP_ERROR_WRONG_ARG; \
8460ae305e6SDmitry Stogov				break; \
84727f38798SDmitry Stogov			} else { \
8480ae305e6SDmitry Stogov				error_code = ZPP_ERROR_WRONG_CALLBACK; \
8490ae305e6SDmitry Stogov				break; \
85027f38798SDmitry Stogov			} \
8510ae305e6SDmitry Stogov		} else if (UNEXPECTED(_error != NULL)) { \
852bdeb220fSAnatol Belski			zend_wrong_callback_error(E_STRICT, _i, _error); \
8530ae305e6SDmitry Stogov		}
85427f38798SDmitry Stogov
85527f38798SDmitry Stogov#define Z_PARAM_FUNC(dest_fci, dest_fcc) \
85627f38798SDmitry Stogov	Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 0, 0)
85727f38798SDmitry Stogov
85827f38798SDmitry Stogov/* old "h" */
8590ae305e6SDmitry Stogov#define Z_PARAM_ARRAY_HT_EX(dest, check_null, separate) \
86027f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
86141e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 0))) { \
86227f38798SDmitry Stogov			_expected_type = Z_EXPECTED_ARRAY; \
8630ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
8640ae305e6SDmitry Stogov			break; \
8650ae305e6SDmitry Stogov		}
86627f38798SDmitry Stogov
86727f38798SDmitry Stogov#define Z_PARAM_ARRAY_HT(dest) \
86827f38798SDmitry Stogov	Z_PARAM_ARRAY_HT_EX(dest, 0, 0)
86927f38798SDmitry Stogov
87027f38798SDmitry Stogov/* old "H" */
8710ae305e6SDmitry Stogov#define Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, check_null, separate) \
87227f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
87341e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_array_ht(_arg, &dest, check_null, 1))) { \
87427f38798SDmitry Stogov			_expected_type = Z_EXPECTED_ARRAY; \
8750ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
8760ae305e6SDmitry Stogov			break; \
8770ae305e6SDmitry Stogov		}
87827f38798SDmitry Stogov
87927f38798SDmitry Stogov#define Z_PARAM_ARRAY_OR_OBJECT_HT(dest) \
88027f38798SDmitry Stogov	Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, 0, 0)
88127f38798SDmitry Stogov
88227f38798SDmitry Stogov/* old "l" */
883c3e3c98eSAnatol Belski#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) \
88427f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
88541e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 0))) { \
88627f38798SDmitry Stogov			_expected_type = Z_EXPECTED_LONG; \
8870ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
8880ae305e6SDmitry Stogov			break; \
8890ae305e6SDmitry Stogov		}
89027f38798SDmitry Stogov
891c3e3c98eSAnatol Belski#define Z_PARAM_LONG(dest) \
892c3e3c98eSAnatol Belski	Z_PARAM_LONG_EX(dest, _dummy, 0, 0)
89327f38798SDmitry Stogov
89427f38798SDmitry Stogov/* old "L" */
895c3e3c98eSAnatol Belski#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \
89627f38798SDmitry Stogov		Z_PARAM_PROLOGUE(separate); \
89741e3fdbaSAndrea Faulds		if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 1))) { \
89827f38798SDmitry Stogov			_expected_type = Z_EXPECTED_LONG; \
8990ae305e6SDmitry Stogov			error_code = ZPP_ERROR_WRONG_ARG; \
9000ae305e6SDmitry Stogov			break; \
9010ae305e6SDmitry Stogov		}
90227f38798SDmitry Stogov
903c3e3c98eSAnatol Belski#define Z_PARAM_STRICT_LONG(dest) \
904c3e3c98e