Changeset 11185
- Timestamp:
- 07/12/07 12:39:09 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midgard/apis/php4/php_midgard_gobject_generic.c
r11177 r11185 18 18 #include "php_midgard_gobject.h" 19 19 #include <TSRM.h> 20 #include <zend_interfaces.h> 20 21 21 22 /* static prototypes */ 22 23 static void php_midgard_datetime_from_string(const gchar *date, zval *zvalue); 23 static const gchar*php_midgard_string_from_datetime(zval *zvalue);24 static zval *php_midgard_string_from_datetime(zval *zvalue); 24 25 25 26 /* GVALUE ROUTINES */ … … 35 36 HashPosition iterator; 36 37 GValue *tmpval; 37 const gchar *dtstr;38 zval*date_zval; 38 39 zend_class_entry *dtce; 39 40 … … 85 86 if(Z_OBJCE_P(zvalue) == dtce) { 86 87 87 d tstr= php_midgard_string_from_datetime(zvalue);88 date_zval = php_midgard_string_from_datetime(zvalue); 88 89 g_value_init(gvalue, G_TYPE_STRING); 89 g_value_set_string(gvalue, dtstr);90 g_warning("DATESTR '%s'", dtstr);90 g_value_set_string(gvalue, Z_STRVAL_P(date_zval)); 91 zval_dtor(date_zval); 91 92 92 93 } else { … … 122 123 123 124 /* It's overloaded, but we need to initialize DateTime object */ 124 /* Disabled for a while 125 /* Disabled for a while 125 126 if(dbklass != NULL) { 126 127 … … 136 137 return TRUE; 137 138 } 138 } 139 */ 139 }*/ 140 140 141 141 /* Generic GValue */ … … 253 253 return FALSE; 254 254 } 255 256 257 255 258 256 /* OBJECTS ROUTINES */ … … 769 767 } 770 768 771 static const gchar*php_midgard_string_from_datetime(zval *zvalue)769 static zval *php_midgard_string_from_datetime(zval *zvalue) 772 770 { 773 771 if(Z_TYPE_P(zvalue) != IS_OBJECT) { … … 777 775 } 778 776 779 /* Create params array and format ISO8601 compatible string */ 780 zval *dt_params; 781 MAKE_STD_ZVAL(dt_params); 782 array_init(dt_params); 783 add_index_string(dt_params, 0, (gchar *)"DateTime::ISO8601", 0); 784 785 zval *f_format; 786 MAKE_STD_ZVAL(f_format); 787 ZVAL_STRING(f_format, "format", 0); 788 789 /* Copy function arguments */ 790 zval ***args = __copy_args(dt_params); 791 792 /* TSRMSLS_FETCH(); */ /* Should be called here (required for CG macro ) */ 777 778 /* get datetime ISO8601 constant */ 779 zval iso_constant; 780 zend_get_constant("DateTime::ISO8601", 17, &iso_constant TSRMLS_CC); 781 782 TSRMLS_FETCH(); 793 783 794 784 zval *retval; 795 call_user_function_ex(NULL, &zvalue, f_format, 796 &retval, 1, args, 1, NULL TSRMLS_CC); 797 efree(args); 798 799 g_warning("STRV %s", Z_STRVAL_P(retval)); 800 return (const gchar *)Z_STRVAL_P(retval); 785 zend_call_method_with_1_params(&zvalue, Z_OBJCE_P(zvalue), 786 NULL, "format", &retval, &iso_constant); 787 788 return retval; 801 789 } 802 790
