implemented get_properties() object handler
authorMichael Wallner <mike@php.net>
Sat, 13 Apr 2013 15:55:44 +0000 (17:55 +0200)
committerMichael Wallner <mike@php.net>
Sat, 13 Apr 2013 15:55:44 +0000 (17:55 +0200)
12 files changed:
package.xml
php_pq.h
src/php_pq_object.c
src/php_pq_object.h
src/php_pqcancel.c
src/php_pqconn.c
src/php_pqcopy.c
src/php_pqlob.c
src/php_pqres.c
src/php_pqstm.c
src/php_pqtxn.c
src/php_pqtypes.c

index 8f2a701..67dfa0d 100644 (file)
@@ -19,9 +19,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2013-03-22</date>
+ <date>2013-04-13</date>
  <version>
-  <release>0.1.0</release>
+  <release>0.2.0dev</release>
   <api>0.1.0</api>
  </version>
  <stability>
@@ -30,7 +30,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Initial release
+* Implemented get_properties() object handler.
 ]]></notes>
  <contents>
   <dir name="/">
index 5021711..8eb8495 100644 (file)
--- 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;
index 78db20f..704737f 100644 (file)
@@ -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) {
index 7bbdd84..311f17f 100644 (file)
@@ -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);
index 326cbcd..8f3d9da 100644 (file)
@@ -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);
index e71199d..5031426 100644 (file)
@@ -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);
index 89ab68c..1ea8a50 100644 (file)
@@ -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);
index 9f3717d..2dc9be3 100644 (file)
@@ -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);
index a1e1d00..57818f4 100644 (file)
@@ -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);
index 016b5b7..83496df 100644 (file)
@@ -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);
index 5c2695f..411b7fb 100644 (file)
@@ -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);
index fc9a16e..8995f26 100644 (file)
@@ -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;