From 6c838021951716e5b37a0c891cd40c669268de8c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sat, 13 Apr 2013 17:55:44 +0200 Subject: [PATCH] implemented get_properties() object handler --- package.xml | 6 +++--- php_pq.h | 2 +- src/php_pq_object.c | 12 +++++++++++- src/php_pq_object.h | 1 + src/php_pqcancel.c | 1 + src/php_pqconn.c | 1 + src/php_pqcopy.c | 1 + src/php_pqlob.c | 1 + src/php_pqres.c | 1 + src/php_pqstm.c | 1 + src/php_pqtxn.c | 1 + src/php_pqtypes.c | 1 + 12 files changed, 24 insertions(+), 5 deletions(-) diff --git a/package.xml b/package.xml index 8f2a701..67dfa0d 100644 --- a/package.xml +++ b/package.xml @@ -19,9 +19,9 @@ http://pear.php.net/dtd/package-2.0.xsd"> mike@php.net yes - 2013-03-22 + 2013-04-13 - 0.1.0 + 0.2.0dev 0.1.0 @@ -30,7 +30,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> BSD, revised diff --git a/php_pq.h b/php_pq.h index 5021711..8eb8495 100644 --- a/php_pq.h +++ b/php_pq.h @@ -14,7 +14,7 @@ #ifndef PHP_PQ_H #define PHP_PQ_H -#define PHP_PQ_EXT_VERSION "0.1.0" +#define PHP_PQ_EXT_VERSION "0.2.0dev" int pq_module_number; zend_module_entry pq_module_entry; diff --git a/src/php_pq_object.c b/src/php_pq_object.c index 78db20f..704737f 100644 --- a/src/php_pq_object.c +++ b/src/php_pq_object.c @@ -70,7 +70,7 @@ static int apply_pi_to_ht(void *p TSRMLS_DC, int argc, va_list argv, zend_hash_k if (addref) { Z_ADDREF_P(property); } - zend_hash_add(ht, pi->name, pi->name_length + 1, (void *) &property, sizeof(zval *), NULL); + zend_hash_update(ht, pi->name, pi->name_length + 1, (void *) &property, sizeof(zval *), NULL); return ZEND_HASH_APPLY_KEEP; } @@ -89,6 +89,16 @@ HashTable *php_pq_object_debug_info(zval *object, int *temp TSRMLS_DC) return ht; } +HashTable *php_pq_object_properties(zval *object TSRMLS_DC) +{ + HashTable *ht = zend_get_std_object_handlers()->get_properties(object TSRMLS_CC); + php_pq_object_t *obj = zend_object_store_get_object(object TSRMLS_CC); + + zend_hash_apply_with_arguments(&obj->zo.ce->properties_info TSRMLS_CC, apply_pi_to_ht, 4, ht, object, obj, 1); + + return ht; +} + zend_class_entry *ancestor(zend_class_entry *ce) { while (ce->parent) { diff --git a/src/php_pq_object.h b/src/php_pq_object.h index 7bbdd84..311f17f 100644 --- a/src/php_pq_object.h +++ b/src/php_pq_object.h @@ -32,6 +32,7 @@ void php_pq_object_to_zval_no_addref(void *o, zval **zv TSRMLS_DC); void php_pq_object_addref(void *o TSRMLS_DC); void php_pq_object_delref(void *o TSRMLS_DC); HashTable *php_pq_object_debug_info(zval *object, int *temp TSRMLS_DC); +HashTable *php_pq_object_properties(zval *object TSRMLS_DC); zend_class_entry *ancestor(zend_class_entry *ce); zval *php_pq_object_read_prop(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC); void php_pq_object_write_prop(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC); diff --git a/src/php_pqcancel.c b/src/php_pqcancel.c index 326cbcd..8f3d9da 100644 --- a/src/php_pqcancel.c +++ b/src/php_pqcancel.c @@ -158,6 +158,7 @@ PHP_MINIT_FUNCTION(pqcancel) php_pqcancel_object_handlers.write_property = php_pq_object_write_prop; php_pqcancel_object_handlers.clone_obj = NULL; php_pqcancel_object_handlers.get_property_ptr_ptr = NULL; + php_pqcancel_object_handlers.get_properties = php_pq_object_properties; php_pqcancel_object_handlers.get_debug_info = php_pq_object_debug_info; zend_hash_init(&php_pqcancel_object_prophandlers, 1, NULL, NULL, 1); diff --git a/src/php_pqconn.c b/src/php_pqconn.c index e71199d..5031426 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -1502,6 +1502,7 @@ PHP_MINIT_FUNCTION(pqconn) php_pqconn_object_handlers.write_property = php_pq_object_write_prop; php_pqconn_object_handlers.clone_obj = NULL; php_pqconn_object_handlers.get_property_ptr_ptr = NULL; + php_pqconn_object_handlers.get_properties = php_pq_object_properties; php_pqconn_object_handlers.get_debug_info = php_pq_object_debug_info; zend_hash_init(&php_pqconn_object_prophandlers, 14, NULL, NULL, 1); diff --git a/src/php_pqcopy.c b/src/php_pqcopy.c index 89ab68c..1ea8a50 100644 --- a/src/php_pqcopy.c +++ b/src/php_pqcopy.c @@ -322,6 +322,7 @@ PHP_MINIT_FUNCTION(pqcopy) php_pqcopy_object_handlers.write_property = php_pq_object_write_prop; php_pqcopy_object_handlers.clone_obj = NULL; php_pqcopy_object_handlers.get_property_ptr_ptr = NULL; + php_pqcopy_object_handlers.get_properties = php_pq_object_properties; php_pqcopy_object_handlers.get_debug_info = php_pq_object_debug_info; zend_hash_init(&php_pqcopy_object_prophandlers, 4, NULL, NULL, 1); diff --git a/src/php_pqlob.c b/src/php_pqlob.c index 9f3717d..2dc9be3 100644 --- a/src/php_pqlob.c +++ b/src/php_pqlob.c @@ -463,6 +463,7 @@ PHP_MINIT_FUNCTION(pqlob) php_pqlob_object_handlers.write_property = php_pq_object_write_prop; php_pqlob_object_handlers.clone_obj = NULL; php_pqlob_object_handlers.get_property_ptr_ptr = NULL; + php_pqlob_object_handlers.get_properties = php_pq_object_properties; php_pqlob_object_handlers.get_debug_info = php_pq_object_debug_info; zend_hash_init(&php_pqlob_object_prophandlers, 3, NULL, NULL, 1); diff --git a/src/php_pqres.c b/src/php_pqres.c index a1e1d00..57818f4 100644 --- a/src/php_pqres.c +++ b/src/php_pqres.c @@ -880,6 +880,7 @@ PHP_MINIT_FUNCTION(pqres) php_pqres_object_handlers.clone_obj = NULL; php_pqres_object_handlers.get_property_ptr_ptr = NULL; php_pqres_object_handlers.get_debug_info = php_pq_object_debug_info; + php_pqres_object_handlers.get_properties = php_pq_object_properties; php_pqres_object_handlers.count_elements = php_pqres_count_elements; zend_hash_init(&php_pqres_object_prophandlers, 6, NULL, NULL, 1); diff --git a/src/php_pqstm.c b/src/php_pqstm.c index 016b5b7..83496df 100644 --- a/src/php_pqstm.c +++ b/src/php_pqstm.c @@ -359,6 +359,7 @@ PHP_MINIT_FUNCTION(pqstm) php_pqstm_object_handlers.write_property = php_pq_object_write_prop; php_pqstm_object_handlers.clone_obj = NULL; php_pqstm_object_handlers.get_property_ptr_ptr = NULL; + php_pqstm_object_handlers.get_properties = php_pq_object_properties; php_pqstm_object_handlers.get_debug_info = php_pq_object_debug_info; zend_hash_init(&php_pqstm_object_prophandlers, 2, NULL, NULL, 1); diff --git a/src/php_pqtxn.c b/src/php_pqtxn.c index 5c2695f..411b7fb 100644 --- a/src/php_pqtxn.c +++ b/src/php_pqtxn.c @@ -886,6 +886,7 @@ PHP_MINIT_FUNCTION(pqtxn) php_pqtxn_object_handlers.write_property = php_pq_object_write_prop; php_pqtxn_object_handlers.clone_obj = NULL; php_pqtxn_object_handlers.get_property_ptr_ptr = NULL; + php_pqtxn_object_handlers.get_properties = php_pq_object_properties; php_pqtxn_object_handlers.get_debug_info = php_pq_object_debug_info; zend_hash_init(&php_pqtxn_object_prophandlers, 4, NULL, NULL, 1); diff --git a/src/php_pqtypes.c b/src/php_pqtypes.c index fc9a16e..8995f26 100644 --- a/src/php_pqtypes.c +++ b/src/php_pqtypes.c @@ -324,6 +324,7 @@ PHP_MINIT_FUNCTION(pqtypes) php_pqtypes_object_handlers.write_property = php_pq_object_write_prop; php_pqtypes_object_handlers.clone_obj = NULL; php_pqtypes_object_handlers.get_property_ptr_ptr = NULL; + php_pqtypes_object_handlers.get_properties = php_pq_object_properties; php_pqtypes_object_handlers.get_debug_info = php_pq_object_debug_info; php_pqtypes_object_handlers.has_dimension = php_pqtypes_object_has_dimension; php_pqtypes_object_handlers.read_dimension = php_pqtypes_object_read_dimension; -- 2.30.2