Skip to content

Generate ext/intl class entries from stubs #6670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions ext/intl/breakiterator/breakiterator.stub.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

/** @generate-function-entries */
/**
* @generate-function-entries
* @generate-class-entries
*/

class IntlBreakIterator implements IteratorAggregate
{
Expand Down Expand Up @@ -86,12 +89,6 @@ public function getRuleStatus() {}
public function getRuleStatusVec() {}
}

class IntlPartsIterator extends IntlIterator
{
/** @return IntlBreakIterator */
public function getBreakIterator() {}
}

class IntlCodePointBreakIterator extends IntlBreakIterator
{
/** @return int */
Expand Down
43 changes: 33 additions & 10 deletions ext/intl/breakiterator/breakiterator_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 6a121ed9817667820f05677a772781d6b788796b */
* Stub hash: 4fe6fb9a231d635a193f61897cf4ff6f1541c0db */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlBreakIterator_createCharacterInstance, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, locale, IS_STRING, 1, "null")
Expand Down Expand Up @@ -72,8 +72,6 @@ ZEND_END_ARG_INFO()

#define arginfo_class_IntlRuleBasedBreakIterator_getRuleStatusVec arginfo_class_IntlBreakIterator_createCodePointInstance

#define arginfo_class_IntlPartsIterator_getBreakIterator arginfo_class_IntlBreakIterator_createCodePointInstance

#define arginfo_class_IntlCodePointBreakIterator_getLastCodePoint arginfo_class_IntlBreakIterator_createCodePointInstance


Expand Down Expand Up @@ -104,7 +102,6 @@ ZEND_METHOD(IntlRuleBasedBreakIterator, getBinaryRules);
ZEND_METHOD(IntlRuleBasedBreakIterator, getRules);
ZEND_METHOD(IntlRuleBasedBreakIterator, getRuleStatus);
ZEND_METHOD(IntlRuleBasedBreakIterator, getRuleStatusVec);
ZEND_METHOD(IntlPartsIterator, getBreakIterator);
ZEND_METHOD(IntlCodePointBreakIterator, getLastCodePoint);


Expand Down Expand Up @@ -145,13 +142,39 @@ static const zend_function_entry class_IntlRuleBasedBreakIterator_methods[] = {
};


static const zend_function_entry class_IntlPartsIterator_methods[] = {
ZEND_ME(IntlPartsIterator, getBreakIterator, arginfo_class_IntlPartsIterator_getBreakIterator, ZEND_ACC_PUBLIC)
ZEND_FE_END
};


static const zend_function_entry class_IntlCodePointBreakIterator_methods[] = {
ZEND_ME(IntlCodePointBreakIterator, getLastCodePoint, arginfo_class_IntlCodePointBreakIterator_getLastCodePoint, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

zend_class_entry *register_class_IntlBreakIterator(zend_class_entry *class_entry_IteratorAggregate)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "IntlBreakIterator", class_IntlBreakIterator_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
zend_class_implements(class_entry, 1, class_entry_IteratorAggregate);

return class_entry;
}

zend_class_entry *register_class_IntlRuleBasedBreakIterator(zend_class_entry *class_entry_IntlBreakIterator)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "IntlRuleBasedBreakIterator", class_IntlRuleBasedBreakIterator_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlBreakIterator);

return class_entry;
}

zend_class_entry *register_class_IntlCodePointBreakIterator(zend_class_entry *class_entry_IntlBreakIterator)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "IntlCodePointBreakIterator", class_IntlCodePointBreakIterator_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlBreakIterator);

return class_entry;
}

22 changes: 6 additions & 16 deletions ext/intl/breakiterator/breakiterator_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,11 @@ static zend_object *BreakIterator_object_create(zend_class_entry *ce)
*/
U_CFUNC void breakiterator_register_BreakIterator_class(void)
{
zend_class_entry ce;

/* Create and register 'BreakIterator' class. */
INIT_CLASS_ENTRY(ce, "IntlBreakIterator", class_IntlBreakIterator_methods);
ce.create_object = BreakIterator_object_create;
ce.get_iterator = _breakiterator_get_iterator;
BreakIterator_ce_ptr = zend_register_internal_class(&ce);

BreakIterator_ce_ptr = register_class_IntlBreakIterator(zend_ce_aggregate);
BreakIterator_ce_ptr->create_object = BreakIterator_object_create;
BreakIterator_ce_ptr->get_iterator = _breakiterator_get_iterator;

memcpy(&BreakIterator_handlers, &std_object_handlers,
sizeof BreakIterator_handlers);
Expand All @@ -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 );

Expand Down Expand Up @@ -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);
}
/* }}} */
8 changes: 2 additions & 6 deletions ext/intl/breakiterator/breakiterator_iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <zend_exceptions.h>
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions ext/intl/breakiterator/breakiterator_iterators.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortuantely, I couldn't register IntlPartsIterator without extracting its stub to its own file, even though I tried multiple approaches.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the problem with it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was that originally, breakiterator_arginfo.h had to be included both in breakiterator_class.cpp and breakiterator_iterators.cpp, so that the class registering functions (e.g. register_class_IntlPartsIterator) became duplicate symbols.


/**
* @generate-function-entries
* @generate-class-entries
*/

class IntlPartsIterator extends IntlIterator
{
/** @return IntlBreakIterator */
public function getBreakIterator() {}
}
25 changes: 25 additions & 0 deletions ext/intl/breakiterator/breakiterator_iterators_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: db9382ccfcb8a4d4ea6d01404ece22088f8d419c */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlPartsIterator_getBreakIterator, 0, 0, 0)
ZEND_END_ARG_INFO()


ZEND_METHOD(IntlPartsIterator, getBreakIterator);


static const zend_function_entry class_IntlPartsIterator_methods[] = {
ZEND_ME(IntlPartsIterator, getBreakIterator, arginfo_class_IntlPartsIterator_getBreakIterator, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

zend_class_entry *register_class_IntlPartsIterator(zend_class_entry *class_entry_IntlIterator)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "IntlPartsIterator", class_IntlPartsIterator_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlIterator);

return class_entry;
}

5 changes: 4 additions & 1 deletion ext/intl/calendar/calendar.stub.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

/** @generate-function-entries */
/**
* @generate-function-entries
* @generate-class-entries
*/

class IntlCalendar
{
Expand Down
23 changes: 22 additions & 1 deletion ext/intl/calendar/calendar_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 18a92d3af801f11e5c3b90e5d272fd98b3515c40 */
* Stub hash: 06651a7cc83f307403826af1362feca173e2ba4b */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -270,3 +270,24 @@ static const zend_function_entry class_IntlGregorianCalendar_methods[] = {
ZEND_ME_MAPPING(isLeapYear, intlgregcal_is_leap_year, arginfo_class_IntlGregorianCalendar_isLeapYear, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

zend_class_entry *register_class_IntlCalendar()
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "IntlCalendar", class_IntlCalendar_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

return class_entry;
}

zend_class_entry *register_class_IntlGregorianCalendar(zend_class_entry *class_entry_IntlCalendar)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "IntlGregorianCalendar", class_IntlGregorianCalendar_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_IntlCalendar);

return class_entry;
}

11 changes: 3 additions & 8 deletions ext/intl/calendar/calendar_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,9 @@ static zend_object *Calendar_object_create(zend_class_entry *ce)
*/
void calendar_register_IntlCalendar_class(void)
{
zend_class_entry ce;

/* Create and register 'IntlCalendar' class. */
INIT_CLASS_ENTRY(ce, "IntlCalendar", class_IntlCalendar_methods);
ce.create_object = Calendar_object_create;
Calendar_ce_ptr = zend_register_internal_class(&ce);
Calendar_ce_ptr = register_class_IntlCalendar();
Calendar_ce_ptr->create_object = Calendar_object_create;

memcpy( &Calendar_handlers, &std_object_handlers,
sizeof Calendar_handlers);
Expand Down Expand Up @@ -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);
}
/* }}} */
5 changes: 4 additions & 1 deletion ext/intl/collator/collator.stub.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

/** @generate-function-entries */
/**
* @generate-function-entries
* @generate-class-entries
*/

class Collator
{
Expand Down
13 changes: 12 additions & 1 deletion ext/intl/collator/collator_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 869c6e60a8f2b153ef79f28a08e165ff3ec2bc14 */
* Stub hash: 3f992cc1efe2d4f193c414ceb2811ee0945a60c5 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0)
Expand Down Expand Up @@ -85,3 +85,14 @@ static const zend_function_entry class_Collator_methods[] = {
ZEND_ME_MAPPING(getSortKey, collator_get_sort_key, arginfo_class_Collator_getSortKey, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

zend_class_entry *register_class_Collator()
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "Collator", class_Collator_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

return class_entry;
}

7 changes: 2 additions & 5 deletions ext/intl/collator/collator_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,9 @@ zend_object *Collator_object_create(zend_class_entry *ce )
*/
void collator_register_Collator_class( void )
{
zend_class_entry ce;

/* Create and register 'Collator' class. */
INIT_CLASS_ENTRY( ce, "Collator", class_Collator_methods );
ce.create_object = Collator_object_create;
Collator_ce_ptr = zend_register_internal_class( &ce );
Collator_ce_ptr = register_class_Collator();
Collator_ce_ptr->create_object = Collator_object_create;

memcpy(&Collator_handlers, &std_object_handlers,
sizeof Collator_handlers);
Expand Down
5 changes: 1 addition & 4 deletions ext/intl/converter/converter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion ext/intl/converter/converter.stub.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

/** @generate-function-entries */
/**
* @generate-function-entries
* @generate-class-entries
*/

class UConverter
{
Expand Down
13 changes: 12 additions & 1 deletion ext/intl/converter/converter_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: e33e2614c969c59b79c6062f7a347a8e8e486d85 */
* Stub hash: da9dd2dc8a994a6856e1fce33d973d979b7b67ee */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_UConverter___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, destination_encoding, IS_STRING, 1, "null")
Expand Down Expand Up @@ -113,3 +113,14 @@ static const zend_function_entry class_UConverter_methods[] = {
ZEND_ME(UConverter, transcode, arginfo_class_UConverter_transcode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_FE_END
};

zend_class_entry *register_class_UConverter()
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "UConverter", class_UConverter_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

return class_entry;
}

5 changes: 4 additions & 1 deletion ext/intl/dateformat/dateformat.stub.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

/** @generate-function-entries */
/**
* @generate-function-entries
* @generate-class-entries
*/

class IntlDateFormatter
{
Expand Down
13 changes: 12 additions & 1 deletion ext/intl/dateformat/dateformat_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 62742b5f463272f43970e98900a89d513c4fb839 */
* Stub hash: 3153bf65bc8776681b763284a7355537c5c9ead4 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 3)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
Expand Down Expand Up @@ -125,3 +125,14 @@ static const zend_function_entry class_IntlDateFormatter_methods[] = {
ZEND_ME_MAPPING(getErrorMessage, datefmt_get_error_message, arginfo_class_IntlDateFormatter_getErrorMessage, ZEND_ACC_PUBLIC)
ZEND_FE_END
};

zend_class_entry *register_class_IntlDateFormatter()
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "IntlDateFormatter", class_IntlDateFormatter_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

return class_entry;
}

Loading