diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp | 178 |
1 files changed, 90 insertions, 88 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index 58f53155d48..f1748719882 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -19,8 +19,8 @@ // // ============================================================================ -ACE_RCSID (be_visitor_valuetype, - valuetype, +ACE_RCSID (be_visitor_valuetype, + valuetype, "$Id$") be_visitor_valuetype::be_visitor_valuetype (be_visitor_context *ctx) @@ -35,6 +35,7 @@ be_visitor_valuetype::~be_visitor_valuetype (void) int be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { + int n_processed = 0; this->elem_number_ = 0; for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); @@ -47,10 +48,20 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), + "bad node in this scope\n"), -1); } + AST_Field *field = AST_Field::narrow_from_decl (d); + + if (field && field->visibility () == AST_Field::vis_PRIVATE) + { + continue; + // Ignore private fields in this run + // AST_Attribute derives from AST_Field, so test for + // vis_PRIVATE is ok (the attribute has it set to vis_NA) + } + be_decl *bd = be_decl::narrow_from_decl (d); // Set the scope node as "node" in which the code is being // generated so that elements in the node's scope can use it @@ -60,24 +71,63 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) this->ctx_->node (bd); this->elem_number_++; + if (bd == 0 || bd->accept (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "codegen for scope failed\n"), + -1); + + } + } + + this->elem_number_ = 0; + + for (UTL_ScopeActiveIterator sj (node, UTL_Scope::IK_decls); + !sj.is_done (); + sj.next()) + { + AST_Decl *d = sj.item (); + + if (!d) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "bad node in this scope\n"), + -1); + } + AST_Field *field = AST_Field::narrow_from_decl (d); - if (field != 0 && field->visibility () == AST_Field::vis_PRIVATE) + if (!field + || (field && field->visibility () != AST_Field::vis_PRIVATE)) { - this->begin_private (); + // Only private fields. + continue; } - else + + ++ n_processed; + + if (n_processed == 1) { - this->begin_public (); + this->begin_private (); } + be_decl *bd = be_decl::narrow_from_decl (d); + // Set the scope node as "node" in which the code is being + // generated so that elements in the node's scope can use it + // for code generation. + + this->ctx_->scope (node->decl ()); + this->ctx_->node (bd); + this->elem_number_++; + if (bd == 0 || bd->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " "codegen for scope failed\n"), -1); - } } @@ -206,7 +256,7 @@ be_visitor_valuetype::visit_constant (be_constant *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_constant - " - "Bad context state\n"), + "Bad context state\n"), -1); } } @@ -283,7 +333,7 @@ be_visitor_valuetype::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_enum - " - "Bad context state\n"), + "Bad context state\n"), -1); } } @@ -293,7 +343,7 @@ be_visitor_valuetype::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_enum - " - "failed to accept visitor\n"), + "failed to accept visitor\n"), -1); } @@ -316,7 +366,7 @@ be_visitor_valuetype::visit_exception (be_exception *node) break; } case TAO_CodeGen::TAO_ROOT_CI: - { + { be_visitor_exception_ci visitor (&ctx); status = node->accept (&visitor); break; @@ -360,7 +410,7 @@ be_visitor_valuetype::visit_exception (be_exception *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_exception - " - "failed to accept visitor\n"), + "failed to accept visitor\n"), -1); } @@ -427,7 +477,7 @@ be_visitor_valuetype::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_structure - " - "failed to accept visitor\n"), + "failed to accept visitor\n"), -1); } @@ -460,7 +510,7 @@ be_visitor_valuetype::visit_structure_fwd (be_structure_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_structure_fwd - " - "failed to accept visitor\n"), + "failed to accept visitor\n"), -1); } @@ -532,7 +582,7 @@ be_visitor_valuetype::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_union - " - "Bad context state\n"), + "Bad context state\n"), -1); } } @@ -542,7 +592,7 @@ be_visitor_valuetype::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_union - " - "failed to accept visitor\n"), + "failed to accept visitor\n"), -1); } @@ -575,7 +625,7 @@ be_visitor_valuetype::visit_union_fwd (be_union_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_union_fwd - " - "failed to accept visitor\n"), + "failed to accept visitor\n"), -1); } @@ -647,7 +697,7 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_typedef - " - "Bad context state\n"), + "Bad context state\n"), -1); } } @@ -657,7 +707,7 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_typedef - " - "failed to accept visitor\n"), + "failed to accept visitor\n"), -1); } @@ -689,7 +739,7 @@ be_visitor_valuetype::gen_pd (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), + "bad node in this scope\n"), -1); } @@ -715,7 +765,7 @@ be_visitor_valuetype::gen_pd (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), + "codegen for scope failed\n"), -1); } } @@ -738,7 +788,7 @@ be_visitor_valuetype::gen_field_pd (be_field *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" "visit_field - " - "Bad field type\n"), + "Bad field type\n"), -1); } @@ -755,11 +805,11 @@ be_visitor_valuetype::gen_field_pd (be_field *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" "visit_field - " - "codegen for field type failed\n"), + "codegen for field type failed\n"), -1); } - // Now output the field name. + // Now output the field name. *os << " " << vt->field_pd_prefix () << node->local_name () << vt->field_pd_postfix () << ";"; @@ -767,54 +817,6 @@ be_visitor_valuetype::gen_field_pd (be_field *node) return 0; } -void -be_visitor_valuetype::gen_obv_init_constructor_args (be_valuetype *node, - unsigned long &index) -{ - TAO_OutStream *os = this->ctx_->stream (); - AST_ValueType *parent = node->inherits_concrete (); - - // Generate for inherited members first. - if (parent != 0) - { - be_valuetype *be_parent = - be_valuetype::narrow_from_decl (parent); - this->gen_obv_init_constructor_args (be_parent, index); - } - - be_visitor_context ctx (*this->ctx_); - be_visitor_args_arglist visitor (&ctx); - - for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); - !si.is_done (); - si.next()) - { - be_field *f = be_field::narrow_from_decl (si.item ()); - - if (f == 0) - { - continue; - } - - *os << (index++ != 0 ? "," : "") << be_nl; - - ACE_CString arg_name ("_tao_init_"); - arg_name += f->local_name ()->get_string (); - Identifier id (arg_name.c_str ()); - UTL_ScopedName sn (&id, 0); - be_type *ft = be_type::narrow_from_decl (f->field_type ()); - bool seen = ft->seen_in_operation (); - - // This sets ft->seen_in_operation (true), so we have to - // restore the original value below. - be_argument arg (AST_Argument::dir_IN, - ft, - &sn); - ft->seen_in_operation (seen); - visitor.visit_argument (&arg); - id.destroy (); - } -} // Generate the _init definition. int @@ -860,18 +862,18 @@ be_visitor_valuetype::gen_init_impl (be_valuetype *node) char fname [NAMEBUFSIZE]; // to hold the full and char lname [NAMEBUFSIZE]; // local _out names - ACE_OS::memset (fname, - '\0', + ACE_OS::memset (fname, + '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, - "%s_init", + ACE_OS::sprintf (fname, + "%s_init", node->full_name ()); - ACE_OS::memset (lname, - '\0', + ACE_OS::memset (lname, + '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, - "%s_init", + ACE_OS::sprintf (lname, + "%s_init", node->local_name ()); // Destructor. @@ -888,7 +890,7 @@ be_visitor_valuetype::gen_init_impl (be_valuetype *node) return 0; } -bool +idl_bool be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) { // VT needs RefCounter if it has concrete factory or supports an @@ -903,7 +905,7 @@ be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) // Now go thru our base VTs and see if one has already. for (int i = 0; i < node->n_inherits (); ++i) { - be_valuetype *vt = + be_valuetype *vt = be_valuetype::narrow_from_decl (node->inherits ()[i]); if (vt != 0) @@ -918,7 +920,7 @@ be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) return 1; } -bool +idl_bool be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) { @@ -950,20 +952,20 @@ be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) return 0; } -bool +idl_bool be_visitor_valuetype::is_amh_exception_holder (be_valuetype *node) { if (ACE_OS::strncmp (node->local_name (), "AMH_", 4) == 0) { - const char *last_E = + const char *last_E = ACE_OS::strrchr (node->full_name (), 'E'); if (last_E != 0 && ACE_OS::strcmp (last_E, "ExceptionHolder") == 0) { - return true; + return I_TRUE; } } - return false; + return I_FALSE; } |