-#define PHP_HTTP_BEGIN_ARGS(method, req_args) PHP_HTTP_BEGIN_ARGS_EX(HttpRequestMethod, method, 0, req_args)
-#define PHP_HTTP_EMPTY_ARGS(method) PHP_HTTP_EMPTY_ARGS_EX(HttpRequestMethod, method, 0)
-#define PHP_HTTP_REQMETH_ME(method, visibility) PHP_ME(HttpRequestMethod, method, PHP_HTTP_ARGS(HttpRequestMethod, method), visibility)
-
-#ifdef register
-# undef register
-#endif
-
-PHP_HTTP_BEGIN_ARGS(__construct, 1)
- PHP_HTTP_ARG_VAL(name, 0)
-PHP_HTTP_END_ARGS;
-
-PHP_HTTP_EMPTY_ARGS(__toString);
-
-PHP_HTTP_EMPTY_ARGS(getId);
-
-PHP_HTTP_BEGIN_ARGS(exists, 1)
- PHP_HTTP_ARG_VAL(method, 0)
-PHP_HTTP_END_ARGS;
-
-PHP_HTTP_BEGIN_ARGS(register, 1)
- PHP_HTTP_ARG_VAL(method, 0)
-PHP_HTTP_END_ARGS;
-
-zend_function_entry php_http_request_method_method_entry[] = {
- PHP_HTTP_REQMETH_ME(__construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
- PHP_HTTP_REQMETH_ME(__toString, ZEND_ACC_PUBLIC)
- PHP_HTTP_REQMETH_ME(getId, ZEND_ACC_PUBLIC)
- PHP_HTTP_REQMETH_ME(exists, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
- PHP_HTTP_REQMETH_ME(register, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-
- EMPTY_FUNCTION_ENTRY
-};
-
-PHP_METHOD(HttpRequestMethod, __construct)
-{
- with_error_handling(EH_THROW, php_http_exception_class_entry) {
- char *meth_str;
- int meth_len;
-
- if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &meth_str, &meth_len)) {
- with_error_handling(EH_THROW, php_http_exception_class_entry) {
- zval *zarg, *zret;
-
- if (SUCCESS == zend_get_parameters(ZEND_NUM_ARGS(), 1, &zarg)) {
- if (zend_call_method_with_1_params(&getThis(), php_http_request_method_class_entry, NULL, "exists", &zret, zarg)) {
- if (i_zend_is_true(zret)) {
- zend_update_property_stringl(php_http_request_method_class_entry, getThis(), ZEND_STRL("name"), meth_str, meth_len TSRMLS_CC);
- } else {
- php_http_error(HE_THROW, PHP_HTTP_E_REQUEST_METHOD, "Unknown request method '%s'", meth_str);
- }
- zval_ptr_dtor(&zret);
- }
- }
- } end_error_handling();
- }
- } end_error_handling();
-}