Compatible to PHP <7.3

This commit is contained in:
CismonX 2019-04-18 19:01:27 +08:00
parent b49ef617c0
commit 09205d719a

View File

@ -13,6 +13,17 @@
#ifdef PHP_ARMA_OPERATORS
#if PHP_VERSION_ID < 70300
// Before PHP 7.3, `-$a` is compile to `MUL -1, $a, ~` instead of `MUL $a, -1, ~`.
#define CONVERT_NEG_1_TO_COMPLEX(zv, type) \
else if (Z_TYPE_P(zv) == IS_LONG && Z_LVAL_P(zv) == -1) { \
zval_set_scalar(&tmp, std::complex<type>(-1)); \
zv1 = &tmp; \
}
#else
#define CONVERT_NEG_1_TO_COMPLEX(zv, type)
#endif
// For non-assignment operators, first operand can be of type double.
#define PHP_ARMA_COMPLEX_OPERATOR(type, func) \
if (instanceof_function(ce, complex<type>::ce)) { \
@ -23,6 +34,7 @@
zval_set_scalar(&tmp, std::complex<type>(real)); \
zv1 = &tmp; \
} \
CONVERT_NEG_1_TO_COMPLEX(zv1, type); \
auto v = complex<type>::operators::func(zv1, zv2, rv); \
if (Z_TYPE(tmp) != IS_UNDEF) { \
zval_ptr_dtor_nogc(&tmp); \