flush WIP
[m6w6/ext-http] / php_http_object.c
index abf72290e26de0ad9dea5052e0d922a82602e8d2..b8589f5aec07b5bc267f781f891c6a2048ae020d 100644 (file)
 
 #include "php_http_api.h"
 
-zend_object_value php_http_object_new(zend_class_entry *ce TSRMLS_DC)
+zend_object *php_http_object_new(zend_class_entry *ce)
 {
-       return php_http_object_new_ex(ce, NULL, NULL TSRMLS_CC);
+       return &php_http_object_new_ex(ce, NULL)->zo;
 }
 
-zend_object_value php_http_object_new_ex(zend_class_entry *ce, void *nothing, php_http_object_t **ptr TSRMLS_DC)
+php_http_object_t *php_http_object_new_ex(zend_class_entry *ce, void *intern)
 {
        php_http_object_t *o;
 
-       o = ecalloc(1, sizeof(php_http_object_t));
-       zend_object_std_init((zend_object *) o, ce TSRMLS_CC);
-       object_properties_init((zend_object *) o, ce);
+       o = ecalloc(1, sizeof(php_http_object_t) + (ce->default_properties_count - 1) * sizeof(zval));
+       zend_object_std_init(&o->zo, ce);
+       object_properties_init(&o->zo, ce);
 
-       if (ptr) {
-               *ptr = o;
-       }
-
-       o->zv.handle = zend_objects_store_put(o, NULL, (zend_objects_free_object_storage_t) zend_objects_free_object_storage, NULL TSRMLS_CC);
-       o->zv.handlers = zend_get_std_object_handlers();
+       o->intern = intern;
+       o->zo.handlers = zend_get_std_object_handlers();
 
-       return o->zv;
+       return o;
 }
 
-STATUS php_http_new(zend_object_value *ovp, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC)
+ZEND_RESULT_CODE php_http_new(void **obj_ptr, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr)
 {
-       zend_object_value ov;
+       void *obj;
 
        if (!ce) {
                ce = parent_ce;
-       } else if (parent_ce && !instanceof_function(ce, parent_ce TSRMLS_CC)) {
-               php_http_throw(unexpected_val, "Class %s does not extend %s", ce->name, parent_ce->name);
+       } else if (parent_ce && !instanceof_function(ce, parent_ce)) {
+               php_http_throw(unexpected_val, "Class %s does not extend %s", ce->name->val, parent_ce->name->val);
                return FAILURE;
        }
 
-       ov = create(ce, intern_ptr, obj_ptr TSRMLS_CC);
-       if (ovp) {
-               *ovp = ov;
+       obj = create(ce, intern_ptr);
+       if (obj_ptr) {
+               *obj_ptr = obj;
        }
        return SUCCESS;
 }
 
-STATUS php_http_method_call(zval *object, const char *method_str, size_t method_len, int argc, zval **argv[], zval **retval_ptr TSRMLS_DC)
+ZEND_RESULT_CODE php_http_method_call(zval *object, const char *method_str, size_t method_len, int argc, zval argv[], zval *retval_ptr)
 {
        zend_fcall_info fci;
-       zval zmethod;
        zval *retval;
-       STATUS rv;
+       ZEND_RESULT_CODE rv;
 
        fci.size = sizeof(fci);
-       fci.object_ptr = object;
-       fci.function_name = &zmethod;
-       fci.retval_ptr_ptr = retval_ptr ? retval_ptr : &retval;
+       fci.object = Z_OBJ_P(object);
+       fci.retval = retval_ptr ? retval_ptr : &retval;
        fci.param_count = argc;
        fci.params = argv;
        fci.no_separation = 1;
        fci.symbol_table = NULL;
        fci.function_table = NULL;
 
-       INIT_PZVAL(&zmethod);
-       ZVAL_STRINGL(&zmethod, method_str, method_len, 0);
+       ZVAL_STRINGL(&fci.function_name, method_str, method_len);
        rv = zend_call_function(&fci, NULL TSRMLS_CC);
+       zval_ptr_dtor(&fci.function_name);
 
        if (!retval_ptr && retval) {
                zval_ptr_dtor(&retval);