-SUBDIRS = tests-idl tests\r
-EXTRA_RULES_SUBDIRS = forb-idl\r
-\r
-lib_LIBRARIES += forb\r
-forb_SOURCES = forb.c cdr.c sha1.c uuid.c iop.c proto.c syncobj.c request.c\r
-forb_CLIENT_IDL = forb-idl.idl\r
-\r
-lib_LIBRARIES += idltest\r
-idltest_CLIENT_IDL = frescor.idl\r
-\r
-\r
-to_forb_subdir=$(1)->forb/$(strip $(1))\r
-\r
-ifeq ($(CONFIG_FORB_PROTO_UNIX),y)\r
-forb_SOURCES += proto_unix.c\r
-renamed_include_HEADERS += $(call to_forb_subdir, proto_unix.h) \r
-endif\r
-\r
-renamed_include_HEADERS += \\r
- $(call to_forb_subdir, forb.h) \\r
- $(call to_forb_subdir, forb-internal.h) \\r
- $(call to_forb_subdir, basic_types.h) \\r
- $(call to_forb_subdir, cdr.h) \\r
- $(call to_forb_subdir, iop.h) \\r
- $(call to_forb_subdir, uuid.h) \\r
- $(call to_forb_subdir, syncobj.h) \\r
- $(call to_forb_subdir, request.h) \\r
- $(call to_forb_subdir, proto.h)\r
-\r
-renamed_include_GEN_HEADERS = \\r
- $(call to_forb_subdir,forb-idl.h)\r
-\r
-default_CONFIG = CONFIG_FORB_PROTO_UNIX=y \\r
- CONFIG_FORB_RECV_BUF_SIZE=4096\r
-\r
-config_include_HEADERS = forb/config.h\r
-config_DEFINES = CONFIG_FORB_PROTO_UNIX \\r
- CONFIG_FORB_RECV_BUF_SIZE\r
+SUBDIRS = tests-idl tests
+EXTRA_RULES_SUBDIRS = forb-idl
+
+IDL_COMPILER += --pidl
+
+lib_LIBRARIES += forb
+forb_SOURCES = forb.c cdr.c sha1.c uuid.c iop.c proto.c syncobj.c request.c
+forb_CLIENT_IDL = types.idl iop-idl.idl
+
+to_forb_subdir=$(1)->forb/$(strip $(1))
+
+ifeq ($(CONFIG_FORB_PROTO_UNIX),y)
+forb_SOURCES += proto_unix.c
+renamed_include_HEADERS += $(call to_forb_subdir, proto_unix.h)
+endif
+
+renamed_include_HEADERS += \
+ $(call to_forb_subdir, forb.h) \
+ $(call to_forb_subdir, forb-internal.h) \
+ $(call to_forb_subdir, basic_types.h) \
+ $(call to_forb_subdir, cdr.h) \
+ $(call to_forb_subdir, iop.h) \
+ $(call to_forb_subdir, uuid.h) \
+ $(call to_forb_subdir, syncobj.h) \
+ $(call to_forb_subdir, request.h) \
+ $(call to_forb_subdir, proto.h)
+
+renamed_include_GEN_HEADERS = \
+ $(call to_forb_subdir,iop-idl.h) \
+ $(call to_forb_subdir,types.h)
+
+default_CONFIG = CONFIG_FORB_PROTO_UNIX=y \
+ CONFIG_FORB_RECV_BUF_SIZE=4096
+
+config_include_HEADERS = forb/config.h
+config_DEFINES = CONFIG_FORB_PROTO_UNIX \
+ CONFIG_FORB_RECV_BUF_SIZE
module forb {
- typedef long long object_key;
-
- typedef char uuid[8];
- struct server_id {
- uuid uuid;
- };
-
- // Inter-ORB protocol
- module iop {
-
- typedef octet message_type;
-
- const message_type REQUEST = 0;
- const message_type REPLY = 1;
- const message_type HELLO = 2;
-
- struct version {
- octet major, minor;
- };
-
- typedef octet message_flags;
-
- const message_flags LITTLE_ENDIAN = 1;
-
- struct message_header {
- version proto_version;
- message_type message_type;
- message_flags flags;
- unsigned long message_size;
- };
- const long MESSAGE_HEADER_SIZE = 8;
-
- struct request_header {
- unsigned long request_id;
- string iface;
- object_key objkey;
- short method_index;
- server_id source; ///< Server ID of request originator
- };
-
- typedef unsigned short reply_flags;
- const reply_flags FLAG_EXCEPTION = 1;
- struct reply_header {
- unsigned long request_id;
- reply_flags flags;
- };
- const long REPLY_HEADER_SIZE = 8;
-
- native address;
-
-// struct hello_header {
-// address source;
-// };
- };
-
__declspec(pidl) interface orb {
typedef string ObjectId;
void register_reference(in ObjectId id, in Object object);
fprintf(ci->fh, "#ifndef %s%s_H\n", rinfo->header_guard_prefix, ci->c_base_name);
fprintf(ci->fh, "#define %s%s_H 1\n", rinfo->header_guard_prefix, ci->c_base_name);
- fprintf(ci->fh, "#include <forb/forb.h>\n");
fprintf(ci->fh, "#define FORB_IDL_SERIAL %d\n", FORB_CONFIG_SERIAL);
- fprintf(ci->fh, "#include <forb/basic_types.h>\n");
- fprintf(ci->fh, "#include <idl_native.h> /* Support of native types defined in IDL. This header should be provided by an application. */\n\n");
+
+ if (rinfo->is_pidl) {
+ /* Include only serialization stuff */
+ fprintf(ci->fh, "#include <forb/cdr.h>\n"
+ "#include <forb/basic_types.h>\n"
+ "\n");
+ } else {
+ fprintf(ci->fh, "#include <forb/forb-internal.h>\n\n");
+ }
fprintf(ci->fh, "#ifdef __cplusplus\n");
fprintf(ci->fh, "extern \"C\" {\n");
fprintf(ci->fh, "%s forb_%s_new(void *instance_data, "
"const struct forb_%s_impl *impl, forb_orb orb)\n"
"{\n"
- " %s obj = forb_malloc(sizeof(*obj));\n"
+ " %s obj = forb_object_new(orb, NULL, 0);\n"
" if (obj) {\n"
" obj->instance_data = instance_data;\n"
" obj->implementation = impl;\n"
" obj->interface = &%s_interface;\n"
- " obj->orb = orb;\n"
- " obj->objkey = (forb_object_key)(unsigned)obj;\n"
" }\n"
" return obj;\n"
"}\n\n", id, id, id, id, id);
fprintf (ci->fh, OIDL_C_WARNING);
/* fprintf (ci->fh, "#include <string.h>\n"); */
/* fprintf (ci->fh, "#define FORB2_STUBS_API\n"); */
- fprintf (ci->fh, "#include \"%s.h\"\n", ci->base_name);
- fprintf (ci->fh, "#include <forb/forb-internal.h>\n\n");
+ fprintf (ci->fh, "#include \"%s.h\"\n\n", ci->base_name);
ck_output_poastuff (tree, rinfo, ci);
}
fprintf (ci->fh, OIDL_C_WARNING);
fprintf (ci->fh, "#include <string.h>\n");
/* fprintf (ci->fh, "#define FORB2_STUBS_API\n"); */
- fprintf (ci->fh, "#include <forb/forb-idl.h>\n");
fprintf (ci->fh, "#include <forb/forb-internal.h>\n");
fprintf (ci->fh, "#include <forb/request.h>\n");
fprintf (ci->fh, "#include <forb/iop.h>\n");
*
*
*/
+
#ifndef FORB_INTERNAL_H
#define FORB_INTERNAL_H
-#include <forb/forb.h>
-#include <forb/forb-idl.h>
#include <forb/basic_types.h>
+#include <forb/cdr.h>
+#include <forb/forb.h>
+#include <idl_native.h> /* Support of native types defined in
+ * IDL. This header should be provided by an
+ * application. */
#include <forb/uuid.h>
#include <ul_list.h>
#include <ul_gavlcust.h>
+#include <forb/forb.h>
/** Object reference structure */
struct forb_object {
- /** @name Fields valid only for implementation */ /*@{*/
+ /** @name Fields valid only for implementation */
+ /*@{*/
/** Any data for implementation (in server) */
void *instance_data;
/*@}*/
/** Server implementing this object */
- forb_server_id *server;
+ forb_server_id server;
/** Object key is just a pointer to the object in the
* implementation's address space. */
forb_object_key objkey;
forb_server_id_to_string(char *dest, const forb_server_id *server_id, size_t n)
{
return forb_uuid_to_string(dest, (forb_uuid_t*)server_id->uuid, n);
-
}
-#include <forb/forb.h>
-#include <forb/forb-idl.h>
#include <forb/forb-internal.h>
+#include <forb/forb.h>
#include <string.h>
#include <ul_gavlcust.h>
#include <forb/uuid.h>
#ifdef CONFIG_FORB_PROTO_UNIX
#include <forb/proto_unix.h>
#endif
+#include <stdio.h>
forb_orb forb_init(void)
{
//gavl_insert(&type_registry, &interface->node);
}
+/**
+ * Creates a new object reference.
+ *
+ * @param orb FORB pseudo object this object reference is handled by.
+ *
+ * @param server_id Server ID of the FORB, where this object is
+ * implemented or NULL if the object is implemented by @a orb.
+ *
+ * @param key Key of the remote object or zero if the object is
+ * implemented by @a orb.
+ *
+ * @return FORB object reference of NULL in case of error.
+ */
+forb_object
+forb_object_new(forb_orb orb,
+ forb_server_id *server_id,
+ forb_object_key key)
+{
+ forb_object obj = forb_malloc(sizeof(*obj));
+ if (obj) {
+ obj->orb = orb;
+ if (key == 0) {
+ obj->objkey = (forb_object_key)(unsigned)obj;
+ } else {
+ obj->objkey = key;
+ }
+ if (server_id) {
+ obj->server = *server_id;
+ } else {
+ obj->server = forb_obj_to_forb(obj)->server_id;
+ }
+ }
+ return obj;
+}
+
/**
* Releases all memory associated with a object reference.
*
* @param obj Object reference to release
*/
-void forb_object_release(forb_object obj)
+void forb_object_destroy(forb_object obj)
{
forb_free(obj);
}
{
forb_uuid_generate((forb_uuid_t*)server_id->uuid);
}
+
+forb_object
+forb_string_to_object(const char *str)
+{
+ return NULL;
+}
+
+/**
+ * Converts object reference to string.
+ *
+ * @param obj Object reference to convert.
+ *
+ * @return String, which must be freed by forb_free() or NULL in case
+ * of error.
+ */
+char *
+forb_object_to_string(const forb_object obj)
+{
+ char *str;
+ size_t s;
+ forb_object_key key;
+ char server_id[65];
+
+ s = 2*sizeof(forb_server_id)+1+2*sizeof(size_t)+1;
+ str = malloc(s);
+ if (!str) {
+ return NULL;
+ }
+
+ forb_server_id_to_string(server_id, &obj->server, s);
+ key = forb_object_to_key(obj);
+ snprintf(str, s, "%s-%llx", server_id, key);
+
+ return str;
+}
#include <forb/basic_types.h>
#include <forb/cdr.h>
+#include <forb/types.h>
#include <fosa.h>
/**
#define CORBA_malloc(size) forb_malloc(size)
#define CORBA_free(ptr) forb_free(ptr)
+forb_object
+forb_object_new(forb_orb orb,
+ forb_server_id *server_id,
+ forb_object_key key);
+void
+forb_object_destroy(forb_object obj);
+
void
forb_register_reference(const char *id, forb_object object);
forb_object
forb_resolve_reference(const char *id);
-void forb_register_interface(const struct forb_interface *interface);
+void
+forb_register_interface(const struct forb_interface *interface);
+
+forb_object
+forb_string_to_object(const char *str);
+
+char *
+forb_object_to_string(const forb_object obj);
#endif
--- /dev/null
+#include "types.idl"
+
+module forb {
+ // Inter-ORB protocol
+ module iop {
+
+ typedef octet message_type;
+
+ const message_type REQUEST = 0;
+ const message_type REPLY = 1;
+ const message_type HELLO = 2;
+
+ struct version {
+ octet major, minor;
+ };
+
+ typedef octet message_flags;
+
+ const message_flags LITTLE_ENDIAN = 1;
+
+ struct message_header {
+ version proto_version;
+ message_type message_type;
+ message_flags flags;
+ unsigned long message_size;
+ };
+ const long MESSAGE_HEADER_SIZE = 8;
+
+ struct request_header {
+ unsigned long request_id;
+ string iface;
+ object_key objkey;
+ short method_index;
+ server_id source; ///< Server ID of request originator
+ };
+
+ typedef unsigned short reply_flags;
+ const reply_flags FLAG_EXCEPTION = 1;
+ struct reply_header {
+ unsigned long request_id;
+ reply_flags flags;
+ };
+ const long REPLY_HEADER_SIZE = 8;
+
+ native address;
+
+// struct hello_header {
+// address source;
+// };
+ };
+};
*
*/
#include <forb/iop.h>
-#include <forb/forb-idl.h>
#include <forb/cdr.h>
/** Version of the protocol */
#ifndef FORB_IOP_H
#define FORB_IOP_H
-#include <forb/forb-idl.h>
+#include <forb/iop-idl.h>
#include <forb/cdr.h>
#include <forb/forb-internal.h>
#include "proto.h"
#include <forb/proto.h>
-#include <forb/forb-idl.h>
#include <forb/forb-internal.h>
#include <forb/iop.h>
#include <forb/config.h>
env->major = FORB_EX_INTERNAL;
return;
}
- peer = forb_get_next_hop(forb, req->obj->server);
+ peer = forb_get_next_hop(forb, &req->obj->server);
if (!peer) {
env->major = FORB_EX_TRANSIENT;
return;
forb_request_delete(forb, req);
env->major = FORB_EX_COMM_FAILURE;
}
-exception:
- ;
}
-test_PROGRAMS = hello_inproc proto_unix discovery
+SUBDIRS = $(ALL_OMK_SUBDIRS)
+
+test_PROGRAMS = hello_inproc proto_unix discovery
CFLAGS += -DTEST
lib_LOADLIBES = forb ulut fosa rt
proto_unix_SOURCES = proto_unix.c
discovery_SOURCES = discovery.c
+
--- /dev/null
+# Generic directory or leaf node makefile for OCERA make framework
+
+ifndef MAKERULES_DIR
+MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
+endif
+
+ifeq ($(MAKERULES_DIR),)
+all : default
+.DEFAULT::
+ @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
+else
+include $(MAKERULES_DIR)/Makefile.rules
+endif
+
--- /dev/null
+test_PROGRAMS = obj2str
+obj2str_SOURCES = obj2str.c
+obj2str_SERVER_IDL = interface.idl
+
+CFLAGS += -I.
+
+
+lib_LOADLIBES = forb ulut fosa rt
--- /dev/null
+interface i {
+ void method();
+};
--- /dev/null
+#include <forb/forb.h>
+#include <stdio.h>
+#include "interface.h"
+
+struct forb_i_impl i_impl = { NULL };
+
+int main()
+{
+ forb_object orb, obj;
+ char *str;
+ orb = forb_init();
+
+ obj = forb_i_new(NULL, &i_impl, orb);
+
+ str = forb_object_to_string(obj);
+ if (str) {
+ printf("Object reference: %s\n", str);
+ forb_free(str);
+ } else {
+ return 1;
+ }
+ return 0;
+}
--- /dev/null
+module forb {
+ typedef long long object_key;
+
+ typedef char uuid[8];
+ struct server_id {
+ uuid uuid;
+ };
+};