Skip to content

Commit c8a8d8a

Browse files
authored
ext/intl last chunk of fast ZPP conversion (#14431)
1 parent 354b647 commit c8a8d8a

7 files changed

+77
-111
lines changed

ext/intl/breakiterator/breakiterator_iterators.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ U_CFUNC PHP_METHOD(IntlPartsIterator, getBreakIterator)
246246
{
247247
INTLITERATOR_METHOD_INIT_VARS;
248248

249-
if (zend_parse_parameters_none() == FAILURE) {
250-
RETURN_THROWS();
251-
}
249+
ZEND_PARSE_PARAMETERS_NONE();
252250

253251
INTLITERATOR_METHOD_FETCH_OBJECT;
254252

@@ -259,9 +257,7 @@ U_CFUNC PHP_METHOD(IntlPartsIterator, getRuleStatus)
259257
{
260258
INTLITERATOR_METHOD_INIT_VARS;
261259

262-
if (zend_parse_parameters_none() == FAILURE) {
263-
RETURN_THROWS();
264-
}
260+
ZEND_PARSE_PARAMETERS_NONE();
265261

266262
INTLITERATOR_METHOD_FETCH_OBJECT;
267263

ext/intl/breakiterator/breakiterator_methods.cpp

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ static void _breakiter_factory(const char *func_name,
4646
INTERNAL_FUNCTION_PARAMETERS)
4747
{
4848
BreakIterator *biter;
49-
const char *locale_str = NULL;
49+
char *locale_str = NULL;
5050
size_t dummy;
5151
char *msg;
5252
UErrorCode status = UErrorCode();
5353
intl_error_reset(NULL);
5454

55-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!",
56-
&locale_str, &dummy) == FAILURE) {
57-
RETURN_THROWS();
58-
}
55+
ZEND_PARSE_PARAMETERS_START(0, 1)
56+
Z_PARAM_OPTIONAL
57+
Z_PARAM_STRING_OR_NULL(locale_str, dummy)
58+
ZEND_PARSE_PARAMETERS_END();
5959

6060
if (locale_str == NULL) {
61-
locale_str = intl_locale_get_default();
61+
locale_str = (char *)intl_locale_get_default();
6262
}
6363

6464
biter = func(Locale::createFromName(locale_str), status);
@@ -113,9 +113,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, createCodePointInstance)
113113
{
114114
intl_error_reset(NULL);
115115

116-
if (zend_parse_parameters_none() == FAILURE) {
117-
RETURN_THROWS();
118-
}
116+
ZEND_PARSE_PARAMETERS_NONE();
119117

120118
CodePointBreakIterator *cpbi = new CodePointBreakIterator();
121119
breakiterator_object_create(return_value, cpbi, 1);
@@ -126,9 +124,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getText)
126124
BREAKITER_METHOD_INIT_VARS;
127125
object = ZEND_THIS;
128126

129-
if (zend_parse_parameters_none() == FAILURE) {
130-
RETURN_THROWS();
131-
}
127+
ZEND_PARSE_PARAMETERS_NONE();
132128

133129
BREAKITER_METHOD_FETCH_OBJECT;
134130

@@ -146,9 +142,9 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, setText)
146142
BREAKITER_METHOD_INIT_VARS;
147143
object = ZEND_THIS;
148144

149-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &text) == FAILURE) {
150-
RETURN_THROWS();
151-
}
145+
ZEND_PARSE_PARAMETERS_START(1, 1)
146+
Z_PARAM_STR(text)
147+
ZEND_PARSE_PARAMETERS_END();
152148

153149
BREAKITER_METHOD_FETCH_OBJECT;
154150

@@ -176,9 +172,7 @@ static void _breakiter_no_args_ret_int32(
176172
BREAKITER_METHOD_INIT_VARS;
177173
object = ZEND_THIS;
178174

179-
if (zend_parse_parameters_none() == FAILURE) {
180-
RETURN_THROWS();
181-
}
175+
ZEND_PARSE_PARAMETERS_NONE();
182176

183177
BREAKITER_METHOD_FETCH_OBJECT;
184178

@@ -195,9 +189,9 @@ static void _breakiter_int32_ret_int32(
195189
BREAKITER_METHOD_INIT_VARS;
196190
object = ZEND_THIS;
197191

198-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &arg) == FAILURE) {
199-
RETURN_THROWS();
200-
}
192+
ZEND_PARSE_PARAMETERS_START(1, 1)
193+
Z_PARAM_LONG(arg)
194+
ZEND_PARSE_PARAMETERS_END();
201195

202196
BREAKITER_METHOD_FETCH_OBJECT;
203197

@@ -233,16 +227,13 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, next)
233227
{
234228
zval *arg = NULL;
235229

236-
if (ZEND_NUM_ARGS() == 0) {
237-
goto no_arg_version;
238-
}
239-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z!", &arg) == FAILURE) {
240-
RETURN_THROWS();
241-
}
230+
ZEND_PARSE_PARAMETERS_START(0, 1)
231+
Z_PARAM_OPTIONAL
232+
Z_PARAM_ZVAL_OR_NULL(arg)
233+
ZEND_PARSE_PARAMETERS_END();
242234

243235
if (arg == NULL) {
244-
ZEND_NUM_ARGS() = 0; /* pretend we don't have any argument */
245-
no_arg_version:
236+
ZEND_NUM_ARGS() = 0;
246237
_breakiter_no_args_ret_int32(&BreakIterator::next,
247238
INTERNAL_FUNCTION_PARAM_PASSTHRU);
248239
} else {
@@ -256,9 +247,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, current)
256247
BREAKITER_METHOD_INIT_VARS;
257248
object = ZEND_THIS;
258249

259-
if (zend_parse_parameters_none() == FAILURE) {
260-
RETURN_THROWS();
261-
}
250+
ZEND_PARSE_PARAMETERS_NONE();
262251

263252
BREAKITER_METHOD_FETCH_OBJECT;
264253

@@ -287,10 +276,9 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, isBoundary)
287276
BREAKITER_METHOD_INIT_VARS;
288277
object = ZEND_THIS;
289278

290-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l",
291-
&offset) == FAILURE) {
292-
RETURN_THROWS();
293-
}
279+
ZEND_PARSE_PARAMETERS_START(1, 1)
280+
Z_PARAM_LONG(offset)
281+
ZEND_PARSE_PARAMETERS_END();
294282

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

313-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &locale_type) == FAILURE) {
314-
RETURN_THROWS();
315-
}
301+
ZEND_PARSE_PARAMETERS_START(1, 1)
302+
Z_PARAM_LONG(locale_type)
303+
ZEND_PARSE_PARAMETERS_END();
316304

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

340-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &key_type) == FAILURE) {
341-
RETURN_THROWS();
342-
}
328+
ZEND_PARSE_PARAMETERS_START(0, 1)
329+
Z_PARAM_OPTIONAL
330+
Z_PARAM_LONG(key_type)
331+
ZEND_PARSE_PARAMETERS_END();
343332

344333
if (key_type != PARTS_ITERATOR_KEY_SEQUENTIAL
345334
&& key_type != PARTS_ITERATOR_KEY_LEFT
@@ -360,9 +349,7 @@ U_CFUNC PHP_METHOD(IntlBreakIterator, getErrorCode)
360349
BREAKITER_METHOD_INIT_VARS;
361350
object = ZEND_THIS;
362351

363-
if (zend_parse_parameters_none() == FAILURE) {
364-
RETURN_THROWS();
365-
}
352+
ZEND_PARSE_PARAMETERS_NONE();
366353

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

378-
if (zend_parse_parameters_none() == FAILURE) {
379-
RETURN_THROWS();
380-
}
381-
365+
ZEND_PARSE_PARAMETERS_NONE();
382366

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

391375
U_CFUNC PHP_METHOD(IntlBreakIterator, getIterator)
392376
{
393-
if (zend_parse_parameters_none() == FAILURE) {
394-
return;
395-
}
377+
ZEND_PARSE_PARAMETERS_NONE();
396378

397379
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
398380
}

ext/intl/breakiterator/codepointiterator_methods.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ U_CFUNC PHP_METHOD(IntlCodePointBreakIterator, getLastCodePoint)
3030
BREAKITER_METHOD_INIT_VARS;
3131
object = ZEND_THIS;
3232

33-
if (zend_parse_parameters_none() == FAILURE) {
34-
RETURN_THROWS();
35-
}
33+
ZEND_PARSE_PARAMETERS_NONE();
3634

3735
BREAKITER_METHOD_FETCH_OBJECT;
3836

ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS, zend_er
3636
{
3737
char *rules;
3838
size_t rules_len;
39-
bool compiled = 0;
39+
bool compiled = false;
4040
UErrorCode status = U_ZERO_ERROR;
4141
BREAKITER_METHOD_INIT_VARS;
4242
object = ZEND_THIS;
4343

44-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b",
45-
&rules, &rules_len, &compiled) == FAILURE) {
46-
RETURN_THROWS();
47-
}
44+
ZEND_PARSE_PARAMETERS_START(1, 2)
45+
Z_PARAM_STRING(rules, rules_len)
46+
Z_PARAM_OPTIONAL
47+
Z_PARAM_BOOL(compiled)
48+
ZEND_PARSE_PARAMETERS_END();
4849

4950
BREAKITER_METHOD_FETCH_OBJECT_NO_CHECK;
5051
if (bio->biter) {
@@ -113,9 +114,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRules)
113114
BREAKITER_METHOD_INIT_VARS;
114115
object = ZEND_THIS;
115116

116-
if (zend_parse_parameters_none() == FAILURE) {
117-
RETURN_THROWS();
118-
}
117+
ZEND_PARSE_PARAMETERS_NONE();
119118

120119
BREAKITER_METHOD_FETCH_OBJECT;
121120

@@ -138,9 +137,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRuleStatus)
138137
BREAKITER_METHOD_INIT_VARS;
139138
object = ZEND_THIS;
140139

141-
if (zend_parse_parameters_none() == FAILURE) {
142-
RETURN_THROWS();
143-
}
140+
ZEND_PARSE_PARAMETERS_NONE();
144141

145142
BREAKITER_METHOD_FETCH_OBJECT;
146143

@@ -152,9 +149,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getRuleStatusVec)
152149
BREAKITER_METHOD_INIT_VARS;
153150
object = ZEND_THIS;
154151

155-
if (zend_parse_parameters_none() == FAILURE) {
156-
RETURN_THROWS();
157-
}
152+
ZEND_PARSE_PARAMETERS_NONE();
158153

159154
BREAKITER_METHOD_FETCH_OBJECT;
160155

@@ -185,9 +180,7 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, getBinaryRules)
185180
BREAKITER_METHOD_INIT_VARS;
186181
object = ZEND_THIS;
187182

188-
if (zend_parse_parameters_none() == FAILURE) {
189-
RETURN_THROWS();
190-
}
183+
ZEND_PARSE_PARAMETERS_NONE();
191184

192185
BREAKITER_METHOD_FETCH_OBJECT;
193186

ext/intl/normalizer/normalizer_normalize.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,11 @@ PHP_FUNCTION( normalizer_get_raw_decomposition )
316316

317317
intl_error_reset(NULL);
318318

319-
if ((zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &input, &input_length, &form) == FAILURE)) {
320-
RETURN_THROWS();
321-
}
319+
ZEND_PARSE_PARAMETERS_START(1, 2)
320+
Z_PARAM_STRING(input, input_length)
321+
Z_PARAM_OPTIONAL
322+
Z_PARAM_LONG(form)
323+
ZEND_PARSE_PARAMETERS_END();
322324

323325
norm = intl_get_normalizer(form, &status);
324326

ext/intl/resourcebundle/resourcebundle_class.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,23 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce )
7474
/* {{{ ResourceBundle_ctor */
7575
static int resourcebundle_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handling *error_handling, bool *error_handling_replaced)
7676
{
77-
const char *bundlename;
77+
char *bundlename;
7878
size_t bundlename_len = 0;
79-
const char *locale;
79+
char *locale;
8080
size_t locale_len = 0;
81-
bool fallback = 1;
81+
bool fallback = true;
8282

8383
zval *object = return_value;
8484
ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P( object );
8585

8686
intl_error_reset( NULL );
8787

88-
if( zend_parse_parameters( ZEND_NUM_ARGS(), "s!s!|b",
89-
&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
90-
{
91-
return FAILURE;
92-
}
88+
ZEND_PARSE_PARAMETERS_START(2, 3)
89+
Z_PARAM_STRING_OR_NULL(locale, locale_len)
90+
Z_PARAM_STRING_OR_NULL(bundlename, bundlename_len)
91+
Z_PARAM_OPTIONAL
92+
Z_PARAM_BOOL(fallback)
93+
ZEND_PARSE_PARAMETERS_END_EX(return FAILURE);
9394

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

106107
if (locale == NULL) {
107-
locale = intl_locale_get_default();
108+
locale = (char *)intl_locale_get_default();
108109
}
109110

110111
if (bundlename_len >= MAXPATHLEN) {
@@ -344,10 +345,9 @@ PHP_FUNCTION( resourcebundle_locales )
344345

345346
intl_errors_reset( NULL );
346347

347-
if( zend_parse_parameters(ZEND_NUM_ARGS(), "s", &bundlename, &bundlename_len ) == FAILURE )
348-
{
349-
RETURN_THROWS();
350-
}
348+
ZEND_PARSE_PARAMETERS_START(1, 1)
349+
Z_PARAM_STRING(bundlename, bundlename_len)
350+
ZEND_PARSE_PARAMETERS_END();
351351

352352
if (bundlename_len >= MAXPATHLEN) {
353353
zend_argument_value_error(1, "is too long");
@@ -409,9 +409,7 @@ PHP_FUNCTION( resourcebundle_get_error_message )
409409
/* }}} */
410410

411411
PHP_METHOD(ResourceBundle, getIterator) {
412-
if (zend_parse_parameters_none() == FAILURE) {
413-
return;
414-
}
412+
ZEND_PARSE_PARAMETERS_NONE();
415413

416414
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
417415
}

0 commit comments

Comments
 (0)