Skip to content

Commit

Permalink
Use PHP new arginfo generation framework
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Dec 10, 2021
1 parent 12478af commit 6060c1a
Show file tree
Hide file tree
Showing 70 changed files with 3,012 additions and 894 deletions.
54 changes: 13 additions & 41 deletions configs/yaf_config_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,18 @@

#include "configs/yaf_config_ini.h"

#if PHP_MAJOR_VERSION > 7
#include "yaf_config_arginfo.h"
#else
#include "yaf_config_legacy_arginfo.h"
#endif

zend_class_entry *yaf_config_ini_ce;

#if defined(HAVE_SPL) && PHP_VERSION_ID < 70200
extern PHPAPI zend_class_entry *spl_ce_Countable;
#endif

/** {{{ ARG_INFO
*/
ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_void_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_construct_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, config_file)
ZEND_ARG_INFO(0, section)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_get_arginfo, 0, 0, 0)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_config_ini_set_arginfo, 0, 0, 2)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

#if PHP_VERSION_ID < 80100
#define yaf_config_ini_oget_arginfo yaf_config_ini_get_arginfo
#define yaf_config_ini_oset_arginfo yaf_config_ini_set_arginfo
#else
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(yaf_config_ini_oget_arginfo, 0, 1, IS_MIXED, 0)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(yaf_config_ini_oset_arginfo, 0, 2, IS_VOID, 0)
ZEND_ARG_INFO(0, name)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()
#endif
/* }}} */

static inline void yaf_deep_copy_section(zval *dst, zval *src) /* {{{ */ {
zval *pzval, *dstpzval, value;
HashTable *ht;
Expand Down Expand Up @@ -518,13 +490,13 @@ PHP_METHOD(yaf_config_ini, readonly) {
/** {{{ yaf_config_ini_methods
*/
zend_function_entry yaf_config_ini_methods[] = {
PHP_ME(yaf_config_ini, __construct, yaf_config_ini_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_config_ini, get, yaf_config_ini_get_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_ini, set, yaf_config_ini_set_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_ini, readonly, yaf_config_ini_void_arginfo, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_ini, offsetGet, get, yaf_config_ini_oget_arginfo, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_ini, offsetSet, set, yaf_config_ini_oset_arginfo, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_ini, __set, set, yaf_config_ini_set_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_ini, __construct, arginfo_class_Yaf_Config_Ini___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_config_ini, get, arginfo_class_Yaf_Config_Ini_get, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_ini, set, arginfo_class_Yaf_Config_Ini_set, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_ini, readonly, arginfo_class_Yaf_Config_Ini_readonly, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_ini, offsetGet, get, arginfo_class_Yaf_Config_Ini_offsetGet, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_ini, offsetSet, set, arginfo_class_Yaf_Config_Ini_offsetSet, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_ini, __set, set, arginfo_class_Yaf_Config_Ini___set, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};

Expand Down
50 changes: 11 additions & 39 deletions configs/yaf_config_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,13 @@

#include "configs/yaf_config_simple.h"

zend_class_entry *yaf_config_simple_ce;

/** {{{ ARG_INFO
*/
ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_void_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_construct_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, config)
ZEND_ARG_INFO(0, readonly)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_set_arginfo, 0, 0, 2)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_config_simple_unset_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

#if PHP_VERSION_ID < 80100
#define yaf_config_simple_oset_arginfo yaf_config_simple_set_arginfo
#define yaf_config_simple_ounset_arginfo yaf_config_simple_unset_arginfo
#if PHP_MAJOR_VERSION > 7
#include "yaf_config_arginfo.h"
#else
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(yaf_config_simple_oset_arginfo, 0, 2, IS_VOID, 0)
ZEND_ARG_INFO(0, name)
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(yaf_config_simple_ounset_arginfo, 0, 1, IS_VOID, 0)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()
#include "yaf_config_legacy_arginfo.h"
#endif
/* }}} */

zend_class_entry *yaf_config_simple_ce;

void yaf_config_simple_init(yaf_config_object *conf, zval *val, int readonly) /* {{{ */ {
if (Z_TYPE_P(val) == IS_ARRAY) {
Expand Down Expand Up @@ -169,12 +141,12 @@ PHP_METHOD(yaf_config_simple, offsetUnset) {
/** {{{ yaf_config_simple_methods
*/
zend_function_entry yaf_config_simple_methods[] = {
PHP_ME(yaf_config_simple, __construct, yaf_config_simple_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_config_simple, set, yaf_config_simple_set_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_simple, readonly, yaf_config_simple_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_simple, offsetUnset, yaf_config_simple_ounset_arginfo, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_simple, __set, set, yaf_config_simple_set_arginfo, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_simple, offsetSet, set, yaf_config_simple_oset_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_simple, __construct, arginfo_class_Yaf_Config_Simple___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_config_simple, set, arginfo_class_Yaf_Config_Simple_set, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_simple, readonly, arginfo_class_Yaf_Config_Simple_readonly, ZEND_ACC_PUBLIC)
PHP_ME(yaf_config_simple, offsetUnset, arginfo_class_Yaf_Config_Simple_offsetUnSet, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_simple, __set, set, arginfo_class_Yaf_Config_Simple___set, ZEND_ACC_PUBLIC)
PHP_MALIAS(yaf_config_simple, offsetSet, set, arginfo_class_Yaf_Config_Simple_offsetSet, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
/* }}} */
Expand Down
16 changes: 7 additions & 9 deletions requests/yaf_request_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@
#include "yaf_request.h"
#include "yaf_exception.h"

#if PHP_MAJOR_VERSION > 7
#include "yaf_request_arginfo.h"
#else
#include "yaf_request_legacy_arginfo.h"
#endif

#include "requests/yaf_request_http.h"

zend_class_entry *yaf_request_http_ce;

/** {{{ ARG_INFO
*/
ZEND_BEGIN_ARG_INFO_EX(yaf_request_http_arginfo, 0, 0, 0)
ZEND_ARG_INFO(0, request_uri)
ZEND_ARG_INFO(0, base_uri)
ZEND_END_ARG_INFO()
/* }}} */

void yaf_request_http_init(yaf_request_object *req, zend_string *request_uri, zend_string *base_uri) /* {{{ */ {
const char *method;
zend_string *settled_uri = NULL;
Expand Down Expand Up @@ -152,7 +150,7 @@ PHP_METHOD(yaf_request_http, __construct) {
/** {{{ yaf_request_http_methods
*/
zend_function_entry yaf_request_http_methods[] = {
PHP_ME(yaf_request_http, __construct, yaf_request_http_arginfo, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
PHP_ME(yaf_request_http, __construct, arginfo_class_Yaf_Request_Http___construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
{NULL, NULL, NULL}
};
/* }}} */
Expand Down
24 changes: 8 additions & 16 deletions requests/yaf_request_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,13 @@
#include "yaf_exception.h"
#include "requests/yaf_request_simple.h"

zend_class_entry *yaf_request_simple_ce;
#if PHP_MAJOR_VERSION > 7
#include "yaf_request_arginfo.h"
#else
#include "yaf_request_legacy_arginfo.h"
#endif

/** {{{ ARG_INFO
*/
ZEND_BEGIN_ARG_INFO_EX(yaf_request_simple_construct_arginfo, 0, 0, 0)
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(0, module)
ZEND_ARG_INFO(0, controller)
ZEND_ARG_INFO(0, action)
ZEND_ARG_INFO(0, params)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_request_simple_void_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()
/* }}} */
zend_class_entry *yaf_request_simple_ce;

void yaf_request_simple_init(yaf_request_object *request, zend_string *module, zend_string *controller, zend_string *action, zend_string *method, zval *params) /* {{{ */ {
if (!method) {
Expand Down Expand Up @@ -136,8 +128,8 @@ PHP_METHOD(yaf_request_simple, isXmlHttpRequest) {
/** {{{ yaf_request_simple_methods
*/
zend_function_entry yaf_request_simple_methods[] = {
PHP_ME(yaf_request_simple, __construct, yaf_request_simple_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_request_simple, isXmlHttpRequest,yaf_request_simple_void_arginfo,ZEND_ACC_PUBLIC)
PHP_ME(yaf_request_simple, __construct, arginfo_class_Yaf_Request_Simple___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_request_simple, isXmlHttpRequest, arginfo_class_Yaf_Request_Simple_isXmlHttpRequest, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
/* }}} */
Expand Down
45 changes: 13 additions & 32 deletions responses/yaf_response_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,16 @@
#include "yaf_response.h"
#include "yaf_exception.h"

#if PHP_MAJOR_VERSION > 7
#include "yaf_response_arginfo.h"
#else
#include "yaf_response_legacy_arginfo.h"
#endif

#include "responses/yaf_response_http.h"

zend_class_entry *yaf_response_http_ce;

/** {{{ ARG_INFO
*/
ZEND_BEGIN_ARG_INFO_EX(yaf_response_http_void_arginfo, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_response_http_set_header_arginfo, 0, 0, 2)
ZEND_ARG_INFO(0, name)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, rep)
ZEND_ARG_INFO(0, response_code)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_response_http_get_header_arginfo, 0, 0, 0)
ZEND_ARG_INFO(0, name)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_response_http_set_all_headers_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, headers)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(yaf_response_http_set_redirect_arginfo, 0, 0, 1)
ZEND_ARG_INFO(0, url)
ZEND_END_ARG_INFO()
/* }}} */

zval *yaf_response_get_header(yaf_response_object *response, zend_string *name) /* {{{ */ {
if (response->header) {
return zend_hash_find(response->header, name);
Expand Down Expand Up @@ -222,7 +203,7 @@ PHP_METHOD(yaf_response_http, setAllHeaders) {
}
/* }}} */

/** {{{ proto public Yaf_Response_Http::getHeader(void)
/** {{{ proto public Yaf_Response_Http::getHeader(string $name = NULL)
*/
PHP_METHOD(yaf_response_http, getHeader) {
zval *header;
Expand Down Expand Up @@ -297,12 +278,12 @@ PHP_METHOD(yaf_response_http, response) {
/** {{{ yaf_response_methods
*/
zend_function_entry yaf_response_http_methods[] = {
PHP_ME(yaf_response_http, setHeader, yaf_response_http_set_header_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, setAllHeaders, yaf_response_http_set_all_headers_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, getHeader, yaf_response_http_get_header_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, clearHeaders, yaf_response_http_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, setRedirect, yaf_response_http_set_redirect_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, response, yaf_response_http_void_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, setHeader, arginfo_class_Yaf_Response_Http_setHeader, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, setAllHeaders, arginfo_class_Yaf_Response_Http_setAllHeaders, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, getHeader, arginfo_class_Yaf_Response_Http_getHeader, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, clearHeaders, arginfo_class_Yaf_Response_Http_clearHeaders, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, setRedirect, arginfo_class_Yaf_Response_Http_setRedirect, ZEND_ACC_PUBLIC)
PHP_ME(yaf_response_http, response, arginfo_class_Yaf_Response_Http_response, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
/* }}} */
Expand Down
10 changes: 8 additions & 2 deletions routes/yaf_route_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#include "yaf_exception.h"
#include "yaf_router.h"

#if PHP_MAJOR_VERSION > 7
#include "yaf_route_arginfo.h"
#else
#include "yaf_route_legacy_arginfo.h"
#endif

#include "routes/yaf_route_interface.h"
#include "routes/yaf_route_static.h"
#include "routes/yaf_route_simple.h"
Expand Down Expand Up @@ -128,8 +134,8 @@ int yaf_route_instance(yaf_route_t *route, HashTable *config) /* {{{ */ {
/** {{{ yaf_route_methods
*/
zend_function_entry yaf_route_methods[] = {
PHP_ABSTRACT_ME(yaf_route, route, yaf_route_route_arginfo)
PHP_ABSTRACT_ME(yaf_route, assemble, yaf_route_assemble_arginfo)
PHP_ABSTRACT_ME(yaf_route, route, arginfo_class_Yaf_Route_Interface_route)
PHP_ABSTRACT_ME(yaf_route, assemble, arginfo_class_Yaf_Route_Interface_assemble)
{NULL, NULL, NULL}
};
/* }}} */
Expand Down
9 changes: 0 additions & 9 deletions routes/yaf_route_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@
#define YAF_ROUTE_ASSEMBLE_ACTION_FORMAT ":a"
#define YAF_ROUTE_ASSEMBLE_CONTROLLER_FORMAT ":c"

YAF_BEGIN_ARG_INFO_EX(yaf_route_route_arginfo, 0, 0, 1)
YAF_ARG_INFO(0, request)
YAF_END_ARG_INFO()

YAF_BEGIN_ARG_INFO_EX(yaf_route_assemble_arginfo, 0, 0, 1)
YAF_ARG_ARRAY_INFO(0, info, 0)
YAF_ARG_ARRAY_INFO(0, query, 1)
YAF_END_ARG_INFO()

extern zend_class_entry *yaf_route_ce;

int yaf_route_instance(yaf_route_t *route, HashTable *config);
Expand Down
20 changes: 9 additions & 11 deletions routes/yaf_route_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@
#include "yaf_exception.h"
#include "yaf_request.h"

#if PHP_MAJOR_VERSION > 7
#include "yaf_route_arginfo.h"
#else
#include "yaf_route_legacy_arginfo.h"
#endif

#include "yaf_router.h"
#include "routes/yaf_route_interface.h"
#include "routes/yaf_route_map.h"

zend_class_entry *yaf_route_map_ce;
static zend_object_handlers yaf_route_map_obj_handlers;

/** {{{ ARG_INFO
*/
ZEND_BEGIN_ARG_INFO_EX(yaf_route_map_construct_arginfo, 0, 0, 0)
ZEND_ARG_INFO(0, controller_prefer)
ZEND_ARG_INFO(0, delimiter)
ZEND_END_ARG_INFO()
/* }}} */

static HashTable *yaf_route_map_get_properties(yaf_object *object) /* {{{ */ {
zval rv;
HashTable *ht;
Expand Down Expand Up @@ -348,9 +346,9 @@ PHP_METHOD(yaf_route_map, assemble) {
/** {{{ yaf_route_map_methods
*/
zend_function_entry yaf_route_map_methods[] = {
PHP_ME(yaf_route_map, __construct, yaf_route_map_construct_arginfo, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_route_map, route, yaf_route_route_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_route_map, assemble, yaf_route_assemble_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(yaf_route_map, __construct, arginfo_class_Yaf_Route_Map___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(yaf_route_map, route, arginfo_class_Yaf_Route_Map_route, ZEND_ACC_PUBLIC)
PHP_ME(yaf_route_map, assemble, arginfo_class_Yaf_Route_Map_assemble, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
/* }}} */
Expand Down
Loading

0 comments on commit 6060c1a

Please sign in to comment.