summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/rpc/com/com.c6
-rw-r--r--ext/rpc/handler.h21
-rw-r--r--ext/rpc/php_rpc.h11
-rw-r--r--ext/rpc/rpc.c220
-rw-r--r--ext/rpc/rpc.dsp48
-rw-r--r--ext/rpc/rpc.h19
-rw-r--r--ext/rpc/tests/test1.php7
7 files changed, 267 insertions, 65 deletions
diff --git a/ext/rpc/com/com.c b/ext/rpc/com/com.c
index b9b380e5c4..c481e653ec 100644
--- a/ext/rpc/com/com.c
+++ b/ext/rpc/com/com.c
@@ -1,7 +1,11 @@
#include <stdio.h>
#include "../handler.h"
+#include "../php_rpc.h"
-RPC_REGISTER_HANDLERS(com);
+RPC_REGISTER_HANDLERS(com)
+
+RPC_FUNCTION_ENTRY_START(com)
+RPC_FUNCTION_ENTRY_END()
RPC_INIT_FUNCTION(com) {
}
diff --git a/ext/rpc/handler.h b/ext/rpc/handler.h
index 02c0b5e83c..3e60ba77f4 100644
--- a/ext/rpc/handler.h
+++ b/ext/rpc/handler.h
@@ -3,13 +3,27 @@
#include "php.h"
-#define RPC_HANDLER(layer) {#layer, layer##_handler_init, &layer##_object_handlers, &layer##_class_entry}
+#define RPC_HANDLER(layer) {#layer, layer##_handler_init, &layer##_object_handlers, &layer##_class_entry, layer##_function_entry}
+
#define RPC_DECLARE_HANDLER(layer) void layer##_handler_init(); \
rpc_object_handlers layer##_object_handlers; \
- zend_class_entry layer##_class_entry;
+ zend_class_entry layer##_class_entry; \
+ function_entry layer##_function_entry[];
+
#define RPC_INIT_FUNCTION(layer) void layer##_handler_init()
+
#define RPC_REGISTER_HANDLERS(layer) zend_class_entry layer##_class_entry; \
- rpc_object_handlers layer##object_handlers;
+ rpc_object_handlers layer##_object_handlers; \
+
+
+#define RPC_FUNCTION_ENTRY_START(layer) function_entry layer##_function_entry[] = { \
+ PHP_FALIAS(layer##_load, rpc_load, NULL) \
+ PHP_FALIAS(layer##_call, rpc_call, NULL) \
+ PHP_FALIAS(layer##_get, rpc_get, NULL) \
+ PHP_FALIAS(layer##_set, rpc_set, NULL)
+
+#define RPC_FUNCTION_ENTRY_END() {NULL, NULL, NULL} \
+ };
typedef struct _rpc_object_handlers {
@@ -21,6 +35,7 @@ typedef struct _rpc_handler_entry {
void (*rpc_handler_init)();
rpc_object_handlers *handlers;
zend_class_entry *ce;
+ function_entry *functions;
} rpc_handler_entry;
typedef struct _rpc_internal {
diff --git a/ext/rpc/php_rpc.h b/ext/rpc/php_rpc.h
index e0ae67f89e..96e4e21942 100644
--- a/ext/rpc/php_rpc.h
+++ b/ext/rpc/php_rpc.h
@@ -20,10 +20,13 @@ PHP_MINIT_FUNCTION(rpc);
PHP_MSHUTDOWN_FUNCTION(rpc);
PHP_MINFO_FUNCTION(rpc);
+ZEND_FUNCTION(rpc_load);
+ZEND_FUNCTION(rpc_call);
+ZEND_FUNCTION(rpc_set);
+ZEND_FUNCTION(rpc_get);
+
ZEND_BEGIN_MODULE_GLOBALS(rpc)
- zend_object_handle handle;
- HashTable *instance;
- HashTable *handlers;
+ int dummy;
ZEND_END_MODULE_GLOBALS(rpc)
#ifdef ZTS
@@ -31,5 +34,7 @@ ZEND_END_MODULE_GLOBALS(rpc)
#else
#define RPC_G(v) (rpc_globals.v)
#endif
+
+#define phpext_rpc_ptr &rpc_module_entry
#endif /* PHP_RPC_H */ \ No newline at end of file
diff --git a/ext/rpc/rpc.c b/ext/rpc/rpc.c
index 4327f359f9..f46dde5b8a 100644
--- a/ext/rpc/rpc.c
+++ b/ext/rpc/rpc.c
@@ -5,16 +5,18 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
-#include "php_rpc.h"
+#include "php_rpc.h"
#include "rpc.h"
#include "layer.h"
ZEND_DECLARE_MODULE_GLOBALS(rpc)
+static int rpc_global_startup(void);
+static int rpc_global_shutdown(void);
static void rpc_globals_ctor(zend_rpc_globals *rpc_globals TSRMLS_DC);
static void rpc_instance_dtor(void *pDest);
-static void rpc_handlers_dtor(void *pDest);
+static void rpc_export_functions(char *name, zend_class_entry *ce, function_entry functions[] TSRMLS_DC);
static zend_object_value rpc_create_object(zend_class_entry *class_type TSRMLS_DC);
/* object handler */
@@ -38,8 +40,6 @@ static int rpc_get_classname(zval *object, char **class_name, zend_uint *class_n
static int rpc_compare(zval *object1, zval *object2 TSRMLS_DC);
/**/
-ZEND_FUNCTION(CONSTRUCTOR);
-
static zend_object_handlers rpc_handlers = {
rpc_add_ref,
rpc_del_ref,
@@ -85,9 +85,13 @@ zend_module_entry rpc_module_entry = {
/* }}} */
static HashTable *instance;
+static HashTable *handlers;
+
+static MUTEX_T mx_instance;
+static unsigned long thread_count = 0;
#ifdef COMPILE_DL_RPC
-ZEND_GET_MODULE(rpc)
+ZEND_GET_MODULE(rpc);
#endif
/* {{{ PHP_INI
@@ -97,52 +101,84 @@ PHP_INI_BEGIN()
PHP_INI_END()
/* }}} */
-static void rpc_globals_ctor(zend_rpc_globals *rpc_globals TSRMLS_DC)
-{
- RPC_G(handle) = 0;
-
- RPC_G(handlers) = (HashTable *) pemalloc(sizeof(HashTable), TRUE);
- RPC_G(instance) = (HashTable *) pemalloc(sizeof(HashTable), TRUE);
-
- zend_hash_init(RPC_G(handlers), 0, NULL, NULL, TRUE);
- zend_hash_init(RPC_G(instance), 0, NULL, rpc_instance_dtor, TRUE);
-}
-
-/* {{{ PHP_MINIT_FUNCTION
+/* still not sure if MINIT is really only once per server and not once per thread
+ * so i keep the init stuff here here
*/
-PHP_MINIT_FUNCTION(rpc)
+static int rpc_global_startup(void)
{
- int i;
+ mx_instance = tsrm_mutex_alloc();
- ZEND_INIT_MODULE_GLOBALS(rpc, rpc_globals_ctor, NULL);
- REGISTER_INI_ENTRIES();
+ handlers = (HashTable *) pemalloc(sizeof(HashTable), TRUE);
+ instance = (HashTable *) pemalloc(sizeof(HashTable), TRUE);
- for (i=0; i < (sizeof(handler_entries) / sizeof(rpc_handler_entry)); i++) {
- handler_entries[i].rpc_handler_init();
+ zend_hash_init(handlers, 0, NULL, NULL, TRUE);
+ zend_hash_init(instance, 0, NULL, rpc_instance_dtor, TRUE);
+
+ FOREACH_HANDLER {
+ HANDLER.rpc_handler_init();
- INIT_OVERLOADED_CLASS_ENTRY((*(handler_entries[i].ce)),
- handler_entries[i].name,
+ /* create a class entry for every rpc handler */
+ INIT_OVERLOADED_CLASS_ENTRY((*(HANDLER.ce)),
+ HANDLER.name,
NULL,
NULL,
NULL,
NULL);
- handler_entries[i].ce->create_object = rpc_create_object;
+ HANDLER.ce->create_object = rpc_create_object;
- zend_register_internal_class(handler_entries[i].ce TSRMLS_CC);
- zend_hash_add(RPC_G(handlers), handler_entries[i].name, strlen(handler_entries[i].name), &(handler_entries[i].handlers), sizeof(rpc_object_handlers *), NULL);
+ /* load all available rpc handler into a hash */
+ zend_hash_add(handlers, HANDLER.name, strlen(HANDLER.name) + 1, &(HANDLER.handlers), sizeof(rpc_object_handlers *), NULL);
}
return SUCCESS;
}
+
+/* same as above for shutdown */
+static int rpc_global_shutdown(void)
+{
+ tsrm_mutex_free(mx_instance);
+
+ zend_hash_destroy(handlers);
+ zend_hash_destroy(instance);
+
+ return SUCCESS;
+}
+
+static void rpc_globals_ctor(zend_rpc_globals *rpc_globals TSRMLS_DC)
+{
+}
+
+/* {{{ PHP_MINIT_FUNCTION
+ */
+PHP_MINIT_FUNCTION(rpc)
+{
+ /* GINIT */
+ if (thread_count++ == 0) {
+ rpc_global_startup();
+ }
+
+ FOREACH_HANDLER {
+ /* register classes and functions */
+ zend_register_internal_class(HANDLER.ce TSRMLS_CC);
+ zend_register_functions(HANDLER.functions, NULL, MODULE_PERSISTENT TSRMLS_CC);
+ }
+
+ ZEND_INIT_MODULE_GLOBALS(rpc, rpc_globals_ctor, NULL);
+ REGISTER_INI_ENTRIES();
+
+ return SUCCESS;
+}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(rpc)
{
- zend_hash_destroy(RPC_G(handlers));
- zend_hash_destroy(RPC_G(instance));
+ /* GSHUTDOWN */
+ if (--thread_count == 0) {
+ rpc_global_shutdown();
+ }
UNREGISTER_INI_ENTRIES();
return SUCCESS;
@@ -167,7 +203,7 @@ static void rpc_instance_dtor(void *pDest)
intern = (rpc_internal **) pDest;
- /* destruct intern */
+ /* TODO: destruct intern */
}
static zend_object_value rpc_create_object(zend_class_entry *class_type TSRMLS_DC)
@@ -175,45 +211,56 @@ static zend_object_value rpc_create_object(zend_class_entry *class_type TSRMLS_D
zend_object_value *zov;
rpc_internal *intern;
+ /* set up the object value struct */
zov = (zend_object_value*) pemalloc(sizeof(zend_object_value), TRUE);
- intern = (rpc_internal *) pemalloc(sizeof(rpc_internal), TRUE);
-
- zov->handle = RPC_G(handle)++;
zov->handlers = &rpc_handlers;
+ /* set up the internal representation of our rpc instance */
+ intern = (rpc_internal *) pemalloc(sizeof(rpc_internal), TRUE);
intern->ce = class_type;
intern->refcount = 0;
intern->data = NULL;
- zend_hash_find(RPC_G(handlers), class_type->name, class_type->name_length, (void **) &(intern->handlers));
+ if (zend_hash_find(handlers, class_type->name, class_type->name_length + 1, (void **) &(intern->handlers)) == FAILURE) {
+ /* TODO: exception */
+ }
- zend_hash_index_update_or_next_insert(RPC_G(instance), zov->handle, &intern, sizeof(rpc_internal *), NULL, HASH_ADD);
+ /* store the instance in a hash and set the key as handle, thus
+ * we can find it later easily
+ */
+ tsrm_mutex_lock(mx_instance);
+ {
+ zov->handle = instance->nNextFreeElement;
+ zend_hash_next_index_insert(instance, &intern, sizeof(rpc_internal *), NULL);
+ }
+ tsrm_mutex_unlock(mx_instance);
return *zov;
}
-/**/
+/* object handler */
static void rpc_add_ref(zval *object)
{
- ZVAL_ADDREF(object);
+ GET_INTERNAL(intern);
+ RPC_ADDREF(intern);
}
static void rpc_del_ref(zval *object)
{
- if (ZVAL_REFCOUNT(object) > 0) {
- ZVAL_DELREF(object);
+ GET_INTERNAL(intern);
+
+ if (RPC_REFCOUNT(intern) > 0) {
+ RPC_DELREF(intern);
}
- if (ZVAL_REFCOUNT(object) == 0) {
- rpc_delete(object);
+ if (RPC_REFCOUNT(intern) == 0) {
+ rpc_instance_dtor(intern);
}
}
static void rpc_delete(zval *object)
{
- TSRMLS_FETCH();
GET_INTERNAL(intern);
-
rpc_instance_dtor(intern);
}
@@ -237,6 +284,7 @@ static zval* rpc_read(zval *object, zval *member, int type TSRMLS_DC)
static void rpc_write(zval *object, zval *member, zval *value TSRMLS_DC)
{
// GET_INTERNAL(intern);
+ /* FIXME */
}
static zval** rpc_get_property(zval *object, zval *member TSRMLS_DC)
@@ -247,7 +295,7 @@ static zval** rpc_get_property(zval *object, zval *member TSRMLS_DC)
return NULL;
}
-static zval **rpc_get_property_zval(zval *object, zval *member TSRMLS_DC)
+static zval** rpc_get_property_zval(zval *object, zval *member TSRMLS_DC)
{
// GET_INTERNAL(intern);
@@ -266,6 +314,7 @@ static zval* rpc_get(zval *property TSRMLS_DC)
static void rpc_set(zval **property, zval *value TSRMLS_DC)
{
// GET_INTERNAL(intern);
+ /* FIXME */
}
static int rpc_has_property(zval *object, zval *member, int check_empty TSRMLS_DC)
@@ -279,6 +328,7 @@ static int rpc_has_property(zval *object, zval *member, int check_empty TSRMLS_D
static void rpc_unset_property(zval *object, zval *member TSRMLS_DC)
{
// GET_INTERNAL(intern);
+ /* FIXME */
}
static HashTable* rpc_get_properties(zval *object TSRMLS_DC)
@@ -291,10 +341,18 @@ static HashTable* rpc_get_properties(zval *object TSRMLS_DC)
static union _zend_function* rpc_get_method(zval *object, char *method, int method_len TSRMLS_DC)
{
-// GET_INTERNAL(intern);
+ zend_function *function;
+
+ function = (zend_function *) emalloc(sizeof(zend_function));
+ function->type = ZEND_OVERLOADED_FUNCTION;
+ function->common.arg_types = NULL;
+ function->common.function_name = method;
+ function->common.scope = NULL;
+
+ // GET_INTERNAL(intern);
/* FIXME */
- return NULL;
+ return function;
}
static int rpc_call(char *method, INTERNAL_FUNCTION_PARAMETERS)
@@ -314,7 +372,8 @@ static union _zend_function* rpc_get_constructor(zval *object TSRMLS_DC)
rpc_ctor->type = ZEND_INTERNAL_FUNCTION;
rpc_ctor->scope = (*intern)->ce;
- rpc_ctor->handler = CONSTRUCTOR_FN;
+ rpc_ctor->arg_types = NULL;
+ rpc_ctor->handler = ZEND_FN(rpc_load);
return (zend_function *) rpc_ctor;
}
@@ -333,8 +392,71 @@ static int rpc_compare(zval *object1, zval *object2 TSRMLS_DC)
return FAILURE;
}
-ZEND_FUNCTION(CONSTRUCTOR)
+/**/
+
+/* constructor */
+ZEND_FUNCTION(rpc_load)
{
+ zval *object = getThis();
+ rpc_internal **intern;
+
+ /* check if we were called as a constructor or as a function */
+ if (!object) {
+ /* we were called as a function so we have to figure out which rpc layer was requested
+ * and then we have to set up a zval containing the object
+ */
+
+ char *key;
+ int key_len;
+
+ /* the name of the rpc layer is prepended to '_load' so lets strip everything after
+ * the first '_' away from the function name
+ */
+ zend_class_entry *ce;
+ key = estrdup(get_active_function_name(TSRMLS_C));
+ key_len = strchr(key, '_') - key;
+ key[key_len] = '\0';
+
+ /* get the class entry for the requested rpc layer */
+ if (zend_hash_find(CG(class_table), key, key_len + 1, (void **) &ce) == FAILURE) {
+ /* TODO: exception here */
+ RETURN_FALSE;
+ }
+
+ /* set up a new zval container */
+ ALLOC_ZVAL(object);
+ INIT_PZVAL(object);
+
+ Z_TYPE_P(object) = IS_OBJECT;
+ ZVAL_REFCOUNT(object) = 1;
+ PZVAL_IS_REF(object) = 1;
+
+ /* create a new object */
+ object->value.obj = rpc_create_object(ce TSRMLS_CC);
+
+ return_value = object;
+
+ /* now everything is set up the same way as if we were called as a constructor */
+ }
+
+ GET_INTERNAL_EX(intern, object);
+
+ /* FIXME */
+}
+
+ZEND_FUNCTION(rpc_call)
+{
+ /* FIXME */
+}
+
+ZEND_FUNCTION(rpc_set)
+{
+ /* FIXME */
+}
+
+ZEND_FUNCTION(rpc_get)
+{
+ /* FIXME */
}
/*
diff --git a/ext/rpc/rpc.dsp b/ext/rpc/rpc.dsp
index a621c4e515..42ba2f5686 100644
--- a/ext/rpc/rpc.dsp
+++ b/ext/rpc/rpc.dsp
@@ -45,7 +45,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_RPC" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40d /d "NDEBUG"
@@ -71,7 +71,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_RPC" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40d /d "_DEBUG"
@@ -97,7 +97,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /D /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_RPC" /FR /YX /FD /D /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40d /d "_DEBUG"
@@ -123,7 +123,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZTS" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZTS" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "COMPILE_DL_RPC" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40d /d "NDEBUG"
@@ -156,8 +156,48 @@ SOURCE=.\rpc.c
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
+SOURCE=.\handler.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\layer.h
+# End Source File
+# Begin Source File
+
SOURCE=.\php_rpc.h
# End Source File
+# Begin Source File
+
+SOURCE=.\rpc.h
+# End Source File
+# End Group
+# Begin Group "tests"
+
+# PROP Default_Filter "*.php"
+# Begin Source File
+
+SOURCE=.\tests\test1.php
+# End Source File
+# End Group
+# Begin Group "layer"
+
+# PROP Default_Filter ""
+# Begin Group "com"
+
+# PROP Default_Filter ""
+# Begin Group "Source Files No. 1"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\com\com.c
+# End Source File
+# End Group
+# Begin Group "Header Files No. 1"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# End Group
# End Group
# End Target
# End Project
diff --git a/ext/rpc/rpc.h b/ext/rpc/rpc.h
index 2d1b0f7697..bdffa8665c 100644
--- a/ext/rpc/rpc.h
+++ b/ext/rpc/rpc.h
@@ -1,11 +1,20 @@
#ifndef RPC_H
#define RPC_H
-#define CONSTRUCTOR __construct
-#define CONSTRUCTOR_FN ZEND_FN(__construct)
+#define FOREACH_HANDLER for (__handler_counter=0; __handler_counter < HANDLER_COUNT; __handler_counter++)
+#define HANDLER handler_entries[__handler_counter]
+#define HANDLER_COUNT (sizeof(handler_entries) / sizeof(rpc_handler_entry))
-#define GET_INTERNAL(intern) GET_INTERNAL_EX(intern, object)
-#define GET_INTERNAL_EX(intern, object) rpc_internal **intern; \
- zend_hash_index_find(RPC_G(instance), object->value.obj.handle, (void **) &intern);
+#define GET_INTERNAL(intern) rpc_internal **intern; \
+ GET_INTERNAL_EX(intern, object)
+#define GET_INTERNAL_EX(intern, object) if (zend_hash_index_find(instance, object->value.obj.handle, (void **) &intern) == FAILURE) { \
+ /* TODO: exception */ \
+ }
+
+#define RPC_REFCOUNT(intern) ((*intern)->refcount)
+#define RPC_ADDREF(intern) (++RPC_REFCOUNT(intern))
+#define RPC_DELREF(intern) (--RPC_REFCOUNT(intern))
+
+static int __handler_counter;
#endif \ No newline at end of file
diff --git a/ext/rpc/tests/test1.php b/ext/rpc/tests/test1.php
index 7e1b9a5274..97e884bf74 100644
--- a/ext/rpc/tests/test1.php
+++ b/ext/rpc/tests/test1.php
@@ -1,4 +1,11 @@
<?php
+print "huhuhdsa";
+
$rpc = new com();
+$rpc->call();
delete $rpc;
+
+$heh = com_load();
+$heh->call;
+delete $heh;
?> \ No newline at end of file