cvs: php4 /ext/rpc rpc.c rpc_proxy.c
| From: | Harald Radi | Date: | Mon, 22 Apr 2002 19:40:01 +0000 |
| Subject: | cvs: php4 /ext/rpc rpc.c rpc_proxy.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-11314@lists.php.net to get a copy of this message | ||
phanto Mon Apr 22 15:40:01 2002 EDT
Modified files:
/php4/ext/rpc rpc.c rpc_proxy.c
Log:
set up a proxy object when requesting a reference to a variable
Index: php4/ext/rpc/rpc.c
diff -u php4/ext/rpc/rpc.c:1.9 php4/ext/rpc/rpc.c:1.10
--- php4/ext/rpc/rpc.c:1.9 Mon Apr 22 10:25:23 2002
+++ php4/ext/rpc/rpc.c Mon Apr 22 15:40:00 2002
@@ -14,6 +14,7 @@
static void rpc_globals_ctor(zend_rpc_globals * TSRMLS_DC);
static void rpc_instance_dtor(void *);
+static void rpc_proxy_dtor(void *pDest);
static void rpc_class_dtor(void *);
static void rpc_string_dtor(void *);
static void rpc_export_functions(char *, zend_class_entry *, function_entry[] TSRMLS_DC);
@@ -44,6 +45,8 @@
static void rpc_internal_set(rpc_internal *, char *, zend_uint, zval *);
/**/
+extern zend_object_handlers rpc_proxy_handlers;
+
static zend_object_handlers rpc_handlers = {
rpc_add_ref,
rpc_del_ref,
@@ -91,6 +94,7 @@
static HashTable *handlers;
static TsHashTable *instance;
+static TsHashTable *proxy;
static TsHashTable *classes;
static zend_llist *classes_list;
@@ -115,11 +119,13 @@
{
handlers = (HashTable *) pemalloc(sizeof(HashTable), TRUE);
instance = (TsHashTable *) pemalloc(sizeof(TsHashTable), TRUE);
+ proxy = (TsHashTable *) pemalloc(sizeof(TsHashTable), TRUE);
classes = (TsHashTable *) pemalloc(sizeof(TsHashTable), TRUE);
classes_list = (zend_llist *) pemalloc(sizeof(zend_llist), TRUE);
zend_hash_init(handlers, 0, NULL, NULL, TRUE);
zend_ts_hash_init(instance, 0, NULL, rpc_instance_dtor, TRUE);
+ zend_ts_hash_init(proxy, 0, NULL, rpc_proxy_dtor, TRUE);
zend_ts_hash_init(classes, 0, NULL, NULL, TRUE);
zend_llist_init(classes_list, sizeof(rpc_class_hash **), rpc_class_dtor, TRUE);
@@ -157,6 +163,7 @@
{
/* destroy instances first */
zend_ts_hash_destroy(instance);
+ zend_ts_hash_destroy(proxy);
zend_ts_hash_destroy(classes);
zend_llist_destroy(classes_list);
@@ -164,6 +171,7 @@
pefree(handlers, TRUE);
pefree(instance, TRUE);
+ pefree(proxy, TRUE);
pefree(classes, TRUE);
UNREGISTER_INI_ENTRIES();
@@ -198,6 +206,15 @@
pefree(*intern, TRUE);
}
+static void rpc_proxy_dtor(void *pDest)
+{
+ rpc_proxy **proxy_intern;
+
+ proxy_intern = (rpc_proxy **) pDest;
+
+ pefree(*proxy_intern, TRUE);
+}
+
static void rpc_class_dtor(void *pDest)
{
rpc_class_hash **hash;
@@ -263,6 +280,31 @@
return *zov;
}
+static zend_object_value rpc_create_proxy(TSRMLS_D)
+{
+ zend_object_value *zov;
+ rpc_proxy *proxy_intern;
+
+ /* set up the object value struct */
+ zov = (zend_object_value*) pemalloc(sizeof(zend_object_value), TRUE);
+ zov->handlers = &rpc_proxy_handlers;
+
+ /* set up the internal representation of the proxy */
+ proxy_intern = (rpc_proxy *) pemalloc(sizeof(rpc_proxy), TRUE);
+
+ /* store the instance in a hash and set the key as handle, thus
+ * we can find it later easily
+ */
+ tsrm_mutex_lock(proxy->mx_writer);
+ {
+ zov->handle = zend_hash_next_free_element(&(proxy->hash));
+ zend_ts_hash_next_index_insert(proxy, &proxy_intern, sizeof(rpc_proxy *), NULL);
+ }
+ tsrm_mutex_unlock(proxy->mx_writer);
+
+ return *zov;
+}
+
/* object handler */
static void rpc_add_ref(zval *object TSRMLS_DC)
@@ -356,10 +398,16 @@
static zval** rpc_get_property(zval *object, zval *member TSRMLS_DC)
{
+ zval **return_value;
GET_INTERNAL(intern);
- /* FIXME */
- return NULL;
+ return_value = emalloc(sizeof(zval *));
+ MAKE_STD_ZVAL(*return_value);
+// ZVAL_DELREF(*return_value);
+ Z_TYPE_P(object) = IS_OBJECT;
+ (*return_value)->value.obj = rpc_create_proxy(TSRMLS_C);
+
+ return return_value;
}
static zval* rpc_get(zval *property TSRMLS_DC)
Index: php4/ext/rpc/rpc_proxy.c
diff -u php4/ext/rpc/rpc_proxy.c:1.1 php4/ext/rpc/rpc_proxy.c:1.2
--- php4/ext/rpc/rpc_proxy.c:1.1 Mon Apr 22 10:25:23 2002
+++ php4/ext/rpc/rpc_proxy.c Mon Apr 22 15:40:00 2002
@@ -1,6 +1,7 @@
#include "php.h"
#include "rpc_proxy.h"
+#include "handler.h"
/* object handler */
static void rpc_proxy_add_ref(zval * TSRMLS_DC);
@@ -22,7 +23,7 @@
static int rpc_proxy_compare(zval *, zval * TSRMLS_DC);
/**/
-static zend_object_handlers rpc_proxy_handlers = {
+zend_object_handlers rpc_proxy_handlers = {
rpc_proxy_add_ref,
rpc_proxy_del_ref,
rpc_proxy_delete,