]> granicus.if.org Git - php/commitdiff
ongoing development ...
authorHarald Radi <phanto@php.net>
Fri, 15 Mar 2002 23:28:10 +0000 (23:28 +0000)
committerHarald Radi <phanto@php.net>
Fri, 15 Mar 2002 23:28:10 +0000 (23:28 +0000)
ext/rpc/com/com.c
ext/rpc/handler.h
ext/rpc/php_rpc.h
ext/rpc/rpc.c
ext/rpc/rpc.dsp
ext/rpc/rpc.h
ext/rpc/tests/test1.php

index b9b380e5c4f1ac09bfadf1d041b5189f057b6930..c481e653ec671dea7b5cd1633885abfe03d2df7d 100644 (file)
@@ -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) {
 }
index 02c0b5e83ca87fa76a05ac6e7d755515b400791c..3e60ba77f45800bf0eddaa3e95fdc758b664717a 100644 (file)
@@ -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 {
index e0ae67f89e9f0ac1d141430dcfb57b80dc2c6bd1..96e4e219428d821785e359af9af21830c5ab402b 100644 (file)
@@ -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
index 4327f359f9194e8b8530d7e74217f16cd594e41f..f46dde5b8a0a52cc393d241fe2d938d1a052f607 100644 (file)
@@ -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 */
 }
 
 /*
index a621c4e515cb73c07bf86a2093754f7e0a03a864..42ba2f5686f6d1d474e2f3fb0926109884e73f0a 100644 (file)
@@ -45,7 +45,7 @@ RSC=rc.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # 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\r
-# 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\r
+# 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\r
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
 # ADD BASE RSC /l 0x40d /d "NDEBUG"\r
@@ -71,7 +71,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # 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\r
-# 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\r
+# 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\r
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
 # ADD BASE RSC /l 0x40d /d "_DEBUG"\r
@@ -97,7 +97,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # 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\r
-# 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\r
+# 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\r
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
 # ADD BASE RSC /l 0x40d /d "_DEBUG"\r
@@ -123,7 +123,7 @@ LINK32=link.exe
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
 # 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\r
-# 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\r
+# 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\r
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
 # ADD BASE RSC /l 0x40d /d "NDEBUG"\r
@@ -156,8 +156,48 @@ SOURCE=.\rpc.c
 # PROP Default_Filter "h;hpp;hxx;hm;inl"\r
 # Begin Source File\r
 \r
+SOURCE=.\handler.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\layer.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\php_rpc.h\r
 # End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\rpc.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "tests"\r
+\r
+# PROP Default_Filter "*.php"\r
+# Begin Source File\r
+\r
+SOURCE=.\tests\test1.php\r
+# End Source File\r
+# End Group\r
+# Begin Group "layer"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Group "com"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Group "Source Files No. 1"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=.\com\com.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files No. 1"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# End Group\r
+# End Group\r
 # End Group\r
 # End Target\r
 # End Project\r
index 2d1b0f7697e6e13d8fbaa93cc83ee707106e121e..bdffa8665cb43a2d7f75e6c4eda5ca0b3a513659 100644 (file)
@@ -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
index 7e1b9a52748e975ba0ca141126d4fd5a3d32760c..97e884bf744ef388dbdc7a590b614f55fc240fa5 100644 (file)
@@ -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