- zend_fcall_info fci;
- zval zmethod;
- zval *retval;
- STATUS rv;
-
- fci.size = sizeof(fci);
- fci.object_ptr = object;
- fci.function_name = &zmethod;
- fci.retval_ptr_ptr = 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);
- rv = zend_call_function(&fci, NULL TSRMLS_CC);
+#if PHP_VERSION_ID >= 50400
+ return Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(zmeth), Z_STRLEN_P(zmeth), NULL TSRMLS_CC);
+#else
+ return Z_OBJ_HT_P(zobject)->get_method(&zobject, Z_STRVAL_P(zmeth), Z_STRLEN_P(zmeth) TSRMLS_CC);
+#endif
+}
+
+php_http_object_method_t *php_http_object_method_init(php_http_object_method_t *cb, zval *zobject, const char *method_str, size_t method_len TSRMLS_DC)
+{
+ zval *zfn;
+
+ if (!cb) {
+ cb = ecalloc(1, sizeof(*cb));
+ } else {
+ memset(cb, 0, sizeof(*cb));
+ }
+
+ MAKE_STD_ZVAL(zfn);
+ ZVAL_STRINGL(zfn, method_str, method_len, 1);
+
+ cb->fci.size = sizeof(cb->fci);
+ cb->fci.function_name = zfn;
+ cb->fcc.initialized = 1;
+ cb->fcc.calling_scope = cb->fcc.called_scope = Z_OBJCE_P(zobject);
+ cb->fcc.function_handler = get_object_method(zobject, cb->fci.function_name TSRMLS_CC);
+
+ return cb;
+}
+
+void php_http_object_method_dtor(php_http_object_method_t *cb)
+{
+ if (cb->fci.function_name) {
+ zval_ptr_dtor(&cb->fci.function_name);
+ cb->fci.function_name = NULL;
+ }
+}