mirror of
https://github.com/danog/ext-pq.git
synced 2024-11-30 04:19:49 +01:00
restore PHP 7 compatibility
This commit is contained in:
parent
80a38048f8
commit
d3e3e97737
@ -127,25 +127,28 @@ HashTable *php_pq_object_debug_info_70(zval *object, int *temp)
|
||||
return php_pq_object_debug_info_80(Z_OBJ_P(object), temp);
|
||||
}
|
||||
|
||||
HashTable *php_pq_object_properties_80(zend_object *object)
|
||||
static inline HashTable *php_pq_object_properties_ex(zend_object *object, HashTable *props)
|
||||
{
|
||||
struct apply_pi_to_ht_arg arg = {NULL};
|
||||
|
||||
arg.ht = zend_get_std_object_handlers()->get_properties(object);
|
||||
arg.ht = props;
|
||||
arg.pq_obj = PHP_PQ_OBJ(NULL, object);
|
||||
arg.gc = 0;
|
||||
|
||||
zend_hash_apply_with_argument(&arg.pq_obj->zo.ce->properties_info, apply_pi_to_ht, &arg);
|
||||
|
||||
return arg.ht;
|
||||
|
||||
}
|
||||
HashTable *php_pq_object_properties_80(zend_object *object)
|
||||
{
|
||||
return php_pq_object_properties_ex(object, zend_std_get_properties(object));
|
||||
}
|
||||
HashTable *php_pq_object_properties_70(zval *object)
|
||||
{
|
||||
return php_pq_object_properties_80(Z_OBJ_P(object));
|
||||
return php_pq_object_properties_ex(Z_OBJ_P(object), zend_std_get_properties(object));
|
||||
}
|
||||
|
||||
HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n)
|
||||
static inline HashTable *php_pq_object_get_gc_ex(zend_object *object, HashTable *props, zval **table, int *n)
|
||||
{
|
||||
struct apply_pi_to_ht_arg arg = {NULL};
|
||||
|
||||
@ -154,7 +157,7 @@ HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n)
|
||||
arg.gc = 1;
|
||||
|
||||
zend_hash_clean(arg.ht);
|
||||
zend_hash_copy(arg.ht, zend_std_get_properties(object), NULL);
|
||||
zend_hash_copy(arg.ht, props, NULL);
|
||||
zend_hash_apply_with_argument(&arg.pq_obj->zo.ce->properties_info, apply_pi_to_ht, &arg);
|
||||
|
||||
*table = NULL;
|
||||
@ -162,9 +165,13 @@ HashTable *php_pq_object_get_gc_80(zend_object *object, zval **table, int *n)
|
||||
|
||||
return arg.ht;
|
||||
}
|
||||
HashTable *php_pq_object_get_gc_80(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)
|
||||
{
|
||||
return php_pq_object_get_gc_80(Z_OBJ_P(object), table, n);
|
||||
return php_pq_object_get_gc_ex(Z_OBJ_P(object), zend_std_get_properties(object), table, n);
|
||||
}
|
||||
|
||||
zend_class_entry *ancestor(zend_class_entry *ce)
|
||||
@ -175,13 +182,11 @@ zend_class_entry *ancestor(zend_class_entry *ce)
|
||||
return ce;
|
||||
}
|
||||
|
||||
zval *php_pq_object_read_prop_80(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp)
|
||||
zval *php_pq_object_read_prop_ex(zend_object *object, zend_string *member, int type, void **cache_slot, zval *tmp, zval *def)
|
||||
{
|
||||
php_pq_object_t *obj = PHP_PQ_OBJ(NULL, object);
|
||||
php_pq_object_prophandler_t *handler;
|
||||
zval *return_value = NULL;
|
||||
|
||||
return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp);
|
||||
zval *return_value = def;
|
||||
|
||||
if (!obj->intern) {
|
||||
php_error(E_RECOVERABLE_ERROR, "%s not initialized", ancestor(obj->zo.ce)->name->val);
|
||||
@ -201,40 +206,54 @@ zval *php_pq_object_read_prop_80(zend_object *object, zend_string *member, int t
|
||||
|
||||
return return_value;
|
||||
}
|
||||
zval *php_pq_object_read_prop_74(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
|
||||
zval *php_pq_object_read_prop_80(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));
|
||||
}
|
||||
zval *php_pq_object_read_prop_70(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_80(Z_OBJ_P(object), member_str, type, cache_slot, tmp);
|
||||
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;
|
||||
}
|
||||
void php_pq_object_read_prop_70(zval *object, zval *member, int type, void **cache_slot, zval *tmp)
|
||||
{
|
||||
(void) php_pq_object_read_prop_74(object, member, type, cache_slot, tmp);
|
||||
}
|
||||
|
||||
zval *php_pq_object_write_prop_80(zend_object *object, zend_string *member, zval *value, void **cache_slot)
|
||||
zval *php_pq_object_write_prop_ex(zend_object *object, zend_string *member, zval *value, void **cache_slot, int *update_std)
|
||||
{
|
||||
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);
|
||||
zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
|
||||
*update_std = 1;
|
||||
} else if ((handler = zend_hash_find_ptr(obj->prophandler, member))) {
|
||||
if (handler->write) {
|
||||
handler->write(obj, value);
|
||||
}
|
||||
*update_std = 0;
|
||||
} else {
|
||||
zend_get_std_object_handlers()->write_property(object, member, value, cache_slot);
|
||||
*update_std = 1;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
zval *php_pq_object_write_prop_80(zend_object *object, zend_string *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_80(Z_OBJ_P(object), member_str, value, cache_slot);
|
||||
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);
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
void php_pq_object_write_prop_70(zval *object, zval *member, zval *value, void **cache_slot)
|
||||
|
@ -75,14 +75,11 @@ 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
|
||||
#elif PHP_VERSION_ID >= 70400
|
||||
# define php_pq_object_read_prop php_pq_object_read_prop_74
|
||||
#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_74(zval *object, zval *member, int type, void **cache_slot, zval *tmp);
|
||||
extern void php_pq_object_read_prop_70(zval *object, zval *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
|
||||
|
@ -205,7 +205,7 @@ static void php_pqlob_object_update_stream(php_pqlob_object_t *obj, zval *zstrea
|
||||
zend_get_std_object_handlers()->write_property(&obj->zo, Z_STR(zmember), zstream, NULL);
|
||||
#else
|
||||
ZVAL_OBJ(&zobj, &obj->zo);
|
||||
zend_get_std_object_handlers()->write_property(zpqlob, &zmember, zstream, NULL);
|
||||
zend_get_std_object_handlers()->write_property(&zobj, &zmember, zstream, NULL);
|
||||
#endif
|
||||
zval_ptr_dtor(&zmember);
|
||||
}
|
||||
|
@ -1195,8 +1195,22 @@ ZEND_BEGIN_ARG_INFO_EX(ai_pqres_getIterator, 0, 0, 0)
|
||||
ZEND_END_ARG_INFO();
|
||||
static PHP_METHOD(pqres, getIterator)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
zend_create_internal_iterator_zval(return_value, ZEND_THIS);
|
||||
zend_error_handling zeh;
|
||||
ZEND_RESULT_CODE rv;
|
||||
|
||||
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
|
||||
rv = zend_parse_parameters_none();
|
||||
zend_restore_error_handling(&zeh);
|
||||
|
||||
if (SUCCESS == rv) {
|
||||
php_pqres_object_t *obj = PHP_PQ_OBJ(getThis(), NULL);
|
||||
|
||||
if (!obj->intern) {
|
||||
throw_exce(EX_UNINITIALIZED, "pq\\Result not initialized");
|
||||
} else {
|
||||
zend_create_internal_iterator_zval(return_value, getThis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static zend_function_entry php_pqres_methods[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user