diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp index e2e2fd57012..e70f3b780a7 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp @@ -76,6 +76,116 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) << "}"; } + *os << be_global->core_versioning_end () << be_nl; + + be_module *module = 0; + + AST_Decl *decl = node; + if (decl->is_nested ()) + { + if (node->defined_in ()->scope_node_type () == AST_Decl::NT_interface) + { + be_interface *intf = 0; + intf = be_interface::narrow_from_scope (node->defined_in ()); + decl = intf; + } + + if (decl->defined_in ()->scope_node_type () == AST_Decl::NT_module) + { + module = be_module::narrow_from_scope (decl->defined_in ()); + + if (!module) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_valuebox_any_op_cs::" + "visit_valuebox - " + "Error parsing nested name\n"), + -1); + } + + // Some compilers handle "any" operators in a namespace corresponding + // to their module, others do not. + *os << "\n\n#if defined (ACE_ANY_OPS_USE_NAMESPACE)\n"; + + be_util::gen_nested_namespace_begin (os, module); + + // Copying insertion. + *os << "// Copying insertion." << be_nl + << "void operator<<= (" << be_idt << be_idt_nl + << "::CORBA::Any &_tao_any," << be_nl + << "const ::" << node->name () << " &_tao_elem" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + + << "if (0 == &_tao_elem) // Trying to de-reference NULL object" << be_idt_nl + << "_tao_any <<= static_cast< ::" << node->name () << " *>( 0 ); // Use non-copying insertion of a NULL" << be_uidt_nl + << "else" << be_idt_nl + + << "TAO::Any_Dual_Impl_T< ::" << node->name () << ">::insert_copy (" + << be_idt << be_idt_nl + << "_tao_any," << be_nl + << "::" << node->name () << "::_tao_any_destructor," << be_nl + << "::" << node->tc_name () << "," << be_nl + << "_tao_elem" << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + // Non-copying insertion. + *os << "// Non-copying insertion." << be_nl + << "void operator<<= (" << be_idt << be_idt_nl + << "::CORBA::Any &_tao_any," << be_nl + << "::" << node->name () << " *_tao_elem" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "TAO::Any_Dual_Impl_T< ::" << node->name () << ">::insert (" + << be_idt << be_idt_nl + << "_tao_any," << be_nl + << "::" << node->name () << "::_tao_any_destructor," << be_nl + << "::" << node->tc_name () << "," << be_nl + << "_tao_elem" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + // Extraction to non-const pointer (deprecated, just calls the other). + *os << "// Extraction to non-const pointer (deprecated)." << be_nl + << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl + << "const ::CORBA::Any &_tao_any," << be_nl + << "::" << node->name () << " *&_tao_elem" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "return _tao_any >>= const_cast<" << be_idt << be_idt_nl + << "const ::" << node->name () << " *&> (" << be_nl + << "_tao_elem" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + // Extraction to const pointer. + *os << "// Extraction to const pointer." << be_nl + << "::CORBA::Boolean operator>>= (" << be_idt << be_idt_nl + << "const ::CORBA::Any &_tao_any," << be_nl + << "const ::" << node->name () << " *&_tao_elem" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "return" << be_idt_nl + << "TAO::Any_Dual_Impl_T< ::" << node->name () << ">::extract (" + << be_idt << be_idt_nl + << "_tao_any," << be_nl + << "::" << node->name () << "::_tao_any_destructor," << be_nl + << "::" << node->tc_name () << "," << be_nl + << "_tao_elem" << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}"; + + be_util::gen_nested_namespace_end (os, module); + + // Emit #else. + *os << be_nl << be_nl + << "#else\n"; + } + } + + *os << be_global->core_versioning_begin () << be_nl; + // Copying insertion. *os << "// Copying insertion." << be_nl << "void operator<<= (" << be_idt << be_idt_nl @@ -145,6 +255,11 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) *os << be_global->core_versioning_end () << be_nl; + if (module != 0) + { + *os << "\n\n#endif"; + } + // All we have to do is to visit the scope and generate code. if (this->visit_scope (node) == -1) { |