int be_visitor_arg_traits::visit_attribute (be_attribute *node) { if (this->ctx_->alias () != 0 || this->generated (node)) { return 0; } AST_String *st = AST_String::narrow_from_decl (node->field_type ()); if (st == 0) { return 0; } ACE_CDR::ULong bound = st->max_size ()->ev ()->u.ulval; if (bound == 0) { return 0; } TAO_OutStream *os = this->ctx_->stream (); *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__; std::string guard_suffix = std::string (this->S_) + std::string ("arg_traits"); // The guard should be generated to prevent multiple declarations, // since a bounded (w)string of the same length may be used or typedef'd // more than once. os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false); bool wide = (st->width () != 1); // It is legal IDL to declare a bounded (w)string as an operation // parameter type. There could be any number of identical // declarations in the same build, translation unit, or even in // the same operation, so we use the argument's flat name to // declare an empty struct, and use that struct as the template // parameter for Arg_Traits<>. *os << be_nl; // Avoid generating a duplicate structure in the skeleton. if (ACE_OS::strlen (this->S_) == 0) { *os << "struct " << node->flat_name () << " {};" << be_nl_2; } *os << "template<>" << be_nl << "class " << this->S_ << "Arg_Traits<" << node->flat_name () << ">" << be_idt_nl << ": public" << be_idt << be_idt_nl << "BD_String_" << this->S_ << "Arg_Traits_T<" << be_nl << "CORBA::" << (wide ? "W" : "") << "String_var," << be_nl << bound << "," << be_nl << this->insert_policy() << ">" << be_uidt << be_uidt << be_uidt_nl << "{" << be_nl << "};"; os->gen_endif (); this->generated (node, true); return 0; }
int be_visitor_arg_traits::visit_operation (be_operation *node) { if (this->generated (node) || node->is_local () || node->imported ()) { return 0; } AST_Type *rt = node->return_type (); AST_Decl::NodeType nt = rt->node_type (); // If our return type is an unaliased bounded (w)string, we create // an empty struct using the operation's flat name for the type, // and use this type as the Arg_Traits<> template parameter. All // this is necessary because there could be any number of such // return types, all identical, in the same interface, valuetype, // translation unit, or build, and we need a unique type for the // Arg_Traits<> template parameter. if (nt == AST_Decl::NT_string || nt == AST_Decl::NT_wstring) { AST_String *str = AST_String::narrow_from_decl (rt); ACE_CDR::ULong bound = str->max_size ()->ev ()->u.ulval; if (bound > 0) { TAO_OutStream *os = this->ctx_->stream (); *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__; std::string guard_suffix = std::string (this->S_) + std::string ("arg_traits"); // The guard should be generated to prevent multiple declarations, // since a bounded (w)string of the same length may be used or typedef'd // more than once. os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false); bool wide = (str->width () != 1); *os << be_nl_2; // Avoid generating a duplicate structure in the skeleton. if (ACE_OS::strlen (this->S_) == 0) { *os << "struct " << node->flat_name () << " {};" << be_nl_2; } *os << "template<>" << be_nl << "class " << this->S_ << "Arg_Traits<" << node->flat_name () << ">" << be_idt_nl << ": public" << be_idt << be_idt_nl << "BD_String_" << this->S_ << "Arg_Traits_T<" << be_nl << "CORBA::" << (wide ? "W" : "") << "String_var," << be_nl << bound << "," << be_nl << this->insert_policy() << ">" << be_uidt << be_uidt << be_uidt_nl << "{" << be_nl << "};"; os->gen_endif (); } } // This will catch (in visit_argument() below) any parameters that // are unaliased, bounded (w)strings. if (this->visit_scope (node) != 0) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_arg_traits::") ACE_TEXT ("visit_operation - visit scope failed\n")), -1); } this->generated (node, true); return 0; }