INIT_CLASS_ENTRY(ce, "com_exception", NULL);
php_com_exception_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(), NULL TSRMLS_CC);
php_com_exception_class_entry->ce_flags |= ZEND_ACC_FINAL;
- php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED;
+// php_com_exception_class_entry->constructor->common.fn_flags |= ZEND_ACC_PROTECTED;
INIT_CLASS_ENTRY(ce, "com_safearray_proxy", NULL);
php_com_saproxy_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
}
}
+static PHP_FUNCTION(com_method_handler)
+{
+ Z_OBJ_HANDLER_P(getThis(), call_method)(
+ ((zend_internal_function*)EG(function_state_ptr)->function)->function_name,
+ INTERNAL_FUNCTION_PARAM_PASSTHRU);
+}
+
static union _zend_function *com_method_get(zval *object, char *name, int len TSRMLS_DC)
{
zend_internal_function f, *fptr = NULL;
php_com_dotnet_object *obj;
union _zend_function *func;
+ DISPID dummy;
obj = CDNO_FETCH(object);
return NULL;
}
+ if (FAILED(php_com_get_id_of_name(obj, name, len, &dummy TSRMLS_CC))) {
+ return NULL;
+ }
+
/* check cache */
if (obj->method_cache == NULL || FAILURE == zend_hash_find(obj->method_cache, name, len, (void**)&fptr)) {
f.type = ZEND_OVERLOADED_FUNCTION;
f.scope = obj->ce;
f.fn_flags = 0;
f.function_name = estrndup(name, len);
+ f.handler = PHP_FN(com_method_handler);
+ fptr = &f;
+
if (obj->typeinfo) {
/* look for byref params */
ITypeComp *comp;
case DESCKIND_TYPECOMP:
ITypeComp_Release(bindptr.lptcomp);
break;
+
+ case DESCKIND_NONE:
+ break;
}
if (TI) {
ITypeInfo_Release(TI);
}
}
- /* save this method in the cache */
- if (!obj->method_cache) {
- ALLOC_HASHTABLE(obj->method_cache);
- zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0);
- }
+ if (fptr) {
+ /* save this method in the cache */
+ if (!obj->method_cache) {
+ ALLOC_HASHTABLE(obj->method_cache);
+ zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0);
+ }
- zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr);
+ zend_hash_update(obj->method_cache, name, len, &f, sizeof(f), (void**)&fptr);
+ }
}
- /* duplicate this into a new chunk of emalloc'd memory,
- * since the engine will efree it */
- func = emalloc(sizeof(*fptr));
- memcpy(func, fptr, sizeof(*fptr));
+ if (fptr) {
+ /* duplicate this into a new chunk of emalloc'd memory,
+ * since the engine will efree it */
+ func = emalloc(sizeof(*fptr));
+ memcpy(func, fptr, sizeof(*fptr));
- return func;
+ return func;
+ }
+
+ return NULL;
}
static int com_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
} else if (wFlags & DISPATCH_PROPERTYPUT) {
zend_update_property(Z_OBJCE_P(disp->object), disp->object, Z_STRVAL_PP(name), Z_STRLEN_PP(name)+1, *params[0] TSRMLS_CC);
} else if (wFlags & DISPATCH_METHOD) {
- if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, *name,
- &retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) {
- ret = S_OK;
- } else {
+ zend_try {
+ if (SUCCESS == call_user_function_ex(EG(function_table), &disp->object, *name,
+ &retval, pdp->cArgs, params, 1, NULL TSRMLS_CC)) {
+ ret = S_OK;
+ } else {
+ ret = DISP_E_EXCEPTION;
+ }
+ } zend_catch {
ret = DISP_E_EXCEPTION;
- }
+ } zend_end_try();
} else {
trace("Don't know how to handle this invocation %08x\n", wFlags);
}