1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Zend: Expose zendi_try_get_long() function via a public API (#10175)

This commit is contained in:
George Peter Banyard
2023-06-19 14:07:46 +01:00
committed by GitHub
parent b0d8c10fd9
commit ea8f934fe5
2 changed files with 11 additions and 1 deletions

View File

@@ -375,7 +375,7 @@ static zend_always_inline zend_result zendi_try_convert_scalar_to_number(zval *o
}
/* }}} */
static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bool *failed) /* {{{ */
static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval *op, bool *failed) /* {{{ */
{
*failed = 0;
switch (Z_TYPE_P(op)) {
@@ -453,6 +453,15 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(zval *op, bo
}
/* }}} */
ZEND_API zend_long ZEND_FASTCALL zval_try_get_long(const zval *op, bool *failed)
{
if (EXPECTED(Z_TYPE_P(op) == IS_LONG)) {
*failed = false;
return Z_LVAL_P(op);
}
return zendi_try_get_long(op, failed);
}
#define ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(opcode) \
if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \
&& UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation))) { \

View File

@@ -275,6 +275,7 @@ ZEND_API void ZEND_FASTCALL convert_to_array(zval *op);
ZEND_API void ZEND_FASTCALL convert_to_object(zval *op);
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(const zval *op, bool is_strict);
ZEND_API zend_long ZEND_FASTCALL zval_try_get_long(const zval *op, bool *failed);
ZEND_API double ZEND_FASTCALL zval_get_double_func(const zval *op);
ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op);
ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op);