From edae4165edbf542bd798f7e4c2df1da086f2ce53 Mon Sep 17 00:00:00 2001 From: Richard Fussenegger Date: Sun, 14 May 2017 15:43:31 +0200 Subject: [PATCH 1/2] Fixed ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO macro The macro was expanding to a wrong macro and thus leads to compile errors upon usage. Changed it to expand to the correct macro, and added Doxygen documentation to help new users. --- Zend/zend_API.h | 65 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/Zend/zend_API.h b/Zend/zend_API.h index b8a6ecfcb77d8..59d7c29747bde 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1,4 +1,4 @@ -/* +/* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ @@ -107,12 +107,67 @@ typedef struct _zend_fcall_info_cache { #define ZEND_ARG_VARIADIC_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) { #name, ZEND_TYPE_ENCODE(type_hint, allow_null), pass_by_ref, 1 }, #define ZEND_ARG_VARIADIC_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, ZEND_TYPE_ENCODE_CLASS_CONST(#classname, allow_null), pass_by_ref, 1 }, - -#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, classname, allow_null) \ +/** + * Start extended argument information block with an object return type + * declaration. + * + * ## Examples + * ```c + * ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arg_info_f, 0, 0, T, 0) + * ZEND_END_ARG_INFO() + * ``` + * + * Above example argument information applied to a function _f_ would result in + * the following PHP function signature: + * + * ```php + * function f(): T {} + * ``` + * + * @param[in] name + * of the variable where the argument information should be assigned to. + * @param[in] return_reference + * whether the routine returns by reference (`1`) or not (`0`). + * @param[in] required_num_args + * total amount of required (non-optional) arguments of the routine. + * @param[in] class_name + * of the object that this routine must return. + * @param[in] allow_null + * whether the routine's return type is nullable (`1`) or not (`0`). + * @see ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO + * for routines that do not take any arguments. + */ +#define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \ static const zend_internal_arg_info name[] = { \ - { (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_ENCODE_CLASS_CONST(#classname, allow_null), return_reference, 0 }, + { (const char*)(zend_uintptr_t)(required_num_args), ZEND_TYPE_ENCODE_CLASS_CONST(#class_name, allow_null), return_reference, 0 }, + +/** + * Start argument information block with return object return type declaration. + * + * ## Examples + * ```c + * ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(arg_info_f, T, 0) + * ZEND_END_ARG_INFO() + * ``` + * + * Above example argument information applied to a function _f_ would result + * in the following PHP function signature: + * + * ```php + * function f(): T {} + * ``` + * + * @param[in] name + * of the variable where the argument information should be assigned to. + * @param[in] class_name + * of the object that this routine must return. + * @param[in] allow_null + * whether the routine's return type is nullable (`1`) or not (`0`). + * @see ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX + * which allows the specification of the total amount of required arguments. + */ #define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(name, class_name, allow_null) \ - ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, 0, -1, class_name, allow_null) + ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, 0, -1, class_name, allow_null) #define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ static const zend_internal_arg_info name[] = { \ From 92f0ce613d6c427492afeeeae6b4b9372ba958b7 Mon Sep 17 00:00:00 2001 From: Richard Fussenegger Date: Wed, 24 May 2017 01:53:43 +0200 Subject: [PATCH 2/2] Changed encoding back to ANSI Thanks Visual Studio ;( --- Zend/zend_API.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 59d7c29747bde..7fb398565fade 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1,4 +1,4 @@ -/* +/* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+