Skip to content

ext/intl last chunk of fast ZPP conversion #14431

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

Merged
merged 1 commit into from
Jun 2, 2024
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
8 changes: 2 additions & 6 deletions ext/intl/breakiterator/breakiterator_iterators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ U_CFUNC PHP_METHOD(IntlPartsIterator, getBreakIterator)
{
INTLITERATOR_METHOD_INIT_VARS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

INTLITERATOR_METHOD_FETCH_OBJECT;

Expand All @@ -259,9 +257,7 @@ U_CFUNC PHP_METHOD(IntlPartsIterator, getRuleStatus)
{
INTLITERATOR_METHOD_INIT_VARS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

INTLITERATOR_METHOD_FETCH_OBJECT;

Expand Down
86 changes: 34 additions & 52 deletions ext/intl/breakiterator/breakiterator_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ static void _breakiter_factory(const char *func_name,
INTERNAL_FUNCTION_PARAMETERS)
{
BreakIterator *biter;
const char *locale_str = NULL;
char *locale_str = NULL;
size_t dummy;
char *msg;
UErrorCode status = UErrorCode();
intl_error_reset(NULL);

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!",
&locale_str, &dummy) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_STRING_OR_NULL(locale_str, dummy)
ZEND_PARSE_PARAMETERS_END();

if (locale_str == NULL) {
locale_str = intl_locale_get_default();
locale_str = (char *)intl_locale_get_default();
}

biter = func(Locale::createFromName(locale_str), status);
Expand Down Expand Up @@ -113,9 +113,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, createCodePointInstance)
{
intl_error_reset(NULL);

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

CodePointBreakIterator *cpbi = new CodePointBreakIterator();
breakiterator_object_create(return_value, cpbi, 1);
Expand All @@ -126,9 +124,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getText)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand All @@ -146,9 +142,9 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, setText)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &text) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STR(text)
ZEND_PARSE_PARAMETERS_END();

BREAKITER_METHOD_FETCH_OBJECT;

Expand Down Expand Up @@ -176,9 +172,7 @@ static void _breakiter_no_args_ret_int32(
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand All @@ -195,9 +189,9 @@ static void _breakiter_int32_ret_int32(
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &arg) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(arg)
ZEND_PARSE_PARAMETERS_END();

BREAKITER_METHOD_FETCH_OBJECT;

Expand Down Expand Up @@ -233,16 +227,13 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, next)
{
zval *arg = NULL;

if (ZEND_NUM_ARGS() == 0) {
goto no_arg_version;
}
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z!", &arg) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL_OR_NULL(arg)
ZEND_PARSE_PARAMETERS_END();

if (arg == NULL) {
ZEND_NUM_ARGS() = 0; /* pretend we don't have any argument */
no_arg_version:
ZEND_NUM_ARGS() = 0;
_breakiter_no_args_ret_int32(&BreakIterator::next,
INTERNAL_FUNCTION_PARAM_PASSTHRU);
} else {
Expand All @@ -256,9 +247,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, current)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand Down Expand Up @@ -287,10 +276,9 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, isBoundary)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "l",
&offset) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END();

if (UNEXPECTED(offset < INT32_MIN || offset > INT32_MAX)) {
zend_argument_value_error(1, "must be between %d and %d", INT32_MIN, INT32_MAX);
Expand All @@ -310,9 +298,9 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getLocale)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &locale_type) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_LONG(locale_type)
ZEND_PARSE_PARAMETERS_END();

/* Change to ValueError? */
if (locale_type != ULOC_ACTUAL_LOCALE && locale_type != ULOC_VALID_LOCALE) {
Expand All @@ -337,9 +325,10 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getPartsIterator)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &key_type) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(key_type)
ZEND_PARSE_PARAMETERS_END();

if (key_type != PARTS_ITERATOR_KEY_SEQUENTIAL
&& key_type != PARTS_ITERATOR_KEY_LEFT
Expand All @@ -360,9 +349,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getErrorCode)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

/* Fetch the object (without resetting its last error code ). */
bio = Z_INTL_BREAKITERATOR_P(object);
Expand All @@ -375,10 +362,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getErrorMessage)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}

ZEND_PARSE_PARAMETERS_NONE();

/* Fetch the object (without resetting its last error code ). */
bio = Z_INTL_BREAKITERATOR_P(object);
Expand All @@ -390,9 +374,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getErrorMessage)

U_CFUNC PHP_METHOD(IntlBreakIterator, getIterator)
{
if (zend_parse_parameters_none() == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_NONE();

zend_create_internal_iterator_zval(return_value, ZEND_THIS);
}
4 changes: 1 addition & 3 deletions ext/intl/breakiterator/codepointiterator_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ U_CFUNC PHP_METHOD(IntlCodePointBreakIterator, getLastCodePoint)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand Down
27 changes: 10 additions & 17 deletions ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend_er
{
char *rules;
size_t rules_len;
bool compiled = 0;
bool compiled = false;
UErrorCode status = U_ZERO_ERROR;
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b",
&rules, &rules_len, &compiled) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STRING(rules, rules_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(compiled)
ZEND_PARSE_PARAMETERS_END();

BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK;
if (bio->biter) {
Expand Down Expand Up @@ -113,9 +114,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRules)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand All @@ -138,9 +137,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRuleStatus)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand All @@ -152,9 +149,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRuleStatusVec)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand Down Expand Up @@ -185,9 +180,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getBinaryRules)
BREAKITER_METHOD_INIT_VARS;
object = ZEND_THIS;

if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_NONE();

BREAKITER_METHOD_FETCH_OBJECT;

Expand Down
8 changes: 5 additions & 3 deletions ext/intl/normalizer/normalizer_normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,11 @@ PHP_FUNCTION( normalizer_get_raw_decomposition )

intl_error_reset(NULL);

if ((zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &input, &input_length, &form) == FAILURE)) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STRING(input, input_length)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(form)
ZEND_PARSE_PARAMETERS_END();

norm = intl_get_normalizer(form, &status);

Expand Down
30 changes: 14 additions & 16 deletions ext/intl/resourcebundle/resourcebundle_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,23 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce )
/* {{{ ResourceBundle_ctor */
static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
{
const char *bundlename;
char *bundlename;
size_t bundlename_len = 0;
const char *locale;
char *locale;
size_t locale_len = 0;
bool fallback = 1;
bool fallback = true;

zval *object = return_value;
ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P( object );

intl_error_reset( NULL );

if( zend_parse_parameters( ZEND_NUM_ARGS(), "s!s!|b",
&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
{
return FAILURE;
}
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STRING_OR_NULL(locale, locale_len)
Z_PARAM_STRING_OR_NULL(bundlename, bundlename_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(fallback)
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);

if (error_handling != NULL) {
zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, error_handling);
Expand All @@ -104,7 +105,7 @@ static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling
INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);

if (locale == NULL) {
locale = intl_locale_get_default();
locale = (char *)intl_locale_get_default();
}

if (bundlename_len >= MAXPATHLEN) {
Expand Down Expand Up @@ -344,10 +345,9 @@ PHP_FUNCTION( resourcebundle_locales )

intl_errors_reset( NULL );

if( zend_parse_parameters(ZEND_NUM_ARGS(), "s", &bundlename, &bundlename_len ) == FAILURE )
{
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STRING(bundlename, bundlename_len)
ZEND_PARSE_PARAMETERS_END();

if (bundlename_len >= MAXPATHLEN) {
zend_argument_value_error(1, "is too long");
Expand Down Expand Up @@ -409,9 +409,7 @@ PHP_FUNCTION( resourcebundle_get_error_message )
/* }}} */

PHP_METHOD(ResourceBundle, getIterator) {
if (zend_parse_parameters_none() == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_NONE();

zend_create_internal_iterator_zval(return_value, ZEND_THIS);
}
Expand Down
Loading
Loading