diff --git a/src/php_pq_misc.c b/src/php_pq_misc.c index dee39d6..3e334c6 100644 --- a/src/php_pq_misc.c +++ b/src/php_pq_misc.c @@ -103,11 +103,8 @@ const char *php_pq_strmode(long mode) } } -int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr) +static inline int compare_index(zend_ulong l, zend_ulong r) { - zend_ulong l = lptr->h; - zend_ulong r = rptr->h; - if (l < r) { return -1; } @@ -116,9 +113,16 @@ int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr) } return 0; } -int php_pq_compare_index_70(const void *lptr, const void *rptr) { - return php_pq_compare_index_80((Bucket *) lptr, (Bucket *) rptr); +#if PHP_VERSION_ID >= 80000 +int php_pq_compare_index(Bucket *lptr, Bucket *rptr) +{ + return compare_index(lptr->h, rptr->h); } +#else +int php_pq_compare_index(const void *lptr, const void *rptr) { + return compare_index(((const Bucket *) lptr)->h, ((const Bucket *) rptr)->h); +} +#endif void php_pq_hash_ptr_dtor(zval *p) { diff --git a/src/php_pq_misc.h b/src/php_pq_misc.h index 1672567..8c0ea23 100644 --- a/src/php_pq_misc.h +++ b/src/php_pq_misc.h @@ -42,12 +42,10 @@ extern const char *php_pq_strmode(long mode); /* compare array index */ #if PHP_VERSION_ID >= 80000 -# define php_pq_compare_index php_pq_compare_index_80 +extern int php_pq_compare_index(Bucket *lptr, Bucket *rptr); #else -# define php_pq_compare_index php_pq_compare_index_70 +extern int php_pq_compare_index(const void *lptr, const void *rptr); #endif -extern int php_pq_compare_index_80(Bucket *lptr, Bucket *rptr); -extern int php_pq_compare_index_70(const void *lptr, const void *rptr); /* free zval ptr values (as hash dtor) */ extern void php_pq_hash_ptr_dtor(zval *p); @@ -92,10 +90,14 @@ extern HashTable *php_pq_parse_array(php_pqres_t *res, const char *val_str, size #define php_pq_cast_object(objval_ptr, cast_type, retval_ptr) \ (Z_OBJ_HT_P(objval_ptr)->cast_object && \ SUCCESS == Z_OBJ_HT_P(objval_ptr)->cast_object(objval_ptr, (retval_ptr), (cast_type))) +# if PHP_VERSION_ID <= 70200 +zval *zend_std_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv); +# endif #endif + extern PHP_MINIT_FUNCTION(pq_misc); #endif diff --git a/src/php_pq_object.c b/src/php_pq_object.c index 27d740e..ae22738 100644 --- a/src/php_pq_object.c +++ b/src/php_pq_object.c @@ -17,6 +17,7 @@ #include #include "php_pq_object.h" +#include "php_pq_misc.h" void *php_pq_object_create(zend_class_entry *ce, void *intern, size_t obj_size, zend_object_handlers *oh, HashTable *ph) { @@ -82,6 +83,8 @@ struct apply_pi_to_ht_arg { unsigned gc:1; }; +static inline int php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int type, zval *return_value); + static int apply_pi_to_ht(zval *p, void *a) { zend_property_info *pi = Z_PTR_P(p); @@ -91,23 +94,29 @@ static int apply_pi_to_ht(zval *p, void *a) php_pq_object_prophandler_t *handler; if ((handler = zend_hash_find_ptr(arg->pq_obj->prophandler, pi->name)) && handler->gc) { - zval member, return_value; + zval return_value; - ZVAL_STR(&member, pi->name); ZVAL_ARR(&return_value, arg->ht); handler->gc(arg->pq_obj, &return_value); } } else { - zval tmp_prop, *property = NULL; + zval tmp_prop, *property; +#if PHP_VERSION_ID < 80000 + zval zobj, zprop; - property = php_pq_object_read_prop_80(&arg->pq_obj->zo, pi->name, BP_VAR_R, NULL, &tmp_prop); + ZVAL_OBJ(&zobj, &arg->pq_obj->zo); + ZVAL_STR(&zprop, pi->name); + property = php_pq_object_read_prop(&zobj, &zprop, BP_VAR_R, NULL, &tmp_prop); +#else + property = php_pq_object_read_prop(&arg->pq_obj->zo, pi->name, BP_VAR_R, NULL, &tmp_prop); +#endif zend_hash_update(arg->ht, pi->name, property); } return ZEND_HASH_APPLY_KEEP; } -HashTable *php_pq_object_debug_info_80(zend_object *object, int *temp) +static inline HashTable *php_pq_object_debug_info_ex(zend_object *object, int *temp) { struct apply_pi_to_ht_arg arg = {NULL}; @@ -122,10 +131,17 @@ HashTable *php_pq_object_debug_info_80(zend_object *object, int *temp) return arg.ht; } -HashTable *php_pq_object_debug_info_70(zval *object, int *temp) +#if PHP_VERSION_ID >= 80000 +HashTable *php_pq_object_debug_info(zend_object *object, int *temp) { - return php_pq_object_debug_info_80(Z_OBJ_P(object), temp); + return php_pq_object_debug_info_ex(object, temp); } +#else +HashTable *php_pq_object_debug_info(zval *object, int *temp) +{ + return php_pq_object_debug_info_ex(Z_OBJ_P(object), temp); +} +#endif static inline HashTable *php_pq_object_properties_ex(zend_object *object, HashTable *props) { @@ -139,14 +155,17 @@ static inline HashTable *php_pq_object_properties_ex(zend_object *object, HashTa return arg.ht; } -HashTable *php_pq_object_properties_80(zend_object *object) +#if PHP_VERSION_ID >= 80000 +HashTable *php_pq_object_properties(zend_object *object) { return php_pq_object_properties_ex(object, zend_std_get_properties(object)); } -HashTable *php_pq_object_properties_70(zval *object) +#else +HashTable *php_pq_object_properties(zval *object) { return php_pq_object_properties_ex(Z_OBJ_P(object), zend_std_get_properties(object)); } +#endif static inline HashTable *php_pq_object_get_gc_ex(zend_object *object, HashTable *props, zval **table, int *n) { @@ -165,14 +184,17 @@ static inline HashTable *php_pq_object_get_gc_ex(zend_object *object, HashTable return arg.ht; } -HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n) +#if PHP_VERSION_ID >= 80000 +HashTable *php_pq_object_get_gc(zend_object *object, zval **table, int *n) { return php_pq_object_get_gc_ex(object, zend_std_get_properties(object), table, n); } -HashTable *php_pq_object_get_gc_70(zval *object, zval **table, int *n) +#else +HashTable *php_pq_object_get_gc(zval *object, zval **table, int *n) { return php_pq_object_get_gc_ex(Z_OBJ_P(object), zend_std_get_properties(object), table, n); } +#endif zend_class_entry *ancestor(zend_class_entry *ce) { @@ -182,11 +204,10 @@ zend_class_entry *ancestor(zend_class_entry *ce) return ce; } -zval *php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp, zval *def) +static inline int php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int type, zval *return_value) { php_pq_object_t *obj = PHP_PQ_OBJ(NULL, object); php_pq_object_prophandler_t *handler; - zval *return_value = def; if (!obj->intern) { php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name->val); @@ -195,80 +216,104 @@ zval *php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int t } else if (type != BP_VAR_R) { php_error(E_WARNING, "Cannot access %s properties by reference or array key/index", ancestor(obj->zo.ce)->name->val); } else { - handler->read(obj, tmp); - zend_get_std_object_handlers()->write_property(object, member, tmp, cache_slot); - return_value = tmp; - - if (cache_slot) { - *cache_slot = NULL; - } + handler->read(obj, return_value); + return SUCCESS; } - return return_value; + return FAILURE; } -zval *php_pq_object_read_prop_80(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp) +#if PHP_VERSION_ID >= 80000 +zval *php_pq_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp) { - return php_pq_object_read_prop_ex(object, member, type, cache_slot, tmp, zend_std_read_property(object, member, type, cache_slot, tmp)); + if (SUCCESS != php_pq_object_read_prop_ex(object, member, type, tmp)) { + return zend_std_read_property(object, member, type, cache_slot, tmp); + } + + tmp = zend_std_write_property(object, member, tmp, cache_slot); + if (cache_slot) { + *cache_slot = NULL; + } + return tmp; } -zval *php_pq_object_read_prop_70(zval *object, zval *member, int type, void **cache_slot, zval *tmp) +#else +zval *php_pq_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp) { zend_string *member_str = zval_get_string(member); - zval *return_value = php_pq_object_read_prop_ex(Z_OBJ_P(object), member_str, type, cache_slot, tmp, zend_std_read_property(object, member, type, cache_slot, tmp)); - zend_string_release(member_str); - return return_value; -} -zval *php_pq_object_write_prop_ex(zend_object *object, zend_string *member, zval *value, void **cache_slot, int *update_std) + if (SUCCESS != php_pq_object_read_prop_ex(Z_OBJ_P(object), member_str, type, tmp)) { + zend_string_release(member_str); + return zend_std_read_property(object, member, type, cache_slot, tmp); + } + zend_string_release(member_str); + +#if PHP_VERSON_ID >= 70400 + tmp = +#endif + zend_std_write_property(object, member, tmp, cache_slot); + if (cache_slot) { + *cache_slot = NULL; + } + return tmp; +} +#endif + +static inline int php_pq_object_write_prop_ex(zend_object *object, zend_string *member, zval *value) { php_pq_object_t *obj = PHP_PQ_OBJ(NULL, object); php_pq_object_prophandler_t *handler; if (!obj->intern) { php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name->val); - *update_std = 1; - } else if ((handler = zend_hash_find_ptr(obj->prophandler, member))) { + } else if (!(handler = zend_hash_find_ptr(obj->prophandler, member))) { + /* default handler */ + } else { if (handler->write) { handler->write(obj, value); } - *update_std = 0; - } else { - *update_std = 1; + return SUCCESS; + } + return FAILURE; +} +#if PHP_VERSION_ID >= 80000 +zval *php_pq_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot) +{ + if (SUCCESS != php_pq_object_write_prop_ex(object, member, value)) { + return zend_std_write_property(object, member, value, cache_slot); } return value; } -zval *php_pq_object_write_prop_80(zend_object *object, zend_string *member, zval *value, void **cache_slot) +#elif PHP_VERSION_ID >= 70400 +zval *php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot) { - int update_std = 0; - zval *return_value = php_pq_object_write_prop_ex(object, member, value, cache_slot, &update_std); - if (update_std) { - return_value = zend_std_write_property(object, member, value, cache_slot); - } - return return_value; -} -zval *php_pq_object_write_prop_74(zval *object, zval *member, zval *value, void **cache_slot) -{ - int update_std = 0; zend_string *member_str = zval_get_string(member); - zval *return_value = php_pq_object_write_prop_ex(Z_OBJ_P(object), member_str, value, cache_slot, &update_std); - zend_string_release(member_str); - if (update_std) { - return_value = zend_std_write_property(object, member, value, cache_slot); + if (SUCCESS != php_pq_object_write_prop_ex(Z_OBJ_P(object), member_str, value)) { + value = zend_std_write_property(object, member, value, cache_slot); } - return return_value; + zend_string_release(member_str); + return value; } -void php_pq_object_write_prop_70(zval *object, zval *member, zval *value, void **cache_slot) +#else +void php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot) { - (void) php_pq_object_write_prop_74(object, member, value, cache_slot); + zend_string *member_str = zval_get_string(member); + if (SUCCESS != php_pq_object_write_prop_ex(Z_OBJ_P(object), member_str, value)) { + zend_std_write_property(object, member, value, cache_slot); + } + zend_string_release(member_str); } +#endif -zval *php_pq_object_get_prop_ptr_null_80(zend_object *object, zend_string *member, int type, void **cache_slot) +#if PHP_VERSION_ID >= 80000 +zval *php_pq_object_get_prop_ptr_null(zend_object *object, zend_string *member, int type, void **cache_slot) { return NULL; } -zval *php_pq_object_get_prop_ptr_null_70(zval *object, zval *member, int type, void **cache_slot) +#else +zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot) { return NULL; } +#endif void php_pq_object_prophandler_dtor(zval *zv) { pefree(Z_PTR_P(zv), 1); diff --git a/src/php_pq_object.h b/src/php_pq_object.h index f8aba1b..0d86883 100644 --- a/src/php_pq_object.h +++ b/src/php_pq_object.h @@ -50,55 +50,24 @@ extern void php_pq_object_addref(void *o); extern void php_pq_object_delref(void *o); #if PHP_VERSION_ID >= 80000 -# define php_pq_object_debug_info php_pq_object_debug_info_80 +extern HashTable *php_pq_object_debug_info(zend_object *object, int *temp); +extern HashTable *php_pq_object_properties(zend_object *object); +extern HashTable *php_pq_object_get_gc(zend_object *object, zval **table, int *n); +extern zval *php_pq_object_read_prop(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp); +extern zval *php_pq_object_write_prop(zend_object *object, zend_string *member, zval *value, void **cache_slot); +extern zval *php_pq_object_get_prop_ptr_null(zend_object *object, zend_string *member, int type, void **cache_slot); #else -# define php_pq_object_debug_info php_pq_object_debug_info_70 +extern HashTable *php_pq_object_debug_info(zval *object, int *temp); +extern HashTable *php_pq_object_properties(zval *object); +extern HashTable *php_pq_object_get_gc(zval *object, zval **table, int *n); +extern zval *php_pq_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp); +# if PHP_VERSION_ID >= 70400 +extern zval *php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot); +# else +extern void php_pq_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot); +# endif +extern zval *php_pq_object_get_prop_ptr_null(zval *object, zval *member, int type, void **cache_slot); #endif -extern HashTable *php_pq_object_debug_info_80(zend_object *object, int *temp); -extern HashTable *php_pq_object_debug_info_70(zval *object, int *temp); - -#if PHP_VERSION_ID >= 80000 -# define php_pq_object_properties php_pq_object_properties_80 -#else -# define php_pq_object_properties php_pq_object_properties_70 -#endif -extern HashTable *php_pq_object_properties_80(zend_object *object); -extern HashTable *php_pq_object_properties_70(zval *object); - -#if PHP_VERSION_ID >= 80000 -# define php_pq_object_get_gc php_pq_object_get_gc_80 -#else -# define php_pq_object_get_gc php_pq_object_get_gc_70 -#endif -extern HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n); -extern HashTable *php_pq_object_get_gc_70(zval *object, zval **table, int *n); - -#if PHP_VERSION_ID >= 80000 -# define php_pq_object_read_prop php_pq_object_read_prop_80 -#else -# define php_pq_object_read_prop php_pq_object_read_prop_70 -#endif -extern zval *php_pq_object_read_prop_80(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp); -extern zval *php_pq_object_read_prop_70(zval *object, zval *member, int type, void **cache_slot, zval *tmp); - -#if PHP_VERSION_ID >= 80000 -# define php_pq_object_write_prop php_pq_object_write_prop_80 -#elif PHP_VERSION_ID >= 70400 -# define php_pq_object_write_prop php_pq_object_write_prop_74 -#else -# define php_pq_object_write_prop php_pq_object_write_prop_70 -#endif -extern zval *php_pq_object_write_prop_80(zend_object *object, zend_string *member, zval *value, void **cache_slot); -extern zval *php_pq_object_write_prop_74(zval *object, zval *member, zval *value, void **cache_slot); -extern void php_pq_object_write_prop_70(zval *object, zval *member, zval *value, void **cache_slot); - -#if PHP_VERSION_ID >= 80000 -# define php_pq_object_get_prop_ptr_null php_pq_object_get_prop_ptr_null_80 -#else -# define php_pq_object_get_prop_ptr_null php_pq_object_get_prop_ptr_null_70 -#endif -extern zval *php_pq_object_get_prop_ptr_null_80(zend_object *object, zend_string *member, int type, void **cache_slot); -extern zval *php_pq_object_get_prop_ptr_null_70(zval *object, zval *member, int type, void **cache_slot); #endif diff --git a/src/php_pqconn.c b/src/php_pqconn.c index da07ff3..fd5ec64 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -515,9 +515,9 @@ static ZEND_RESULT_CODE php_pqconn_update_socket(zval *zobj, php_pqconn_object_t retval = FAILURE; } #if PHP_VERSION_ID >= 80000 - zend_get_std_object_handlers()->write_property(Z_OBJ_P(zobj), Z_STR(zmember), &zsocket, NULL); + zend_std_write_property(Z_OBJ_P(zobj), Z_STR(zmember), &zsocket, NULL); #else - zend_get_std_object_handlers()->write_property(zobj, &zmember, &zsocket, NULL); + zend_std_write_property(zobj, &zmember, &zsocket, NULL); #endif zval_ptr_dtor(&zsocket); zval_ptr_dtor(&zmember); diff --git a/src/php_pqlob.c b/src/php_pqlob.c index f183337..0c1fc28 100644 --- a/src/php_pqlob.c +++ b/src/php_pqlob.c @@ -202,10 +202,10 @@ static void php_pqlob_object_update_stream(php_pqlob_object_t *obj, zval *zstrea php_stream_to_zval(obj->intern->stream, zstream); #if PHP_VERSION_ID >= 80000 - zend_get_std_object_handlers()->write_property(&obj->zo, Z_STR(zmember), zstream, NULL); + zend_std_write_property(&obj->zo, Z_STR(zmember), zstream, NULL); #else ZVAL_OBJ(&zobj, &obj->zo); - zend_get_std_object_handlers()->write_property(&zobj, &zmember, zstream, NULL); + zend_std_write_property(&zobj, &zmember, zstream, NULL); #endif zval_ptr_dtor(&zmember); } diff --git a/src/php_pqres.c b/src/php_pqres.c index e9608ef..7e51271 100644 --- a/src/php_pqres.c +++ b/src/php_pqres.c @@ -383,12 +383,7 @@ static zend_object_iterator_funcs php_pqres_iterator_funcs = { #endif }; -#if PHP_VERSION_ID >= 80000 -# define php_pqres_count_elements php_pqres_count_elements_80 -#else -# define php_pqres_count_elements php_pqres_count_elements_70 -#endif -static ZEND_RESULT_CODE php_pqres_count_elements_80(zend_object *object, long *count) +static inline ZEND_RESULT_CODE php_pqres_count_elements_ex(zend_object *object, long *count) { php_pqres_object_t *obj = PHP_PQ_OBJ(NULL, object); @@ -399,10 +394,17 @@ static ZEND_RESULT_CODE php_pqres_count_elements_80(zend_object *object, long *c return SUCCESS; } } -static ZEND_RESULT_CODE php_pqres_count_elements_70(zval *object, long *count) +#if PHP_VERSION_ID >= 80000 +static ZEND_RESULT_CODE php_pqres_count_elements(zend_object *object, long *count) { - return php_pqres_count_elements_80(Z_OBJ_P(object), count); + return php_pqres_count_elements_ex(object, count); } +#else +static ZEND_RESULT_CODE php_pqres_count_elements(zval *object, long *count) +{ + return php_pqres_count_elements_ex(Z_OBJ_P(object), count); +} +#endif ZEND_RESULT_CODE php_pqres_success(PGresult *res) { @@ -1157,7 +1159,7 @@ static PHP_METHOD(pqres, count) { if (SUCCESS == rv) { long count; - if (SUCCESS != php_pqres_count_elements_70(getThis(), &count)) { + if (SUCCESS != php_pqres_count_elements_ex(Z_OBJ_P(getThis()), &count)) { throw_exce(EX_UNINITIALIZED, "pq\\Result not initialized"); } else { RETVAL_LONG(count); @@ -1191,6 +1193,7 @@ static PHP_METHOD(pqres, desc) { } } +#if PHP_VERSION_ID >= 80000 ZEND_BEGIN_ARG_INFO_EX(ai_pqres_getIterator, 0, 0, 0) ZEND_END_ARG_INFO(); static PHP_METHOD(pqres, getIterator) @@ -1212,6 +1215,7 @@ static PHP_METHOD(pqres, getIterator) } } } +#endif static zend_function_entry php_pqres_methods[] = { PHP_ME(pqres, bind, ai_pqres_bind, ZEND_ACC_PUBLIC) @@ -1223,7 +1227,9 @@ static zend_function_entry php_pqres_methods[] = { PHP_ME(pqres, count, ai_pqres_count, ZEND_ACC_PUBLIC) PHP_ME(pqres, map, ai_pqres_map, ZEND_ACC_PUBLIC) PHP_ME(pqres, desc, ai_pqres_desc, ZEND_ACC_PUBLIC) +#if PHP_VERSION_ID >= 80000 PHP_ME(pqres, getIterator, ai_pqres_getIterator, ZEND_ACC_PUBLIC) +#endif {0} }; @@ -1242,7 +1248,11 @@ PHP_MINIT_FUNCTION(pqres) php_pqres_class_entry = zend_register_internal_class_ex(&ce, NULL); php_pqres_class_entry->create_object = php_pqres_create_object; php_pqres_class_entry->get_iterator = php_pqres_iterator_init; +#if PHP_VERSION_ID >= 80000 zend_class_implements(php_pqres_class_entry, 2, zend_ce_aggregate, spl_ce_Countable); +#else + zend_class_implements(php_pqres_class_entry, 2, zend_ce_traversable, spl_ce_Countable); +#endif memcpy(&php_pqres_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_pqres_object_handlers.offset = XtOffsetOf(php_pqres_object_t, zo); diff --git a/src/php_pqtypes.c b/src/php_pqtypes.c index 01e4e32..b1f36cf 100644 --- a/src/php_pqtypes.c +++ b/src/php_pqtypes.c @@ -69,7 +69,7 @@ static void php_pqtypes_object_gc_connection(void *o, zval *return_value) add_next_index_zval(return_value, &zconn); } -static int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_long *index) +static inline int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_long *index) { if (Z_TYPE_P(member) == IS_LONG) { *index = Z_LVAL_P(member); @@ -94,12 +94,7 @@ static int has_dimension(HashTable *ht, zval *member, zend_string **key, zend_lo } } -#if PHP_VERSION_ID >= 80000 -# define php_pqtypes_object_has_dimension php_pqtypes_object_has_dimension_80 -#else -# define php_pqtypes_object_has_dimension php_pqtypes_object_has_dimension_70 -#endif -static int php_pqtypes_object_has_dimension_80(zend_object *object, zval *member, int check_empty) +static inline int php_pqtypes_object_has_dimension_ex(zend_object *object, zval *member, int check_empty) { php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object); zend_string *key = NULL; @@ -128,17 +123,19 @@ static int php_pqtypes_object_has_dimension_80(zend_object *object, zval *member return 0; } -static int php_pqtypes_object_has_dimension_70(zval *object, zval *member, int check_empty) -{ - return php_pqtypes_object_has_dimension_80(Z_OBJ_P(object), member, check_empty); -} - #if PHP_VERSION_ID >= 80000 -# define php_pqtypes_object_read_dimension php_pqtypes_object_read_dimension_80 +static int php_pqtypes_object_has_dimension(zend_object *object, zval *member, int check_empty) +{ + return php_pqtypes_object_has_dimension_ex(object, member, check_empty); +} #else -# define php_pqtypes_object_read_dimension php_pqtypes_object_read_dimension_70 +static int php_pqtypes_object_has_dimension(zval *object, zval *member, int check_empty) +{ + return php_pqtypes_object_has_dimension_ex(Z_OBJ_P(object), member, check_empty); +} #endif -static zval *php_pqtypes_object_read_dimension_80(zend_object *object, zval *member, int type, zval *rv) + +static inline zval *php_pqtypes_object_read_dimension_ex(zend_object *object, zval *member, int type, zval *rv) { php_pqtypes_object_t *obj = PHP_PQ_OBJ(NULL, object); zend_string *key = NULL; @@ -156,38 +153,41 @@ static zval *php_pqtypes_object_read_dimension_80(zend_object *object, zval *mem return data; } -static zval *php_pqtypes_object_read_dimension_70(zval *object, zval *member, int type, zval *rv) +#if PHP_VERSION_ID >= 80000 +static zval *php_pqtypes_object_read_dimension(zend_object *object, zval *member, int type, zval *rv) { - return php_pqtypes_object_read_dimension_80(Z_OBJ_P(object), member, type, rv); + return php_pqtypes_object_read_dimension_ex(object, member, type, rv); } +#else +static zval *php_pqtypes_object_read_dimension(zval *object, zval *member, int type, zval *rv) +{ + return php_pqtypes_object_read_dimension_ex(Z_OBJ_P(object), member, type, rv); +} +#endif #if PHP_VERSION_ID >= 80000 -# define php_pqtypes_object_write_dimension php_pqtypes_object_write_dimension_80 +static void php_pqtypes_object_write_dimension(zend_object *object, zval *offset, zval *value) +{ + throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); +} #else -# define php_pqtypes_object_write_dimension php_pqtypes_object_write_dimension_70 +static void php_pqtypes_object_write_dimension(zval *object, zval *offset, zval *value) +{ + throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); +} #endif -static void php_pqtypes_object_write_dimension_80(zend_object *object, zval *offset, zval *value) -{ - throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); -} -static void php_pqtypes_object_write_dimension_70(zval *object, zval *offset, zval *value) -{ - throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); -} #if PHP_VERSION_ID >= 80000 -# define php_pqtypes_object_unset_dimension php_pqtypes_object_unset_dimension_80 +static void php_pqtypes_object_unset_dimension(zend_object *object, zval *offset) +{ + throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); +} #else -# define php_pqtypes_object_unset_dimension php_pqtypes_object_unset_dimension_70 +static void php_pqtypes_object_unset_dimension(zval *object, zval *offset) +{ + throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); +} #endif -static void php_pqtypes_object_unset_dimension_80(zend_object *object, zval *offset) -{ - throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); -} -static void php_pqtypes_object_unset_dimension_70(zval *object, zval *offset) -{ - throw_exce(EX_RUNTIME, "pq\\Types object must not be modified"); -} ZEND_BEGIN_ARG_INFO_EX(ai_pqtypes_construct, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 0)