diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-06-04 16:09:46 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-06-04 16:09:46 +0000 |
commit | 7078c345efdbb2daf750ab1205bdd214dda08bf4 (patch) | |
tree | 668db6c3d7496f9619fe0acc8bf0fcbfb87b6c92 | |
parent | 137dc608f64c1e2994fcc1739b3628176c43e9c2 (diff) | |
download | ATCD-7078c345efdbb2daf750ab1205bdd214dda08bf4.tar.gz |
ChangeLogTag: Tue Jun 4 11:08:40 2002 Jeff Parsons <parsons@cs.wustl.edu>
85 files changed, 2251 insertions, 743 deletions
diff --git a/TAO/TAO_IDL/ast/ast_array.cpp b/TAO/TAO_IDL/ast/ast_array.cpp index e5451585fc0..f7f0ea49710 100644 --- a/TAO/TAO_IDL/ast/ast_array.cpp +++ b/TAO/TAO_IDL/ast/ast_array.cpp @@ -168,6 +168,26 @@ AST_Array::ast_accept (ast_visitor *visitor) return visitor->visit_array (this); } +// Compute the size type of the node in question. +int +AST_Array::compute_size_type (void) +{ + AST_Type *type = this->base_type (); + + if (!type) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_array::compute_size_type - " + "bad base type\n"), + -1); + } + + // Our size type is the same as our type. + this->size_type (type->size_type ()); + + return 0; +} + // Data accessors. unsigned long AST_Array::n_dims (void) diff --git a/TAO/TAO_IDL/ast/ast_predefined_type.cpp b/TAO/TAO_IDL/ast/ast_predefined_type.cpp index d53ee4bddfd..33a39e4739a 100644 --- a/TAO/TAO_IDL/ast/ast_predefined_type.cpp +++ b/TAO/TAO_IDL/ast/ast_predefined_type.cpp @@ -212,6 +212,23 @@ AST_PredefinedType::dump (ACE_OSTREAM_TYPE &o) AST_Decl::dump (o); } +// Compute the size type of the node in question. +int +AST_PredefinedType::compute_size_type (void) +{ + if (this->pt () == AST_PredefinedType::PT_any + || this->pt () == AST_PredefinedType::PT_pseudo) + { + this->size_type (AST_Type::VARIABLE); + } + else + { + this->size_type (AST_Type::FIXED); + } + + return 0; +} + int AST_PredefinedType::ast_accept (ast_visitor *visitor) { diff --git a/TAO/TAO_IDL/ast/ast_structure.cpp b/TAO/TAO_IDL/ast/ast_structure.cpp index dbba255a6a4..91528cf3576 100644 --- a/TAO/TAO_IDL/ast/ast_structure.cpp +++ b/TAO/TAO_IDL/ast/ast_structure.cpp @@ -501,6 +501,43 @@ AST_Structure::dump (ACE_OSTREAM_TYPE &o) o << "}"; } +// Compute the size type of the node in question. +int +AST_Structure::compute_size_type (void) +{ + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + // Get the next AST decl node. + AST_Decl *d = si.item (); + + if (d->node_type () == AST_Decl::NT_enum_val) + { + continue; + } + + AST_Field *f = AST_Field::narrow_from_decl (d); + AST_Type *t = f->field_type (); + + if (t != 0) + { + this->size_type (t->size_type ()); + + // While we're iterating, we might as well do this one too. + this->has_constructor (t->has_constructor ()); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "WARNING (%N:%l) be_structure::compute_size_type - " + "narrow_from_decl returned 0\n")); + } + } + + return 0; +} + int AST_Structure::ast_accept (ast_visitor *visitor) { diff --git a/TAO/TAO_IDL/ast/ast_typedef.cpp b/TAO/TAO_IDL/ast/ast_typedef.cpp index 8aff97ae8c9..158f88b15ed 100644 --- a/TAO/TAO_IDL/ast/ast_typedef.cpp +++ b/TAO/TAO_IDL/ast/ast_typedef.cpp @@ -74,6 +74,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_visitor.h" #include "utl_identifier.h" +#include "ace/Log_Msg.h" + ACE_RCSID (ast, ast_typedef, "$Id$") @@ -139,6 +141,29 @@ AST_Typedef::dump (ACE_OSTREAM_TYPE&o) this->local_name ()->dump (o); } +// Compute the size type of the node in question. +int +AST_Typedef::compute_size_type (void) +{ + AST_Type *type = this->base_type (); + + if (type == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_typedef::compute_size_type - " + "bad base type\n"), + -1); + } + + // Our size type is the same as our type. + this->size_type (type->size_type ()); + + // While we're here, take care of has_constructor. + this->has_constructor (type->has_constructor ()); + + return 0; +} + int AST_Typedef::ast_accept (ast_visitor *visitor) { diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp index 7b5d9513569..c74a05e4ee6 100644 --- a/TAO/TAO_IDL/ast/ast_union.cpp +++ b/TAO/TAO_IDL/ast/ast_union.cpp @@ -1130,6 +1130,38 @@ AST_Union::dump (ACE_OSTREAM_TYPE &o) o << "}"; } +// Compute the size type of the node in question. +int +AST_Union::compute_size_type (void) +{ + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + // Get the next AST decl node. + AST_Decl *d = si.item (); + AST_Field *f = AST_Field::narrow_from_decl (d); + + if (f != 0) + { + AST_Type *t = f->field_type (); + // Our sizetype depends on the sizetype of our members. Although + // previous value of sizetype may get overwritten, we are + // guaranteed by the "size_type" call that once the value reached + // be_decl::VARIABLE, nothing else can overwrite it. + this->size_type (t->size_type ()); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "WARNING (%N:%l) be_union::compute_size_type - " + "narrow_from_decl returned 0\n")); + } + } + + return 0; +} + int AST_Union::ast_accept (ast_visitor *visitor) { diff --git a/TAO/TAO_IDL/ast/ast_valuetype.cpp b/TAO/TAO_IDL/ast/ast_valuetype.cpp index bfcf3e426c7..f77b423da07 100644 --- a/TAO/TAO_IDL/ast/ast_valuetype.cpp +++ b/TAO/TAO_IDL/ast/ast_valuetype.cpp @@ -81,6 +81,18 @@ AST_ValueType::redefine (AST_Interface *from) this->pd_truncatable = vt->pd_truncatable; } +AST_Interface ** +AST_ValueType::supports (void) const +{ + return this->pd_supports; +} + +long +AST_ValueType::n_supports (void) const +{ + return this->pd_n_supports; +} + AST_ValueType * AST_ValueType::inherits_concrete (void) const { diff --git a/TAO/TAO_IDL/be/be_array.cpp b/TAO/TAO_IDL/be/be_array.cpp index 89147b5999e..e598750ab63 100644 --- a/TAO/TAO_IDL/be/be_array.cpp +++ b/TAO/TAO_IDL/be/be_array.cpp @@ -196,26 +196,6 @@ be_array::gen_dimensions (TAO_OutStream *os, return 0; } -// Compute the size type of the node in question. -int -be_array::compute_size_type (void) -{ - be_type *type = be_type::narrow_from_decl (this->base_type ()); - - if (!type) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::compute_size_type - " - "bad base type\n"), - -1); - } - - // Our size type is the same as our type. - this->size_type (type->size_type ()); - - return 0; -} - int be_array::accept (be_visitor *visitor) { diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 2b21f4470d7..e655e8eda06 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -22,13 +22,13 @@ #include "be_interface.h" #include "be_interface_strategy.h" +#include "be_attribute.h" +#include "be_operation.h" #include "be_visitor.h" #include "be_helper.h" #include "be_stream_factory.h" #include "be_extern.h" #include "utl_identifier.h" -#include "ast_attribute.h" -#include "ast_operation.h" #include "ast_generator.h" #include "global_extern.h" #include "idl_defines.h" @@ -82,7 +82,7 @@ be_interface::be_interface (UTL_ScopedName *n, this->size_type (AST_Type::VARIABLE); // always the case this->has_constructor (I_TRUE); // always the case - if (! abstract) + if (! abstract && this->node_type () == AST_Decl::NT_interface) { this->analyze_parentage (ih, nih); @@ -510,35 +510,18 @@ be_interface::gen_stub_ctor (TAO_OutStream *os) if (this->has_mixed_parentage_) { - AST_Interface **parent = 0; - idl_bool nested = this->is_nested (); - - for (ACE_Unbounded_Queue_Iterator<AST_Interface *> iter ( - this->abstract_parents_ - ); - iter.done () == 0; - iter.advance ()) + int status = + this->traverse_inheritance_graph ( + be_interface::gen_abstract_init_helper, + os, + I_TRUE + ); + + if (status == -1) { - iter.next (parent); - idl_bool both_nested = nested && (*parent)->is_nested (); - - if (both_nested) - { - UTL_Scope *parent_scope = (*parent)->defined_in (); - AST_Decl *parent_decl = ScopeAsDecl (parent_scope); - - *os << be_nl - << "this->ACE_NESTED_CLASS (" - << parent_decl->name () << ", " - << (*parent)->local_name () - << ")::obj_ = this;"; - } - else - { - *os << be_nl - << "this->" << (*parent)->name () - << "::obj_ = this;"; - } + ACE_ERROR ((LM_ERROR, + "be_interface::gen_stub_ctor - " + "inheritance graph traversal failed\n")); } } @@ -1528,44 +1511,18 @@ be_interface::analyze_parentage (AST_Interface **parents, if (parents[i]->is_abstract ()) { this->has_mixed_parentage_ = I_TRUE; - be_global->mixed_parentage_interfaces.enqueue_tail (this); - this->abstract_parents_.enqueue_tail (parents[i]); - this->complete_abstract_paths (parents[i]); + break; } } -} -void -be_interface::complete_abstract_paths (AST_Interface *ai) -{ - AST_Interface **parents = ai->inherits (); - long n_parents = ai->n_inherits (); - - for (long i = 0; i < n_parents; ++i) + if (this->has_mixed_parentage_ == I_TRUE) { - if (parents[i]->is_abstract ()) - { - this->abstract_parents_.enqueue_tail (parents[i]); - this->complete_abstract_paths (parents[i]); - } + be_global->mixed_parentage_interfaces.enqueue_tail (this); } } // **************************************************************** -class be_code_emitter_wrapper : public TAO_IDL_Inheritance_Hierarchy_Worker -{ -public: - be_code_emitter_wrapper (be_interface::tao_code_emitter emitter); - - virtual int emit (be_interface *derived_interface, - TAO_OutStream *output_stream, - be_interface *base_interface); - -private: - be_interface::tao_code_emitter emitter_; -}; - be_code_emitter_wrapper:: be_code_emitter_wrapper (be_interface::tao_code_emitter emitter) : emitter_ (emitter) @@ -1587,34 +1544,15 @@ be_code_emitter_wrapper::emit (be_interface *derived_interface, // out by the function passed as argument. int be_interface::traverse_inheritance_graph (be_interface::tao_code_emitter gen, - TAO_OutStream *os) -{ - be_code_emitter_wrapper wrapper (gen); - - return this->traverse_inheritance_graph (wrapper, os); -} - -int -be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker &worker, - TAO_OutStream *os) + TAO_OutStream *os, + idl_bool abstract_paths_only) { - // Queue data structure needed for breadth-first traversal of - // inheritance tree. - ACE_Unbounded_Queue <be_interface*> queue; - - // For a special case of a deeply nested inheritance graph and one specific - // way of inheritance in which a node that was already visited, - // but is not present in - // the queue, gets inserted at the tail. This situation arises when a node - // multiply inherits from two or more interfaces in which the first parent is - // higher up in the tree than the second parent. In addition, if the second - // parent turns out to be a child of the first . - - // Queue of dequeued nodes to be searched for the above case. - ACE_Unbounded_Queue <be_interface*> del_queue; + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); // Insert ourselves in the queue. - if (queue.enqueue_tail (this) == -1) + if (insert_queue.enqueue_tail (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::traverse_inheritance_graph - " @@ -1622,19 +1560,33 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & -1); } + be_code_emitter_wrapper wrapper (gen); + + return this->traverse_inheritance_graph (wrapper, + os, + abstract_paths_only); +} + +int +be_interface::traverse_inheritance_graph ( + TAO_IDL_Inheritance_Hierarchy_Worker &worker, + TAO_OutStream *os, + idl_bool abstract_paths_only + ) +{ // Do until queue is empty. - while (!queue.is_empty ()) + while (!this->insert_queue.is_empty ()) { be_interface *bi; // element inside the queue // Use breadth-first strategy i.e., first generate entries for ourselves, // followed by nodes that we immediately inherit from, and so on. In the // process make sure that we do not generate code for the same node more - // than once. Such a case may arise due to multiple inheritance forming a - // diamond like inheritance graph. + // than once. Such a case may arise due to multiple inheritance forming + // a diamond-like inheritance graph. // Dequeue the element at the head of the queue. - if (queue.dequeue_head (bi)) + if (this->insert_queue.dequeue_head (bi)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::traverse_graph - " @@ -1643,7 +1595,7 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & } // Insert the dequeued element in the del_queue. - if (del_queue.enqueue_tail (bi) == -1) + if (this->del_queue.enqueue_tail (bi) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::traverse_graph - " @@ -1678,12 +1630,19 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & -1); } + if (abstract_paths_only && ! parent->is_abstract ()) + { + continue; + } + // Now insert this node at the tail of the queue, but make sure that // it doesn't already exist in the queue. int found = 0; // Initialize an iterator to search the queue for duplicates. - for (ACE_Unbounded_Queue_Iterator<be_interface*> q_iter (queue); + for (ACE_Unbounded_Queue_Iterator<be_interface*> q_iter ( + this->insert_queue + ); !q_iter.done (); (void) q_iter.advance ()) { @@ -1707,7 +1666,7 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & // Initialize an iterator to search the del_queue for duplicates. for (ACE_Unbounded_Queue_Iterator<be_interface*> del_q_iter ( - del_queue + this->del_queue ); !found && !del_q_iter.done (); (void) del_q_iter.advance ()) @@ -1733,7 +1692,7 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & if (!found) { // Insert the parent in the queue. - if (queue.enqueue_tail (parent) == -1) + if (this->insert_queue.enqueue_tail (parent) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::gen_server_skeletons - " @@ -2230,6 +2189,17 @@ be_interface::gen_skel_helper (be_interface *derived, return 0; } + // If an operation or an attribute is abstract (declared in an + // abstract interface), we will either generate the full + // definition (if there are no concrete interfaces between the + // abstract ancestor and us) or, if there is a concrete ancestor + // in between, we will catch its definition elsewhere in this + // traversal. + if (ancestor->is_abstract ()) + { + return 0; + } + // Else generate code that does the cast to the appropriate type. if (ancestor->nmembers () > 0) @@ -2246,17 +2216,6 @@ be_interface::gen_skel_helper (be_interface *derived, // Get the next AST decl node AST_Decl *d = si.item (); - // If an operation or an attribute is abstract (declared in an - // abstract interface), we will either generate the full - // definition (if there are no concrete interfaces between the - // abstract ancestor and us) or, if there is a concrete ancestor - // in between, we will catch its definition elsewhere in this - // iteration. - if (d->is_abstract ()) - { - continue; - } - if (d->node_type () == AST_Decl::NT_op) { // Start from current indentation level. @@ -2471,6 +2430,37 @@ be_interface::in_mult_inheritance_helper (be_interface *derived, return 0; } +int +be_interface::gen_abstract_init_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } + + if (node->is_nested () && base->is_nested ()) + { + UTL_Scope *parent_scope = base->defined_in (); + AST_Decl *parent_decl = ScopeAsDecl (parent_scope); + + *os << be_nl + << "this->ACE_NESTED_CLASS (" + << parent_decl->name () << ", " + << base->local_name () + << ")::obj_ = this;"; + } + else + { + *os << be_nl + << "this->" << base->name () + << "::obj_ = this;"; + } + + return 0; +} + void be_interface::destroy (void) { diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index 55dd9b721c0..b5520ef1995 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -156,23 +156,6 @@ be_predefined_type::compute_tc_name (void) this->tc_name_->nconc (conc_name); } -// Compute the size type of the node in question. -int -be_predefined_type::compute_size_type (void) -{ - if (this->pt () == AST_PredefinedType::PT_any - || this->pt () == AST_PredefinedType::PT_pseudo) - { - this->size_type (AST_Type::VARIABLE); - } - else - { - this->size_type (AST_Type::FIXED); - } - - return 0; -} - void be_predefined_type::compute_repoID (void) { diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index 89de95bd510..f4a41acbf30 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -656,43 +656,6 @@ be_structure::gen_out_impl (char *, return 0; } -// Compute the size type of the node in question. -int -be_structure::compute_size_type (void) -{ - for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node. - AST_Decl *d = si.item (); - - if (d->node_type () == AST_Decl::NT_enum_val) - { - continue; - } - - AST_Field *f = AST_Field::narrow_from_decl (d); - AST_Type *t = f->field_type (); - - if (t != 0) - { - this->size_type (t->size_type ()); - - // While we're iterating, we might as well do this one too. - this->has_constructor (t->has_constructor ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_structure::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - } - - return 0; -} - void be_structure::destroy (void) { diff --git a/TAO/TAO_IDL/be/be_typedef.cpp b/TAO/TAO_IDL/be/be_typedef.cpp index b5c0ffafaac..3a9a71562bf 100644 --- a/TAO/TAO_IDL/be/be_typedef.cpp +++ b/TAO/TAO_IDL/be/be_typedef.cpp @@ -69,29 +69,6 @@ be_typedef::primitive_base_type (void) return d; } -// Compute the size type of the node in question. -int -be_typedef::compute_size_type (void) -{ - be_type *type = be_type::narrow_from_decl (this->base_type ()); - - if (type == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_typedef::compute_size_type - " - "bad base type\n"), - -1); - } - - // Our size type is the same as our type. - this->size_type (type->size_type ()); - - // While we're here, take care of has_constructor. - this->has_constructor (type->has_constructor ()); - - return 0; -} - AST_Decl::NodeType be_typedef::base_node_type (void) const { diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index c5577a14be0..4477c463d60 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -676,38 +676,6 @@ be_union::gen_out_impl (char *, return 0; } -// Compute the size type of the node in question. -int -be_union::compute_size_type (void) -{ - for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node. - AST_Decl *d = si.item (); - AST_Field *f = AST_Field::narrow_from_decl (d); - - if (f != 0) - { - AST_Type *t = f->field_type (); - // Our sizetype depends on the sizetype of our members. Although - // previous value of sizetype may get overwritten, we are - // guaranteed by the "size_type" call that once the value reached - // be_decl::VARIABLE, nothing else can overwrite it. - this->size_type (t->size_type ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_union::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - } - - return 0; -} - idl_bool be_union::has_duplicate_case_labels (void) { diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index bff427aa4cc..424cd38ed7e 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -25,6 +25,7 @@ #include "be_helper.h" #include "ast_module.h" #include "idl_defines.h" +#include "nr_extern.h" ACE_RCSID (be, be_valuetype, @@ -90,7 +91,8 @@ be_valuetype::be_valuetype (UTL_ScopedName *n, UTL_Scope (AST_Decl::NT_valuetype), COMMON_Base (0, abstract), - full_obv_skel_name_ (0) + full_obv_skel_name_ (0), + supports_abstract_ (0) { // Check that redefine() copies all members. @@ -106,6 +108,15 @@ be_valuetype::be_valuetype (UTL_ScopedName *n, // Always the case. this->has_constructor (I_TRUE); + + for (long i = 0; i < this->pd_n_supports; ++i) + { + if (this->pd_supports[i]->is_abstract ()) + { + this->supports_abstract_ = I_TRUE; + break; + } + } } be_valuetype::~be_valuetype (void) @@ -167,28 +178,30 @@ be_valuetype::gen_var_defn (char *local_name) TAO_OutStream *ch = tao_cg->client_header (); + *ch << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the var definition (always in the client header). // Depending upon the data type, there are some differences which we account // for over here. - // Start with whatever was our current indent level. *ch << "class " << be_global->stub_export_macro () << " " << namebuf << be_nl; *ch << "{" << be_nl; *ch << "public:" << be_idt_nl; // Default constructor. - *ch << namebuf << " (void); // default constructor" << be_nl; + *ch << namebuf << " (void);" << be_nl; *ch << namebuf << " (" << local_name << "*);" << be_nl; *ch << namebuf << " (const " << local_name << "*); // (TAO extension)" << be_nl; // Copy constructor. *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << be_nl; + " &);" << be_nl; // Destructor. - *ch << "~" << namebuf << " (void); // destructor" << be_nl; + *ch << "~" << namebuf << " (void);" << be_nl; *ch << be_nl; // Assignment operator from a pointer. @@ -213,8 +226,8 @@ be_valuetype::gen_var_defn (char *local_name) // The return types of in, out, inout, and _retn are based on the parameter // passing rules and the base type. *ch << local_name << "* in (void) const;" << be_nl; - *ch << local_name << "* &inout (void);" << be_nl; - *ch << local_name << "* &out (void);" << be_nl; + *ch << local_name << "*& inout (void);" << be_nl; + *ch << local_name << "*& out (void);" << be_nl; *ch << local_name << "* _retn (void);" << be_nl; // Generate an additional member function that returns @@ -276,170 +289,158 @@ be_valuetype::gen_var_impl (char *local_name, // Depending upon the data type, there are some differences which we account // for over here. - cs->indent (); // start with whatever was our current indent level + *cs << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *cs << "// *************************************************************" << be_nl; *cs << "// Operations for class " << fname << be_nl; - *cs << "// *************************************************************\n\n"; + *cs << "// *************************************************************" + << be_nl << be_nl; // Default constructor. *cs << fname << "::" << lname << - " (void) // default constructor" << be_nl; + " (void)" << be_nl; *cs << " " << ": ptr_ (0)" << be_nl; - *cs << "{}\n\n"; + *cs << "{}" << be_nl << be_nl; // Constructor from a pointer. - cs->indent (); *cs << fname << "::" << lname << " (" << local_name << "* p)" << be_nl; *cs << " : ptr_ (p)" << be_nl; - *cs << "{}\n\n"; + *cs << "{}" << be_nl << be_nl; // Constructor from a const pointer. // TAO extension - it appears that there are problems with at least g++ // which reclaims amguity between T(T*) and T(const T_var &) - cs->indent (); *cs << fname << "::" << lname << " (const " << local_name << "* p)" << be_nl; *cs << " : ptr_ (ACE_const_cast(" << local_name << "*, p))" << be_nl; - *cs << "{}\n\n"; + *cs << "{}" << be_nl << be_nl; // The additional ptr () member function. This member function must be // defined before the remaining member functions including the copy // constructor because this inline function is used elsewhere. Hence to make // inlining of this function possible, we must define it before its use. - cs->indent (); - *cs << full_name << "* " << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::ptr (void) const" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Copy constructor. - cs->indent (); *cs << fname << "::" << lname << " (const " << lname << - " &p) // copy constructor" << be_nl; + " &p)" << be_nl; *cs << "{" << be_idt_nl << "CORBA::add_ref (p.ptr ());" << be_nl << "this->ptr_ = p.ptr ();" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; // Destructor. - cs->indent (); *cs << fname << "::~" << lname << " (void) // destructor" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "CORBA::remove_ref (this->ptr_);\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "CORBA::remove_ref (this->ptr_);" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (" << local_name << "* p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl; *cs << "this->ptr_ = p;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator from _var. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (const " << lname << " &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "if (this != &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl << local_name << "* tmp = p.ptr ();" << be_nl << "CORBA::add_ref (tmp);" << be_nl - << "this->ptr_ = tmp;\n"; - cs->decr_indent (); - *cs << "}" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + << "this->ptr_ = tmp;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Other extra methods - cast operator (). - cs->indent (); *cs << fname << "::operator const " << full_name << "* () const // cast" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; - cs->indent (); *cs << fname << "::operator " << full_name << "* () // cast " << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // operator-> - cs->indent (); *cs << full_name << "* " << be_nl; *cs << fname << "::operator-> (void) const" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // in, inout, out, and _retn. - cs->indent (); *cs << full_name << "*" << be_nl; *cs << fname << "::in (void) const" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; - cs->indent (); *cs << full_name << "* &" << be_nl; *cs << fname << "::inout (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; - cs->indent (); *cs << full_name << "* &" << be_nl; *cs << fname << "::out (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl; *cs << "this->ptr_ = 0;" << be_nl; - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; - cs->indent (); *cs << full_name << "* " << be_nl; *cs << fname << "::_retn (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "// yield ownership of managed obj reference" << be_nl; *cs << local_name << "* tmp = this->ptr_;" << be_nl; *cs << "this->ptr_ = 0;" << be_nl; - *cs << "return tmp;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return tmp;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; return 0; } @@ -462,6 +463,9 @@ be_valuetype::gen_out_defn (char *) ch = tao_cg->client_header (); + *ch << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the out definition (always in the client header). *ch << "class " << be_global->stub_export_macro () @@ -492,10 +496,10 @@ be_valuetype::gen_out_defn (char *) << "*);" << be_nl; // Cast. - *ch << "operator " << this->local_name () << "* &();" << be_nl; + *ch << "operator " << this->local_name () << "*& ();" << be_nl; // ptr function. - *ch << this->local_name () << "* &ptr (void);" << be_nl; + *ch << this->local_name () << "*& ptr (void);" << be_nl; // operator -> *ch << this->local_name () << "* operator-> (void);" << be_nl; @@ -537,115 +541,107 @@ be_valuetype::gen_out_impl (char *, cs = tao_cg->client_stubs (); + *cs << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the var implementation in the inline file // Depending upon the data type, there are some differences which we account // for over here. - // Start with whatever was our current indent level. - cs->indent (); - *cs << "// *************************************************************" << be_nl; *cs << "// Operations for class " << fname << be_nl; - *cs << "// *************************************************************\n\n"; + *cs << "// *************************************************************" + << be_nl << be_nl; // Constructor from a pointer. - cs->indent (); *cs << fname << "::" << lname << " (" << this->local_name () << "* &p)" << be_nl; *cs << " : ptr_ (p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "this->ptr_ = 0;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "this->ptr_ = 0;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Constructor from _var &. - cs->indent (); *cs << fname << "::" << lname << " (" << this->local_name () - << "_var &p) // constructor from _var" << be_nl; + << "_var &p)" << be_nl; *cs << " : ptr_ (p.out ())" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl; - *cs << "this->ptr_ = 0;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "this->ptr_ = 0;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Copy constructor. - cs->indent (); *cs << fname << "::" << lname << " (const " << lname - << " &p) // copy constructor" << be_nl; + << " &p)" << be_nl; *cs << " : ptr_ (ACE_const_cast (" << lname << "&,p).ptr_)" << be_nl; - *cs << "{}\n\n"; + *cs << "{}" << be_nl << be_nl; // Assignment operator from _out &. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (const " << lname << " &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "this->ptr_ = ACE_const_cast (" << lname << "&,p).ptr_;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator from _var. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (const " << this->local_name () << "_var &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << this->local_name () << "* tmp = p.ptr ();" << be_nl << "CORBA::add_ref (tmp);" << be_nl << "this->ptr_ = tmp;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator from *. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (" << this->local_name () << "* p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "this->ptr_ = p;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Other extra methods - cast operator (). - cs->indent (); *cs << fname << "::operator " << this->name () << "* &() // cast" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // ptr function. - cs->indent (); *cs << this->name () << "* &" << be_nl; *cs << fname << "::ptr (void) // ptr" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // operator-> - cs->indent (); *cs << this->name () << "* " << be_nl; *cs << fname << "::operator-> (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; + *cs << "// *************************************************************" + << be_nl << be_nl; return 0; } @@ -663,8 +659,10 @@ be_valuetype::gen_helper_header (char* , << "TAO_NAMESPACE CORBA" << be_nl << "{" << be_idt_nl - << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" << this->full_name () << " *);" << be_nl - << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" << this->full_name () << " *);" + << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" + << this->full_name () << " *);" << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" + << this->full_name () << " *);" << be_uidt_nl << "}" << be_nl << "TAO_NAMESPACE_CLOSE" << be_nl @@ -690,8 +688,10 @@ be_valuetype::gen_helper_inline (char* , << "TAO_NAMESPACE CORBA" << be_nl << "{" << be_idt_nl - << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" << this->full_name () << " *);" << be_nl - << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" << this->full_name () << " *);" + << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" + << this->full_name () << " *);" << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" + << this->full_name () << " *);" << be_uidt_nl << "}" << be_nl << "TAO_NAMESPACE_CLOSE" << be_nl @@ -887,6 +887,239 @@ be_valuetype::in_recursion (AST_Type *node) return 0; } +idl_bool +be_valuetype::supports_abstract (void) const +{ + return this->supports_abstract_; +} + +// Template method that traverses the inheritance graph in a breadth-first +// style. The actual work on each element in the inheritance graph is carried +// out by the function passed as argument. +int +be_valuetype::traverse_supports_list_graphs ( + be_interface::tao_code_emitter gen, + TAO_OutStream *os, + idl_bool abstract_paths_only + ) +{ + long n_supports = this->n_supports (); + + if (n_supports == 0) + { + return 0; + } + + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + be_interface *supported_interface = 0; + + for (long i = 0; i < n_supports; ++i) + { + if (abstract_paths_only + && ! this->pd_supports[i]->is_abstract ()) + { + continue; + } + + supported_interface = + be_interface::narrow_from_decl (this->pd_supports[i]); + + // Insert a supported interface in the queue. + if (this->insert_queue.enqueue_tail (supported_interface) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_valuetype::" + "traverse_supports_graph_list - " + "error generating entries\n"), + -1); + } + } + + be_code_emitter_wrapper wrapper (gen); + + return this->traverse_inheritance_graph (wrapper, + os, + abstract_paths_only); +} + +int +be_valuetype::traverse_concrete_inheritance_graph (tao_code_emitter gen, + TAO_OutStream *os) +{ + AST_Interface *supported = this->supports_concrete (); + + if (supported == 0) + { + return 0; + } + + be_interface *concrete = be_interface::narrow_from_decl (supported); + + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + // Insert the supported concrete interface in the queue. + if (this->insert_queue.enqueue_tail (concrete) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_valuetype::" + "traverse_concrete_inheritance_graph - " + "error generating entries\n"), + -1); + } + + be_code_emitter_wrapper wrapper (gen); + + return this->traverse_inheritance_graph (wrapper, + os); +} + +int +be_valuetype::abstract_supports_helper (be_interface *, + be_interface *base, + TAO_OutStream *os) +{ + *os << "," << be_nl + << "public virtual "; + + if (base->is_nested ()) + { + UTL_Scope *parent_scope = base->defined_in (); + AST_Decl *parent_decl = ScopeAsDecl (parent_scope); + + *os << "ACE_NESTED_CLASS (" + << parent_decl->name () << ", " + << base->local_name (); + } + else + { + *os << base->local_name (); + } + + return 0; +} + +int +be_valuetype::gen_abstract_init_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node->is_nested () && base->is_nested ()) + { + UTL_Scope *parent_scope = base->defined_in (); + AST_Decl *parent_decl = ScopeAsDecl (parent_scope); + + *os << be_nl + << "this->ACE_NESTED_CLASS (" + << parent_decl->name () << ", " + << base->local_name () + << ")::val_ = this;"; + } + else + { + *os << be_nl + << "this->" << base->name () + << "::val_ = this;"; + } + + return 0; +} + +int +be_valuetype::gen_skel_helper (be_interface *concrete, + be_interface *ancestor, + TAO_OutStream *os) +{ + // If derived and ancestor are same, skip it. + if (concrete == ancestor) + { + return 0; + } + + // If an operation or an attribute is abstract (declared in an + // abstract interface), we will either generate the full + // definition (if there are no concrete interfaces between the + // abstract ancestor and us) or, if there is a concrete ancestor + // in between, we will catch its definition elsewhere in this + // traversal. + if (ancestor->is_abstract ()) + { + return 0; + } + + // Else generate code that does the cast to the appropriate type. + + if (ancestor->nmembers () > 0) + { + // If there are elements in ancestor scope i.e., any operations and + // attributes defined by "ancestor", become methods on the derived class + // which call the corresponding method of the base class by doing the + // proper casting. + + for (UTL_ScopeActiveIterator si (ancestor, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + // Get the next AST decl node + AST_Decl *d = si.item (); + + if (d->node_type () == AST_Decl::NT_op) + { + // Start from current indentation level. + os->indent (); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) + { + // Generate the static method corresponding to this method. + *os << "static void " << d->local_name () + << "_skel (" << be_idt << be_idt_nl + << "TAO_ServerRequest &req, " << be_nl + << "void *obj," << be_nl + << "void *context" << be_nl + << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt << "\n\n"; + } + else + { // Generate code in the inline file. + // Generate the static method corresponding to this method. + *os << "ACE_INLINE void " + << concrete->full_skel_name () << "::" + << d->local_name () + << "_skel (" << be_idt << be_idt_nl + << "TAO_ServerRequest &req," << be_nl + << "void *obj," << be_nl + << "void *context" << be_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl; + *os << ancestor->full_skel_name () + << "_ptr impl = (" + << concrete->full_skel_name () + << "_ptr) obj;" << be_nl; + *os << ancestor->full_skel_name () + << "::" << d->local_name () + << "_skel (" << be_idt << be_idt_nl + << "req," << be_nl + << "(" << ancestor->full_skel_name () + << "_ptr) impl," << be_nl + << "context" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}\n"; + } + } + } // End of scope iterator. + } + + return 0; +} // Narrowing. IMPL_NARROW_METHODS2 (be_valuetype, be_interface, AST_ValueType) diff --git a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp index 3c48f9aacd2..74090920d4a 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp @@ -45,7 +45,9 @@ be_visitor_args::type_name (be_type *node, const char *suffix) { static char namebuf [NAMEBUFSIZE]; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); be_type *bt; diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp index 47cfcf3d9b1..c1dc6f4fdba 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp @@ -20,6 +20,7 @@ #include "be_visitor_enum/enum_ch.h" #include "be_visitor_sequence/sequence_ch.h" +#include "nr_extern.h" ACE_RCSID (be_visitor_field, field_ch, @@ -121,8 +122,13 @@ be_visitor_field_ch::visit_array (be_array *node) { // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope ()); } @@ -173,10 +179,15 @@ be_visitor_field_ch::visit_enum (be_enum *node) } } - // Now use this enum as a "type" for the subsequent declarator. + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope ()); } @@ -203,10 +214,15 @@ be_visitor_field_ch::visit_interface (be_interface *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope (), "_var"); } @@ -233,10 +249,15 @@ be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope (), "_var"); } @@ -263,10 +284,15 @@ be_visitor_field_ch::visit_valuetype (be_valuetype *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope (), "_var"); } @@ -293,10 +319,15 @@ be_visitor_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope (), "_var"); } @@ -329,9 +360,15 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) } else if (node->pt () == AST_PredefinedType::PT_pseudo) { + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (bt->defined_in ()->scope_node_type () == AST_Decl::NT_interface) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope (), "_var"); } @@ -342,9 +379,15 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) } else { - // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // This was a typedefed array. + // ACE_NESTED_CLASS macro generated by nested_type_name + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope ()); } @@ -409,7 +452,15 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) // is not necessary in all cases. be_typedef *tdef = be_typedef::narrow_from_decl (bt); - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME + // This was a typedefed array. + // ACE_NESTED_CLASS macro generated by nested_type_name + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module || !tdef) { *os << bt->nested_type_name (this->ctx_->scope ()); @@ -473,9 +524,15 @@ be_visitor_field_ch::visit_structure (be_structure *node) } } + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope ()); } @@ -545,9 +602,15 @@ be_visitor_field_ch::visit_union (be_union *node) } } + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { *os << bt->nested_type_name (this->ctx_->scope ()); } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp index 217757a940c..fe949a9f22f 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp @@ -56,17 +56,17 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) continue; } - *os << "public virtual "; - *os << inherited->full_base_proxy_impl_name (); - - has_concrete_parent = 1; - - if (i < node->n_inherits () - 1) + if (has_concrete_parent == 1) { // Node is the case of multiple // inheritance, so put a comma. *os << ", " << be_nl; } + + *os << "public virtual "; + *os << inherited->full_base_proxy_impl_name (); + + has_concrete_parent = 1; } if (has_concrete_parent == 1) @@ -111,3 +111,56 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) return 0; } + +int +be_visitor_interface_base_proxy_impl_ch::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_base_proxy_impl_ch" + "::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); + be_visitor_operation_base_proxy_impl_ch op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp index cc3a5b0470e..f1a25688dc2 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp @@ -159,3 +159,74 @@ int be_visitor_interface_direct_collocated_sh::visit_interface ( os->gen_endif (); return 0; } + +int +be_visitor_interface_direct_collocated_sh::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_thru_poa_proxy_" + "impl_sh::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + AST_Decl::NodeType nt = d->node_type (); + + if (nt == AST_Decl::NT_op || nt == AST_Decl::NT_attr) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + if (nt == AST_Decl::NT_op) + { + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_COLLOCATED_SH); + be_visitor_operation_direct_collocated_sh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + else + { + AST_Attribute *attr = AST_Attribute::narrow_from_decl (d); + be_attribute new_attr (attr->readonly (), + attr->field_type (), + &item_new_name, + attr->is_local (), + attr->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_DIRECT_COLLOCATED_SH); + be_visitor_attribute attr_visitor (&ctx); + attr_visitor.visit_attribute (&new_attr); + } + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp index 81a1c0b8f5f..34b9ab7a8cc 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp @@ -88,3 +88,56 @@ be_visitor_interface_direct_proxy_impl_sh::visit_interface ( return 0; } + +int +be_visitor_interface_direct_proxy_impl_sh::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_thru_poa_proxy_" + "impl_sh::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_COLLOCATED_SH); + be_visitor_operation_direct_collocated_sh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp index 0543958e25e..682cb033560 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp @@ -57,3 +57,68 @@ be_visitor_interface_direct_proxy_impl_ss::visit_interface ( return 0; } + +int +be_visitor_interface_direct_proxy_impl_ss::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_direct_proxy" + "_impl_ss::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + + new_op.set_defined_in (node); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_COLLOCATED_SS); + be_visitor_operation_direct_proxy_impl_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp index cd163a43a14..daa38fec381 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp @@ -78,3 +78,70 @@ int be_visitor_interface_interceptors_cs::visit_interface (be_interface *node) return 0; } + +int +be_visitor_interface_interceptors_cs::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_interceptors_cs::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + AST_Decl::NodeType nt = d->node_type (); + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + + new_op.set_defined_in (node); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); + be_visitor_operation_interceptors_cs op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp index 71af3db39f3..73ea3e39982 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp @@ -74,3 +74,68 @@ int be_visitor_interface_interceptors_ss::visit_interface (be_interface *node) return 0; } + +int +be_visitor_interface_interceptors_ss::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_interceptors_ss::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + + new_op.set_defined_in (node); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); + be_visitor_operation_interceptors_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp index e1993f4f3b4..e77085cb02b 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp @@ -42,8 +42,6 @@ be_visitor_interface::visit_interface (be_interface *) return -1; } -// Overridden so we can deal with possible operations or attributes -// in abstract parent classes. int be_visitor_interface::visit_scope (be_scope *node) { @@ -53,65 +51,99 @@ be_visitor_interface::visit_scope (be_scope *node) } be_interface *intf = be_interface::narrow_from_scope (node); - AST_Interface **parent = 0; - AST_Decl *d = 0; - be_decl *bd = 0; - - for (ACE_Unbounded_Queue_Iterator<AST_Interface *> iter ( - intf->abstract_parents_ - ); - iter.done () == 0; - iter.advance ()) + + if (intf == 0) { - iter.next (parent); + return 0; + } - for (UTL_ScopeActiveIterator si ((*parent), UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - d = si.item (); - - if (d == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::visit_scope - " - "bad node in this scope\n"), - -1); - } - - AST_Decl::NodeType nt = d->node_type (); - - if (nt == AST_Decl::NT_op || nt == AST_Decl::NT_attr) - { - UTL_ScopedName *item_new_name = - (UTL_ScopedName *)intf->name ()->copy (); - - Identifier *id = 0; - ACE_NEW_RETURN (id, - Identifier (d->local_name ()->get_string ()), - -1); - - UTL_ScopedName *sn = 0; - ACE_NEW_RETURN (sn, - UTL_ScopedName (id, - 0), - -1); - - item_new_name->nconc (sn); - d->set_name (item_new_name); - d->set_defined_in (node); - bd = be_decl::narrow_from_decl (d); - - if (bd == 0 || bd->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_scope - " - "codegen for scope failed\n"), - -1); - } - } - } + if (intf->is_abstract ()) + { + return 0; + } + + if (! intf->has_mixed_parentage ()) + { + return 0; + } + + be_interface::tao_code_emitter helper = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_INTERFACE_CH: + helper = + be_visitor_interface_ch::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: + helper = + be_visitor_interface_base_proxy_impl_ch::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: + helper = + be_visitor_interface_remote_proxy_impl_ch::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_CS: + helper = + be_visitor_interface_cs::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: + helper = + be_visitor_interface_remote_proxy_impl_cs::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: + helper = + be_visitor_interface_interceptors_cs::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_SH: + helper = + be_visitor_interface_sh::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: + helper = + be_visitor_interface_thru_poa_proxy_impl_sh::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: + helper = + be_visitor_interface_direct_proxy_impl_sh::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_SS: + helper = + be_visitor_interface_ss::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: + helper = + be_visitor_interface_interceptors_ss::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: + helper = + be_visitor_interface_direct_proxy_impl_ss::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS: + helper = + be_visitor_interface_thru_poa_proxy_impl_ss::gen_abstract_ops_helper; + break; + default: + break; + } + + if (helper == 0) + { + return 0; + } + + int status = + intf->traverse_inheritance_graph (helper, + this->ctx_->stream (), + I_TRUE); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_*::" + "visit_scope - " + "traversal of inheritance graph failed\n"), + -1); } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp index 6cef4c07873..0d00f73cd42 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp @@ -435,3 +435,54 @@ be_visitor_interface_ch::visit_interface (be_interface *node) node->cli_hdr_gen (I_TRUE); return 0; } + +int +be_visitor_interface_ch::gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interface::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_OPERATION_CH); + be_visitor_operation_ch op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp index 5e2248810a8..a7c8676bb80 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp @@ -293,24 +293,10 @@ be_visitor_interface_cs::visit_interface (be_interface *node) *os << be_nl << "this->" << inherited->flat_name () << "_setup_collocation" << " (collocated);"; - - if (i == n_parents - 1) - { - *os << be_uidt_nl; - } - else - { - *os << be_nl; - } } } - if (has_concrete_parent == 0) - { - *os << be_uidt_nl; - } - - *os << "}" << be_nl << be_nl; + *os << be_uidt_nl << "}" << be_nl << be_nl; } } @@ -554,10 +540,11 @@ be_visitor_interface_cs::visit_interface (be_interface *node) *os << "if (" << be_idt << be_idt_nl; - if (node->traverse_inheritance_graph ( - be_interface::is_a_helper, - os - ) == -1) + int status = + node->traverse_inheritance_graph (be_interface::is_a_helper, + os); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_cs::" @@ -699,9 +686,8 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - // Smart Proxy classes. - if (! node->is_local () && ! node->is_abstract ()) + if (! node->is_local ()) { be_visitor_context ctx (*this->ctx_); be_visitor *visitor = 0; @@ -738,3 +724,66 @@ be_visitor_interface_cs::visit_interface (be_interface *node) return 0; } + +int +be_visitor_interface_cs::gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_cs::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + + new_op.set_defined_in (node); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_CS); + be_visitor_operation_cs op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp index 8b08b686d62..488ca9ee094 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp @@ -130,15 +130,15 @@ be_visitor_interface_sh::visit_interface (be_interface *node) continue; } + if (has_concrete_parent == 1) + { + *os << "," << be_nl; + } + *os << "public virtual " << "POA_" << parent->name (); has_concrete_parent = 1; - - if (i < n_parents - 1) - { - *os << "," << be_nl; - } } } @@ -319,6 +319,57 @@ be_visitor_interface_sh::visit_interface (be_interface *node) return 0; } +int +be_visitor_interface_sh::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_sh::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_OPERATION_SH); + be_visitor_operation_sh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} void be_visitor_interface_sh::this_method (be_interface *node) diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp index 48aaad64572..555118958d8 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp @@ -95,7 +95,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) -1); } - *os << "// TAO_IDL - Generated from " << be_nl + *os << be_nl << "// TAO_IDL - Generated from " << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Find if we are at the top scope or inside some module, @@ -381,6 +381,67 @@ be_visitor_interface_ss::visit_interface (be_interface *node) return 0; } +int +be_visitor_interface_ss::gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_ss::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + + new_op.set_defined_in (node); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_SS); + be_visitor_operation_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} void be_visitor_interface_ss::this_method (be_interface *node) diff --git a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp index 3b2047a85b3..d5bc901855b 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp @@ -43,7 +43,7 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) if (node->accept (&bpi_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" + "be_visitor_interface_proxy_impls_ch::" "visit_interface - " "codegen for Base Proxy Impl. class failed\n"), -1); @@ -56,7 +56,7 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) if (node->accept (&rpi_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" + "be_visitor_interface_proxy_impls_ch::" "visit_interface - " "codegen for Remote Proxy Broker class failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp index bb2987e5c47..7815575cfa6 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp @@ -92,3 +92,56 @@ be_visitor_interface_remote_proxy_impl_ch::visit_interface ( return 0; } + +int +be_visitor_interface_remote_proxy_impl_ch::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_remote_proxy_" + "impl_ch::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); + be_visitor_operation_proxy_impl_xh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp index c12fcdfe6bf..948f03d86d5 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp @@ -73,3 +73,68 @@ be_visitor_interface_remote_proxy_impl_cs::visit_interface ( return 0; } + +int +be_visitor_interface_remote_proxy_impl_cs::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_remote_proxy_" + "impl_cs::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + + new_op.set_defined_in (node); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); + be_visitor_operation_remote_proxy_impl_cs op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp index 26d27cc6675..a6f1879ce34 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp @@ -124,59 +124,58 @@ be_visitor_interface_strategized_proxy_broker_ss::visit_interface ( << "switch (strategy)" << be_idt_nl // idt = 4 << "{" << be_nl; - if (be_global->gen_thru_poa_collocation ()) - { - *os << "case TAO_Collocation_Strategies::CS_THRU_POA_STRATEGY:" - << be_idt_nl // idt = 5 - << "ACE_NEW_THROW_EX (" - << be_idt << be_idt_nl //idt = 7 - << "this->proxy_cache_[strategy]," << be_nl - << node->full_thru_poa_proxy_impl_name () << "," << be_nl - << "CORBA::NO_MEMORY ()" - << be_uidt << be_uidt_nl // idt = 5 - << ");" << be_nl - << "ACE_CHECK;" << be_nl - << "break;" - << be_nl << be_uidt_nl; // idt = 4 - } - - if (be_global->gen_direct_collocation ()) - { - *os << "case TAO_Collocation_Strategies::CS_DIRECT_STRATEGY:" - << be_idt_nl // idt = 5 - << "ACE_NEW_THROW_EX (" - << be_idt << be_idt_nl //idt = 7 - << "this->proxy_cache_[strategy]," << be_nl - << node->full_direct_proxy_impl_name () << "," << be_nl - << "CORBA::NO_MEMORY ()" - << be_uidt << be_uidt_nl // idt = 5 - << ");" << be_nl - << "ACE_CHECK;" << be_nl - << "break;" - << be_nl << be_uidt_nl; // idt = 4 - } - - *os << "case TAO_Collocation_Strategies::CS_REMOTE_STRATEGY:" << be_nl - << "default:" + + if (be_global->gen_thru_poa_collocation ()) + { + *os << "case TAO_Collocation_Strategies::CS_THRU_POA_STRATEGY:" + << be_idt_nl // idt = 5 + << "ACE_NEW_THROW_EX (" + << be_idt << be_idt_nl //idt = 7 + << "this->proxy_cache_[strategy]," << be_nl + << node->full_thru_poa_proxy_impl_name () << "," << be_nl + << "CORBA::NO_MEMORY ()" + << be_uidt << be_uidt_nl // idt = 5 + << ");" << be_nl + << "ACE_CHECK;" << be_nl + << "break;" + << be_nl << be_uidt_nl; // idt = 4 + } + + if (be_global->gen_direct_collocation ()) + { + *os << "case TAO_Collocation_Strategies::CS_DIRECT_STRATEGY:" << be_idt_nl // idt = 5 << "ACE_NEW_THROW_EX (" << be_idt << be_idt_nl //idt = 7 << "this->proxy_cache_[strategy]," << be_nl - << "::" << node->full_remote_proxy_impl_name () << "," << be_nl + << node->full_direct_proxy_impl_name () << "," << be_nl << "CORBA::NO_MEMORY ()" << be_uidt << be_uidt_nl // idt = 5 << ");" << be_nl << "ACE_CHECK;" << be_nl << "break;" - << be_uidt_nl // idt = 4 - << be_uidt_nl // idt = 3 - + << be_nl << be_uidt_nl; // idt = 4 + } + + *os << "case TAO_Collocation_Strategies::CS_REMOTE_STRATEGY:" << be_nl + << "default:" + << be_idt_nl // idt = 5 + << "ACE_NEW_THROW_EX (" + << be_idt << be_idt_nl //idt = 7 + << "this->proxy_cache_[strategy]," << be_nl + << "::" << node->full_remote_proxy_impl_name () << "," << be_nl + << "CORBA::NO_MEMORY ()" + << be_uidt << be_uidt_nl // idt = 5 + << ");" << be_nl + << "ACE_CHECK;" << be_nl + << "break;" + << be_uidt_nl // idt = 4 + << be_uidt_nl // idt = 3 << "}" << be_uidt_nl // idt = 2 << be_uidt_nl // idt = 1 << "}" << be_uidt_nl // idt = 0 - << "}" << be_nl << be_nl; *os << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp index 83f0263cb1a..8c82eb6f2dd 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp @@ -95,3 +95,56 @@ be_visitor_interface_thru_poa_proxy_impl_sh::visit_interface ( return 0; } + +int +be_visitor_interface_thru_poa_proxy_impl_sh::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_thru_poa_proxy_" + "impl_sh::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + + ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_COLLOCATED_SH); + be_visitor_operation_proxy_impl_xh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp index 2043482b952..3c6d9f4550e 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp @@ -63,3 +63,68 @@ be_visitor_interface_thru_poa_proxy_impl_ss::visit_interface ( return 0; } + +int +be_visitor_interface_thru_poa_proxy_impl_ss::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_thru_poa_proxy" + "_impl_ss::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + + new_op.set_defined_in (node); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_COLLOCATED_SS); + be_visitor_operation_thru_poa_proxy_impl_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_module/module.cpp b/TAO/TAO_IDL/be/be_visitor_module/module.cpp index 5d65aee361d..db31834b964 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/module.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/module.cpp @@ -620,9 +620,27 @@ be_visitor_module::visit_valuetype (be_valuetype *node) break; } case TAO_CodeGen::TAO_MODULE_SH: - case TAO_CodeGen::TAO_MODULE_IH: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SH); + be_visitor_valuetype_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SI: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SI); + be_visitor_valuetype_si visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SS: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SS); + be_visitor_valuetype_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_IS: return 0; // nothing to do. default: diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp index aa800265c20..daba6c407e4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp @@ -122,7 +122,7 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation ( *os << "ACE_ENV_SINGLE_ARG_DECL"; } - *os << ")" << be_uidt; + *os << ")"; // now generate the throw specs if (this->gen_throw_spec (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp index 6ba019ca283..444bdeddc8a 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp @@ -86,8 +86,8 @@ be_visitor_operation_arglist::visit_operation (be_operation *node) -1); } - *os << be_uidt_nl // idt = 1 - << ")" << be_uidt; // idt = 0 + *os << be_uidt_nl + << ")"; // idt = 0 // Now generate the throw specs. if (this->gen_throw_spec (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 892e96267b7..53a1574f633 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -111,7 +111,7 @@ be_visitor_operation::gen_throw_spec (be_operation *node) throw_spec_close = "))"; } - *os << be_idt_nl << throw_spec_open + *os << be_nl << throw_spec_open << be_idt_nl << "CORBA::SystemException"; if (node->exceptions ()) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp index 63d045dfad5..b4e04fbacd4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp @@ -107,9 +107,6 @@ be_visitor_operation_is::visit_operation (be_operation *node) -1); } - // Generate the exceptions thrown by the operation - // this->gen_throw_spec (node); - *os <<be_idt_nl << "{"<<be_idt_nl; *os << "//Add your implementation here"<<be_uidt_nl; *os << "}" << be_nl << be_uidt_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp index dee8e532915..75bb86403c3 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp @@ -45,8 +45,6 @@ int be_visitor_operation_thru_poa_collocated_sh::visit_operation ( TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); - os->indent (); - *os << "virtual "; // STEP I: generate the return type. diff --git a/TAO/TAO_IDL/be/be_visitor_root/root.cpp b/TAO/TAO_IDL/be/be_visitor_root/root.cpp index 5db849fd050..b8538e12eec 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root.cpp @@ -941,9 +941,27 @@ be_visitor_root::visit_valuetype (be_valuetype *node) break; } case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_IH: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SH); + be_visitor_valuetype_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SI: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SI); + be_visitor_valuetype_si visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SS: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SS); + be_visitor_valuetype_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_IH: case TAO_CodeGen::TAO_ROOT_IS: case TAO_CodeGen::TAO_ROOT_TIE_SH: return 0; // nothing to do. diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp index 14f0697b73c..d21e37a7b34 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp @@ -326,7 +326,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "failed creating name\n"), -1); + "failed creating name\n"), + -1); } if (node->cli_hdr_gen () || node->imported ()) @@ -359,7 +360,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } *os << "class " << node->local_name () << ";" << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype.cpp index 21138183912..fd38a0cb138 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype.cpp @@ -64,6 +64,9 @@ #include "be_visitor_valuetype/valuetype_ch.cpp" #include "be_visitor_valuetype/valuetype_ci.cpp" #include "be_visitor_valuetype/valuetype_cs.cpp" +#include "be_visitor_valuetype/valuetype_sh.cpp" +#include "be_visitor_valuetype/valuetype_si.cpp" +#include "be_visitor_valuetype/valuetype_ss.cpp" #include "be_visitor_valuetype/valuetype_obv_ch.cpp" #include "be_visitor_valuetype/valuetype_obv_ci.cpp" #include "be_visitor_valuetype/valuetype_obv_cs.cpp" diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp index f5288638ccb..0b984e62acb 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp @@ -88,6 +88,7 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) { *os << be_uidt_nl; } + *os << ")"; be_visitor_context ctx = *this->ctx_; @@ -102,18 +103,18 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) { case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: // Each method is pure virtual in the Valuetype class. - *os << " = 0;" << be_uidt_nl; + *os << " = 0;" << be_nl; break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CH: - *os << ";" << be_uidt_nl; + *os << ";" << be_nl; break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CS: default: - *os << be_uidt_nl; + *os << be_nl; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index b094ad35002..e47b851459d 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -367,14 +367,6 @@ be_visitor_valuetype::visit_enum (be_enum *node) return 0; } - -int -be_visitor_valuetype::visit_operation (be_operation *) -{ - // Is overridden in derived visitors. - return 0; -} - int be_visitor_valuetype::visit_exception (be_exception *node) { @@ -976,10 +968,7 @@ be_visitor_valuetype::gen_field_pd (be_field *node) // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - ctx.sub_state (TAO_CodeGen::TAO_USE_FULL_NAME); ctx.state (TAO_CodeGen::TAO_FIELD_CH); - be_visitor_field_ch visitor (&ctx); if (bt->accept(&visitor) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp index 9774bf240b5..074e721ab65 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp @@ -40,65 +40,60 @@ be_visitor_valuetype_ch::~be_visitor_valuetype_ch (void) int be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os = this->ctx_->stream (); - - if (!node->cli_hdr_gen () && !node->imported ()) + if (node->cli_hdr_gen () || node->imported ()) { - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - - *os << "// Valuetype class" << be_nl; + return 0; + } - // == STEP 1: Generate the class name and class names we inherit == + TAO_OutStream *os = this->ctx_->stream (); - // Forward declaration. - *os << "class " << node->local_name () << ";" << be_nl; + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - os->gen_ifdef_macro (node->flat_name (), "_ptr"); + // == STEP 1: Generate the class name and class names we inherit == - *os << "typedef " << node->local_name () - << " *" << node->local_name () << "_ptr;" << be_nl; + // Forward declaration. + *os << "class " << node->local_name () << ";" << be_nl; - os->gen_endif (); + os->gen_ifdef_macro (node->flat_name (), "_ptr"); - // Generate the ifdefined macro for the _var type. - os->gen_ifdef_macro (node->flat_name (), "_var"); + *os << "typedef " << node->local_name () + << " *" << node->local_name () << "_ptr;" << be_nl; - // Generate the _var declaration. - if (node->gen_var_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "codegen for _var failed\n"), - -1); - } + os->gen_endif (); - os->gen_endif (); + // Generate the ifdefined macro for the _var type. + os->gen_ifdef_macro (node->flat_name (), "_var"); - // Generate the ifdef macro for the _out class. - os->gen_ifdef_macro (node->flat_name (), - "_out"); + // Generate the _var declaration. + if (node->gen_var_defn () == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_valuetype - " + "codegen for _var failed\n"), + -1); + } - // Generate the _out declaration. - if (node->gen_out_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "codegen for _out failed\n"), - -1); - } + os->gen_endif (); - // Generate the endif macro. - os->gen_endif (); - } + // Generate the ifdef macro for the _out class. + os->gen_ifdef_macro (node->flat_name (), + "_out"); - if (node->imported ()) + // Generate the _out declaration. + if (node->gen_out_defn () == -1) { - return 0; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_valuetype - " + "codegen for _out failed\n"), + -1); } + // Generate the endif macro. + os->gen_endif (); + // Now the valuetype definition itself. os->gen_ifdef_macro (node->flat_name ()); @@ -148,29 +143,34 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) *os << "public virtual "; *os << inherited->nested_type_name (scope); } // end of for loop - - if (i > 0) - { - if (i > 1) - { - *os << be_uidt; - } - - *os << be_uidt_nl; - } } else { - *os << "public virtual CORBA_ValueBase" << be_uidt_nl; + *os << "public virtual CORBA_ValueBase"; + } + + int status = + node->traverse_supports_list_graphs ( + be_valuetype::abstract_supports_helper, + os, + I_TRUE + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_valuetype - " + "traversal of supported interfaces failed\n"), + -1); } // Generate the body. - *os << "{" << be_nl + *os << be_uidt << be_uidt_nl << "{" << be_nl << "public:" << be_idt_nl; - // Generate the _ptr_type and _var_type typedef. - *os << "typedef " << node->local_name () << "* _ptr_type;" << be_nl - << "typedef " << node->local_name () << "_var _var_type;" + // Generate the _var_type typedef. + *os << "typedef " << node->local_name () << "_var _var_type;" << be_nl << be_nl; // Generate the static _downcast operation. @@ -185,10 +185,10 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << node->local_name () << " *&" << be_uidt_nl << ");" << be_uidt_nl << "virtual const char* " - << "_tao_obv_repository_id () const;" + << "_tao_obv_repository_id (void) const;" << be_nl << "static const char* " - << "_tao_obv_static_repository_id ();" << be_nl << be_nl; + << "_tao_obv_static_repository_id (void);" << be_nl << be_nl; *os << "static void _tao_any_destructor (void *);" << be_nl << be_nl; @@ -204,14 +204,36 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) -1); } - // Protected member: + // Generate pure virtual declarations of the operations in our + // supported interfaces. + status = + node->traverse_supports_list_graphs ( + be_visitor_valuetype_ch::gen_supported_ops, + os + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_valuetype - " + "traversal of supported interfaces failed\n"), + -1); + } + + // If we inherit from both CORBA::ValueBase and CORBA::AbstractBase, + // we have to add this to avoid ambiguity. + if (node->supports_abstract ()) + { + *os << be_nl << "virtual void _add_ref (void) = 0;" << be_nl; + } // Generate the "protected" constructor so that users cannot // instantiate us. *os << be_uidt_nl << "protected:" << be_idt_nl << node->local_name () - << " ();" << be_nl - << "virtual ~" << node->local_name () << " ();\n" << be_nl; + << " (void);" << be_nl + << "virtual ~" << node->local_name () << " (void);\n" << be_nl; *os << "// TAO internals" << be_nl << "virtual void *_tao_obv_narrow (ptr_arith_t);" << be_nl; @@ -269,7 +291,6 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) os->gen_endif (); - // Generate the _init -related declarations. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CH); @@ -374,9 +395,9 @@ be_visitor_valuetype_ch::visit_field (be_field *node) return -1; } - be_visitor_context* ctx = new be_visitor_context (*this->ctx_); - ctx->state (TAO_CodeGen::TAO_FIELD_OBV_CH); - be_visitor_valuetype_field_ch visitor (ctx); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_FIELD_OBV_CH); + be_visitor_valuetype_field_ch visitor (&ctx); if (vt->opt_accessor ()) { @@ -414,3 +435,56 @@ be_visitor_valuetype_ch::begin_private (void) *os << be_uidt_nl << "protected:" << be_idt_nl; } + +int +be_visitor_valuetype_ch::gen_supported_ops (be_interface *, + be_interface *base, + TAO_OutStream *os) +{ + // We inherit from abstract supported interfaces, so no need + // to declare their pure virtual operations again in our scope. + if (base->is_abstract ()) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "gen_supported_ops - " + "bad node in this scope\n"), + -1); + } + + AST_Decl::NodeType nt = d->node_type (); + be_visitor_valuetype_ch visitor (&ctx); + + if (nt == AST_Decl::NT_op) + { + be_operation *op = be_operation::narrow_from_decl (d); + + if (visitor.visit_operation (op) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "gen_supported_ops - " + "failed to accept visitor\n"), + -1); + } + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp index c845a8a0589..0717c18d30c 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp @@ -26,6 +26,7 @@ ACE_RCSID (be_visitor_valuetype, // ************************************************** // Valuetype visitor for client inline. // ************************************************** + be_visitor_valuetype_ci::be_visitor_valuetype_ci (be_visitor_context *ctx) : be_visitor_valuetype (ctx), opt_accessor_ (0) @@ -53,21 +54,45 @@ be_visitor_valuetype_ci::visit_valuetype (be_valuetype *node) os->indent (); - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::" << node->local_name () << - " () // default constructor" << be_nl; - *os << "{}" << be_nl << be_nl; + *os << node->name () << "::" << node->local_name () << " (void)" << be_nl; + + if (node->supports_abstract ()) + { + *os << "{" << be_idt; + + int status = + node->traverse_supports_list_graphs ( + be_valuetype::gen_abstract_init_helper, + os, + I_TRUE + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ci::" + "visit_valuetype - " + "traversal of supported interfaces failed\n"), + -1); + } + + *os << be_uidt_nl << "}" << be_nl << be_nl; + } + else + { + *os << "{}" << be_nl << be_nl; + } *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::~" << node->local_name () << - " () // destructor" << be_nl; + *os << node->name () << "::~" << node->local_name () << " (void)" << be_nl; *os << "{}\n" << be_nl; *os << "ACE_INLINE const char* " << be_nl - << node->name() << "::_tao_obv_static_repository_id ()" << be_nl + << node->name () << "::_tao_obv_static_repository_id ()" << be_nl << "{" << be_idt_nl << "return \"" << node->repoID () << "\";" << be_uidt_nl << "}\n\n"; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp index e9f1bcce497..c5fbdbe5693 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp @@ -38,11 +38,10 @@ be_visitor_valuetype_init_ch::~be_visitor_valuetype_init_ch (void) int be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) { - if (node->is_abstract ()) - { - return 0; - } + { + return 0; + } // There are three possible situations. // (1) If there is no initializers but at least one operation. diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp index b5d36ce4f13..4dd8506ef4d 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp @@ -38,6 +38,29 @@ be_visitor_valuetype_init_ci::~be_visitor_valuetype_init_ci (void) int be_visitor_valuetype_init_ci::visit_valuetype (be_valuetype *node) { + if (node->is_abstract ()) + { + return 0; + } + + // There are three possible situations. + // (1) If there is no initializers but at least one operation. + // In this case we don't need to bother about factory. + // + // (2) There are no (operations or initializers) (i.e. only state + // members) then we need a concrete type-specific factory + // class whose create_for_unmarshal creates OBV_ class. + // + // (3) There is at least one operation and at least one initializer. + // In this case we need to generate abstract factory class. + + FactoryStyle factory_style = determine_factory_style (node); + + if (factory_style == FS_NO_FACTORY) // nothing to do + { + return 0; // bail out + } + // Just generate the factory _var impl. // To hold the full and local _var names. diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp index e6e53263f96..7c249596015 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp @@ -56,12 +56,11 @@ be_visitor_valuetype_init_cs::visit_valuetype (be_valuetype *node) FactoryStyle factory_style = determine_factory_style (node); - if(factory_style == FS_NO_FACTORY) // nothing to do + if (factory_style == FS_NO_FACTORY) // nothing to do { return 0; // bail out } - TAO_OutStream *os; // output stream os = this->ctx_->stream (); diff --git a/TAO/TAO_IDL/be_include/be_array.h b/TAO/TAO_IDL/be_include/be_array.h index c1a7f9588fb..777daca8e56 100644 --- a/TAO/TAO_IDL/be_include/be_array.h +++ b/TAO/TAO_IDL/be_include/be_array.h @@ -58,9 +58,6 @@ public: DEF_NARROW_FROM_DECL (be_array); protected: - virtual int compute_size_type (void); - // Compute the size type if it is unknown. - virtual int create_name (void); // Create a name for us. }; diff --git a/TAO/TAO_IDL/be_include/be_codegen.h b/TAO/TAO_IDL/be_include/be_codegen.h index 1707a66e3f6..1fa40019b2d 100644 --- a/TAO/TAO_IDL/be_include/be_codegen.h +++ b/TAO/TAO_IDL/be_include/be_codegen.h @@ -533,9 +533,6 @@ public: TAO_TC_DEFN_ENCAP_LEN, // encap size computation TAO_TC_DEFN_SCOPE_LEN, // scope size computation - // Means the upcall has arguments. - TAO_USE_FULL_NAME, - // Means we are not generating the assignment operator. TAO_UNION_COPY_CONSTRUCTOR, diff --git a/TAO/TAO_IDL/be_include/be_interface.h b/TAO/TAO_IDL/be_include/be_interface.h index 334c36364b8..4324ece4040 100644 --- a/TAO/TAO_IDL/be_include/be_interface.h +++ b/TAO/TAO_IDL/be_include/be_interface.h @@ -32,6 +32,7 @@ class TAO_OutStream; class TAO_IDL_Inheritance_Hierarchy_Worker; +class be_visitor; // Forward declaration of the strategy class be_interface_strategy; @@ -212,13 +213,19 @@ public: /// Iterate over the inheritance hierarchy and call the /// worker->emit() method for each interface on it. - virtual int traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker &worker, - TAO_OutStream *os); + int traverse_inheritance_graph ( + TAO_IDL_Inheritance_Hierarchy_Worker &worker, + TAO_OutStream *os, + idl_bool abstract_paths_only = I_FALSE + ); /// Wrap the @c gen parameter and call the generic version of /// traverse_inheritance_graph() - virtual int traverse_inheritance_graph (tao_code_emitter gen, - TAO_OutStream *os); + int traverse_inheritance_graph ( + tao_code_emitter gen, + TAO_OutStream *os, + idl_bool abstract_paths_only = I_FALSE + ); int in_mult_inheritance (void); // Am I in some form of multiple inheritance @@ -282,20 +289,25 @@ public: // Helper method to determine if the interface node is involved in some kind // of multiple inheritance or not. Required on the skeleton side. - static int gen_def_ctors_helper (be_interface* node, - be_interface* base, + static int gen_def_ctors_helper (be_interface *node, + be_interface *base, TAO_OutStream *os); // Helper method to generate a call to the default // constructors of all the base classes. - static int gen_copy_ctors_helper (be_interface* node, - be_interface* base, + static int gen_copy_ctors_helper (be_interface *node, + be_interface *base, TAO_OutStream *os); // Helper method to generate a call to the copy // constructors of all the base classes. + static int gen_abstract_init_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper method to initialize the obj_ member of each generated abstract + // base class. int gen_operation_table (void); // Generate the operation table including entries for inherited interfaces. @@ -339,10 +351,22 @@ public: idl_bool has_mixed_parentage (void) const; // Do we have both abstract and concrete parents? - ACE_Unbounded_Queue<AST_Interface *> abstract_parents_; - // List of all our abstract parents, and all our other ancestors - // that are abstract with no concrete parent in between. We must - // implement the operations of all these interfaces. +protected: + // Queue data structure needed for breadth-first traversal of + // inheritance tree. + ACE_Unbounded_Queue<be_interface *> insert_queue; + + // For a special case of a deeply nested inheritance graph and one specific + // way of inheritance in which a node that was already visited, + // but is not present in + // the queue, gets inserted at the tail. This situation arises when a node + // multiply inherits from two or more interfaces in which the first parent is + // higher up in the tree than the second parent. In addition, if the second + // parent turns out to be a child of the first . + + // Queue of dequeued nodes to be searched for the above case. + ACE_Unbounded_Queue<be_interface *> del_queue; + private: void gen_gperf_input_header (TAO_OutStream *ss); // Output the header (type declaration and %%) to the gperf's input @@ -378,10 +402,6 @@ private: void gen_linear_search_instance (const char *flat_name); // Create an instance of the linear search optable. - void complete_abstract_paths (AST_Interface *ai); - // Recursively gather all abstract ancestors we have without a concrete - // ancestor in between. - int skel_count_; // Number of static skeletons in the operation table. @@ -426,7 +446,7 @@ public: /** * This is a no-op, simply put here to keep compilers happy. */ - virtual ~TAO_IDL_Inheritance_Hierarchy_Worker (); + virtual ~TAO_IDL_Inheritance_Hierarchy_Worker (void); /// Define the method invoked during the inheritance traversal /** @@ -448,4 +468,17 @@ public: be_interface *base_interface) = 0; }; +class be_code_emitter_wrapper : public TAO_IDL_Inheritance_Hierarchy_Worker +{ +public: + be_code_emitter_wrapper (be_interface::tao_code_emitter emitter); + + virtual int emit (be_interface *derived_interface, + TAO_OutStream *output_stream, + be_interface *base_interface); + +private: + be_interface::tao_code_emitter emitter_; +}; + #endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_predefined_type.h b/TAO/TAO_IDL/be_include/be_predefined_type.h index 220fa110df8..57ae1a7a62a 100644 --- a/TAO/TAO_IDL/be_include/be_predefined_type.h +++ b/TAO/TAO_IDL/be_include/be_predefined_type.h @@ -50,9 +50,6 @@ public: DEF_NARROW_FROM_DECL (be_predefined_type); protected: - virtual int compute_size_type (void); - // Compute the size type if it is unknown. - virtual void compute_tc_name (void); // Overridden method. diff --git a/TAO/TAO_IDL/be_include/be_sequence.h b/TAO/TAO_IDL/be_include/be_sequence.h index c0a563690b1..6d7ec629437 100644 --- a/TAO/TAO_IDL/be_include/be_sequence.h +++ b/TAO/TAO_IDL/be_include/be_sequence.h @@ -63,7 +63,7 @@ public: idl_bool abstract); // Constructor. - virtual int create_name (be_typedef *node=0); + virtual int create_name (be_typedef *node = 0); // Create a name for ourselves. If we are typedefed, then we get the name of // the typedef node, else we generate a name for ourselves. diff --git a/TAO/TAO_IDL/be_include/be_structure.h b/TAO/TAO_IDL/be_include/be_structure.h index aa950558a31..8830f052572 100644 --- a/TAO/TAO_IDL/be_include/be_structure.h +++ b/TAO/TAO_IDL/be_include/be_structure.h @@ -66,10 +66,6 @@ public: DEF_NARROW_METHODS3 (be_structure, AST_Structure, be_scope, be_type); DEF_NARROW_FROM_DECL (be_structure); DEF_NARROW_FROM_SCOPE (be_structure); - -protected: - virtual int compute_size_type (void); - // Compute the size type if it is unknown. }; #endif diff --git a/TAO/TAO_IDL/be_include/be_typedef.h b/TAO/TAO_IDL/be_include/be_typedef.h index 842d64ed3cd..dd9de21206e 100644 --- a/TAO/TAO_IDL/be_include/be_typedef.h +++ b/TAO/TAO_IDL/be_include/be_typedef.h @@ -57,11 +57,6 @@ public: // Narrowing. DEF_NARROW_METHODS2 (be_typedef, AST_Typedef, be_type); DEF_NARROW_FROM_DECL (be_typedef); - -protected: - virtual int compute_size_type (void); - // Compute the size type if it is unknown. - }; #endif diff --git a/TAO/TAO_IDL/be_include/be_union.h b/TAO/TAO_IDL/be_include/be_union.h index 24a27b860c3..2901fa1bf2f 100644 --- a/TAO/TAO_IDL/be_include/be_union.h +++ b/TAO/TAO_IDL/be_include/be_union.h @@ -70,10 +70,6 @@ public: DEF_NARROW_METHODS3 (be_union, AST_Union, be_scope, be_type); DEF_NARROW_FROM_DECL(be_union); DEF_NARROW_FROM_SCOPE(be_union); - -protected: - virtual int compute_size_type (void); - // Compute the size type if it is unknown. }; #endif diff --git a/TAO/TAO_IDL/be_include/be_valuetype.h b/TAO/TAO_IDL/be_include/be_valuetype.h index 322f298f69a..be9c0b63feb 100644 --- a/TAO/TAO_IDL/be_include/be_valuetype.h +++ b/TAO/TAO_IDL/be_include/be_valuetype.h @@ -96,6 +96,24 @@ public: // For building the name for private data fields. be_valuetype *statefull_inherit (void); + /// Load the insert queue with all the interfaces we support, and + /// call the generic version of traverse_inheritance_graph(). + int traverse_supports_list_graphs ( + tao_code_emitter gen, + TAO_OutStream *os, + idl_bool abstract_paths_only = I_FALSE + ); + + /// Load the insert queue with the concrete interface we support, and + /// call the generic version of traverse_inheritance_graph(). + int traverse_concrete_inheritance_graph ( + tao_code_emitter gen, + TAO_OutStream *os + ); + + idl_bool supports_abstract (void) const; + // Do we support at least one abstract interface? + // Visiting. virtual int accept (be_visitor *visitor); @@ -118,8 +136,29 @@ public: virtual idl_bool in_recursion (AST_Type *node = 0); // Check if we are in recursion. + static int abstract_supports_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper method passed to the template method to generate code for + // adding abstract supported interfaces to the inheritance list. + + static int gen_abstract_init_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper method to initialize the val_ member of the generated + // C++ class for each abstract interface that we support. + + static int gen_skel_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper method to generate *_skel operations for the concrete + // interface that we support (if any) and those of its base classes. + private: char *full_obv_skel_name_; + + idl_bool supports_abstract_; + // Do we support at least one abstract interface? }; #endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/base_proxy_impl_ch.h b/TAO/TAO_IDL/be_include/be_visitor_interface/base_proxy_impl_ch.h index 1e00449cd4c..73b04dd8e16 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/base_proxy_impl_ch.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/base_proxy_impl_ch.h @@ -36,6 +36,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* BE_BASE_PROXY_IMPL_CH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/direct_collocated_sh.h b/TAO/TAO_IDL/be_include/be_visitor_interface/direct_collocated_sh.h index 76e937d32e9..b948a423c5d 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/direct_collocated_sh.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/direct_collocated_sh.h @@ -37,6 +37,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* _BE_INTERFACE_DIRECT_COLLOCATED_SH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_sh.h b/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_sh.h index 322c3ae3f09..0c16d1467ea 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_sh.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_sh.h @@ -36,6 +36,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* BE_DIRECT_PROXY_IMPL_SH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_ss.h b/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_ss.h index c278e4cfdb8..91586f0d42a 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/direct_proxy_impl_ss.h @@ -35,6 +35,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* BE_DIRECT_PROXY_IMPL_SS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_cs.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_cs.h index 19159d8050a..26617298145 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_cs.h @@ -37,6 +37,12 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* _BE_INTERFACE_INTERCEPTORS_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_ss.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_ss.h index 5bcf269f7cc..936773ccdaa 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interceptors_ss.h @@ -38,6 +38,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* _BE_INTERFACE_INTERCEPTORS_SS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h index db2905fc6d3..9d2b0119d25 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h @@ -61,8 +61,8 @@ public: // visit the interface node virtual int visit_scope (be_scope *node); - // Overrides the method so we can deal with possible operations or - // attributes from a parent abstract interface. + // An override of the base class method so we can generate code for + // any abstract parents the interface may have. // =visit methods on all elements syntactically valid in a Interface scope diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ch.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ch.h index 0294553503b..f0a8e9b94b2 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ch.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ch.h @@ -44,6 +44,12 @@ public: virtual int visit_interface (be_interface *node); // set the right context and make a visitor + + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* _BE_INTERFACE_INTERFACE_CH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h index 51e3f8a7a88..d5e927d7f9e 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h @@ -41,6 +41,12 @@ public: virtual int visit_interface (be_interface *node); // set the right context and make a visitor + + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the definitions for the operations + // of any abstract parents we may have. }; #endif /* _BE_INTERFACE_INTERFACE_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h index f62e1e28d5d..f7fb788769b 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_sh.h @@ -24,27 +24,33 @@ class be_visitor_interface_sh : public be_visitor_interface { - // - // = TITLE - // be_visitor_interface_sh - // - // = DESCRIPTION - // This is a concrete visitor to generate the server header for interface - // - // - public: - be_visitor_interface_sh (be_visitor_context *ctx); - // constructor + // + // = TITLE + // be_visitor_interface_sh + // + // = DESCRIPTION + // This is a concrete visitor to generate the server header for interface + // + // +public: + be_visitor_interface_sh (be_visitor_context *ctx); + // constructor + + ~be_visitor_interface_sh (void); + // destructor + + virtual int visit_interface (be_interface *node); + // set the right context and make a visitor - ~be_visitor_interface_sh (void); - // destructor - - virtual int visit_interface (be_interface *node); - // set the right context and make a visitor - - protected: - virtual void this_method (be_interface *node); - virtual int generate_amh_classes (be_interface *node); + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. + +protected: + virtual void this_method (be_interface *node); + virtual int generate_amh_classes (be_interface *node); }; #endif /* _BE_INTERFACE_INTERFACE_SH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h index 2f0b008520d..fee57ebfe38 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_ss.h @@ -42,6 +42,12 @@ public: virtual int visit_interface (be_interface *node); // set the right context and make a visitor + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. + protected: virtual void this_method (be_interface *node); virtual void dispatch_method (be_interface *node); diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_ch.h b/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_ch.h index b02d729add6..0eb989aa593 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_ch.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_ch.h @@ -36,6 +36,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* BE_REMOTE_PROXY_IMPL_CH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_cs.h b/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_cs.h index 156ed3ba878..3588e6b1178 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/remote_proxy_impl_cs.h @@ -36,6 +36,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* BE_REMOTE_PROXY_IMPL_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_sh.h b/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_sh.h index 550b8b05268..2c9970a02b5 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_sh.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_sh.h @@ -36,6 +36,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* BE_THRU_POA_PROXY_IMPL_SH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_ss.h b/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_ss.h index 3ace820c52a..7595dceb14b 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/thru_poa_proxy_impl_ss.h @@ -36,6 +36,11 @@ public: virtual int visit_interface (be_interface *node); // visit an interface + static int gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper to generate the declarations for the operations + // of any abstract parents we may have. }; #endif /* BE_THRU_POA_PROXY_IMPL_SS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_valuetype.h b/TAO/TAO_IDL/be_include/be_visitor_valuetype.h index 6fe7d7a9f37..7dcaf198e15 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_valuetype.h +++ b/TAO/TAO_IDL/be_include/be_visitor_valuetype.h @@ -28,6 +28,9 @@ #include "be_visitor_valuetype/valuetype_obv_cs.h" #include "be_visitor_valuetype/valuetype_ci.h" #include "be_visitor_valuetype/valuetype_cs.h" +#include "be_visitor_valuetype/valuetype_sh.h" +#include "be_visitor_valuetype/valuetype_si.h" +#include "be_visitor_valuetype/valuetype_ss.h" #include "be_visitor_valuetype/any_op_ch.h" #include "be_visitor_valuetype/any_op_cs.h" #include "be_visitor_valuetype/cdr_op_ch.h" diff --git a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h index 7b58834188d..0116761b97a 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h +++ b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h @@ -66,9 +66,6 @@ public: virtual int visit_enum (be_enum *node); // visit an enum - virtual int visit_operation (be_operation *node); - // visit operation - virtual int visit_exception (be_exception *node); // visit exception (not used) diff --git a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ch.h b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ch.h index 527262a2721..054f2ed38af 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ch.h +++ b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ch.h @@ -48,8 +48,14 @@ public: virtual int visit_operation (be_operation *node); virtual int visit_field (be_field *node); - void begin_public (); - void begin_private (); + void begin_public (void); + void begin_private (void); + + static int gen_supported_ops (be_interface *node, + be_interface *base, + TAO_OutStream *os); + // Helper method passed to the template method to generate code for + // the operations of the parents of supported interfaces. }; #endif /* _BE_VALUETYPE_VALUETYPE_CH_H_ */ diff --git a/TAO/TAO_IDL/fe/fe_interface_header.cpp b/TAO/TAO_IDL/fe/fe_interface_header.cpp index 3c39e4d3155..9e0c59d79bd 100644 --- a/TAO/TAO_IDL/fe/fe_interface_header.cpp +++ b/TAO/TAO_IDL/fe/fe_interface_header.cpp @@ -264,6 +264,27 @@ FE_InterfaceHeader::FE_InterfaceHeader (UTL_ScopedName *n, this->compile_inheritance (inherits, I_FALSE); } + + int abstract_parent_seen = 0; + + if (this->pd_n_inherits > 0) + { + AST_Interface *iface = 0; + + for (long i = 0; i < this->pd_n_inherits; ++i) + { + iface = this->pd_inherits[i]; + + if (iface->is_abstract ()) + { + abstract_parent_seen = 1; + } + else if (abstract_parent_seen == 1) + { + idl_global->err ()->abstract_expected (iface); + } + } + } } FE_InterfaceHeader::~FE_InterfaceHeader (void) @@ -339,7 +360,7 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, AST_Interface *i = 0; long j = 0; long k = 0; - idl_bool inh_err = 0; + int inh_err = 0; iused = 0; iused_flat = 0; @@ -393,15 +414,15 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, if (i != 0) { - inh_err = !this->check_inherit (i, - for_valuetype); + inh_err = this->check_inherit (i, + for_valuetype); } else { - inh_err = 1; + inh_err = -1; } - if (inh_err) + if (inh_err == -1) { idl_global->err ()->interface_expected (d); break; @@ -456,17 +477,20 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, } } -idl_bool +int FE_InterfaceHeader::check_inherit (AST_Interface *i, idl_bool for_valuetype) { idl_bool is_valuetype = (i->node_type () == AST_Decl::NT_valuetype); - if (i != 0 - && !(for_valuetype ^ is_valuetype) - && (this->pd_is_local || !i->is_local ())) + if ( + // Non-local interfaces may not inherit from local ones. + (! this->pd_is_local && i->is_local ()) + // Both valuetype or both interface. + || (for_valuetype ^ is_valuetype) + ) { - return 1; + return -1; } else { @@ -531,8 +555,14 @@ FE_OBVHeader::FE_OBVHeader (UTL_ScopedName *n, if (!iface->is_abstract ()) { - this->pd_inherits_concrete = - AST_ValueType::narrow_from_decl (iface); + AST_ValueType *vt = AST_ValueType::narrow_from_decl (iface); + + if (vt == 0) + { + idl_global->err ()->valuetype_expected (iface); + } + + this->pd_inherits_concrete = vt; } for (long i = 1; i < this->pd_n_inherits; ++i) @@ -541,10 +571,7 @@ FE_OBVHeader::FE_OBVHeader (UTL_ScopedName *n, if (!iface->is_abstract ()) { - idl_global->err ()->abstract_inheritance_error ( - this->name (), - iface->name () - ); + idl_global->err ()->abstract_expected (iface); } } } @@ -646,9 +673,9 @@ FE_OBVHeader::compile_supports (UTL_NameList *supports) } // Remove typedefs, if any. - while (d->node_type () == AST_Decl::NT_typedef) + if (d->node_type () == AST_Decl::NT_typedef) { - d = AST_Typedef::narrow_from_decl (d)->base_type (); + d = AST_Typedef::narrow_from_decl (d)->primitive_base_type (); } if (d->node_type () == AST_Decl::NT_interface) @@ -686,8 +713,7 @@ FE_OBVHeader::compile_supports (UTL_NameList *supports) } else { - idl_global->err ()->abstract_support_error (this->name (), - iface->name ()); + idl_global->err ()->abstract_expected (iface); continue; } } diff --git a/TAO/TAO_IDL/include/ast_array.h b/TAO/TAO_IDL/include/ast_array.h index 4f74b748fb0..1023ed7b1ec 100644 --- a/TAO/TAO_IDL/include/ast_array.h +++ b/TAO/TAO_IDL/include/ast_array.h @@ -117,6 +117,10 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); +protected: + virtual int compute_size_type (void); + // Compute the size type if it is unknown. + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_predefined_type.h b/TAO/TAO_IDL/include/ast_predefined_type.h index c9a3fa919c8..72b604b69f2 100644 --- a/TAO/TAO_IDL/include/ast_predefined_type.h +++ b/TAO/TAO_IDL/include/ast_predefined_type.h @@ -122,6 +122,10 @@ public: // Cleanup. virtual void destroy (void); +protected: + virtual int compute_size_type (void); + // Compute the size type if it is unknown. + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_structure.h b/TAO/TAO_IDL/include/ast_structure.h index 1110be80e8d..3f37b011656 100644 --- a/TAO/TAO_IDL/include/ast_structure.h +++ b/TAO/TAO_IDL/include/ast_structure.h @@ -128,6 +128,11 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + +protected: + virtual int compute_size_type (void); + // Compute the size type if it is unknown. + protected: ACE_Unbounded_Queue<AST_Field *> fields_; // Container for this struct's field nodes. Excludes nodes included diff --git a/TAO/TAO_IDL/include/ast_typedef.h b/TAO/TAO_IDL/include/ast_typedef.h index 2d72dadcb2c..e31c3b1b696 100644 --- a/TAO/TAO_IDL/include/ast_typedef.h +++ b/TAO/TAO_IDL/include/ast_typedef.h @@ -107,6 +107,10 @@ public: // Cleanup. virtual void destroy (void); +protected: + virtual int compute_size_type (void); + // Compute the size type if it is unknown. + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_union.h b/TAO/TAO_IDL/include/ast_union.h index 9ff2ade23b6..1da84ff230b 100644 --- a/TAO/TAO_IDL/include/ast_union.h +++ b/TAO/TAO_IDL/include/ast_union.h @@ -140,6 +140,10 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); +protected: + virtual int compute_size_type (void); + // Compute the size type if it is unknown. + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_valuetype.h b/TAO/TAO_IDL/include/ast_valuetype.h index cbf0f4e2caf..7c7d15e26bf 100644 --- a/TAO/TAO_IDL/include/ast_valuetype.h +++ b/TAO/TAO_IDL/include/ast_valuetype.h @@ -28,6 +28,10 @@ public: // This also calls the base class version. virtual void redefine (AST_Interface *from); + AST_Interface **supports (void) const; + + long n_supports (void) const; + AST_ValueType *inherits_concrete (void) const; AST_Interface *supports_concrete (void) const; diff --git a/TAO/TAO_IDL/include/fe_interface_header.h b/TAO/TAO_IDL/include/fe_interface_header.h index d5f61ebb910..b651676de8c 100644 --- a/TAO/TAO_IDL/include/fe_interface_header.h +++ b/TAO/TAO_IDL/include/fe_interface_header.h @@ -134,8 +134,8 @@ protected: void compile_one_inheritance (AST_Interface *i); // Called from compile_inheritance(). - idl_bool check_inherit (AST_Interface *i, - idl_bool for_valuetype); + int check_inherit (AST_Interface *i, + idl_bool for_valuetype); }; diff --git a/TAO/TAO_IDL/include/utl_err.h b/TAO/TAO_IDL/include/utl_err.h index 85537fe8fc4..8b05c806b2f 100644 --- a/TAO/TAO_IDL/include/utl_err.h +++ b/TAO/TAO_IDL/include/utl_err.h @@ -113,6 +113,7 @@ public: EIDL_CONSTANT_EXPECTED, // We got something else.. EIDL_INTERFACE_EXPECTED, // We got something else.. EIDL_VALUETYPE_EXPECTED, // We got something else.. + EIDL_ABSTRACT_EXPECTED, // We got something else.. EIDL_NAME_CASE_ERROR, // Identifier spellings differ only in case EIDL_NAME_CASE_WARNING, // Same as above, but only a warning EIDL_KEYWORD_ERROR, // Case-insensitive clash with IDL keyword @@ -247,6 +248,12 @@ public: // key, emits, publishes or consumes declaration. void valuetype_expected (AST_Decl *d); + // Report a situation where an abstract type was expected but we got + // something else instead. This is the case in an inheritance + // list where a concrete type appears after an abstract type, or + // where a valuetype inherits more than one concrete valuetype. + void abstract_expected (AST_Decl *d); + // Report a situation where an enumerator was expected but we got // something else instead. This occurs when a union with an enum // discriminator is being parsed and one of the branch labels is diff --git a/TAO/TAO_IDL/util/utl_err.cpp b/TAO/TAO_IDL/util/utl_err.cpp index 49f92726a2b..e4d64e0c165 100644 --- a/TAO/TAO_IDL/util/utl_err.cpp +++ b/TAO/TAO_IDL/util/utl_err.cpp @@ -154,6 +154,8 @@ error_string (UTL_Error::ErrorCode c) return "interface expected: "; case UTL_Error::EIDL_VALUETYPE_EXPECTED: return "value type expected: "; + case UTL_Error::EIDL_ABSTRACT_EXPECTED: + return "abstract type expected: "; case UTL_Error::EIDL_EVAL_ERROR: return "expression evaluation error: "; case UTL_Error::EIDL_NAME_CASE_ERROR: @@ -959,6 +961,22 @@ UTL_Error::valuetype_expected (AST_Decl *d) idl_global->set_err_count (idl_global->err_count () + 1); } +// Report a situation where an abstract type was expected but we got +// something else instead. This is the case in an inheritance +// list where a concrete type appears after an abstract type, or +// where a valuetype inherits more than one concrete valuetype. +void +UTL_Error::abstract_expected (AST_Decl *d) +{ + idl_error_header (EIDL_ABSTRACT_EXPECTED, + d->line (), + d->file_name ()); + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM); + ACE_ERROR ((LM_ERROR, + "\n")); + idl_global->set_err_count (idl_global->err_count () + 1); +} + // Report a situation where an enumerator was expected but we // got something else. This may occur in a union with an enum // discriminator where a label did not evaluate to a constant |