foreign interface
- From: Frank Rehberger <Frank Rehberger web de>
- To: "orbit-list gnome org" <orbit-list gnome org>,Frank Rehberger web de
- Subject: foreign interface
- Date: Sun, 19 Aug 2001 15:30:49 +0200
All,
implementing the CORBA language binding for Mozart-OZ I discovered that
all CORBA/ORbit-interfaces relay on the way, C stores its data types.
Even if a script language stores abstract data-types in form of
hastables, those have to be transformed to C-structures to do
marshalling.
For this reason most script languages create their own interfaces,
relaying on top of GIOP, as Python. If you have a look at those
implementations, one can see that the difference to the
ORBit-implementation is traversing foreign data-structures and
converting foreign data to C. But beside that most of the code is
duplicated.
In addition most scripting languages have their own runtime environment,
doing threading etc. Suspending within native functions waiting for
CORBA response, will block those mechanisms, too. Suspending within
native method calls should be avoided.
Therefor I did sketch a ORBit-foreign interface that can be used for all
script languages (I hope). Traversing, converting and creating foreign
data structures will be done using interfaces. If you want to create a
new binding for ORbit, all you have to do is, define foreign CORBA data
structures within you script language and define interfaces that convert
foreign primitives to C. You dont have to think about how CORBA is doing
masrhalling and demarshalling.
Request and Response are seperated using the DII mechanisms. Having done
the initial method invocation request, controll can be given back to the
foreign runtime-environment, polling for response from time to time.
Later, I would like to add the code to ORBit2.
Please have a look at the header-file, the first sketch, and tell me,
what should be renamed or done different/better. The list of functions
to convert primitives is incomplete. Functions are grouped by object.
cu, Frank
-------------------------------------------------------------
Frank Rehberger <frehberg@cs.tu-berlin.de>
-------------------------------------------------------------
"Global order can arise from local interactions."
[A.Turing, 1952]
-------------------------------------------------------------
#ifndef __ORBIT_FOREIGN__
#define __ORBIT_FOREIGN__
#if defined(__cplusplus)
extern "C" {
#endif
#include <orb/orbit.h>
#include <glib.h>
typedef gpointer FrgnMethodDescr;
typedef gpointer FrgnParameter;
typedef gpointer FrgnTypeCode;
typedef gpointer FrgnMethodCall;
typedef gpointer FrgnValue;
typedef gpointer FrgnFactory;
typedef gpointer FrgnData;
typedef struct
{
gchar * (*name)(FrgnMethodDescr descr);
guint (*n_parameter)(FrgnMethodDescr descr);
FrgnParameter (*nth_paramter)(FrgnMethodDescr descr, guint nth);
} ORBit_IFrgnMethodDescr;
typedef struct
{
guint (*flags)(FrgnParameter param);
FrgnTypeCode (*typecode)(FrgnParameter param);
} ORBit_IFrgnParameterDescr;
typedef struct
{
CORBA_TCKind (*kind)(FrgnTypeCode tc);
guint (*n_subtypes)(FrgnTypeCode tc);
FrgnTypeCode (*nth_subtype)(FrgnTypeCode tc, gint nth);
} ORBit_IFrgnTypeCode;
typedef struct
{
guint (*n_arguments)(FrgnMethodCall call);
FrgnValue (*nth_argument)(FrgnMethodCall call, guint nth);
void (*set_nth_argument)(FrgnMethodCall call, guint nth, FrgnValue value);
} ORBit_IFrgMethodDef;
typedef struct
{
void (*long_to_c)(CORBA_long * buf, FrgnValue leaf);
void (*ulong_to_c)(CORBA_unsigned_long *buf, FrgnValue leaf);
guint (*string_len)(FrgnValue leaf);
void (*string_to_c)(CORBA_char* str, FrgnValue leaf);
FrgnValue (*nth_subcomp)(FrgnValue value, guint nth, CORBA_char* name);
// ...
} ORBit_IValue;
typedef struct
{
FrgnValue (*frgn_long)(CORBA_long val, FrgnData data);
FrgnValue (*frgn_ulong)(CORBA_unsigned_long val, FrgnData data);
FrgnValue (*frgn_string)(CORBA_char* val, FrgnData data);
FrgnValue (*frgn_struct)(FrgnValue components[],
FrgnTypeCode struct_spec,
FrgnData data);
// ...
} ORBit_IFrgnFactory;
typedef struct
{
ORBit_IFrgnMethodDescr method_descr;
ORBit_IFrgnParameterDescr parameter_descr;
ORBit_IFrgnTypeCode typecode;
ORBit_IFrgMethodDef method_def;
ORBit_IValue value;
ORBit_IFrgnFactory factory;
} ORBit_ICollection;
typedef guint ORBit_RequestID;
/** will marshall all "in" arguments and will return a request id */
ORBit_RequestID orbit_foreign_request(CORBA_Object obj,
FrgnMethodDescr descr,
FrgnMethodCall call,
FrgnData data,
ORBit_ICollection * icollection,
CORBA_Environment *ev);
/** if response did arrive, stream will be demarshalled. To create
foreign data types the factory-collection will be used.
returns true if response arrived and demarhalling was succesfull,
otherwise false */
gboolean orbit_foreign_response_check(CORBA_Object obj,
FrgnMethodDescr descr,
FrgnMethodCall call,
FrgnData data,
ORBit_ICollection * icollection,
ORBit_RequestID id,
CORBA_Environment *ev);
#if defined(__cplusplus)
}
#endif
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]