From 069b85237df2556807cebd1064376fc88b80866a 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: [PATCH 1/2] Generate ext/intl class entries from stubs --- ext/intl/breakiterator/breakiterator.stub.php | 11 ++--- .../breakiterator/breakiterator_arginfo.h | 43 ++++++++++++++----- .../breakiterator/breakiterator_class.cpp | 22 +++------- .../breakiterator/breakiterator_iterators.cpp | 8 +--- .../breakiterator_iterators.stub.php | 12 ++++++ .../breakiterator_iterators_arginfo.h | 25 +++++++++++ ext/intl/calendar/calendar.stub.php | 5 ++- ext/intl/calendar/calendar_arginfo.h | 23 +++++++++- ext/intl/calendar/calendar_class.cpp | 11 ++--- ext/intl/collator/collator.stub.php | 5 ++- 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 | 5 ++- ext/intl/converter/converter_arginfo.h | 13 +++++- ext/intl/dateformat/dateformat.stub.php | 5 ++- ext/intl/dateformat/dateformat_arginfo.h | 13 +++++- ext/intl/dateformat/dateformat_class.c | 7 +-- ext/intl/formatter/formatter.stub.php | 5 ++- ext/intl/formatter/formatter_arginfo.h | 13 +++++- ext/intl/formatter/formatter_class.c | 7 +-- ext/intl/intl_error.c | 8 +--- ext/intl/intl_error.h | 2 +- ext/intl/locale/locale.stub.php | 5 ++- ext/intl/locale/locale_arginfo.h | 13 +++++- ext/intl/locale/locale_class.c | 15 +------ ext/intl/msgformat/msgformat.stub.php | 5 ++- ext/intl/msgformat/msgformat_arginfo.h | 13 +++++- ext/intl/msgformat/msgformat_class.c | 7 +-- ext/intl/normalizer/normalizer.stub.php | 5 ++- 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 | 9 +++- ext/intl/php_intl_arginfo.h | 18 +++++++- ext/intl/spoofchecker/spoofchecker.stub.php | 5 ++- ext/intl/spoofchecker/spoofchecker_arginfo.h | 13 +++++- ext/intl/spoofchecker/spoofchecker_class.c | 7 +-- ext/intl/timezone/timezone.stub.php | 5 ++- 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 | 5 ++- ext/intl/uchar/uchar_arginfo.h | 13 +++++- 44 files changed, 320 insertions(+), 151 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 35a57e44b9094..2c403117fcbe2 100644 --- a/ext/intl/breakiterator/breakiterator.stub.php +++ b/ext/intl/breakiterator/breakiterator.stub.php @@ -1,6 +1,9 @@ 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 7c955a5ecb232..4eb0fd8da99e8 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 0000000000000..6080cc326d578 --- /dev/null +++ b/ext/intl/breakiterator/breakiterator_iterators.stub.php @@ -0,0 +1,12 @@ +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 f42d1508cb965..7c9f16b7584f3 100644 --- a/ext/intl/collator/collator.stub.php +++ b/ext/intl/collator/collator.stub.php @@ -1,6 +1,9 @@ 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 90971302ce287..7c4ac65262a10 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 5b82b098f47f7..d3174003ae2d2 100644 --- a/ext/intl/converter/converter.stub.php +++ b/ext/intl/converter/converter.stub.php @@ -1,6 +1,9 @@ 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 045b0640ce72f..24421ab32b095 100644 --- a/ext/intl/formatter/formatter.stub.php +++ b/ext/intl/formatter/formatter.stub.php @@ -1,6 +1,9 @@ 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 6babe701529fe..f21ddf3fb75a4 100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c @@ -203,14 +203,8 @@ void intl_errors_set_code( intl_error* err, UErrorCode err_code ) } /* }}} */ -void intl_register_IntlException_class( void ) +void intl_register_IntlException_handlers(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; } diff --git a/ext/intl/intl_error.h b/ext/intl/intl_error.h index 927e5cdfd296e..bc48026342c88 100644 --- a/ext/intl/intl_error.h +++ b/ext/intl/intl_error.h @@ -48,6 +48,6 @@ void intl_errors_set( intl_error* err, UErrorCode code, const char* msg, smart_str intl_parse_error_to_string( UParseError* pe ); // exported to be called on extension MINIT -void intl_register_IntlException_class( void ); +void intl_register_IntlException_handlers( void ); #endif // INTL_ERROR_H diff --git a/ext/intl/locale/locale.stub.php b/ext/intl/locale/locale.stub.php index e5703293c025b..239b8f3dafbf9 100644 --- a/ext/intl/locale/locale.stub.php +++ b/ext/intl/locale/locale.stub.php @@ -1,6 +1,9 @@ create_object = NULL; } /* }}} */ diff --git a/ext/intl/msgformat/msgformat.stub.php b/ext/intl/msgformat/msgformat.stub.php index a9a3e3e181bb9..15795a19081f0 100644 --- a/ext/intl/msgformat/msgformat.stub.php +++ b/ext/intl/msgformat/msgformat.stub.php @@ -1,6 +1,9 @@ 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 243ace532d1cc..201090741f89c 100644 --- a/ext/intl/normalizer/normalizer.stub.php +++ b/ext/intl/normalizer/normalizer.stub.php @@ -1,6 +1,9 @@ create_object = NULL; } /* }}} */ diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 2b91266e7ed65..b6718533b8fcd 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); + intl_register_IntlException_handlers(); /* 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 26b7922c2c702..8f2692e3d2c39 100644 --- a/ext/intl/php_intl.stub.php +++ b/ext/intl/php_intl.stub.php @@ -1,6 +1,13 @@ 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 60ec7524a60a3..56c34b4d3fad4 100644 --- a/ext/intl/timezone/timezone.stub.php +++ b/ext/intl/timezone/timezone.stub.php @@ -1,6 +1,9 @@ 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 0f44b454b4499..ee90007546883 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 f3ebd78bcb75c..b11b6101f99cb 100644 --- a/ext/intl/uchar/uchar.stub.php +++ b/ext/intl/uchar/uchar.stub.php @@ -1,6 +1,9 @@ Date: Mon, 8 Feb 2021 19:51:42 +0100 Subject: [PATCH 2/2] Inline create_object handler --- ext/intl/intl_error.c | 5 ----- ext/intl/intl_error.h | 3 --- ext/intl/php_intl.c | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index f21ddf3fb75a4..64cf45ce6171e 100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c @@ -203,11 +203,6 @@ void intl_errors_set_code( intl_error* err, UErrorCode err_code ) } /* }}} */ -void intl_register_IntlException_handlers(void) -{ - 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 bc48026342c88..bcf5d2cc4a2ce 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_handlers( void ); - #endif // INTL_ERROR_H diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index b6718533b8fcd..01361ed262a4e 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -216,7 +216,7 @@ PHP_MINIT_FUNCTION( intl ) /* Register 'IntlException' PHP class */ IntlException_ce_ptr = register_class_IntlException(zend_ce_exception); - intl_register_IntlException_handlers(); + IntlException_ce_ptr->create_object = zend_ce_exception->create_object; /* Register 'IntlIterator' PHP class */ intl_register_IntlIterator_class( );