Skip to content

Commit bf1a6e6

Browse files
remicolletramsey
andauthored
split MINIT for each classes (#6)
Co-authored-by: Ben Ramsey <[email protected]>
1 parent 4133644 commit bf1a6e6

38 files changed

+1128
-920
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
"prefer-stable": true,
2626
"autoload-dev": {
2727
"classmap": [
28-
"src/php/ecma_intl.stub.php"
28+
"src/php/classes/category.stub.php",
29+
"src/php/classes/intl.stub.php",
30+
"src/php/classes/locale.stub.php",
31+
"src/php/classes/locale_character_direction.stub.php",
32+
"src/php/classes/locale_options.stub.php",
33+
"src/php/classes/locale_text_info.stub.php",
34+
"src/php/classes/locale_week_day.stub.php",
35+
"src/php/classes/locale_week_info.stub.php"
2936
]
3037
},
3138
"config": {

package.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,39 @@ Fix: ensure build directories are created for each source directory, fixing an i
7777
<dir name="classes">
7878
<file name="category.c" role="src"/>
7979
<file name="category.h" role="src"/>
80+
<file name="category_arginfo.h" role="src"/>
81+
<file name="category.stub.php" role="src"/>
8082
<file name="intl.c" role="src"/>
8183
<file name="intl.h" role="src"/>
84+
<file name="intl_arginfo.h" role="src"/>
85+
<file name="intl.stub.php" role="src"/>
8286
<file name="locale.c" role="src"/>
8387
<file name="locale.h" role="src"/>
88+
<file name="locale_arginfo.h" role="src"/>
89+
<file name="locale.stub.php" role="src"/>
8490
<file name="locale_character_direction.c" role="src"/>
8591
<file name="locale_character_direction.h" role="src"/>
92+
<file name="locale_character_direction_arginfo.h" role="src"/>
93+
<file name="locale_character_direction.stub.php" role="src"/>
8694
<file name="locale_options.c" role="src"/>
8795
<file name="locale_options.h" role="src"/>
96+
<file name="locale_options_arginfo.h" role="src"/>
97+
<file name="locale_options.stub.php" role="src"/>
8898
<file name="locale_text_info.c" role="src"/>
8999
<file name="locale_text_info.h" role="src"/>
100+
<file name="locale_text_info_arginfo.h" role="src"/>
101+
<file name="locale_text_info.stub.php" role="src"/>
90102
<file name="locale_week_day.c" role="src"/>
91103
<file name="locale_week_day.h" role="src"/>
104+
<file name="locale_week_day_arginfo.h" role="src"/>
105+
<file name="locale_week_day.stub.php" role="src"/>
92106
<file name="locale_week_info.c" role="src"/>
93107
<file name="locale_week_info.h" role="src"/>
108+
<file name="locale_week_info_arginfo.h" role="src"/>
109+
<file name="locale_week_info.stub.php" role="src"/>
94110
</dir>
95111
<file name="ecma_intl.c" role="src"/>
96112
<file name="ecma_intl.h" role="src"/>
97-
<file name="ecma_intl.stub.php" role="doc"/>
98-
<file name="ecma_intl_arginfo.h" role="src"/>
99113
<file name="php_common.h" role="src"/>
100114
</dir>
101115
</dir>

src/php/classes/category.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212

1313
#include "php/classes/category.h"
1414

15+
#include "php/classes/category_arginfo.h"
16+
1517
zend_class_entry *ecma_ce_IntlCategory = NULL;
1618

17-
void registerEcmaIntlCategory() {
19+
PHP_MINIT_FUNCTION(ecma_intl_category) {
1820
ecma_ce_IntlCategory = register_class_Ecma_Intl_Category();
21+
22+
return SUCCESS;
1923
}

src/php/classes/category.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
extern zend_class_entry *ecma_ce_IntlCategory;
1919

20-
void registerEcmaIntlCategory(void);
20+
PHP_MINIT_FUNCTION(ecma_intl_category);
2121

2222
#endif /* ECMA_INTL_PHP_CLASSES_CATEGORY_H */

src/php/classes/category.stub.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* Copyright (c) php-ecma-intl contributors.
5+
*
6+
* This source file is subject to the BSD-3-Clause license that is bundled with
7+
* this package in the file LICENSE and is available at the following web
8+
* address: https://opensource.org/license/bsd-3-clause/
9+
*
10+
* This source file may utilize copyrighted material from third-party open
11+
* source projects, the use of which is acknowledged in the NOTICE file bundled
12+
* with this package.
13+
*
14+
* @generate-class-entries
15+
*/
16+
17+
namespace Ecma\Intl
18+
{
19+
/**
20+
* Categories of values supported by this implementation.
21+
*
22+
* @link https://tc39.es/ecma402/#sec-intl.supportedvaluesof ECMA-402, section 8.3.2, Intl.supportedValuesOf
23+
*/
24+
enum Category: string
25+
{
26+
case Calendar = 'calendar';
27+
case Collation = 'collation';
28+
case Currency = 'currency';
29+
case NumberingSystem = 'numberingSystem';
30+
case TimeZone = 'timeZone';
31+
case Unit = 'unit';
32+
}
33+
}

src/php/classes/category_arginfo.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* This is a generated file, edit the .stub.php file instead.
2+
* Stub hash: 430525d27dcfa691b8f1e7204cbc53adb2db059f */
3+
4+
5+
6+
7+
static const zend_function_entry class_Ecma_Intl_Category_methods[] = {
8+
ZEND_FE_END
9+
};
10+
11+
static zend_class_entry *register_class_Ecma_Intl_Category(void)
12+
{
13+
zend_class_entry *class_entry = zend_register_internal_enum("Ecma\\Intl\\Category", IS_STRING, class_Ecma_Intl_Category_methods);
14+
15+
zval enum_case_Calendar_value;
16+
zend_string *enum_case_Calendar_value_str = zend_string_init("calendar", strlen("calendar"), 1);
17+
ZVAL_STR(&enum_case_Calendar_value, enum_case_Calendar_value_str);
18+
zend_enum_add_case_cstr(class_entry, "Calendar", &enum_case_Calendar_value);
19+
20+
zval enum_case_Collation_value;
21+
zend_string *enum_case_Collation_value_str = zend_string_init("collation", strlen("collation"), 1);
22+
ZVAL_STR(&enum_case_Collation_value, enum_case_Collation_value_str);
23+
zend_enum_add_case_cstr(class_entry, "Collation", &enum_case_Collation_value);
24+
25+
zval enum_case_Currency_value;
26+
zend_string *enum_case_Currency_value_str = zend_string_init("currency", strlen("currency"), 1);
27+
ZVAL_STR(&enum_case_Currency_value, enum_case_Currency_value_str);
28+
zend_enum_add_case_cstr(class_entry, "Currency", &enum_case_Currency_value);
29+
30+
zval enum_case_NumberingSystem_value;
31+
zend_string *enum_case_NumberingSystem_value_str = zend_string_init("numberingSystem", strlen("numberingSystem"), 1);
32+
ZVAL_STR(&enum_case_NumberingSystem_value, enum_case_NumberingSystem_value_str);
33+
zend_enum_add_case_cstr(class_entry, "NumberingSystem", &enum_case_NumberingSystem_value);
34+
35+
zval enum_case_TimeZone_value;
36+
zend_string *enum_case_TimeZone_value_str = zend_string_init("timeZone", strlen("timeZone"), 1);
37+
ZVAL_STR(&enum_case_TimeZone_value, enum_case_TimeZone_value_str);
38+
zend_enum_add_case_cstr(class_entry, "TimeZone", &enum_case_TimeZone_value);
39+
40+
zval enum_case_Unit_value;
41+
zend_string *enum_case_Unit_value_str = zend_string_init("unit", strlen("unit"), 1);
42+
ZVAL_STR(&enum_case_Unit_value, enum_case_Unit_value_str);
43+
zend_enum_add_case_cstr(class_entry, "Unit", &enum_case_Unit_value);
44+
45+
return class_entry;
46+
}

src/php/classes/intl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@
1616
#include "ecma402/locale.h"
1717
#include "php/classes/category.h"
1818

19+
#include "php/classes/intl_arginfo.h"
20+
1921
#include <ext/spl/spl_iterators.h>
2022
#include <unicode/uloc.h>
2123

2224
zend_class_entry *ecma_ce_Intl = NULL;
2325

24-
void registerEcmaIntl() { ecma_ce_Intl = register_class_Ecma_Intl(); }
26+
PHP_MINIT_FUNCTION(ecma_intl) {
27+
ecma_ce_Intl = register_class_Ecma_Intl();
28+
29+
return SUCCESS;
30+
}
2531

2632
PHP_METHOD(Ecma_Intl, __construct) { ZEND_PARSE_PARAMETERS_NONE(); }
2733

src/php/classes/intl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
extern zend_class_entry *ecma_ce_Intl;
1919

20-
void registerEcmaIntl(void);
20+
PHP_MINIT_FUNCTION(ecma_intl);
2121

2222
#endif /* ECMA_INTL_PHP_CLASSES_INTL_H */

src/php/classes/intl.stub.php

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
/**
4+
* Copyright (c) php-ecma-intl contributors.
5+
*
6+
* This source file is subject to the BSD-3-Clause license that is bundled with
7+
* this package in the file LICENSE and is available at the following web
8+
* address: https://opensource.org/license/bsd-3-clause/
9+
*
10+
* This source file may utilize copyrighted material from third-party open
11+
* source projects, the use of which is acknowledged in the NOTICE file bundled
12+
* with this package.
13+
*
14+
* @generate-class-entries
15+
*/
16+
17+
namespace Ecma
18+
{
19+
final class Intl
20+
{
21+
/**
22+
* The current ICU library version.
23+
*
24+
* @var string
25+
* @cvalue U_ICU_VERSION
26+
*/
27+
public const ICU_VERSION = UNKNOWN;
28+
29+
/**
30+
* Unicode version number.
31+
*
32+
* @var string
33+
* @cvalue U_UNICODE_VERSION
34+
*/
35+
public const UNICODE_VERSION = UNKNOWN;
36+
37+
/**
38+
* Returns an array of canonical locale names for the input locale(s).
39+
*
40+
* @link https://tc39.es/ecma402/#sec-intl.getcanonicallocales ECMA-402, section 8.3.1, Intl.getCanoncialLocales
41+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales MDN: Intl.getCanonicalLocales()
42+
*
43+
* @phpstan-param iterable<\Stringable|string>|\Stringable|string|null $locales
44+
*
45+
* @return string[]
46+
*/
47+
public static function getCanonicalLocales(iterable|\Stringable|string|null $locales): array
48+
{
49+
}
50+
51+
/**
52+
* Returns an array containing the supported calendar, collation,
53+
* currency, numbering systems, or unit values supported by this
54+
* implementation.
55+
*
56+
* @link https://tc39.es/ecma402/#sec-intl.supportedvaluesof ECMA-402, section 8.3.2, Intl.supportedValuesOf
57+
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf MDN: Intl.supportedValuesOf()
58+
*
59+
* @return string[]
60+
*/
61+
public static function supportedValuesOf(Intl\Category $category): array
62+
{
63+
}
64+
65+
/**
66+
* Intl may not be instantiated.
67+
*/
68+
private function __construct()
69+
{
70+
}
71+
}
72+
}

src/php/classes/intl_arginfo.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* This is a generated file, edit the .stub.php file instead.
2+
* Stub hash: 868093634998e28b498ffe100b93c61ad2000765 */
3+
4+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Ecma_Intl_getCanonicalLocales, 0, 1, IS_ARRAY, 0)
5+
ZEND_ARG_OBJ_TYPE_MASK(0, locales, Traversable|Stringable, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, NULL)
6+
ZEND_END_ARG_INFO()
7+
8+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Ecma_Intl_supportedValuesOf, 0, 1, IS_ARRAY, 0)
9+
ZEND_ARG_OBJ_INFO(0, category, Ecma\\Intl\\Category, 0)
10+
ZEND_END_ARG_INFO()
11+
12+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Ecma_Intl___construct, 0, 0, 0)
13+
ZEND_END_ARG_INFO()
14+
15+
16+
ZEND_METHOD(Ecma_Intl, getCanonicalLocales);
17+
ZEND_METHOD(Ecma_Intl, supportedValuesOf);
18+
ZEND_METHOD(Ecma_Intl, __construct);
19+
20+
21+
static const zend_function_entry class_Ecma_Intl_methods[] = {
22+
ZEND_ME(Ecma_Intl, getCanonicalLocales, arginfo_class_Ecma_Intl_getCanonicalLocales, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
23+
ZEND_ME(Ecma_Intl, supportedValuesOf, arginfo_class_Ecma_Intl_supportedValuesOf, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
24+
ZEND_ME(Ecma_Intl, __construct, arginfo_class_Ecma_Intl___construct, ZEND_ACC_PRIVATE)
25+
ZEND_FE_END
26+
};
27+
28+
static zend_class_entry *register_class_Ecma_Intl(void)
29+
{
30+
zend_class_entry ce, *class_entry;
31+
32+
INIT_NS_CLASS_ENTRY(ce, "Ecma", "Intl", class_Ecma_Intl_methods);
33+
class_entry = zend_register_internal_class_ex(&ce, NULL);
34+
class_entry->ce_flags |= ZEND_ACC_FINAL;
35+
36+
zval const_ICU_VERSION_value;
37+
zend_string *const_ICU_VERSION_value_str = zend_string_init(U_ICU_VERSION, strlen(U_ICU_VERSION), 1);
38+
ZVAL_STR(&const_ICU_VERSION_value, const_ICU_VERSION_value_str);
39+
zend_string *const_ICU_VERSION_name = zend_string_init_interned("ICU_VERSION", sizeof("ICU_VERSION") - 1, 1);
40+
zend_declare_class_constant_ex(class_entry, const_ICU_VERSION_name, &const_ICU_VERSION_value, ZEND_ACC_PUBLIC, NULL);
41+
zend_string_release(const_ICU_VERSION_name);
42+
43+
zval const_UNICODE_VERSION_value;
44+
zend_string *const_UNICODE_VERSION_value_str = zend_string_init(U_UNICODE_VERSION, strlen(U_UNICODE_VERSION), 1);
45+
ZVAL_STR(&const_UNICODE_VERSION_value, const_UNICODE_VERSION_value_str);
46+
zend_string *const_UNICODE_VERSION_name = zend_string_init_interned("UNICODE_VERSION", sizeof("UNICODE_VERSION") - 1, 1);
47+
zend_declare_class_constant_ex(class_entry, const_UNICODE_VERSION_name, &const_UNICODE_VERSION_value, ZEND_ACC_PUBLIC, NULL);
48+
zend_string_release(const_UNICODE_VERSION_name);
49+
50+
return class_entry;
51+
}

0 commit comments

Comments
 (0)