diff options
Diffstat (limited to 'TAO')
28 files changed, 1786 insertions, 220 deletions
diff --git a/TAO/TAO_IDL/be_include/be.h b/TAO/TAO_IDL/be_include/be.h index eb2ebff48f7..cf2ef67dde2 100644 --- a/TAO/TAO_IDL/be_include/be.h +++ b/TAO/TAO_IDL/be_include/be.h @@ -69,13 +69,23 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // be.h // -// Main include file for dummy BE + +// ACE includes + +#include "ace/ACE.h" +#include "ace/OS.h" +#include "ace/Singleton.h" +#include "ace/Synch.h" +#include "ace/Log_Msg.h" /* * BE includes */ +#include "be_decl.h" // class BE_Decl +#include "be_scope.h" // class BE_Scope #include "be_generator.h" // BE generator class +#include "be_type.h" #include "be_predefined_type.h" // class BE_PredefinedType #include "be_module.h" // class BE_Module #include "be_interface.h" // class BE_Interface @@ -100,4 +110,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "be_root.h" // class BE_Root #include "be_helper.h" // helper functions +#include "be_codegen.h" // code generator +#include "be_factory.h" // factory + #endif // _BE_BE_HH diff --git a/TAO/TAO_IDL/be_include/be_argument.h b/TAO/TAO_IDL/be_include/be_argument.h index 86e3c468e0c..a20676a1c82 100644 --- a/TAO/TAO_IDL/be_include/be_argument.h +++ b/TAO/TAO_IDL/be_include/be_argument.h @@ -1,19 +1,62 @@ -#if !defined(BE_ARGUMENT_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_argument.h +// +// = DESCRIPTION +// Extension of class AST_Argument that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_ARGUMENT_H) #define BE_ARGUMENT_H /* * BE_Argument */ -class be_argument : public virtual AST_Argument { +class be_argument : public virtual AST_Argument, + public virtual be_decl +{ public: - // Operations - be_argument(); - be_argument(AST_Argument::Direction d, AST_Type *ft, UTL_ScopedName *n, - UTL_StrList *p); + // =Operations + + be_argument (void); + // default constructor + + be_argument (AST_Argument::Direction d, AST_Type *ft, UTL_ScopedName *n, + UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // generate client header for the argument + + virtual int gen_client_stubs (void); + // generate client side stubs for the argument + + virtual int gen_server_header (void); + // generate server header for the argument + + virtual int gen_server_skeletons (void); + // generate server skeletons for the argument + + virtual int gen_client_inline (void); + // Generates the client-side inline for the argument + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the argument // Narrowing - DEF_NARROW_METHODS1(be_argument, AST_Argument); - DEF_NARROW_FROM_DECL(be_argument); + DEF_NARROW_METHODS2 (be_argument, AST_Argument, be_decl); + DEF_NARROW_FROM_DECL (be_argument); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_array.h b/TAO/TAO_IDL/be_include/be_array.h index 3bfe45d366f..11608b56717 100644 --- a/TAO/TAO_IDL/be_include/be_array.h +++ b/TAO/TAO_IDL/be_include/be_array.h @@ -1,18 +1,73 @@ -#if !defined(BE_ARRAY_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_array.h +// +// = DESCRIPTION +// Extension of class AST_Array that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_ARRAY_H) #define BE_ARRAY_H /* * BE_Array */ -class be_array : public virtual AST_Array { +class be_array : public virtual AST_Array, + public virtual be_type +{ public: - // Operations - be_array(); - be_array(UTL_ScopedName *n, unsigned long ndims, UTL_ExprList *dims); + // =Operations + + be_array (void); + // default constructor + + be_array (UTL_ScopedName *n, unsigned long ndims, UTL_ExprList *dims); + // constructor + + virtual int gen_client_header (void); + // generate client header for array + + virtual int gen_client_stubs (void); + // generate client side stubs for array + + virtual int gen_server_header (void); + // generate server header for array + + virtual int gen_server_skeletons (void); + // generate server skeletons for array + + virtual int gen_client_inline (void); + // Generates the client-side inline for the array + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the array + + virtual int gen_typecode (void); + // generate the typecode + + virtual int gen_forany_defn (void); + // the forany class + + virtual int gen_forany_impl (void); + // the forany impl + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation // Narrowing - DEF_NARROW_METHODS1(be_array, AST_Array); - DEF_NARROW_FROM_DECL(be_array); + DEF_NARROW_METHODS2 (be_array, AST_Array, be_type); + DEF_NARROW_FROM_DECL (be_array); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_attribute.h b/TAO/TAO_IDL/be_include/be_attribute.h index f3f957a230c..2461013a402 100644 --- a/TAO/TAO_IDL/be_include/be_attribute.h +++ b/TAO/TAO_IDL/be_include/be_attribute.h @@ -1,18 +1,61 @@ -#if !defined(BE_ATTRIBUTE_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_attribute.h +// +// = DESCRIPTION +// Extension of class AST_Attribute that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_ATTRIBUTE_H) #define BE_ATTRIBUTE_H /* * BE_Attribute */ -class be_attribute : public virtual AST_Attribute { +class be_attribute : public virtual AST_Attribute, + public virtual be_decl +{ public: - // Operations - be_attribute(); - be_attribute(idl_bool ro, AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p); + // =Operations + + be_attribute (void); + // default constructor + + be_attribute (idl_bool ro, AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // generate client header for the attribute + + virtual int gen_client_stubs (void); + // generate client side stubs for the attribute + + virtual int gen_server_header (void); + // generate server header for the attribute + + virtual int gen_server_skeletons (void); + // generate server skeletons for the attribute + + virtual int gen_client_inline (void); + // Generates the client-side inline for the attribute + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the attribute // Narrowing - DEF_NARROW_METHODS1(be_attribute, AST_Attribute); - DEF_NARROW_FROM_DECL(be_attribute); + DEF_NARROW_METHODS2 (be_attribute, AST_Attribute, be_decl); + DEF_NARROW_FROM_DECL (be_attribute); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_codegen.h b/TAO/TAO_IDL/be_include/be_codegen.h new file mode 100644 index 00000000000..668cf30637e --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_codegen.h @@ -0,0 +1,171 @@ +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_codegen.h +// +// = DESCRIPTION +// The Code generator class +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (TAO_BE_CODEGEN_H) +#define TAO_BE_CODEGEN_H + +class TAO_CodeGen +{ + // = TITLE + // TAO_CodeGen + // + // = DESCRIPTION + // Holds global parameters for the Back End and generates the C++ mapping + // +public: + // define all the code generation states. + + enum CG_STATE + { + TAO_INITIAL, + TAO_ROOT, + TAO_MODULE, + TAO_INTERFACE, + TAO_CONSTANT, + TAO_SEQUENCE_BASE, + TAO_SEQUENCE_BODY, + TAO_UNION_DISCTYPEDEFN, // union has a different kind of mapping + TAO_UNION_PUBLIC, + TAO_UNION_PRIVATE, + TAO_STRUCT, + TAO_FIELD, + TAO_EXCEPTION, + TAO_ENUM, + TAO_ARRAY_DEFN, + TAO_ARRAY_OTHER, + TAO_STRING, + TAO_OPERATION, + TAO_ARGUMENT, + TAO_ATTRIBUTE, + TAO_TYPEDEF + }; + + TAO_CodeGen (void); + // Constructor + + ~TAO_CodeGen (void); + // destructor + + int gen_cplusplus_mapping (void); + // generate the C++ mapping for CORBA IDL + + int client_header (const char *fname); + // set the client header stream + + TAO_OutStream *client_header (void); + // get the client header stream + + int client_stubs (const char *fname); + // set the client stub stream + + TAO_OutStream *client_stubs (void); + // get the client stubs stream + + int client_inline (const char *fname); + // set the client inline stream + + TAO_OutStream *client_inline (void); + // get the client inline stream + + int server_header (const char *fname); + // set the server header stream + + TAO_OutStream *server_header (void); + // get the server header stream + + int server_skeletons (const char *fname); + // set the server skeletons stream + + TAO_OutStream *server_skeletons (void); + // get the server skeletons stream + + int server_inline (const char *fname); + // set the server inline stream + + TAO_OutStream *server_inline (void); + // get the server inline stream + + void outstream (TAO_OutStream *os); + // set current out stream + + TAO_OutStream *outstream (void); + // retrieve current out stream being used + + int end_client_header (void); + // put a last #endif in the client header + + int end_server_header (void); + // put a last #endif in the server header + + void push (CG_STATE s); + // set the code generation state + + void pop (void); + // out of the current state + + void reset (void); + // reset the stack to 1 + + CG_STATE state (void); + // return the current state + + void node (AST_Decl *n); + // pass info + + AST_Decl *node (void); + // retrieve passed info + +private: + TAO_OutStream *client_header_; + // client header stream + + TAO_OutStream *client_stubs_; + // client stub file stream + + TAO_OutStream *client_inline_; + // client side inline definitions + + TAO_OutStream *server_header_; + // server header stream + + TAO_OutStream *server_skeletons_; + // server skeleton stream + + TAO_OutStream *server_inline_; + // server side inline file + + TAO_OutStream *curr_os_; + // currently used out stream + + CG_STATE *state_; + // code generation state stack + + int top_; + // top of state stack + + int size_; + // size of allocated stack + + AST_Decl *node_; +}; + +typedef ACE_Singleton<TAO_CodeGen, ACE_SYNCH_MUTEX> TAO_CODEGEN; +// Singleton instance of the BE code generator + + +#endif // if !defined + diff --git a/TAO/TAO_IDL/be_include/be_constant.h b/TAO/TAO_IDL/be_include/be_constant.h index cc0797b02c4..e59426cfc5e 100644 --- a/TAO/TAO_IDL/be_include/be_constant.h +++ b/TAO/TAO_IDL/be_include/be_constant.h @@ -1,21 +1,68 @@ -#if !defined(BE_CONSTANT_H) +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_constant.h +// +// = DESCRIPTION +// Extension of class AST_Constant that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_CONSTANT_H) #define BE_CONSTANT_H /* * BE_Constant */ -class be_constant : public virtual AST_Constant { +class be_constant : public virtual AST_Constant , public virtual be_decl +{ public: // Operations - be_constant(); - be_constant(AST_Expression::ExprType et, - AST_Expression *v, - UTL_ScopedName *n, - UTL_StrList *p); + + be_constant (void); + // constructor + + be_constant (AST_Expression::ExprType et, + AST_Expression *v, + UTL_ScopedName *n, + UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the constant + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the constant + + virtual int gen_server_header (void); + // Generates the server-side header information for the constant + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the constant + + virtual int gen_client_inline (void); + // Generates the client-side inline for the constant + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the constant // Narrowing - DEF_NARROW_METHODS1(be_constant, AST_Constant); - DEF_NARROW_FROM_DECL(be_constant); + DEF_NARROW_METHODS2 (be_constant, AST_Constant, be_decl); + DEF_NARROW_FROM_DECL (be_constant); + +private: + char *exprtype_to_string (void); + // returns the appropriate type }; -#endif +#endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_decl.h b/TAO/TAO_IDL/be_include/be_decl.h new file mode 100644 index 00000000000..f2ec78a4ad4 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_decl.h @@ -0,0 +1,167 @@ +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_decl.h +// +// = DESCRIPTION +// Extension of the AST_Decl class. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (TAO_BE_DECL_H) +#define TAO_BE_DECL_H + +/* + * BE_Decl + */ +class be_decl : public virtual AST_Decl +{ + // = TITLE + // be_decl + // = DESCRIPTION + // The back end extension of the AST_Decl class. Provides an abstract + // interface + // +public: + enum SIZE_TYPE + { + FIXED, + VARIABLE + }; + // indicates if we are fixed size or variable. Most useful for structs, + // unions, and arrays. + + // =Operations + + be_decl (void); + // Default constructor + + be_decl (AST_Decl::NodeType type, UTL_ScopedName *n, UTL_StrList *pragmas); + // constructor that sets the node type + + ~be_decl (void); + // destructor + + virtual int gen_var_defn (void); + // generate the _var class definition + + virtual int gen_var_impl (void); + // generate the implementation for the _var class + + virtual int gen_out_defn (void); + // generate the _out class definition + + virtual int gen_out_impl (void); + // generate the _out implementation + + virtual int gen_client_header (void) = 0; + // Generates the client-side header information for the decl + + virtual int gen_client_stubs (void) = 0; + // Generates the client-side stubs for the decl + + virtual int gen_server_header (void) = 0; + // Generates the server-side header information for the decl + + virtual int gen_server_skeletons (void) = 0; + // Generates the server-side skeletons for the decl + + virtual int gen_client_inline (void) = 0; + // Generates the client-side inline for the decl + + virtual int gen_server_inline (void) = 0; + // Generates the server-side inlines for the decl + + virtual int gen_typecode (void); + // generate the typecode data structure + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + + virtual idl_bool lookup_seq_name (Identifier *); + // lookup a name inside a list of generated seq names + + virtual idl_bool add_seq_name (Identifier *); + // add a generated seq name to a list. + + virtual void size_type (SIZE_TYPE); + // set the size type + + virtual SIZE_TYPE size_type (void) const; + // return our size type + + const char *repoID (void); + // retrieve the repository ID + + const char *fullname (void); + // return the stringified full name + + const char *flatname (void); + // return the flattened full scoped name + + UTL_ScopedName *tc_name (void); + // return the typecode name + + // Narrowing + DEF_NARROW_METHODS1 (be_decl, AST_Decl); + DEF_NARROW_FROM_DECL (be_decl); + +protected: + // =helper + + virtual void compute_repoID (void); + // computes the repoID + + virtual void compute_fullname (void); + // computes the fully scoped name + + virtual void compute_tc_name (void); + // computes the fully scoped typecode name + + virtual void compute_flatname (void); + // compute the flattened fully scoped name + + virtual int tc_name2long (const char *name, long *&, long &); + // name represented as a padded array of longs + + // variables that indicate if the code generation for that node is already + // been done. This way we avoid regenerating same code. + idl_bool cli_hdr_gen_; + idl_bool cli_stub_gen_; + idl_bool cli_inline_gen_; + idl_bool srv_hdr_gen_; + idl_bool srv_skel_gen_; + idl_bool srv_inline_gen_; + + UTL_IdList *seq_names_; + // list of generated sequence names in the current scope + + char *fullname_; + // our full scoped name + + char *flatname_; + // flattened fully scoped name + + char *repoID_; + // repository ID + + UTL_ScopedName *tc_name_; + // typecode name + + SIZE_TYPE size_type_; + // whether we are fixed or variable size (by default fixed) + + long encap_len_; + // encapsulation length - required for typecodes +}; + +#endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_enum.h b/TAO/TAO_IDL/be_include/be_enum.h index 634da4c9a1e..9250c3c7c95 100644 --- a/TAO/TAO_IDL/be_include/be_enum.h +++ b/TAO/TAO_IDL/be_include/be_enum.h @@ -1,19 +1,82 @@ -#if !defined(BE_ENUM_H) +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_enum.h +// +// = DESCRIPTION +// Extension of class AST_Enum that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_ENUM_H) #define BE_ENUM_H /* * BE_Enum */ -class be_enum : public virtual AST_Enum { +class be_enum : public virtual AST_Enum, + public virtual be_scope, + public virtual be_type +{ public: // Operations - be_enum(); - be_enum(UTL_ScopedName *n, UTL_StrList *p); + + be_enum (void); + // default constructor + + be_enum (UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the enum + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the enum + + virtual int gen_server_header (void); + // Generates the server-side header information for the enum + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the enum + + virtual int gen_client_inline (void); + // Generates the client-side inline for the enum + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the enum + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + + virtual int member_count (void); + // return the count of members // Narrowing - DEF_NARROW_METHODS1(be_enum, AST_Enum); - DEF_NARROW_FROM_DECL(be_enum); - DEF_NARROW_FROM_SCOPE(be_enum); + DEF_NARROW_METHODS3 (be_enum, AST_Enum, be_scope, be_type); + DEF_NARROW_FROM_DECL (be_enum); + DEF_NARROW_FROM_SCOPE (be_enum); + +private: + //=helper + + int compute_member_count (void); + // count the number of members + + int member_count_; + // number of members }; #endif diff --git a/TAO/TAO_IDL/be_include/be_enum_val.h b/TAO/TAO_IDL/be_include/be_enum_val.h index 533c422e287..872575a0437 100644 --- a/TAO/TAO_IDL/be_include/be_enum_val.h +++ b/TAO/TAO_IDL/be_include/be_enum_val.h @@ -1,18 +1,68 @@ -#if !defined(BE_ENUM_VAL_H) +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_enum_val.h +// +// = DESCRIPTION +// Extension of class AST_EnumVal that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_ENUM_VAL_H) #define BE_ENUM_VAL_H /* * BE_EnumVal */ -class be_enum_val : public virtual AST_EnumVal { +class be_enum_val : public virtual AST_EnumVal, + public virtual be_decl +{ public: - // Operations - be_enum_val(); - be_enum_val(unsigned long v, UTL_ScopedName *n, UTL_StrList *p); + // =Operations + + be_enum_val (void); + // default constructor + + be_enum_val (unsigned long v, UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the EnumVal + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the EnumVal + + virtual int gen_server_header (void); + // Generates the server-side header information for the EnumVal + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the EnumVal + + virtual int gen_client_inline (void); + // Generates the client-side inline for the EnumVal + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the EnumVal + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation // Narrowing - DEF_NARROW_METHODS1(be_enum_val, AST_EnumVal); - DEF_NARROW_FROM_DECL(be_enum_val); + DEF_NARROW_METHODS2 (be_enum_val, AST_EnumVal, be_decl); + DEF_NARROW_FROM_DECL (be_enum_val); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_exception.h b/TAO/TAO_IDL/be_include/be_exception.h index 401539c0ef0..36318ce7ef6 100644 --- a/TAO/TAO_IDL/be_include/be_exception.h +++ b/TAO/TAO_IDL/be_include/be_exception.h @@ -4,16 +4,61 @@ /* * BE_Exception */ -class be_exception : public virtual AST_Exception { +class be_exception : public virtual AST_Exception, + public virtual be_scope, + public virtual be_decl + +{ public: // Operations - be_exception(); - be_exception(UTL_ScopedName *n, UTL_StrList *p); + be_exception (void); + // default constructor + + be_exception (UTL_ScopedName *n, UTL_StrList *p); + // constructor + + // =code generation + + virtual int gen_client_header (void); + // generate client header + + virtual int gen_client_inline (void); + // generate client inline + + virtual int gen_client_stubs (void); + // generate client stubs + + virtual int gen_server_header (void); + // generate server header + + virtual int gen_server_inline (void); + // generate server inline + + virtual int gen_server_skeletons (void); + // generate server skeletons + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + + virtual int member_count (void); + // return the count of members // Narrowing - DEF_NARROW_METHODS1(be_exception, AST_Exception); - DEF_NARROW_FROM_DECL(be_exception); - DEF_NARROW_FROM_SCOPE(be_exception); + DEF_NARROW_METHODS3 (be_exception, AST_Exception, be_scope, be_decl); + DEF_NARROW_FROM_DECL (be_exception); + DEF_NARROW_FROM_SCOPE (be_exception); + +private: + //=helper + + int compute_member_count (void); + // count the number of members + + int member_count_; + // number of members }; #endif diff --git a/TAO/TAO_IDL/be_include/be_expression.h b/TAO/TAO_IDL/be_include/be_expression.h index 217d77ba03d..ae3d90d2164 100644 --- a/TAO/TAO_IDL/be_include/be_expression.h +++ b/TAO/TAO_IDL/be_include/be_expression.h @@ -1,23 +1,43 @@ -#if !defined(BE_EXPRESSION_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_expression.h +// +// = DESCRIPTION +// Extension of class AST_Expression that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_EXPRESSION_H) #define BE_EXPRESSION_H /* * BE_Expression */ -class be_expr_val : public virtual AST_Expression { +class be_expression : public virtual AST_Expression +{ public: // Operations - be_expr_val(UTL_ScopedName *n); - be_expr_val(AST_Expression *b, AST_Expression::ExprType t); - be_expr_val(AST_Expression::ExprComb c, - AST_Expression *v1, - AST_Expression *v2); - be_expr_val(long l); - be_expr_val(long l, AST_Expression::ExprType t); - be_expr_val(unsigned long l); - be_expr_val(String *s); - be_expr_val(char c); - be_expr_val(double d); + be_expression (UTL_ScopedName *n); + be_expression (AST_Expression *b, AST_Expression::ExprType t); + be_expression (AST_Expression::ExprComb c, + AST_Expression *v1, + AST_Expression *v2); + be_expression (long l); + be_expression (long l, AST_Expression::ExprType t); + be_expression (unsigned long l); + be_expression (String *s); + be_expression (char c); + be_expression (double d); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_factory.h b/TAO/TAO_IDL/be_include/be_factory.h new file mode 100644 index 00000000000..297e8477f67 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_factory.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL Backend +// +// = FILENAME +// be_factory.h +// +// = DESCRIPTION +// Defines a factory that returns a specialized output stream object that +// understands a specific Front End +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (TAO_BE_FACTORY_H) +#define TAO_BE_FACTORY_H + +class TAO_OutStream_Factory +{ + // =TITLE + // TAO_OutStream_Factory + // =DESCRIPTION + // factory to produce specialized instances of the output stream objects +public: + enum TAO_OutStream_Type + { + TAO_SUNSOFT, + TAO_FLICK + }; + + TAO_OutStream_Factory (void); + // constructor + + ~TAO_OutStream_Factory (void); + // destructor + + TAO_OutStream *make_outstream (void); + // make the specialized out stream class + + int set_stream_type (TAO_OutStream_Type t); + // set the stream type + +private: + TAO_OutStream_Type strm_type_; +}; + +typedef ACE_Singleton<TAO_OutStream_Factory,ACE_SYNCH_MUTEX> TAO_OUTSTREAM_FACTORY; +// Singleton instance of the OutStream factory + +#endif // if !defined + diff --git a/TAO/TAO_IDL/be_include/be_field.h b/TAO/TAO_IDL/be_include/be_field.h index 6abf91859bd..95e14f19759 100644 --- a/TAO/TAO_IDL/be_include/be_field.h +++ b/TAO/TAO_IDL/be_include/be_field.h @@ -1,18 +1,68 @@ -#if !defined(BE_FIELD_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_field.h +// +// = DESCRIPTION +// Extension of class AST_Field that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_FIELD_H) #define BE_FIELD_H /* * BE_Field */ -class be_field : public virtual AST_Field { +class be_field : public virtual AST_Field, + public virtual be_decl +{ public: - // Operations - be_field(); - be_field(AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p); + // =Operations + + be_field (void); + // default constructor + + be_field (AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the field + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the field + + virtual int gen_server_header (void); + // Generates the server-side header information for the field + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the field + + virtual int gen_client_inline (void); + // Generates the client-side inline for the field + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the field + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation // Narrowing - DEF_NARROW_METHODS1(be_field, AST_Field); - DEF_NARROW_FROM_DECL(be_field); + DEF_NARROW_METHODS2 (be_field, AST_Field, be_decl); + DEF_NARROW_FROM_DECL (be_field); + }; #endif diff --git a/TAO/TAO_IDL/be_include/be_helper.h b/TAO/TAO_IDL/be_include/be_helper.h index 039dc60ee3f..3a3740b52fc 100644 --- a/TAO/TAO_IDL/be_include/be_helper.h +++ b/TAO/TAO_IDL/be_include/be_helper.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ // ============================================================================ // // = LIBRARY @@ -7,78 +8,99 @@ // be_helper.h // // = DESCRIPTION -// Helper utilities and global singleton "params" class +// Defines the abstract class for outputting the C++ mapping. This is a +// helper class to the singleton TAO_CodeGen class // // = AUTHOR // Aniruddha Gokhale // // ============================================================================ -#if !defined (TAO_BE_HELPER_H) -#define TAO_BE_HELPER_H +#if !defined (TAO_BE_OUTSTRM_H) +#define TAO_BE_OUTSTRM_H -#include "iostream.h" -#include "fstream.h" -#include "ace/ACE.h" -#include "ace/OS.h" -#include "ace/Singleton.h" -#include "ace/Synch.h" +// a dummy structure to inform TAO_OutStream's << operator to put a newline +// and use the current indentation for the succeeding line +struct TAO_NL +{ +public: + TAO_NL (void); +}; -class TAO_BE_Params -// = TITLE -// Holds global parameters for the Back End -// -// = DESCRIPTION -// +class TAO_OutStream { + // =TITLE + /// TAO_OutStream + // =DESCRIPTION + // Defines an interface by which the backend code generator can print its + // output to the underlying I/O handle. This is a helper class that will be + // used by the TAO_CodeGen class. However, this is an abstract class and + // classes that understand specific front ends must derive from this + // class. public: - TAO_BE_Params(); - // Constructor + TAO_OutStream (void); + // constructor. - void client_header(streambuf *sbuf); - // set the client header stream + ~TAO_OutStream (void); + // destructor - streambuf* client_header(); - // get the client header stream + int open (const char *fname); + // open the underlying low-level handle for output - void client_stubs(streambuf* f); - // set the client stub stream + int incr_indent (unsigned short flag=1); + // increment the indentation level and by default actually indent the output + // accordingly - streambuf* client_stubs(); - // get the client stubs stream + int decr_indent (unsigned short flag=1); + // decrease the indentation level and by default actually indent the output + // accordingly - void server_header(streambuf* f); - // set the server header stream + int reset (void); + // reset indentation level to 0 - streambuf* server_header(); - // get the server header stream + int indent (void); + // indent starting next line - void server_skeletons(streambuf* f); - // set the server skeletons stream + int nl (void); + // put a newline and indent on the next line - streambuf* server_skeletons(); - // get the server skeletons stream -private: - streambuf *pd_client_header; - // client header stream + int print (const char *format, ...); + // "printf" style variable argument print - streambuf *pd_client_stubs; - // client stub file stream + // =overloaded operators - streambuf *pd_server_header; - // server header stream + TAO_OutStream &operator<< (const char *str); + // output the char string and return a reference to ourselves - streambuf *pd_server_skeletons; - // server skeleton stream -}; + TAO_OutStream &operator<< (const int num); + // output the integer and return a reference to ourselves + + TAO_OutStream &operator<< (const TAO_NL nl); + // The following will be provided by specialized classes -typedef ACE_Singleton<TAO_BE_Params,ACE_Thread_Mutex> TAO_BE_PARAMS; -// Singleton instance of BE parameters + TAO_OutStream &operator<< (Identifier *id); + // output an Identifier node -const char* be_get_client_hdr_fname(); -const char* be_get_client_stub_fname(); -const char* be_get_server_hdr_fname(); -const char* be_get_server_skeleton_fname(); + TAO_OutStream &operator<< (UTL_IdList *idl); + // output a scoped name + TAO_OutStream &operator<< (AST_Expression *expr); + // output an AST_Expression node + + // provided by specialized classes + virtual TAO_OutStream &print (Identifier *id) = 0; + + virtual TAO_OutStream &print (UTL_IdList *idl) = 0; + + virtual TAO_OutStream &print (AST_Expression *idl) = 0; + +protected: + FILE *fp_; + // the underlying low-level I/O handle + + int indent_level_; + // indentation level + +}; -#endif +#endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_interface.h b/TAO/TAO_IDL/be_include/be_interface.h index 9cf35a04967..c4291663e74 100644 --- a/TAO/TAO_IDL/be_include/be_interface.h +++ b/TAO/TAO_IDL/be_include/be_interface.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ // ============================================================================ // // = LIBRARY @@ -23,39 +24,65 @@ /* * BE_Interface */ -class be_interface : public virtual AST_Interface +class be_interface : public virtual AST_Interface, + public virtual be_scope, + public virtual be_type +{ // = TITLE // The back end extension of the AST_Interface class // // = DESCRIPTION // -{ public: // Operations - be_interface(); + be_interface (void); // Default constructor - be_interface(UTL_ScopedName *n, AST_Interface **ih, long nih, - UTL_StrList *p); + be_interface (UTL_ScopedName *n, AST_Interface **ih, long nih, + UTL_StrList *p); // Constructor that sets its scoped name <n>, a list of inherited interfaces // <ih>, the number of inherited interfaces <nih>, and any prgmas <p> - void gen_client_header(); + virtual int gen_client_header (void); // Generates the client-side header information for the interface - void gen_client_stubs(); + virtual int gen_client_stubs (void); // Generates the client-side stubs for the interface - void gen_server_header(); + virtual int gen_server_header (void); // Generates the server-side header information for the interface - void gen_server_skeletons(); + virtual int gen_server_skeletons (void); // Generates the server-side skeletons for the interface + virtual int gen_client_inline (void); + // Generates the client-side inline for the interface + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the interface + + const char *full_skel_name (void); + // retrieve the fully scoped skel class name + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + // Narrowing - DEF_NARROW_METHODS1(be_interface, AST_Interface); - DEF_NARROW_FROM_DECL(be_interface); - DEF_NARROW_FROM_SCOPE(be_interface); + DEF_NARROW_METHODS3 (be_interface, AST_Interface, be_scope, be_type); + DEF_NARROW_FROM_DECL (be_interface); + DEF_NARROW_FROM_SCOPE (be_interface); + +private: + void compute_fullskelname (void); + // compute the fully scoped skel class name + + // helper methods for the C++ mapping process + int gen_operation_table (void); + + char *full_skel_name_; // fully scoped skeleton name }; -#endif +#endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_module.h b/TAO/TAO_IDL/be_include/be_module.h index b882563d812..b4089e066e5 100644 --- a/TAO/TAO_IDL/be_include/be_module.h +++ b/TAO/TAO_IDL/be_include/be_module.h @@ -1,20 +1,65 @@ -#if !defined(_BE_MODULE_H) +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_module.h +// +// = DESCRIPTION +// Extension of class AST_Module that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (_BE_MODULE_H) #define _BE_MODULE_H /* * BE_Module */ -class be_module : public virtual AST_Module { +class be_module : public virtual AST_Module, + public virtual be_scope, + public virtual be_decl +{ public: - // Operations - be_module(); - be_module(UTL_ScopedName *n, UTL_StrList *p); + // =Operations + + be_module (void); + // default constructor + + be_module (UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the module + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the module + + virtual int gen_server_header (void); + // Generates the server-side header information for the module + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the module + + virtual int gen_client_inline (void); + // Generates the client-side inline for the module + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the module // Narrowing - DEF_NARROW_METHODS1(be_module, AST_Module); - DEF_NARROW_FROM_DECL(be_module); - DEF_NARROW_FROM_SCOPE(be_module); + DEF_NARROW_METHODS3 (be_module, AST_Module, be_scope, be_decl); + DEF_NARROW_FROM_DECL (be_module); + DEF_NARROW_FROM_SCOPE (be_module); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_operation.h b/TAO/TAO_IDL/be_include/be_operation.h index 46751aad21b..64b449ea758 100644 --- a/TAO/TAO_IDL/be_include/be_operation.h +++ b/TAO/TAO_IDL/be_include/be_operation.h @@ -1,20 +1,64 @@ -#if !defined(BE_OPERATION_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_operation.h +// +// = DESCRIPTION +// Extension of class AST_Operation that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_OPERATION_H) #define BE_OPERATION_H /* * BE_Operation */ -class be_operation : public virtual AST_Operation { +class be_operation : public virtual AST_Operation, + public virtual be_scope, + public virtual be_decl +{ public: - // Operations - be_operation(); - be_operation(AST_Type *rt, AST_Operation::Flags fl, UTL_ScopedName *n, - UTL_StrList *p); + // =Operations + + be_operation (void); + // default constructor + + be_operation (AST_Type *rt, AST_Operation::Flags fl, UTL_ScopedName *n, + UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // generate client header + + virtual int gen_client_stubs (void); + // generate client side stubs + + virtual int gen_server_header (void); + // generate server header + + virtual int gen_server_skeletons (void); + // generate server skeletons + + virtual int gen_client_inline (void); + // Generates the client-side inline for the operation + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the operation // Narrowing - DEF_NARROW_METHODS1(be_operation, AST_Operation); - DEF_NARROW_FROM_DECL(be_operation); - DEF_NARROW_FROM_SCOPE(be_operation); + DEF_NARROW_METHODS3 (be_operation, AST_Operation, be_scope, be_decl); + DEF_NARROW_FROM_DECL (be_operation); + DEF_NARROW_FROM_SCOPE (be_operation); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_predefined_type.h b/TAO/TAO_IDL/be_include/be_predefined_type.h index 758a5a73238..81df502f216 100644 --- a/TAO/TAO_IDL/be_include/be_predefined_type.h +++ b/TAO/TAO_IDL/be_include/be_predefined_type.h @@ -1,4 +1,24 @@ -#ifndef _BE_PREDEFINED_TYPE_H +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_predefined_type.h +// +// = DESCRIPTION +// Extension of class AST_PredefinedType that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (_BE_PREDEFINED_TYPE_H) #define _BE_PREDEFINED_TYPE_H // be_classes.hh @@ -8,16 +28,50 @@ /* * BE_PredefinedType */ -class be_predefined_type : public virtual AST_PredefinedType { +class be_predefined_type : public virtual AST_PredefinedType, + public virtual be_type +{ public: - // Operations - be_predefined_type(); - be_predefined_type(AST_PredefinedType::PredefinedType t, UTL_ScopedName *n, - UTL_StrList *p); + // =Operations + + be_predefined_type (void); + // default constructor + + be_predefined_type (AST_PredefinedType::PredefinedType t, UTL_ScopedName *n, + UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the predefined type + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the predefined type + + virtual int gen_server_header (void); + // Generates the server-side header information for the predefined type + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the predefined type + + virtual int gen_client_inline (void); + // Generates the client-side inline for the predefined type + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the predefined type + + virtual int gen_typecode (void); + // generate the typecode + + const char *const gen_corba_mapping (void); + // helper for all the above virtual methods // Narrowing - DEF_NARROW_METHODS1(be_predefined_type, AST_PredefinedType); - DEF_NARROW_FROM_DECL(be_predefined_type); + DEF_NARROW_METHODS2 (be_predefined_type, AST_PredefinedType, be_type); + DEF_NARROW_FROM_DECL (be_predefined_type); + +protected: + virtual void compute_tc_name (void); + // overridden method }; #endif diff --git a/TAO/TAO_IDL/be_include/be_root.h b/TAO/TAO_IDL/be_include/be_root.h index 7a15cb58080..f1b16b8e22f 100644 --- a/TAO/TAO_IDL/be_include/be_root.h +++ b/TAO/TAO_IDL/be_include/be_root.h @@ -1,3 +1,4 @@ +/* -*- c++ -*- */ // ============================================================================ // // = LIBRARY @@ -7,8 +8,7 @@ // be_root.h // // = DESCRIPTION -// Extension of class AST_Root that provides additional means for C++ -// mapping of an interface. +// Extension of class AST_Root that provides the backend // // = AUTHOR // Copyright 1994-1995 by Sun Microsystems, Inc. @@ -20,40 +20,55 @@ #if !defined (TAO_BE_ROOT_H) #define TAO_BE_ROOT_H -class be_root : public virtual AST_Root +class be_root : public virtual AST_Root, + public virtual be_scope, + public virtual be_decl +{ // = TITLE // The back end extension of the AST_Root class // // = DESCRIPTION // -{ public: // Operations - be_root(); + be_root (void); // Default constructor - be_root(UTL_ScopedName *n, UTL_StrList *p); + be_root (UTL_ScopedName *n, UTL_StrList *p); // Constructor that sets its scoped name <n>, and any pragmas <p> - long gen_idl2cplusplus_mapping(); + int gen_idl2cplusplus_mapping (void); // generates the IDL to C++ mapping - long gen_client_header(); - // Generates the client-side header information for the interface + virtual int gen_client_header (void); + // Generates the client-side header information for the root + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the root + + virtual int gen_server_header (void); + // Generates the server-side header information for the root + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the root - long gen_client_stubs(); - // Generates the client-side stubs for the interface + virtual int gen_client_inline (void); + // Generates the client-side inline for the root - long gen_server_header(); - // Generates the server-side header information for the interface + virtual int gen_server_inline (void); + // Generates the server-side inlines for the root - long gen_server_skeletons(); - // Generates the server-side skeletons for the interface + // =Scope management functions that override the AST scope management methods + // since the AST methods set the names of the sequences, strings, and arrays + // to a fixed value which interferes with our back-end code generation + AST_Sequence *fe_add_sequence (AST_Sequence *); + AST_String *fe_add_string (AST_String *); + AST_Array *fe_add_array (AST_Array *); // Narrowing - DEF_NARROW_METHODS1(be_root, AST_root); - DEF_NARROW_FROM_DECL(be_root); - DEF_NARROW_FROM_SCOPE(be_root); + DEF_NARROW_METHODS3 (be_root, AST_Root, be_scope, be_decl); + DEF_NARROW_FROM_DECL (be_root); + DEF_NARROW_FROM_SCOPE (be_root); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_scope.h b/TAO/TAO_IDL/be_include/be_scope.h new file mode 100644 index 00000000000..5a63e7f31dc --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_scope.h @@ -0,0 +1,74 @@ +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_scope.h +// +// = DESCRIPTION +// Extension of the UTL_Scope CFE class +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (TAO_BE_SCOPE_H) +#define TAO_BE_SCOPE_H + +/* + * BE_Scope + */ +class be_scope : public virtual UTL_Scope +{ + // = TITLE + // be_scope + // = DESCRIPTION + // The back end extension of the UTL_Scope class + // +public: + // Operations + + be_scope (void); + // Default constructor + + be_scope (AST_Decl::NodeType nt); + // constructor that sets the node type + + virtual ~be_scope (void); + // destructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the scope + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the scope + + virtual int gen_server_header (void); + // Generates the server-side header information for the scope + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the scope + + virtual int gen_client_inline (void); + // Generates the client-side inline for the scope + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the scope + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + + // Narrowing + DEF_NARROW_METHODS1 (be_scope, UTL_Scope); + DEF_NARROW_FROM_SCOPE (be_scope); +}; + +#endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_sequence.h b/TAO/TAO_IDL/be_include/be_sequence.h index 135cb1810c0..455cab25375 100644 --- a/TAO/TAO_IDL/be_include/be_sequence.h +++ b/TAO/TAO_IDL/be_include/be_sequence.h @@ -1,18 +1,77 @@ -#if !defined(BE_SEQUENCE_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_sequence.h +// +// = DESCRIPTION +// Extension of class AST_Sequence that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_SEQUENCE_H) #define BE_SEQUENCE_H /* * BE_Sequence */ -class be_sequence : public virtual AST_Sequence { +class be_sequence : public virtual AST_Sequence, + public virtual be_type +{ public: - // Operations - be_sequence(); - be_sequence(AST_Expression *v, AST_Type *bt); + // =Operations + + be_sequence (void); + // default constructor + + be_sequence (AST_Expression *v, AST_Type *bt); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the sequence + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the sequence + + virtual int gen_server_header (void); + // Generates the server-side header information for the sequence + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the sequence + + virtual int gen_client_inline (void); + // Generates the client-side inline for the sequence + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the sequence + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation // Narrowing - DEF_NARROW_METHODS1(be_sequence, AST_Sequence); - DEF_NARROW_FROM_DECL(be_sequence); + DEF_NARROW_METHODS2 (be_sequence, AST_Sequence, be_type); + DEF_NARROW_FROM_DECL (be_sequence); + +private: + void compute_scoped_name (void); + // for anonymous sequences, we compute our scoped name + + idl_bool unbounded_; + // whether we are bounded or unbounded + + be_sequence *seq_node_; + // if we enclose a sequence node }; #endif diff --git a/TAO/TAO_IDL/be_include/be_string.h b/TAO/TAO_IDL/be_include/be_string.h index 3cf8f065a85..9e3801d3e35 100644 --- a/TAO/TAO_IDL/be_include/be_string.h +++ b/TAO/TAO_IDL/be_include/be_string.h @@ -1,19 +1,70 @@ -#if !defined(BE_STRING_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_string.h +// +// = DESCRIPTION +// Extension of class AST_String that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_STRING_H) #define BE_STRING_H /* * BE_String */ -class be_string : public virtual AST_String { +class be_string : public virtual AST_String, + public virtual be_type +{ public: // Operations - be_string(); - be_string(AST_Expression *v); - be_string(AST_Expression *v, long wide); + + be_string (void); + // default constructor + + be_string (AST_Expression *v); + // constructor + + be_string (AST_Expression *v, long wide); + // constructor + + virtual int gen_client_header (void); + // generate client header for string + + virtual int gen_client_stubs (void); + // generate client side stubs for string + + virtual int gen_server_header (void); + // generate server header for string + + virtual int gen_server_skeletons (void); + // generate server skeletons for string + + virtual int gen_client_inline (void); + // Generates the client-side inline for the string + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the string + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation // Narrowing - DEF_NARROW_METHODS1(be_string, AST_String); - DEF_NARROW_FROM_DECL(be_string); + DEF_NARROW_METHODS2 (be_string, AST_String, be_type); + DEF_NARROW_FROM_DECL (be_string); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_structure.h b/TAO/TAO_IDL/be_include/be_structure.h index aff675dc176..fb317dd57dc 100644 --- a/TAO/TAO_IDL/be_include/be_structure.h +++ b/TAO/TAO_IDL/be_include/be_structure.h @@ -1,19 +1,82 @@ -#if !defined(BE_STRUCTURE_H) +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_structure.h +// +// = DESCRIPTION +// Extension of class AST_Structure that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_STRUCTURE_H) #define BE_STRUCTURE_H /* * BE_Structure */ -class be_structure : public virtual AST_Structure { +class be_structure : public virtual AST_Structure, + public virtual be_scope, + public virtual be_type +{ public: - // Operations - be_structure(); - be_structure(UTL_ScopedName *n, UTL_StrList *p); + // =Operations + + be_structure (void); + // default constructor + + be_structure (UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the struct + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the struct + + virtual int gen_server_header (void); + // Generates the server-side header information for the struct + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the struct + + virtual int gen_client_inline (void); + // Generates the client-side inline for the struct + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the struct + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + + virtual int member_count (void); + // return the count of members // Narrowing - DEF_NARROW_METHODS1(be_structure, AST_Structure); - DEF_NARROW_FROM_DECL(be_structure); - DEF_NARROW_FROM_SCOPE(be_structure); + DEF_NARROW_METHODS3 (be_structure, AST_Structure, be_scope, be_type); + DEF_NARROW_FROM_DECL (be_structure); + DEF_NARROW_FROM_SCOPE (be_structure); + +private: + //=helper + + int compute_member_count (void); + // count the number of members + + int member_count_; + // number of members }; #endif diff --git a/TAO/TAO_IDL/be_include/be_sunsoft.h b/TAO/TAO_IDL/be_include/be_sunsoft.h new file mode 100644 index 00000000000..7dc6c512fe3 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_sunsoft.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_sunsoft.h +// +// = DESCRIPTION +// SunSoft specific backend output generation +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (TAO_BE_HELPER_H) +#define TAO_BE_HELPER_H + +class TAO_SunSoft_OutStream : public TAO_OutStream +{ + // =TITLE + // TAO_SunSoft_OutStream + // =DESCRIPTION + // Backend specific to SunSoft AST nodes +public: + TAO_SunSoft_OutStream (void); + // constructor + + ~TAO_SunSoft_OutStream (void); + // destuctor + + virtual TAO_OutStream &print (Identifier *id); + // output the SunSoft IDL Identifier Node + + virtual TAO_OutStream &print (UTL_IdList *idl); + // output the SunSoft IDL UTL_IdList Node which is usually used to maintain a + // scoped name + + virtual TAO_OutStream &print (AST_Expression *expr); + // output the contents of the AST_Expression node +}; + +#endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_type.h b/TAO/TAO_IDL/be_include/be_type.h new file mode 100644 index 00000000000..80ee7bd7afe --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_type.h @@ -0,0 +1,79 @@ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_type.h +// +// = DESCRIPTION +// Extension of class AST_Type that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_TYPE_H) +#define BE_TYPE_H + +/* + * BE_Type + */ +class be_type : public virtual AST_Type, + public virtual be_decl +{ +public: + // =Operations + + be_type (void); + // default constructor + + be_type (AST_Decl::NodeType nt, UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the type + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the type + + virtual int gen_server_header (void); + // Generates the server-side header information for the type + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the type + + virtual int gen_client_inline (void); + // Generates the client-side inline for the type + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the type + + virtual int gen_typecode (void); + // generate the typecode data structure + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + + // Narrowing + DEF_NARROW_METHODS2 (be_type, AST_Type, be_decl); + DEF_NARROW_FROM_DECL (be_type); + +private: + // helpers + int gen_predefined_type (void); + int gen_string (void); + int gen_array (void); + int gen_sequence (void); + int gen_enum (void); + int gen_struct (void); + int gen_union (void); + int gen_typedef (void); + int gen_interface (void); +}; + +#endif diff --git a/TAO/TAO_IDL/be_include/be_typedef.h b/TAO/TAO_IDL/be_include/be_typedef.h index 163f37e03c4..d2327235bb2 100644 --- a/TAO/TAO_IDL/be_include/be_typedef.h +++ b/TAO/TAO_IDL/be_include/be_typedef.h @@ -1,18 +1,65 @@ -#if !defined(BE_TYPEDEF_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_typedef.h +// +// = DESCRIPTION +// Extension of class AST_typedef that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_TYPEDEF_H) #define BE_TYPEDEF_H /* * BE_Typedef */ -class be_typedef : public virtual AST_Typedef { +class be_typedef : public virtual AST_Typedef, + public virtual be_type +{ public: - // Operations - be_typedef(); - be_typedef(AST_Type *bt, UTL_ScopedName *n, UTL_StrList *p); + // =Operations + + be_typedef (void); + // default constructor + + be_typedef (AST_Type *bt, UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the typedef + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the typedef + + virtual int gen_server_header (void); + // Generates the server-side header information for the typedef + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the typedef + + virtual int gen_client_inline (void); + // Generates the client-side inline for the typedef + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the typedef + + virtual int gen_typecode (void); + // generate the typecode // Narrowing - DEF_NARROW_METHODS1(be_typedef, AST_Typedef); - DEF_NARROW_FROM_DECL(be_typedef); + DEF_NARROW_METHODS2 (be_typedef, AST_Typedef, be_type); + DEF_NARROW_FROM_DECL (be_typedef); + }; #endif diff --git a/TAO/TAO_IDL/be_include/be_union.h b/TAO/TAO_IDL/be_include/be_union.h index 2960c0b65c7..7b461898e87 100644 --- a/TAO/TAO_IDL/be_include/be_union.h +++ b/TAO/TAO_IDL/be_include/be_union.h @@ -1,19 +1,90 @@ -#if !defined(BE_UNION_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_union.h +// +// = DESCRIPTION +// Extension of class AST_Union that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_UNION_H) #define BE_UNION_H /* * BE_Union */ -class be_union : public virtual AST_Union { +class be_union : public virtual AST_Union, + public virtual be_scope, + public virtual be_type +{ public: - // Operations - be_union(); + // =Operations + + be_union (void); + // default constructor + be_union(AST_ConcreteType *dt, UTL_ScopedName *n, UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the union + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the union + + virtual int gen_server_header (void); + // Generates the server-side header information for the union + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the union + + virtual int gen_client_inline (void); + // Generates the client-side inline for the union + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the union + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation + + virtual int member_count (void); + // return the count of members + + virtual int default_index (void); + // return the default index used // Narrowing - DEF_NARROW_METHODS1(be_union, AST_Union); + DEF_NARROW_METHODS3 (be_union, AST_Union, be_scope, be_type); DEF_NARROW_FROM_DECL(be_union); DEF_NARROW_FROM_SCOPE(be_union); + +private: + //=helper + + int compute_member_count (void); + // count the number of members + + int compute_default_index (void); + // count the default index + + int member_count_; + // number of members + + int default_index_; + // default label index (zero based indexing) }; #endif diff --git a/TAO/TAO_IDL/be_include/be_union_branch.h b/TAO/TAO_IDL/be_include/be_union_branch.h index 3121d311114..a8feadd19b1 100644 --- a/TAO/TAO_IDL/be_include/be_union_branch.h +++ b/TAO/TAO_IDL/be_include/be_union_branch.h @@ -1,19 +1,67 @@ -#if !defined(BE_UNION_BRANCH_H) +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_union_branch.h +// +// = DESCRIPTION +// Extension of class AST_UnionBranch that provides additional means for C++ +// mapping. +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems, Inc. +// and +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (BE_UNION_BRANCH_H) #define BE_UNION_BRANCH_H /* * BE_UnionBranch */ -class be_union_branch : public virtual AST_UnionBranch { +class be_union_branch : public virtual AST_UnionBranch, + public virtual be_decl +{ public: // Operations - be_union_branch(); - be_union_branch(AST_UnionLabel *lab, AST_Type *ft, UTL_ScopedName *n, - UTL_StrList *p); + be_union_branch (void); + // default constructor + + be_union_branch (AST_UnionLabel *lab, AST_Type *ft, UTL_ScopedName *n, + UTL_StrList *p); + // constructor + + virtual int gen_client_header (void); + // Generates the client-side header information for the union branch + + virtual int gen_client_stubs (void); + // Generates the client-side stubs for the union branch + + virtual int gen_server_header (void); + // Generates the server-side header information for the union branch + + virtual int gen_server_skeletons (void); + // Generates the server-side skeletons for the union branch + + virtual int gen_client_inline (void); + // Generates the client-side inline for the union branch + + virtual int gen_server_inline (void); + // Generates the server-side inlines for the union branch + + virtual int gen_typecode (void); + // generate the typecode + + virtual long tc_encap_len (void); + // return the total byte length of ourselves represented as an encapsulation // Narrowing - DEF_NARROW_METHODS1(be_union_branch, AST_UnionBranch); - DEF_NARROW_FROM_DECL(be_union_branch); + DEF_NARROW_METHODS2 (be_union_branch, AST_UnionBranch, be_decl); + DEF_NARROW_FROM_DECL (be_union_branch); }; #endif |