Skip to content
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

split MINIT for each classes #6

Merged
merged 11 commits into from
Aug 30, 2023
Merged
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
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
"prefer-stable": true,
"autoload-dev": {
"classmap": [
"src/php/ecma_intl.stub.php"
"src/php/classes/category.stub.php",
"src/php/classes/intl.stub.php",
"src/php/classes/locale.stub.php",
"src/php/classes/locale_character_direction.stub.php",
"src/php/classes/locale_options.stub.php",
"src/php/classes/locale_text_info.stub.php",
"src/php/classes/locale_week_day.stub.php",
"src/php/classes/locale_week_info.stub.php"
]
},
"config": {
Expand Down
18 changes: 16 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,39 @@ Fix: ensure build directories are created for each source directory, fixing an i
<dir name="classes">
<file name="category.c" role="src"/>
<file name="category.h" role="src"/>
<file name="category_arginfo.h" role="src"/>
<file name="category.stub.php" role="src"/>
<file name="intl.c" role="src"/>
<file name="intl.h" role="src"/>
<file name="intl_arginfo.h" role="src"/>
<file name="intl.stub.php" role="src"/>
<file name="locale.c" role="src"/>
<file name="locale.h" role="src"/>
<file name="locale_arginfo.h" role="src"/>
<file name="locale.stub.php" role="src"/>
<file name="locale_character_direction.c" role="src"/>
<file name="locale_character_direction.h" role="src"/>
<file name="locale_character_direction_arginfo.h" role="src"/>
<file name="locale_character_direction.stub.php" role="src"/>
<file name="locale_options.c" role="src"/>
<file name="locale_options.h" role="src"/>
<file name="locale_options_arginfo.h" role="src"/>
<file name="locale_options.stub.php" role="src"/>
<file name="locale_text_info.c" role="src"/>
<file name="locale_text_info.h" role="src"/>
<file name="locale_text_info_arginfo.h" role="src"/>
<file name="locale_text_info.stub.php" role="src"/>
<file name="locale_week_day.c" role="src"/>
<file name="locale_week_day.h" role="src"/>
<file name="locale_week_day_arginfo.h" role="src"/>
<file name="locale_week_day.stub.php" role="src"/>
<file name="locale_week_info.c" role="src"/>
<file name="locale_week_info.h" role="src"/>
<file name="locale_week_info_arginfo.h" role="src"/>
<file name="locale_week_info.stub.php" role="src"/>
</dir>
<file name="ecma_intl.c" role="src"/>
<file name="ecma_intl.h" role="src"/>
<file name="ecma_intl.stub.php" role="doc"/>
<file name="ecma_intl_arginfo.h" role="src"/>
<file name="php_common.h" role="src"/>
</dir>
</dir>
Expand Down
6 changes: 5 additions & 1 deletion src/php/classes/category.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@

#include "php/classes/category.h"

#include "php/classes/category_arginfo.h"

zend_class_entry *ecma_ce_IntlCategory = NULL;

void registerEcmaIntlCategory() {
PHP_MINIT_FUNCTION(ecma_intl_category) {
ecma_ce_IntlCategory = register_class_Ecma_Intl_Category();

return SUCCESS;
}
2 changes: 1 addition & 1 deletion src/php/classes/category.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

extern zend_class_entry *ecma_ce_IntlCategory;

void registerEcmaIntlCategory(void);
PHP_MINIT_FUNCTION(ecma_intl_category);

#endif /* ECMA_INTL_PHP_CLASSES_CATEGORY_H */
33 changes: 33 additions & 0 deletions src/php/classes/category.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* Copyright (c) php-ecma-intl contributors.
*
* This source file is subject to the BSD-3-Clause license that is bundled with
* this package in the file LICENSE and is available at the following web
* address: https://opensource.org/license/bsd-3-clause/
*
* This source file may utilize copyrighted material from third-party open
* source projects, the use of which is acknowledged in the NOTICE file bundled
* with this package.
*
* @generate-class-entries
*/

namespace Ecma\Intl
{
/**
* Categories of values supported by this implementation.
*
* @link https://tc39.es/ecma402/#sec-intl.supportedvaluesof ECMA-402, section 8.3.2, Intl.supportedValuesOf
*/
enum Category: string
{
case Calendar = 'calendar';
case Collation = 'collation';
case Currency = 'currency';
case NumberingSystem = 'numberingSystem';
case TimeZone = 'timeZone';
case Unit = 'unit';
}
}
46 changes: 46 additions & 0 deletions src/php/classes/category_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 430525d27dcfa691b8f1e7204cbc53adb2db059f */




static const zend_function_entry class_Ecma_Intl_Category_methods[] = {
ZEND_FE_END
};

static zend_class_entry *register_class_Ecma_Intl_Category(void)
{
zend_class_entry *class_entry = zend_register_internal_enum("Ecma\\Intl\\Category", IS_STRING, class_Ecma_Intl_Category_methods);

zval enum_case_Calendar_value;
zend_string *enum_case_Calendar_value_str = zend_string_init("calendar", strlen("calendar"), 1);
ZVAL_STR(&enum_case_Calendar_value, enum_case_Calendar_value_str);
zend_enum_add_case_cstr(class_entry, "Calendar", &enum_case_Calendar_value);

zval enum_case_Collation_value;
zend_string *enum_case_Collation_value_str = zend_string_init("collation", strlen("collation"), 1);
ZVAL_STR(&enum_case_Collation_value, enum_case_Collation_value_str);
zend_enum_add_case_cstr(class_entry, "Collation", &enum_case_Collation_value);

zval enum_case_Currency_value;
zend_string *enum_case_Currency_value_str = zend_string_init("currency", strlen("currency"), 1);
ZVAL_STR(&enum_case_Currency_value, enum_case_Currency_value_str);
zend_enum_add_case_cstr(class_entry, "Currency", &enum_case_Currency_value);

zval enum_case_NumberingSystem_value;
zend_string *enum_case_NumberingSystem_value_str = zend_string_init("numberingSystem", strlen("numberingSystem"), 1);
ZVAL_STR(&enum_case_NumberingSystem_value, enum_case_NumberingSystem_value_str);
zend_enum_add_case_cstr(class_entry, "NumberingSystem", &enum_case_NumberingSystem_value);

zval enum_case_TimeZone_value;
zend_string *enum_case_TimeZone_value_str = zend_string_init("timeZone", strlen("timeZone"), 1);
ZVAL_STR(&enum_case_TimeZone_value, enum_case_TimeZone_value_str);
zend_enum_add_case_cstr(class_entry, "TimeZone", &enum_case_TimeZone_value);

zval enum_case_Unit_value;
zend_string *enum_case_Unit_value_str = zend_string_init("unit", strlen("unit"), 1);
ZVAL_STR(&enum_case_Unit_value, enum_case_Unit_value_str);
zend_enum_add_case_cstr(class_entry, "Unit", &enum_case_Unit_value);

return class_entry;
}
8 changes: 7 additions & 1 deletion src/php/classes/intl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
#include "ecma402/locale.h"
#include "php/classes/category.h"

#include "php/classes/intl_arginfo.h"

#include <ext/spl/spl_iterators.h>
#include <unicode/uloc.h>

zend_class_entry *ecma_ce_Intl = NULL;

void registerEcmaIntl() { ecma_ce_Intl = register_class_Ecma_Intl(); }
PHP_MINIT_FUNCTION(ecma_intl) {
ecma_ce_Intl = register_class_Ecma_Intl();

return SUCCESS;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/php/classes/intl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

extern zend_class_entry *ecma_ce_Intl;

void registerEcmaIntl(void);
PHP_MINIT_FUNCTION(ecma_intl);

#endif /* ECMA_INTL_PHP_CLASSES_INTL_H */
72 changes: 72 additions & 0 deletions src/php/classes/intl.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

/**
* Copyright (c) php-ecma-intl contributors.
*
* This source file is subject to the BSD-3-Clause license that is bundled with
* this package in the file LICENSE and is available at the following web
* address: https://opensource.org/license/bsd-3-clause/
*
* This source file may utilize copyrighted material from third-party open
* source projects, the use of which is acknowledged in the NOTICE file bundled
* with this package.
*
* @generate-class-entries
*/

namespace Ecma
{
final class Intl
{
/**
* The current ICU library version.
*
* @var string
* @cvalue U_ICU_VERSION
*/
public const ICU_VERSION = UNKNOWN;

/**
* Unicode version number.
*
* @var string
* @cvalue U_UNICODE_VERSION
*/
public const UNICODE_VERSION = UNKNOWN;

/**
* Returns an array of canonical locale names for the input locale(s).
*
* @link https://tc39.es/ecma402/#sec-intl.getcanonicallocales ECMA-402, section 8.3.1, Intl.getCanoncialLocales
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales MDN: Intl.getCanonicalLocales()
*
* @phpstan-param iterable<\Stringable|string>|\Stringable|string|null $locales
*
* @return string[]
*/
public static function getCanonicalLocales(iterable|\Stringable|string|null $locales): array
{
}

/**
* Returns an array containing the supported calendar, collation,
* currency, numbering systems, or unit values supported by this
* implementation.
*
* @link https://tc39.es/ecma402/#sec-intl.supportedvaluesof ECMA-402, section 8.3.2, Intl.supportedValuesOf
* @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/supportedValuesOf MDN: Intl.supportedValuesOf()
*
* @return string[]
*/
public static function supportedValuesOf(Intl\Category $category): array
{
}

/**
* Intl may not be instantiated.
*/
private function __construct()
{
}
}
}
51 changes: 51 additions & 0 deletions src/php/classes/intl_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 868093634998e28b498ffe100b93c61ad2000765 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Ecma_Intl_getCanonicalLocales, 0, 1, IS_ARRAY, 0)
ZEND_ARG_OBJ_TYPE_MASK(0, locales, Traversable|Stringable, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, NULL)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Ecma_Intl_supportedValuesOf, 0, 1, IS_ARRAY, 0)
ZEND_ARG_OBJ_INFO(0, category, Ecma\\Intl\\Category, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Ecma_Intl___construct, 0, 0, 0)
ZEND_END_ARG_INFO()


ZEND_METHOD(Ecma_Intl, getCanonicalLocales);
ZEND_METHOD(Ecma_Intl, supportedValuesOf);
ZEND_METHOD(Ecma_Intl, __construct);


static const zend_function_entry class_Ecma_Intl_methods[] = {
ZEND_ME(Ecma_Intl, getCanonicalLocales, arginfo_class_Ecma_Intl_getCanonicalLocales, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_ME(Ecma_Intl, supportedValuesOf, arginfo_class_Ecma_Intl_supportedValuesOf, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_ME(Ecma_Intl, __construct, arginfo_class_Ecma_Intl___construct, ZEND_ACC_PRIVATE)
ZEND_FE_END
};

static zend_class_entry *register_class_Ecma_Intl(void)
{
zend_class_entry ce, *class_entry;

INIT_NS_CLASS_ENTRY(ce, "Ecma", "Intl", class_Ecma_Intl_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL;

zval const_ICU_VERSION_value;
zend_string *const_ICU_VERSION_value_str = zend_string_init(U_ICU_VERSION, strlen(U_ICU_VERSION), 1);
ZVAL_STR(&const_ICU_VERSION_value, const_ICU_VERSION_value_str);
zend_string *const_ICU_VERSION_name = zend_string_init_interned("ICU_VERSION", sizeof("ICU_VERSION") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_ICU_VERSION_name, &const_ICU_VERSION_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_ICU_VERSION_name);

zval const_UNICODE_VERSION_value;
zend_string *const_UNICODE_VERSION_value_str = zend_string_init(U_UNICODE_VERSION, strlen(U_UNICODE_VERSION), 1);
ZVAL_STR(&const_UNICODE_VERSION_value, const_UNICODE_VERSION_value_str);
zend_string *const_UNICODE_VERSION_name = zend_string_init_interned("UNICODE_VERSION", sizeof("UNICODE_VERSION") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_UNICODE_VERSION_name, &const_UNICODE_VERSION_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_UNICODE_VERSION_name);

return class_entry;
}
6 changes: 5 additions & 1 deletion src/php/classes/locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "php/classes/locale_week_day.h"
#include "php/classes/locale_week_info.h"

#include "php/classes/locale_arginfo.h"

#include <Zend/zend_interfaces.h>
#include <ext/json/php_json.h>
#include <string.h>
Expand Down Expand Up @@ -80,7 +82,7 @@ static void setWeekInfo(zend_object *object, ecma402_locale *locale);
static UCalendarDaysOfWeek weekDayEcmaToIcu(ecma402_dayOfWeek day);
static ecma402_dayOfWeek weekDayIcuToEcma(UCalendarDaysOfWeek day);

void registerEcmaIntlLocale() {
PHP_MINIT_FUNCTION(ecma_intl_locale) {
ecma_ce_IntlLocale = register_class_Ecma_Intl_Locale(php_json_serializable_ce,
zend_ce_stringable);
ecma_ce_IntlLocale->create_object = ecma_createIntlLocale;
Expand All @@ -90,6 +92,8 @@ void registerEcmaIntlLocale() {

ecma_handlers_IntlLocale.offset = XtOffsetOf(ecma_IntlLocale, std);
ecma_handlers_IntlLocale.free_obj = freeLocaleObj;

return SUCCESS;
}

zend_object *ecma_createIntlLocale(zend_class_entry *classEntry) {
Expand Down
3 changes: 2 additions & 1 deletion src/php/classes/locale.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ static inline ecma_IntlLocale *ecma_IntlLocaleFromObj(zend_object *obj) {
extern zend_class_entry *ecma_ce_IntlLocale;
extern zend_object_handlers ecma_handlers_IntlLocale;

void registerEcmaIntlLocale(void);
zend_object *ecma_createIntlLocale(zend_class_entry *classEntry);

PHP_MINIT_FUNCTION(ecma_intl_locale);

#endif /* ECMA_INTL_PHP_CLASSES_LOCALE_H */
Loading