[srm-cvs] CVS Update: - Added conversion from/to objects

From: <d.rethans[@]jdimedia.nl>
Date: Thu Jun 06 2002 - 13:07:29 CEST

Date: Thu Jun 6 13:07:29 CEST 2002
User: Derick Rethans
Directory: php_srm

Log Message:
 [0.75]
 - Added conversion from/to objects
 
Modified files:
           php_srm/srm_util.c (version: 1.10)

[FILE: /php_srm/srm_util.c]

--- php_srm/srm_util.c:1.9 Sat Apr 20 21:38:27 2002 GMT
+++ php_srm/srm_util.c Thu Jun 06 09:07:28 2002 GMT
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: cvstemp,v 1.9 2002/04/20 23:38:27 sniper Exp $ */
+/* $Id: cvstemp,v 1.10 2002/06/06 11:07:28 derick Exp $ */
 
 #include "php.h"
 #include "php_srm.h"
@@ -55,6 +55,7 @@
                         tmp->value_length = value->value.str.len;
                         break;
                 case IS_ARRAY:
+ case IS_OBJECT:
                         myht = HASH_OF(value);
                         i = zend_hash_num_elements(myht);
 
@@ -86,7 +87,11 @@
                                         }
                                 }
                         }
- VALP_SET_HASH(tmp);
+ if (value->type == IS_ARRAY) {
+ VALP_SET_HASH(tmp);
+ } else if (value->type == IS_OBJECT) {
+ VALP_SET_OBJECT(tmp);
+ }
                         SRMVALP_HASH(tmp) = tmp_list_hash;
                         break;
                 default:
@@ -176,6 +181,32 @@
                                                         t = calloc (((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.len + 1, 1);
                                                         memcpy (t, ((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.val, ((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.len);
                                                         add_assoc_zval_ex (result_array, t, ((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.len + 1, test);
+ break;
+ }
+ }
+ }
+ if (alloc == 1)
+ FREE_ZVAL(result);
+ return result_array;
+ }
+ case SRM_VALUE_OBJECT: {
+ char *t;
+ srm_llist_element *record;
+
+ MAKE_STD_ZVAL(result_array);
+ num_items = (SRMVALP_HASH(value))->size;
+
+ object_init(result_array);
+ for (i = 0; i < (SRMVALP_HASH(value))->slots; i++) {
+ for (record = SRM_LLIST_HEAD((SRMVALP_HASH(value)->table)[i]); record != NULL; record = SRM_LLIST_NEXT(record))
+ {
+ test = srmval_to_zval (((srm_hash_element *) SRM_LLIST_VALP(record))->ptr, 1);
+ switch (((srm_hash_element *) SRM_LLIST_VALP(record))->key.type) {
+ case SRM_HASH_KEY_IS_STRING:
+ /* Copy key to a buffer which ends with \0 */
+ t = calloc (((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.len + 1, 1);
+ memcpy (t, ((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.val, ((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.len);
+ add_property_zval_ex (result_array, t, ((srm_hash_element *) SRM_LLIST_VALP(record))->key.value.str.len + 1, test);
                                                         break;
                                         }
                                 }
Received on Thu Jun 6 13:57:17 2002

This archive was generated by hypermail 2.1.8 : Tue Jan 06 2009 - 08:00:02 CET