mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Add explicit IntlPartsIterator::getRuleStatus() method
Rather than doing a magic forward, explicitly add a forwarding method. This must be the most frivolous use of get_method I've ever seen.
This commit is contained in:
parent
bb9ef2bedb
commit
a5ad9eeefa
3 changed files with 26 additions and 48 deletions
|
@ -28,6 +28,7 @@ extern "C" {
|
||||||
#include "../intl_convert.h"
|
#include "../intl_convert.h"
|
||||||
#include "../locale/locale.h"
|
#include "../locale/locale.h"
|
||||||
#include <zend_exceptions.h>
|
#include <zend_exceptions.h>
|
||||||
|
#include <zend_interfaces.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
static zend_class_entry *IntlPartsIterator_ce_ptr;
|
static zend_class_entry *IntlPartsIterator_ce_ptr;
|
||||||
|
@ -229,48 +230,6 @@ void IntlIterator_from_BreakIterator_parts(zval *break_iter_zv,
|
||||||
((zoi_break_iter_parts*)ii->iterator)->key_type = key_type;
|
((zoi_break_iter_parts*)ii->iterator)->key_type = key_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
U_CFUNC zend_object *IntlPartsIterator_object_create(zend_class_entry *ce)
|
|
||||||
{
|
|
||||||
zend_object *retval = IntlIterator_ce_ptr->create_object(ce);
|
|
||||||
retval->handlers = &IntlPartsIterator_handlers;
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
U_CFUNC zend_function *IntlPartsIterator_get_method(zend_object **object_ptr, zend_string *method, const zval *key)
|
|
||||||
{
|
|
||||||
zend_function *ret;
|
|
||||||
zend_string *lc_method_name;
|
|
||||||
ALLOCA_FLAG(use_heap);
|
|
||||||
|
|
||||||
if (key == NULL) {
|
|
||||||
ZSTR_ALLOCA_ALLOC(lc_method_name, ZSTR_LEN(method), use_heap);
|
|
||||||
zend_str_tolower_copy(ZSTR_VAL(lc_method_name), ZSTR_VAL(method), ZSTR_LEN(method));
|
|
||||||
} else {
|
|
||||||
lc_method_name = Z_STR_P(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ZSTR_LEN(method) == sizeof("getrulestatus") - 1
|
|
||||||
&& memcmp("getrulestatus", ZSTR_VAL(lc_method_name), ZSTR_LEN(lc_method_name)) == 0) {
|
|
||||||
IntlIterator_object *obj = php_intl_iterator_fetch_object(*object_ptr);
|
|
||||||
if (obj->iterator && !Z_ISUNDEF(obj->iterator->data)) {
|
|
||||||
zval *break_iter_zv = &obj->iterator->data;
|
|
||||||
*object_ptr = Z_OBJ_P(break_iter_zv);
|
|
||||||
ret = Z_OBJ_HANDLER_P(break_iter_zv, get_method)(object_ptr, method, key);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = zend_std_get_method(object_ptr, method, key);
|
|
||||||
|
|
||||||
end:
|
|
||||||
if (key == NULL) {
|
|
||||||
ZSTR_ALLOCA_FREE(lc_method_name, use_heap);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
U_CFUNC PHP_METHOD(IntlPartsIterator, getBreakIterator)
|
U_CFUNC PHP_METHOD(IntlPartsIterator, getBreakIterator)
|
||||||
{
|
{
|
||||||
INTLITERATOR_METHOD_INIT_VARS;
|
INTLITERATOR_METHOD_INIT_VARS;
|
||||||
|
@ -284,15 +243,26 @@ U_CFUNC PHP_METHOD(IntlPartsIterator, getBreakIterator)
|
||||||
RETURN_COPY_DEREF(&ii->iterator->data);
|
RETURN_COPY_DEREF(&ii->iterator->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
U_CFUNC PHP_METHOD(IntlPartsIterator, getRuleStatus)
|
||||||
|
{
|
||||||
|
INTLITERATOR_METHOD_INIT_VARS;
|
||||||
|
|
||||||
|
if (zend_parse_parameters_none() == FAILURE) {
|
||||||
|
RETURN_THROWS();
|
||||||
|
}
|
||||||
|
|
||||||
|
INTLITERATOR_METHOD_FETCH_OBJECT;
|
||||||
|
|
||||||
|
zval *iter = &ii->iterator->data;
|
||||||
|
ZEND_ASSERT(Z_TYPE_P(iter) == IS_OBJECT);
|
||||||
|
zend_call_method_with_0_params(
|
||||||
|
Z_OBJ_P(iter), Z_OBJCE_P(iter), NULL, "getrulestatus", return_value);
|
||||||
|
}
|
||||||
|
|
||||||
U_CFUNC void breakiterator_register_IntlPartsIterator_class(void)
|
U_CFUNC void breakiterator_register_IntlPartsIterator_class(void)
|
||||||
{
|
{
|
||||||
/* Create and register 'BreakIterator' class. */
|
/* Create and register 'BreakIterator' class. */
|
||||||
IntlPartsIterator_ce_ptr = register_class_IntlPartsIterator(IntlIterator_ce_ptr);
|
IntlPartsIterator_ce_ptr = register_class_IntlPartsIterator(IntlIterator_ce_ptr);
|
||||||
IntlPartsIterator_ce_ptr->create_object = IntlPartsIterator_object_create;
|
|
||||||
|
|
||||||
memcpy(&IntlPartsIterator_handlers, &IntlIterator_handlers,
|
|
||||||
sizeof IntlPartsIterator_handlers);
|
|
||||||
IntlPartsIterator_handlers.get_method = IntlPartsIterator_get_method;
|
|
||||||
|
|
||||||
#define PARTSITER_DECL_LONG_CONST(name) \
|
#define PARTSITER_DECL_LONG_CONST(name) \
|
||||||
zend_declare_class_constant_long(IntlPartsIterator_ce_ptr, #name, \
|
zend_declare_class_constant_long(IntlPartsIterator_ce_ptr, #name, \
|
||||||
|
|
|
@ -6,4 +6,7 @@ class IntlPartsIterator extends IntlIterator
|
||||||
{
|
{
|
||||||
/** @tentative-return-type */
|
/** @tentative-return-type */
|
||||||
public function getBreakIterator(): IntlBreakIterator {}
|
public function getBreakIterator(): IntlBreakIterator {}
|
||||||
|
|
||||||
|
/** @tentative-return-type */
|
||||||
|
public function getRuleStatus(): int {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
/* This is a generated file, edit the .stub.php file instead.
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
* Stub hash: e99b1e4a81bff12f44d22075d4b9f3f4627b1050 */
|
* Stub hash: 267199a0a3532b5acf1d700f14329cdb2f2db0e1 */
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IntlPartsIterator_getBreakIterator, 0, 0, IntlBreakIterator, 0)
|
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IntlPartsIterator_getBreakIterator, 0, 0, IntlBreakIterator, 0)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_IntlPartsIterator_getRuleStatus, 0, 0, IS_LONG, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
|
||||||
ZEND_METHOD(IntlPartsIterator, getBreakIterator);
|
ZEND_METHOD(IntlPartsIterator, getBreakIterator);
|
||||||
|
ZEND_METHOD(IntlPartsIterator, getRuleStatus);
|
||||||
|
|
||||||
|
|
||||||
static const zend_function_entry class_IntlPartsIterator_methods[] = {
|
static const zend_function_entry class_IntlPartsIterator_methods[] = {
|
||||||
ZEND_ME(IntlPartsIterator, getBreakIterator, arginfo_class_IntlPartsIterator_getBreakIterator, ZEND_ACC_PUBLIC)
|
ZEND_ME(IntlPartsIterator, getBreakIterator, arginfo_class_IntlPartsIterator_getBreakIterator, ZEND_ACC_PUBLIC)
|
||||||
|
ZEND_ME(IntlPartsIterator, getRuleStatus, arginfo_class_IntlPartsIterator_getRuleStatus, ZEND_ACC_PUBLIC)
|
||||||
ZEND_FE_END
|
ZEND_FE_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue