From c6723728dff93c6d4276d32cac7bf2b8465be93a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 5 Feb 2021 20:57:57 +0100 Subject: Generate ext/intl class entries from stubs Closes GH-6670 --- ext/intl/breakiterator/breakiterator.stub.php | 8 +--- ext/intl/breakiterator/breakiterator_arginfo.h | 43 +++++++++++++++++----- ext/intl/breakiterator/breakiterator_class.cpp | 22 +++-------- ext/intl/breakiterator/breakiterator_iterators.cpp | 8 +--- .../breakiterator/breakiterator_iterators.stub.php | 9 +++++ .../breakiterator_iterators_arginfo.h | 25 +++++++++++++ ext/intl/calendar/calendar.stub.php | 2 +- ext/intl/calendar/calendar_arginfo.h | 23 +++++++++++- ext/intl/calendar/calendar_class.cpp | 11 ++---- ext/intl/collator/collator.stub.php | 2 +- ext/intl/collator/collator_arginfo.h | 13 ++++++- ext/intl/collator/collator_class.c | 7 +--- ext/intl/converter/converter.c | 5 +-- ext/intl/converter/converter.stub.php | 2 +- ext/intl/converter/converter_arginfo.h | 13 ++++++- ext/intl/dateformat/dateformat.stub.php | 2 +- ext/intl/dateformat/dateformat_arginfo.h | 13 ++++++- ext/intl/dateformat/dateformat_class.c | 7 +--- ext/intl/formatter/formatter.stub.php | 2 +- ext/intl/formatter/formatter_arginfo.h | 13 ++++++- ext/intl/formatter/formatter_class.c | 7 +--- ext/intl/intl_error.c | 11 ------ ext/intl/intl_error.h | 3 -- ext/intl/locale/locale.stub.php | 2 +- ext/intl/locale/locale_arginfo.h | 13 ++++++- ext/intl/locale/locale_class.c | 15 +------- ext/intl/msgformat/msgformat.stub.php | 2 +- ext/intl/msgformat/msgformat_arginfo.h | 13 ++++++- ext/intl/msgformat/msgformat_class.c | 7 +--- ext/intl/normalizer/normalizer.stub.php | 2 +- ext/intl/normalizer/normalizer_arginfo.h | 13 ++++++- ext/intl/normalizer/normalizer_class.c | 16 +------- ext/intl/php_intl.c | 5 ++- ext/intl/php_intl.stub.php | 6 ++- ext/intl/php_intl_arginfo.h | 18 ++++++++- ext/intl/spoofchecker/spoofchecker.stub.php | 2 +- ext/intl/spoofchecker/spoofchecker_arginfo.h | 13 ++++++- ext/intl/spoofchecker/spoofchecker_class.c | 7 +--- ext/intl/timezone/timezone.stub.php | 2 +- ext/intl/timezone/timezone_arginfo.h | 13 ++++++- ext/intl/timezone/timezone_class.cpp | 13 +------ ext/intl/uchar/uchar.c | 5 +-- ext/intl/uchar/uchar.stub.php | 2 +- ext/intl/uchar/uchar_arginfo.h | 13 ++++++- 44 files changed, 276 insertions(+), 157 deletions(-) create mode 100644 ext/intl/breakiterator/breakiterator_iterators.stub.php create mode 100644 ext/intl/breakiterator/breakiterator_iterators_arginfo.h diff --git a/ext/intl/breakiterator/breakiterator.stub.php b/ext/intl/breakiterator/breakiterator.stub.php index 35a57e44b9..bae4726be4 100644 --- a/ext/intl/breakiterator/breakiterator.stub.php +++ b/ext/intl/breakiterator/breakiterator.stub.php @@ -1,6 +1,6 @@ create_object = BreakIterator_object_create; + BreakIterator_ce_ptr->get_iterator = _breakiterator_get_iterator; memcpy(&BreakIterator_handlers, &std_object_handlers, sizeof BreakIterator_handlers); @@ -236,8 +234,6 @@ U_CFUNC void breakiterator_register_BreakIterator_class(void) BreakIterator_handlers.get_debug_info = BreakIterator_get_debug_info; BreakIterator_handlers.free_obj = BreakIterator_objects_free; - zend_class_implements(BreakIterator_ce_ptr, 1, zend_ce_aggregate); - zend_declare_class_constant_long(BreakIterator_ce_ptr, "DONE", sizeof("DONE") - 1, BreakIterator::DONE ); @@ -271,15 +267,9 @@ U_CFUNC void breakiterator_register_BreakIterator_class(void) /* Create and register 'RuleBasedBreakIterator' class. */ - INIT_CLASS_ENTRY(ce, "IntlRuleBasedBreakIterator", - class_IntlRuleBasedBreakIterator_methods); - RuleBasedBreakIterator_ce_ptr = zend_register_internal_class_ex(&ce, - BreakIterator_ce_ptr); + RuleBasedBreakIterator_ce_ptr = register_class_IntlRuleBasedBreakIterator(BreakIterator_ce_ptr); /* Create and register 'CodePointBreakIterator' class. */ - INIT_CLASS_ENTRY(ce, "IntlCodePointBreakIterator", - class_IntlCodePointBreakIterator_methods); - CodePointBreakIterator_ce_ptr = zend_register_internal_class_ex(&ce, - BreakIterator_ce_ptr); + CodePointBreakIterator_ce_ptr = register_class_IntlCodePointBreakIterator(BreakIterator_ce_ptr); } /* }}} */ diff --git a/ext/intl/breakiterator/breakiterator_iterators.cpp b/ext/intl/breakiterator/breakiterator_iterators.cpp index 7c955a5ecb..4eb0fd8da9 100644 --- a/ext/intl/breakiterator/breakiterator_iterators.cpp +++ b/ext/intl/breakiterator/breakiterator_iterators.cpp @@ -24,7 +24,7 @@ extern "C" { #define USE_BREAKITERATOR_POINTER #include "breakiterator_class.h" -#include "breakiterator_arginfo.h" +#include "breakiterator_iterators_arginfo.h" #include "../intl_convert.h" #include "../locale/locale.h" #include @@ -287,12 +287,8 @@ U_CFUNC PHP_METHOD(IntlPartsIterator, getBreakIterator) U_CFUNC void breakiterator_register_IntlPartsIterator_class(void) { - zend_class_entry ce; - /* Create and register 'BreakIterator' class. */ - INIT_CLASS_ENTRY(ce, "IntlPartsIterator", class_IntlPartsIterator_methods); - IntlPartsIterator_ce_ptr = zend_register_internal_class_ex(&ce, - 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, diff --git a/ext/intl/breakiterator/breakiterator_iterators.stub.php b/ext/intl/breakiterator/breakiterator_iterators.stub.php new file mode 100644 index 0000000000..9a82640c20 --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_iterators.stub.php @@ -0,0 +1,9 @@ +create_object = Calendar_object_create; memcpy( &Calendar_handlers, &std_object_handlers, sizeof Calendar_handlers); @@ -331,8 +328,6 @@ void calendar_register_IntlCalendar_class(void) CALENDAR_DECL_LONG_CONST("WALLTIME_NEXT_VALID", UCAL_WALLTIME_NEXT_VALID); /* Create and register 'IntlGregorianCalendar' class. */ - INIT_CLASS_ENTRY(ce, "IntlGregorianCalendar", class_IntlGregorianCalendar_methods); - GregorianCalendar_ce_ptr = zend_register_internal_class_ex(&ce, - Calendar_ce_ptr); + GregorianCalendar_ce_ptr = register_class_IntlGregorianCalendar(Calendar_ce_ptr); } /* }}} */ diff --git a/ext/intl/collator/collator.stub.php b/ext/intl/collator/collator.stub.php index f42d1508cb..7a987a25ab 100644 --- a/ext/intl/collator/collator.stub.php +++ b/ext/intl/collator/collator.stub.php @@ -1,6 +1,6 @@ create_object = Collator_object_create; memcpy(&Collator_handlers, &std_object_handlers, sizeof Collator_handlers); diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 90971302ce..7c4ac65262 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -966,10 +966,7 @@ static zend_object *php_converter_clone_object(zend_object *object) { /* {{{ php_converter_minit */ int php_converter_minit(INIT_FUNC_ARGS) { - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "UConverter", class_UConverter_methods); - php_converter_ce = zend_register_internal_class(&ce); + php_converter_ce = register_class_UConverter(); php_converter_ce->create_object = php_converter_create_object; memcpy(&php_converter_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); php_converter_object_handlers.offset = XtOffsetOf(php_converter_object, obj); diff --git a/ext/intl/converter/converter.stub.php b/ext/intl/converter/converter.stub.php index 5b82b098f4..8847bdcab0 100644 --- a/ext/intl/converter/converter.stub.php +++ b/ext/intl/converter/converter.stub.php @@ -1,6 +1,6 @@ create_object = IntlDateFormatter_object_create; memcpy(&IntlDateFormatter_handlers, &std_object_handlers, sizeof IntlDateFormatter_handlers); diff --git a/ext/intl/formatter/formatter.stub.php b/ext/intl/formatter/formatter.stub.php index 045b0640ce..8118b19d47 100644 --- a/ext/intl/formatter/formatter.stub.php +++ b/ext/intl/formatter/formatter.stub.php @@ -1,6 +1,6 @@ create_object = NumberFormatter_object_create; NumberFormatter_ce_ptr->serialize = zend_class_serialize_deny; NumberFormatter_ce_ptr->unserialize = zend_class_unserialize_deny; diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index 6babe70152..64cf45ce61 100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c @@ -203,17 +203,6 @@ void intl_errors_set_code( intl_error* err, UErrorCode err_code ) } /* }}} */ -void intl_register_IntlException_class( void ) -{ - zend_class_entry ce; - - /* Create and register 'IntlException' class. */ - INIT_CLASS_ENTRY_EX( ce, "IntlException", sizeof( "IntlException" ) - 1, NULL ); - IntlException_ce_ptr = zend_register_internal_class_ex( &ce, - zend_ce_exception ); - IntlException_ce_ptr->create_object = zend_ce_exception->create_object; -} - smart_str intl_parse_error_to_string( UParseError* pe ) { smart_str ret = {0}; diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 927e5cdfd2..bcf5d2cc4a 100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h @@ -47,7 +47,4 @@ void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, // Other error helpers smart_str intl_parse_error_to_string( UParseError* pe ); -// exported to be called on extension MINIT -void intl_register_IntlException_class( void ); - #endif // INTL_ERROR_H diff --git a/ext/intl/locale/locale.stub.php b/ext/intl/locale/locale.stub.php index e5703293c0..f20d2d3d97 100644 --- a/ext/intl/locale/locale.stub.php +++ b/ext/intl/locale/locale.stub.php @@ -1,6 +1,6 @@ create_object = NULL; } /* }}} */ diff --git a/ext/intl/msgformat/msgformat.stub.php b/ext/intl/msgformat/msgformat.stub.php index a9a3e3e181..f46e663203 100644 --- a/ext/intl/msgformat/msgformat.stub.php +++ b/ext/intl/msgformat/msgformat.stub.php @@ -1,6 +1,6 @@ create_object = MessageFormatter_object_create; memcpy(&MessageFormatter_handlers, &std_object_handlers, sizeof MessageFormatter_handlers); diff --git a/ext/intl/normalizer/normalizer.stub.php b/ext/intl/normalizer/normalizer.stub.php index 243ace532d..0c9e1785dc 100644 --- a/ext/intl/normalizer/normalizer.stub.php +++ b/ext/intl/normalizer/normalizer.stub.php @@ -1,6 +1,6 @@ create_object = NULL; } /* }}} */ diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 2b91266e7e..01361ed262 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -215,7 +215,8 @@ PHP_MINIT_FUNCTION( intl ) spoofchecker_register_constants( INIT_FUNC_ARGS_PASSTHRU ); /* Register 'IntlException' PHP class */ - intl_register_IntlException_class( ); + IntlException_ce_ptr = register_class_IntlException(zend_ce_exception); + IntlException_ce_ptr->create_object = zend_ce_exception->create_object; /* Register 'IntlIterator' PHP class */ intl_register_IntlIterator_class( ); @@ -224,7 +225,7 @@ PHP_MINIT_FUNCTION( intl ) breakiterator_register_BreakIterator_class( ); /* Register 'IntlPartsIterator' class */ - breakiterator_register_IntlPartsIterator_class( ); + breakiterator_register_IntlPartsIterator_class(); /* Global error handling. */ intl_error_init( NULL ); diff --git a/ext/intl/php_intl.stub.php b/ext/intl/php_intl.stub.php index 26b7922c2c..70bb606da4 100644 --- a/ext/intl/php_intl.stub.php +++ b/ext/intl/php_intl.stub.php @@ -1,6 +1,10 @@ create_object = Spoofchecker_object_create; memcpy(&Spoofchecker_handlers, &std_object_handlers, sizeof Spoofchecker_handlers); diff --git a/ext/intl/timezone/timezone.stub.php b/ext/intl/timezone/timezone.stub.php index 60ec7524a6..e8d46bde87 100644 --- a/ext/intl/timezone/timezone.stub.php +++ b/ext/intl/timezone/timezone.stub.php @@ -1,6 +1,6 @@ create_object = TimeZone_object_create; memcpy(&TimeZone_handlers, &std_object_handlers, sizeof TimeZone_handlers); diff --git a/ext/intl/uchar/uchar.c b/ext/intl/uchar/uchar.c index 0f44b454b4..ee90007546 100644 --- a/ext/intl/uchar/uchar.c +++ b/ext/intl/uchar/uchar.c @@ -612,10 +612,9 @@ IC_CHAR_METHOD_CHAR(getBidiPairedBracket) /* }}} */ int php_uchar_minit(INIT_FUNC_ARGS) { - zend_class_entry tmp, *ce; + zend_class_entry *ce; - INIT_CLASS_ENTRY(tmp, "IntlChar", class_IntlChar_methods); - ce = zend_register_internal_class(&tmp); + ce = register_class_IntlChar(); #define IC_CONSTL(name, val) \ zend_declare_class_constant_long(ce, name, strlen(name), val); diff --git a/ext/intl/uchar/uchar.stub.php b/ext/intl/uchar/uchar.stub.php index f3ebd78bcb..2bb667e44e 100644 --- a/ext/intl/uchar/uchar.stub.php +++ b/ext/intl/uchar/uchar.stub.php @@ -1,6 +1,6 @@