php-src/ext/rpc/handler.h

111 lines
3.6 KiB
C
Raw Normal View History

#ifndef HANDLER_H
#define HANDLER_H
#include "php.h"
2002-03-16 16:15:34 +00:00
#define RPC_HANDLER(layer) {#layer, layer##_handler_init, &layer##_object_handlers, \
&layer##_class_entry, layer##_function_entry, \
layer##_method_entry}
2002-03-15 23:28:10 +00:00
#define RPC_DECLARE_HANDLER(layer) void layer##_handler_init(); \
rpc_object_handlers layer##_object_handlers; \
2002-03-15 23:28:10 +00:00
zend_class_entry layer##_class_entry; \
2002-03-16 16:15:34 +00:00
function_entry layer##_function_entry[]; \
function_entry layer##_method_entry[];
2002-03-15 23:28:10 +00:00
#define RPC_INIT_FUNCTION(layer) void layer##_handler_init()
2002-03-15 23:28:10 +00:00
#define RPC_REGISTER_HANDLERS_START(layer) zend_class_entry layer##_class_entry; \
2002-03-16 16:15:34 +00:00
rpc_object_handlers layer##_object_handlers = {
#define RPC_REGISTER_HANDLERS_END() };
2002-03-15 23:28:10 +00:00
#define RPC_FUNCTION_ENTRY_START(layer) function_entry layer##_function_entry[] = { \
2002-03-16 16:15:34 +00:00
ZEND_FALIAS(layer##_load, rpc_load, NULL) \
ZEND_FALIAS(layer##_call, rpc_call, NULL) \
ZEND_FALIAS(layer##_get, rpc_get, NULL) \
ZEND_FALIAS(layer##_set, rpc_set, NULL)
2002-03-15 23:28:10 +00:00
#define RPC_FUNCTION_ENTRY_END() {NULL, NULL, NULL} \
};
2002-03-16 16:15:34 +00:00
#define RPC_METHOD_ENTRY_START(layer) function_entry layer##_method_entry[] = {
#define RPC_METHOD_ENTRY_END() {NULL, NULL, NULL} \
};
#define POOL TRUE
#define DONT_POOL FALSE
#define DONT_HASH 0
#define HASH_AS_INT 1
#define HASH_AS_STRING 2
#define HASH_WITH_SIGNATURE 4
#define HASH_AS_INT_WITH_SIGNATURE (HASH_AS_INT + HASH_WITH_SIGNATURE)
#define HASH_AS_STRING_WITH_SIGNATURE (HASH_AS_STRING + HASH_WITH_SIGNATURE)
2002-03-16 16:15:34 +00:00
#define CLASS 0
#define METHOD 1
#define PROPERTY 2
2002-03-16 16:15:34 +00:00
2002-03-15 13:10:35 +00:00
2002-03-16 16:15:34 +00:00
/* rpc handler that have to be implemented by a
* specific rpc layer
*/
typedef struct _rpc_object_handlers {
const zend_bool pool_instances;
const zend_uint hash_type;
int (*rpc_hash)(char *name, zend_uint name_len, char **hash, zend_uint *hash_len, int num_args, zval **args[], int type);
int (*rpc_ctor)(char *class_name, zend_uint class_name_len, void **data, int num_args, zval **args[]);
2002-03-16 16:15:34 +00:00
int (*rpc_dtor)(void **data);
int (*rpc_call)(char *method_name, zend_uint method_name_len, void **data, zval **return_value, int num_args, zval **args[]);
2002-03-16 16:15:34 +00:00
int (*rpc_get)(char *property_name, zend_uint property_name_len, zval *return_value, void **data);
int (*rpc_set)(char *property_name, zend_uint property_name_len, zval *value, zval *return_value, void **data);
int (*rpc_compare)(void **data1, void **data2);
int (*rpc_get_classname)(char **class_name, zend_uint *class_name_length, void **data);
int (*rpc_has_property)(char *property_name, zend_uint property_name_length, void **data);
int (*rpc_unset_property)(char *property_name, zend_uint property_name_length, void **data);
int (*rpc_get_properties)(HashTable **properties, void **data);
} rpc_object_handlers;
2002-03-16 16:15:34 +00:00
/* handler entry */
typedef struct _rpc_handler_entry {
char *name;
void (*rpc_handler_init)();
rpc_object_handlers *handlers;
zend_class_entry *ce;
2002-03-15 23:28:10 +00:00
function_entry *functions;
2002-03-16 16:15:34 +00:00
function_entry *methods;
} rpc_handler_entry;
/* string */
typedef struct _rpc_string {
char *str;
zend_uint len;
} rpc_string;
/* class/method/function hash */
typedef struct _rpc_class_hash {
rpc_string name; /* must be first entry */
WormHashTable methods;
WormHashTable properties;
} rpc_class_hash;
2002-03-16 16:15:34 +00:00
/* internal data */
2002-03-15 13:10:35 +00:00
typedef struct _rpc_internal {
char *class_name;
zend_uint class_name_len;
2002-03-15 13:10:35 +00:00
zend_class_entry *ce;
rpc_object_handlers **handlers;
void *data;
zend_uint refcount;
zend_uint clonecount;
zend_bool pool_instances;
rpc_class_hash *hash;
WormHashTable function_table;
MUTEX_T mx_handler;
2002-03-15 13:10:35 +00:00
} rpc_internal;
#endif /* HANDLER_H */