Manually initialize PDORow handlers

Makes it easier to see what is specified and what isn't, and allows
grepping...
This commit is contained in:
Nikita Popov 2019-01-10 12:28:32 +01:00
parent cf3317c790
commit 32de3469d9
2 changed files with 52 additions and 64 deletions

View file

@ -2262,38 +2262,7 @@ static zend_object *dbstmt_clone_obj(zval *zobject)
}
zend_object_handlers pdo_dbstmt_object_handlers;
static int pdo_row_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
void pdo_stmt_init(void)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "PDOStatement", pdo_dbstmt_functions);
pdo_dbstmt_ce = zend_register_internal_class(&ce);
pdo_dbstmt_ce->get_iterator = pdo_stmt_iter_get;
pdo_dbstmt_ce->create_object = pdo_dbstmt_new;
pdo_dbstmt_ce->serialize = zend_class_serialize_deny;
pdo_dbstmt_ce->unserialize = zend_class_unserialize_deny;
zend_class_implements(pdo_dbstmt_ce, 1, zend_ce_traversable);
zend_declare_property_null(pdo_dbstmt_ce, "queryString", sizeof("queryString")-1, ZEND_ACC_PUBLIC);
memcpy(&pdo_dbstmt_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
pdo_dbstmt_object_handlers.offset = XtOffsetOf(pdo_stmt_t, std);
pdo_dbstmt_object_handlers.dtor_obj = zend_objects_destroy_object;
pdo_dbstmt_object_handlers.free_obj = pdo_dbstmt_free_storage;
pdo_dbstmt_object_handlers.write_property = dbstmt_prop_write;
pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete;
pdo_dbstmt_object_handlers.get_method = dbstmt_method_get;
pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare;
pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj;
INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions);
pdo_row_ce = zend_register_internal_class(&ce);
pdo_row_ce->ce_flags |= ZEND_ACC_FINAL; /* when removing this a lot of handlers need to be redone */
pdo_row_ce->create_object = pdo_row_new;
pdo_row_ce->serialize = pdo_row_serialize;
pdo_row_ce->unserialize = zend_class_unserialize_deny;
}
zend_object_handlers pdo_row_object_handlers;
PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt)
{
@ -2656,37 +2625,6 @@ static int row_compare(zval *object1, zval *object2)
return -1;
}
const zend_object_handlers pdo_row_object_handlers = {
0,
zend_objects_destroy_object,
pdo_row_free_storage,
NULL,
row_prop_read,
row_prop_write,
row_dim_read,
row_dim_write,
NULL,
NULL,
NULL,
row_prop_exists,
row_prop_delete,
row_dim_exists,
row_dim_delete,
row_get_properties,
row_method_get,
row_call_method,
row_get_ctor,
row_get_classname,
row_compare,
NULL, /* cast */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
void pdo_row_free_storage(zend_object *std)
{
pdo_row_t *row = (pdo_row_t *)std;
@ -2712,6 +2650,56 @@ static int pdo_row_serialize(zval *object, unsigned char **buffer, size_t *buf_l
}
/* }}} */
void pdo_stmt_init(void)
{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "PDOStatement", pdo_dbstmt_functions);
pdo_dbstmt_ce = zend_register_internal_class(&ce);
pdo_dbstmt_ce->get_iterator = pdo_stmt_iter_get;
pdo_dbstmt_ce->create_object = pdo_dbstmt_new;
pdo_dbstmt_ce->serialize = zend_class_serialize_deny;
pdo_dbstmt_ce->unserialize = zend_class_unserialize_deny;
zend_class_implements(pdo_dbstmt_ce, 1, zend_ce_traversable);
zend_declare_property_null(pdo_dbstmt_ce, "queryString", sizeof("queryString")-1, ZEND_ACC_PUBLIC);
memcpy(&pdo_dbstmt_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
pdo_dbstmt_object_handlers.offset = XtOffsetOf(pdo_stmt_t, std);
pdo_dbstmt_object_handlers.dtor_obj = zend_objects_destroy_object;
pdo_dbstmt_object_handlers.free_obj = pdo_dbstmt_free_storage;
pdo_dbstmt_object_handlers.write_property = dbstmt_prop_write;
pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete;
pdo_dbstmt_object_handlers.get_method = dbstmt_method_get;
pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare;
pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj;
INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions);
pdo_row_ce = zend_register_internal_class(&ce);
pdo_row_ce->ce_flags |= ZEND_ACC_FINAL; /* when removing this a lot of handlers need to be redone */
pdo_row_ce->create_object = pdo_row_new;
pdo_row_ce->serialize = pdo_row_serialize;
pdo_row_ce->unserialize = zend_class_unserialize_deny;
memcpy(&pdo_row_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
pdo_row_object_handlers.free_obj = pdo_row_free_storage;
pdo_row_object_handlers.clone_obj = NULL;
pdo_row_object_handlers.get_property_ptr_ptr = NULL;
pdo_row_object_handlers.read_property = row_prop_read;
pdo_row_object_handlers.write_property = row_prop_write;
pdo_row_object_handlers.has_property = row_prop_exists;
pdo_row_object_handlers.unset_property = row_prop_delete;
pdo_row_object_handlers.read_dimension = row_dim_read;
pdo_row_object_handlers.write_dimension = row_dim_write;
pdo_row_object_handlers.has_dimension = row_dim_exists;
pdo_row_object_handlers.unset_dimension = row_dim_delete;
pdo_row_object_handlers.get_properties = row_get_properties;
pdo_row_object_handlers.get_method = row_method_get;
pdo_row_object_handlers.call_method = row_call_method;
pdo_row_object_handlers.get_constructor = row_get_ctor;
pdo_row_object_handlers.get_class_name = row_get_classname;
pdo_row_object_handlers.compare_objects = row_compare;
}
/*
* Local variables:
* tab-width: 4

View file

@ -49,7 +49,7 @@ extern zend_object *pdo_row_new(zend_class_entry *ce);
extern const zend_function_entry pdo_row_functions[];
extern zend_class_entry *pdo_row_ce;
void pdo_row_free_storage(zend_object *std);
extern const zend_object_handlers pdo_row_object_handlers;
extern zend_object_handlers pdo_row_object_handlers;
zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object);