IDL file

Jayakumar Muthukumarasamy ([email protected])
Wed, 14 Dec 1994 19:01:03 -0500 (EST)

Hi Pedro,

I have enclosed a copy of the IDL description for the Application-IDL
interface. It is not yet complete. Specifically, there will be changes to
the interface "manager", and possibly there will be another interface
called "file". Do take a look at it, and pass me your comments.

thanks,
-jk

---------------------------------------------------------------------------

/*
* Assumptions about common member functions. For each attribute (this
* includes attributes which are sequences too), there are functions that
* set/get the value of the attribute. The function name is the name of
* the attribute itself. This will be generated in the process of
* translating to C++. Also for sequences of the following format.
*
* attribute sequence<T> A
*
* there are functions as follows (while this is generally true, exceptions
* do exist, and are notified appropriately).
*
* boolean delete_from_A(in string item);
* This function deletes "item" from the sequence. The return value
* is FALSE, if the item was not originally present in the sequence.
*
* void add_as_first_to_A(in T item);
* This function adds "item" as the first item to the sequence. This
* function always succeeds.
*
* void add_as_last_to_A(in T item);
* This function adds "item" as the last item to the sequence. This
* function always succeeds.
*
* boolean add_after_to_A(in string after, in T item);
* This function adds "item" to the sequence after the item "after".
* The return value is FALSE if the item "after" does not exist.
*
* boolean get_from_A(in string item, out T out_item);
* This function returns the "item" in the output parameter "out_item".
* The return value is FALSE is "item" does not exist.
*
* boolean set_in_A(in string item, in T new_item);
* This function sets the "item" in the value specified by the parameter
* "new_item". The return value is FALSE is "item" does not exist.
*
*
*/

#define DEFINE_SEQUENCE_OPS(NAME, TYPE) \
boolean delete_from_ ## NAME (in string item); \
void add_as_first_to_ ## NAME (in TYPE item); \
void add_as_last_to_ ## NAME (in TYPE item); \
boolean add_after_to_ ## NAME (in string after, in TYPE item); \
boolean get_from_ ## NAME (in string item, out TYPE out_item); \
boolean set_in_ ## NAME (in string item, in TYPE new_item); \

/*
* Define the IDL module.
*/
module IDL {

/*
* some typedefs.
*/
typedef unsigned short ushort;
typedef unsigned long ulong;

/*
* Some forward declarations.
*/
interface itype;
interface ifield;
interface isequence;
interface iarray;
interface ienum;
interface istruct;
interface iexception;
struct itriple;
interface iunion;
interface iattribute;
interface iparameter;
interface imethod;
interface iinterface;
interface imodule;
interface manager;

/*
* Define an itype. An itype has a type, and a value. There is
* some duplication here. We should be using any's to represent
* the "type, value" pair. But, the current implementation of any's
* is inextricably tied to the value class. I am not sure what
* the standard says about this. So, we will go with this for
* now.
*/
interface itype {

/*
* enumeration of possible types.
*/
enum idl_type {
t_void, /* void */
t_short, /* short */
t_long, /* long */
t_ushort, /* unsigned short */
t_ulong, /* unsigned long */
t_float, /* float */
t_double, /* double */
t_boolean, /* boolean */
t_char, /* char */
t_octet, /* octet */
t_object, /* object reference i.e. Object */
t_struct, /* struct */
t_any, /* any */
t_union, /* union */
t_enum, /* enum */
t_string, /* string */
t_sequence, /* sequence */
t_array /* array */
};

attribute idl_type type; /* the type of the field */

/*
* We have a union here to hold the value. It definitely
* does not make sense to define a variable of type void.
* So it has been commented. But, with Object I am not
* sure. Some IDL compilers accept it, while others don't.
*/
union ivalue switch(idl_type) {
// case t_void: void v_void;
case t_short: short v_short;
case t_long: long v_long;
case t_ushort: ushort v_ushort;
case t_ulong: ulong v_ulong;
case t_float: float v_float;
case t_double: double v_double;
case t_boolean: boolean v_boolean;
case t_char: char v_char;
case t_octet: octet v_octet;
// case t_object: Object v_object;
case t_struct: istruct v_struct;
case t_any: any v_any;
case t_union: iunion v_union;
case t_enum: ienum v_enum;
case t_string: string v_string;
case t_sequence: isequence v_sequence;
case t_array: iarray v_array;
};

/*
* These should be static functions ideally. But IDL
* doesn't support static functions.
*
* get_string_type - get the string form of "type".
* is_valid - check if "type" is valid.
*/
string get_string_type(in idl_type type);
boolean is_valid(in idl_type type);
};

/*
* Define an ifield. An ifield has a name, which is the name of
* the field, and a type which is the type of the field.
*/
interface ifield {
attribute itype type; /* the type of this field */
attribute string name; /* the name of this field */
};

/*
* Define an isequence. An isequence has a type, and a size. A size
* of -1 indicates an unbounded sequence. "type" is of type "itype"
* instead of "itype::idl_type", since we can have sequence
* of sequences.
*
* is_bounded - returns "TRUE" if this sequence is bounded
* and "FALSE" if it is not.
*/
interface isequence {
attribute itype type;
attribute int size;

boolean is_bounded();
};

/*
* Define an iarray. An iarray has a type, the number of dimensions
* and the values for the dimensions. The sequence here is a
* little different from the other sequences. We don't use the
* standard interface for the sequence as described above. We use
* a similar but more natural interface here.
*
* sizeof - returns the size of dimension "dim".
* change_sizeof - change the sizeof "dim" to "size".
* delete_dimension - delete the dimension "dim".
* add_dimension - add "dim" of size "size" after dimension
* "after".
*/
interface iarray {
attribute itype type;
attribute sequence<int> sizes;
attribute int dimensions;

int sizeof(in int dim);
boolean change_sizeof(in int dim, in int size);
boolean delete_dimension(in int dim);
boolean add_dimension(in int dim, in int size, in int after);
};

/*
* Define an ienum. An ienum consists of a list of strings which
* are the ids.
*/
interface ienum {
attribute string enum_name;
attribute sequence<string> enum_ids;

DEFINE_SEQUENCE_OPS(enum_ids, string);
};

/*
* Define an istruct. An istruct consists of a name which is the
* name of the structure, and a sequence of fields.
*/
interface istruct {
attribute string struct_name;
attribute sequence<ifield> fields;

DEFINE_SEQUENCE_OPS(fields, ifield);
};

/*
* Define an iexception. An iexception consists of a name which is
* the name of the exception, and a sequence of fields.
*/
interface iexception {
attribute string exception_name;
attribute sequence<ifield> fields;

DEFINE_SEQUENCE_OPS(fields, ifield);
};

/*
* Define an itriple. An itriple has the enum_id, the type of a
* variable and the name of a variable. This defines a member of
* a union.
*/
struct itriple {
attribute itype type;
attribute string name;
attribute string id;
};

/*
* Define an iunion. An iunion has a discriminator, and a sequence
* of itriples
*/
interface iunion {
attribute itype discriminator;
attribute sequence<itriple> fields;

DEFINE_SEQUENCE_OPS(fields, itriple);
};

/*
* An iattribute is a ifield with an additional attribute.
*/
interface iattribute : ifield {
attribute int is_readonly;
};

/*
* An iparameter contains, the mode, the type, and the name.
*/
interface iparameter {
enum imode {
mode_in, mode_inout, mode_out
};
attribute itype type;
attribute string param_name;
attribute imode mode;
};

/*
* An imethod has a name, a return_value, and a list of parameters.
*/
interface imethod {
attribute string name;
attribute itype return_value;
attribute sequence<iparameter> parameters;

DEFINE_SEQUENCE_OPS(parameters, iparameter);
};

/*
* An iinterface has typedefs, constants, attributes, exceptions,
* and methods.
*/
interface iinterface {
attribute sequence<string> typedefs;
attribute sequence<string> constants;
attribute sequence<iattribute> attributes;
attribute sequence<iexception> exceptions;
attribute sequence<imethod> methods;

DEFINE_SEQUENCE_OPS(typedefs, string);
DEFINE_SEQUENCE_OPS(constants, string);
DEFINE_SEQUENCE_OPS(attributes, iattribute);
DEFINE_SEQUENCE_OPS(exceptions, iexception);
DEFINE_SEQUENCE_OPS(methods, imethod);
};

/*
* An imodule has typedefs, constants, exceptions, interfaces, and
* other modules.
*/
interface imodule {
attribute sequence<string> typedefs;
attribute sequence<string> constants;
attribute sequence<iexception> exceptions;
attribute sequence<iinterface> interfaces;
attribute sequence<imodule> modules;

DEFINE_SEQUENCE_OPS(typedefs, string);
DEFINE_SEQUENCE_OPS(constants, string);
DEFINE_SEQUENCE_OPS(exceptions, iexception);
DEFINE_SEQUENCE_OPS(interfaces, iinterface);
DEFINE_SEQUENCE_OPS(modules, imodule);
};

/*
* This defines the manager interface to the IDL module. This will
* contain all the generic functions.
*/
interface manager {
sequence<string> get_all_modules();
sequence<string> get_all_interfaces();
sequence<string> get_all_types();
sequence<string> get_all_exceptions();
sequence<string> get_all_constants();
sequence<string> get_all_typedefs();

imodule get_module(in string module_name);
iinterface get_interface(in string interface_name);
iexception get_exception(in string exception_name);

/*
* I guess we will need these functions too.
*/
boolean parse_idl_file(in string filename);
boolean write_idl_file(in string filename);
boolean write_all_files();
};
};

---------------------------------------------------------------------------