From 8f0194c14cfa9e52c2bfdb4eda7cee2b8fde811c Mon Sep 17 00:00:00 2001 From: parsons Date: Wed, 4 Oct 2000 23:54:26 +0000 Subject: ChangeLogTag: Wed Oct 4 18:49:18 2000 Jeff Parsons --- TAO/TAO_IDL/ast/ast_enum.cpp | 4 +- TAO/TAO_IDL/ast/ast_generator.cpp | 76 ++++++++++++++++++++++++------- TAO/TAO_IDL/ast/ast_interface.cpp | 21 ++++++--- TAO/TAO_IDL/ast/ast_interface_fwd.cpp | 15 +++--- TAO/TAO_IDL/ast/ast_module.cpp | 2 +- TAO/TAO_IDL/be/be_generator.cpp | 6 +-- TAO/TAO_IDL/be/be_valuetype.cpp | 36 +++++---------- TAO/TAO_IDL/be_include/be_interface.h | 4 +- TAO/TAO_IDL/be_include/be_interface_fwd.h | 1 - TAO/TAO_IDL/be_include/be_valuetype.h | 10 ---- TAO/TAO_IDL/be_include/be_valuetype_fwd.h | 2 +- TAO/TAO_IDL/include/ast_interface.h | 13 ++++-- TAO/TAO_IDL/include/ast_interface_fwd.h | 2 +- 13 files changed, 111 insertions(+), 81 deletions(-) (limited to 'TAO/TAO_IDL') diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp index 36a3787ce24..a448762a1a2 100644 --- a/TAO/TAO_IDL/ast/ast_enum.cpp +++ b/TAO/TAO_IDL/ast/ast_enum.cpp @@ -313,10 +313,10 @@ AST_Enum::dump (ostream &o) while (!i->is_done ()) { d = i->item (); - d->local_name()->dump (o); + d->local_name ()->dump (o); i->next (); - if (!i->is_done()) + if (!i->is_done ()) { o << ", "; } diff --git a/TAO/TAO_IDL/ast/ast_generator.cpp b/TAO/TAO_IDL/ast/ast_generator.cpp index a01fcb6d295..089df63509b 100644 --- a/TAO/TAO_IDL/ast/ast_generator.cpp +++ b/TAO/TAO_IDL/ast/ast_generator.cpp @@ -175,35 +175,77 @@ AST_Generator::create_interface_fwd (UTL_ScopedName *n, return retval; } -// Create a be_valuetype node. +// Create an AST_Interface node which is a valuetype. AST_Interface * -AST_Generator::create_valuetype (UTL_ScopedName *, - AST_Interface ** /* ih */, - long /* nih */, - UTL_StrList *) +AST_Generator::create_valuetype (UTL_ScopedName *n, + AST_Interface **ih, + long nih, + UTL_StrList *p) { +#ifdef IDL_HAS_VALUETYPE + AST_Interface *retval = 0; + ACE_NEW_RETURN (retval, + AST_Interface (n, + ih, + nih, + 0, + 0, + p, + 0, + 0), + 0); + // Valuetypes are represented as be_valuetype derived from be_interface, // which derives from AST_Interface. If you construct a backend which // utilizes only the AST_... classes, you must instantiate an object that // returns true from AST_Interface::is_valuetype(). - // (currently not implemented) - // Also invoke - // (AST_Module::narrow_from_scope (this->defined_in ()))->set_has_nested_valuetype (); + // (@@@ (JP) implemented 2000/10/4) + retval->set_valuetype (); + + // The following helps with OBV_ namespace generation. + AST_Module *m = AST_Module::narrow_from_scope (retval->defined_in ()); + + if (m != 0) + { + m->set_has_nested_valuetype (); + } - ACE_ASSERT (0); - return 0; + return retval; +#else + ACE_ERROR_RETURN ((LM_ERROR, + "Valuetype support not enabled\n"), + 0); +#endif /* IDL_HAS_VALUETYPE */ } -// Create a be_valuetype_fwd node. +// Create an AST_InterfaceFwd node whose full_definition +// member is a valuetype. AST_InterfaceFwd * -AST_Generator::create_valuetype_fwd (UTL_ScopedName *, - UTL_StrList *) +AST_Generator::create_valuetype_fwd (UTL_ScopedName *n, + UTL_StrList *p) { - // see note in create_valuetype() - // dummy placeholder must return true from is_valuetype(). + // See note in create_valuetype(). + // Dummy placeholder must return true from is_valuetype(). + +#ifdef IDL_HAS_VALUETYPE + AST_Interface *dummy = this->create_valuetype (n, + 0, + -1, + p); - ACE_ASSERT (0); - return 0; + AST_InterfaceFwd *retval = 0; + ACE_NEW_RETURN (retval, + AST_InterfaceFwd (dummy, + n, + p), + 0); + + return retval; +#else + ACE_ERROR_RETURN ((LM_ERROR, + "Valuetype support not enabled\n"), + 0); +#endif /* IDL_HAS_VALUETYPE */ } diff --git a/TAO/TAO_IDL/ast/ast_interface.cpp b/TAO/TAO_IDL/ast/ast_interface.cpp index db62e6ac95d..b4cf95450f1 100644 --- a/TAO/TAO_IDL/ast/ast_interface.cpp +++ b/TAO/TAO_IDL/ast/ast_interface.cpp @@ -82,7 +82,8 @@ AST_Interface::AST_Interface (void) : pd_inherits (0), pd_n_inherits (0), pd_inherits_flat (0), - pd_n_inherits_flat (0) + pd_n_inherits_flat (0), + is_valuetype_ (0) { } @@ -103,7 +104,8 @@ AST_Interface::AST_Interface(UTL_ScopedName *n, pd_inherits (ih), pd_n_inherits (nih), pd_inherits_flat (ih_flat), - pd_n_inherits_flat (nih_flat) + pd_n_inherits_flat (nih_flat), + is_valuetype_ (0) { } @@ -111,28 +113,33 @@ AST_Interface::~AST_Interface (void) { } -// Public operations +// Public operations. idl_bool AST_Interface::is_valuetype (void) { - return 0; + return this->is_valuetype_; } +void +AST_Interface::set_valuetype (void) +{ + this->is_valuetype_ = 1; +} idl_bool AST_Interface::is_abstract_valuetype (void) { - return 0; + return this->is_valuetype_ && this->is_abstract_; } void AST_Interface::set_abstract_valuetype (void) { - ACE_ASSERT (0); + this->is_valuetype_ = 1; + this->is_abstract_ = 1; } - void AST_Interface::be_replace_operation (AST_Decl *old_op, AST_Decl *new_op) diff --git a/TAO/TAO_IDL/ast/ast_interface_fwd.cpp b/TAO/TAO_IDL/ast/ast_interface_fwd.cpp index 26bfd324b2d..5bec2141413 100644 --- a/TAO/TAO_IDL/ast/ast_interface_fwd.cpp +++ b/TAO/TAO_IDL/ast/ast_interface_fwd.cpp @@ -99,7 +99,8 @@ AST_InterfaceFwd::~AST_InterfaceFwd (void) // Private operations. -idl_bool AST_InterfaceFwd::is_local (void) +idl_bool +AST_InterfaceFwd::is_local (void) { return this->full_definition ()->is_local (); } @@ -109,16 +110,16 @@ idl_bool AST_InterfaceFwd::is_valuetype (void) return this->full_definition ()->is_valuetype (); } -idl_bool AST_InterfaceFwd::is_abstract_valuetype (void) +idl_bool +AST_InterfaceFwd::is_abstract_valuetype (void) { return this->full_definition ()->is_abstract_valuetype (); } -void AST_InterfaceFwd::set_abstract_valuetype (void) +void +AST_InterfaceFwd::set_abstract_valuetype (void) { - // Don't forget about dummy placeholder ! (see constructor) - // (only if the be class isn't used). - ACE_ASSERT (0); + this->full_definition ()->set_abstract_valuetype (); } // Redefinition of inherited virtual operations. @@ -155,7 +156,7 @@ AST_InterfaceFwd::dump (ostream &o) // Data accessors. -AST_Interface * +AST_Interface * AST_InterfaceFwd::full_definition (void) { return this->pd_full_definition; diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp index 3f081956525..2ee23293c0a 100644 --- a/TAO/TAO_IDL/ast/ast_module.cpp +++ b/TAO/TAO_IDL/ast/ast_module.cpp @@ -759,7 +759,7 @@ AST_Module::set_has_nested_valuetype (void) { AST_Module *pm = AST_Module::narrow_from_scope (parent); - if (pm) + if (pm != 0) { pm->set_has_nested_valuetype (); } diff --git a/TAO/TAO_IDL/be/be_generator.cpp b/TAO/TAO_IDL/be/be_generator.cpp index 6da693fe5c0..54e45fdbc16 100644 --- a/TAO/TAO_IDL/be/be_generator.cpp +++ b/TAO/TAO_IDL/be/be_generator.cpp @@ -64,12 +64,10 @@ trademarks or registered trademarks of Sun Microsystems, Inc. */ -// be_generator.cc -// -// Implementation of BE generator class +// Implementation of BE generator class. // // This implements the same protocol as AST_Generator but creates instances -// of the BE-subclassed classes instead of of AST classes +// of the BE-subclassed classes instead of of AST classes. #include "idl.h" #include "idl_extern.h" diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index 044270f9baa..6830aeb695b 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -29,8 +29,7 @@ ACE_RCSID(be, be_valuetype, "$Id$") // Default constructor. be_valuetype::be_valuetype (void) - : full_obv_skel_name_ (0), - abstract_ (0) + : full_obv_skel_name_ (0) { // Always the case. this->size_type (be_decl::VARIABLE); @@ -44,6 +43,9 @@ be_valuetype::be_valuetype (void) // Always the case. this->has_constructor (I_TRUE); + + // Set the base (AST_Interface) class member. + this->set_valuetype (); } // Constructor used to build the AST. @@ -59,7 +61,7 @@ be_valuetype::be_valuetype (UTL_ScopedName *n, 0, p, 0, - 0), + set_abstract), AST_Interface (n, ih, nih, @@ -67,15 +69,14 @@ be_valuetype::be_valuetype (UTL_ScopedName *n, 0, p, 0, - 0), + set_abstract), AST_Decl (AST_Decl::NT_interface, // It's like an interface. n, p), UTL_Scope (AST_Decl::NT_interface), COMMON_Base (0, set_abstract), - full_obv_skel_name_ (0), - abstract_ (set_abstract) + full_obv_skel_name_ (0) { // Check that redefine() copies all members. @@ -91,6 +92,9 @@ be_valuetype::be_valuetype (UTL_ScopedName *n, // Always the case. this->has_constructor (I_TRUE); + + // Set the base (AST_Interface) class member. + this->set_valuetype (); } be_valuetype::~be_valuetype (void) @@ -105,7 +109,7 @@ be_valuetype::redefine (AST_Interface *from, this->AST_Interface::redefine (from, p); - abstract_ = from->is_abstract_valuetype (); + this->is_abstract_ = from->is_abstract_valuetype (); } // Is true if non-virtual accessor and modifier should be generated @@ -116,24 +120,6 @@ be_valuetype::opt_accessor (void) return be_global->obv_opt_accessor (); } -idl_bool -be_valuetype::is_valuetype (void) -{ - return 1; -} - -idl_bool -be_valuetype::is_abstract_valuetype (void) -{ - return this->abstract_; -} - -void -be_valuetype::set_abstract_valuetype (void) -{ - this->abstract_ = 1; -} - // Compute stringified fully scoped skeleton name (OBV_name). void be_valuetype::compute_fullobvskelname (void) diff --git a/TAO/TAO_IDL/be_include/be_interface.h b/TAO/TAO_IDL/be_include/be_interface.h index ccc50e0b332..685d2442421 100644 --- a/TAO/TAO_IDL/be_include/be_interface.h +++ b/TAO/TAO_IDL/be_include/be_interface.h @@ -227,8 +227,8 @@ public: // constructors of all the base classes. static int gen_copy_ctors_helper (be_interface* node, - be_interface* base, - TAO_OutStream *os); + be_interface* base, + TAO_OutStream *os); // Helper method to generate a call to the copy // constructors of all the base classes. diff --git a/TAO/TAO_IDL/be_include/be_interface_fwd.h b/TAO/TAO_IDL/be_include/be_interface_fwd.h index 724496be0b3..067ff99bf54 100644 --- a/TAO/TAO_IDL/be_include/be_interface_fwd.h +++ b/TAO/TAO_IDL/be_include/be_interface_fwd.h @@ -73,7 +73,6 @@ public: // Narrowing. DEF_NARROW_METHODS2 (be_interface_fwd, AST_InterfaceFwd, be_type); DEF_NARROW_FROM_DECL (be_interface_fwd); - }; #endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_valuetype.h b/TAO/TAO_IDL/be_include/be_valuetype.h index 165dcaf9856..4fa1c966a27 100644 --- a/TAO/TAO_IDL/be_include/be_valuetype.h +++ b/TAO/TAO_IDL/be_include/be_valuetype.h @@ -98,14 +98,6 @@ public: // Visiting. virtual int accept (be_visitor *visitor); - virtual idl_bool is_valuetype (void); - - // Data accessors. - - virtual idl_bool is_abstract_valuetype (void); - - virtual void set_abstract_valuetype (void); - // Narrowing. DEF_NARROW_METHODS1 (be_valuetype, be_interface); DEF_NARROW_FROM_DECL (be_valuetype); @@ -117,8 +109,6 @@ public: private: char *full_obv_skel_name_; - - idl_bool abstract_; }; #endif /* IDL_HAS_VALUETYPE */ diff --git a/TAO/TAO_IDL/be_include/be_valuetype_fwd.h b/TAO/TAO_IDL/be_include/be_valuetype_fwd.h index 12522547b47..e8844c377cb 100644 --- a/TAO/TAO_IDL/be_include/be_valuetype_fwd.h +++ b/TAO/TAO_IDL/be_include/be_valuetype_fwd.h @@ -47,7 +47,7 @@ public: virtual ~be_valuetype_fwd (void); // Destructor. - virtual void set_abstract_valuetype (); + virtual void set_abstract_valuetype (void); virtual int gen_var_defn (char *local_name = 0); // Generate the _var class definition. diff --git a/TAO/TAO_IDL/include/ast_interface.h b/TAO/TAO_IDL/include/ast_interface.h index 0e621d01dd1..2ea8cda35a2 100644 --- a/TAO/TAO_IDL/include/ast_interface.h +++ b/TAO/TAO_IDL/include/ast_interface.h @@ -133,11 +133,13 @@ public: return (pd_n_inherits < 0) ? I_FALSE : I_TRUE; } - virtual idl_bool is_valuetype (void); + idl_bool is_valuetype (void); - virtual idl_bool is_abstract_valuetype (void); + void set_valuetype (void); - virtual void set_abstract_valuetype (void); + idl_bool is_abstract_valuetype (void); + + void set_abstract_valuetype (void); // Check if any member's name clashes with a parent's // member's name, or if any parents' members' names @@ -155,6 +157,11 @@ public: // AST Dumping. virtual void dump (ostream &o); +protected: + + idl_bool is_valuetype_; + // + private: // Helper function for fwd_redefinition_helper. static idl_bool compare_names (AST_Interface *that, diff --git a/TAO/TAO_IDL/include/ast_interface_fwd.h b/TAO/TAO_IDL/include/ast_interface_fwd.h index 1facd86c72b..a5d850a9151 100644 --- a/TAO/TAO_IDL/include/ast_interface_fwd.h +++ b/TAO/TAO_IDL/include/ast_interface_fwd.h @@ -99,7 +99,7 @@ public: DEF_NARROW_FROM_DECL(AST_InterfaceFwd); // AST Dumping. - virtual void dump(ostream &); + virtual void dump (ostream &); private: // Data. -- cgit v1.2.1