diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp | 149 |
1 files changed, 56 insertions, 93 deletions
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 7890fd7ac59..43021787f23 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp @@ -20,13 +20,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" +#include "be_visitor_typecode/typecode_decl.h" +#include "be_visitor_operation/rettype.h" -ACE_RCSID(be_visitor_valuetype, valuetype_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_ch, + "$Id$") // ****************************************************** @@ -49,6 +50,9 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) 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; // == STEP 1: Generate the class name and class names we inherit == @@ -79,18 +83,20 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) os->gen_endif (); // Generate the ifdef macro for the _out class. - os->gen_ifdef_macro (node->flat_name (), "_out"); + os->gen_ifdef_macro (node->flat_name (), + "_out"); - // Generate the _out declaration + // 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); + "codegen for _out failed\n"), + -1); } - // generate the endif macro. + // Generate the endif macro. os->gen_endif (); } @@ -110,13 +116,14 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) // (ordinary (not abstract) interfaces ignored). *os << be_idt_nl <<": "; + int i; // loop index int n_inherits_valuetypes = 0; idl_bool valuebase_inherited = 0; if (node->n_inherits () > 0) { - for (i = 0; i < node->n_inherits (); i++) + for (i = 0; i < node->n_inherits (); ++i) { // %! move is_nested() and nested_type_name() to // AST_Interface, then type AST_Interface can be used @@ -191,16 +198,16 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) *os << "{" << be_nl << "public:" << be_idt_nl - // Generate the _ptr_type and _var_type typedef - // but we must protect against certain versions of g++ + // Generate the _ptr_type and _var_type typedef + // but we must protect against certain versions of g++ << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" << be_nl << "typedef " << node->local_name () << "* _ptr_type;" << be_nl << "typedef " << node->local_name () << "_var _var_type;\n" << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl - // Generate the static _downcast operation. - // (see OMG 20.17.{4,5}). + // Generate the static _downcast operation. + // (see OMG 20.17.{4,5}). << "static " << node->local_name () << "* " << "_downcast (CORBA::ValueBase* );" << be_nl << "// The address of static _downcast is implicit used as type id\n" @@ -250,8 +257,8 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "_tao_marshal_v (TAO_OutputCDR &);" << be_nl; *os << "virtual CORBA::Boolean " << "_tao_unmarshal_v (TAO_InputCDR &);" << be_nl; - // %! optimize _downcast away: extra parameter with type info - // set (void *) in CDR Stream with the right derived pointer. + // %! optimize _downcast away: extra parameter with type info + // set (void *) in CDR Stream with the right derived pointer. } @@ -265,7 +272,7 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "void operator= (const " << node->local_name () << " &);" << be_nl; - // Map fields to private data (if optimizing). + // Map fields to private data (if optimizing). if (node->opt_accessor ()) { *os << be_uidt_nl << "protected:" << be_idt_nl; @@ -275,6 +282,7 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "_tao_unmarshal_state (TAO_InputCDR &);" << be_uidt_nl << be_nl; *os << "private:" << be_idt_nl; + this->gen_pd (node); } else // Need a way to access the state of derived OBV_ classes. @@ -292,51 +300,40 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) } *os << be_uidt_nl << "};" << be_nl; + os->gen_endif (); // Generate the _init -related declarations. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_valuetype_init_ch visitor (&ctx); - if (!visitor) + if (visitor.visit_valuetype (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "NULL visitor.\n" - ), -1); + "failed to generate _init construct.\n"), + -1); } - if (visitor->visit_valuetype(node) == -1) + // Step last: generate typecode declaration. + if (be_global->tc_support ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "failed to generate _init construct.\n" - ), -1); - } + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); + be_visitor_typecode_decl visitor (&ctx); - delete visitor; - - // Step last: generate typecode declaration - { - be_visitor *visitor; - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_structure - " - "TypeCode declaration failed\n" - ), - -1); - } - } + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_structure - " + "TypeCode declaration failed\n"), + -1); + } + } node->cli_hdr_gen (I_TRUE); @@ -348,7 +345,6 @@ int be_visitor_valuetype_ch::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; this->ctx_->node (node); // save the node @@ -356,7 +352,7 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) *os << "virtual "; // STEP I: Generate the return type. - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -370,20 +366,10 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) // Grab the right visitor to generate the return type. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype or_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_operation - " @@ -391,8 +377,6 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) -1); } - delete visitor; - // STEP 2: Generate the operation name. *os << " " << node->local_name (); @@ -400,20 +384,10 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ch::" - "visit_operation - " - "Bad visitor to argument list\n"), - -1); - } + be_visitor_obv_operation_arglist ooa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&ooa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ch::" "visit_operation - " @@ -421,8 +395,6 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) -1); } - delete visitor; - return 0; } @@ -438,36 +410,25 @@ be_visitor_valuetype_ch::visit_field (be_field *node) be_visitor_context* ctx = new be_visitor_context (*this->ctx_); ctx->state (TAO_CodeGen::TAO_FIELD_OBV_CH); - be_visitor_valuetype_field_ch *visitor = - new be_visitor_valuetype_field_ch (ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_obv_ch::" - "visit_field - bad visitor\n"), - -1); - } + be_visitor_valuetype_field_ch visitor (ctx); if (vt->opt_accessor ()) { - visitor->setenclosings ("",";"); + visitor.setenclosings ("",";"); } else { - visitor->setenclosings ("virtual "," = 0;"); + visitor.setenclosings ("virtual "," = 0;"); } - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_obv_ch::" - "visit_field - codegen failed\n"), + "visit_field - codegen failed\n"), -1); } - delete visitor; return 0; } @@ -476,6 +437,7 @@ void be_visitor_valuetype_ch::begin_public (void) { TAO_OutStream *os = this->ctx_->stream (); + *os << "public:" << be_idt_nl; } @@ -483,5 +445,6 @@ void be_visitor_valuetype_ch::begin_private (void) { TAO_OutStream *os = this->ctx_->stream (); + *os << be_uidt_nl << "protected:" << be_idt_nl; } |