diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_valuetype')
16 files changed, 0 insertions, 5514 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp deleted file mode 100644 index c5538060056..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// arglist.cpp -// -// = DESCRIPTION -// Visitor generating the parameter list of operations -// in the Valuetype class. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// based on code from Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, arglist, "$Id$") - - -// ************************************************************ -// operation visitor to generate the argument list. -// We have separated code generation for this from the 4 main -// visitors to avoid code duplication and tight coupling -// ************************************************************ - -be_visitor_obv_operation_arglist::be_visitor_obv_operation_arglist (be_visitor_context - *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_obv_operation_arglist::~be_visitor_obv_operation_arglist (void) -{ -} - -int -be_visitor_obv_operation_arglist::visit_operation (be_operation *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - *os << " ("; - // *os << " (" << be_idt << be_idt << "\n"; - - // all we do is hand over code generation to our scope - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_obv_operation_arglist::" - "visit_operation - " - "codegen for scope failed\n"), - -1); - } - - - // *os << be_uidt; - // os->indent (); - *os << ")";// << be_uidt; - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - // each method is pure virtual in the Valuetype class - *os << " = 0;\n"; - break; - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: - break; - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: - break; - default: - *os << "\n"; - } - if (!this->ctx_->attribute ()) // hack to get a nice newline - *os << "\n"; - return 0; -} - -int -be_visitor_obv_operation_arglist::visit_argument (be_argument *node) -{ - // TAO_OutStream *os = this->ctx_->stream (); - - // get the visitor that will dump the argument's mapping in the operation - // signature. - be_visitor_context ctx (*this->ctx_); - - // first grab the interface definition inside which this operation is - // defined. We need this since argument types may very well be declared - // inside the scope of the interface node. In such cases, we would like to - // generate the appropriate relative scoped names. - be_operation *op = this->ctx_->be_scope_as_operation (); - if (!op) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "Bad operation\n"), - -1); - } - - // We need the interface node in which this operation was defined. However, - // if this operation node was an attribute node in disguise, we get this - // information from the context - // %! use AST_Interface - be_valuetype *intf; - intf = this->ctx_->attribute () - ? be_valuetype::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) - : be_valuetype::narrow_from_scope (op->defined_in ()); - - if (!intf) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "Bad interface\n"), - -1); - } - ctx.scope (intf); // set new scope - - // snipped from - // be_visitor_args_arglist::visit_argument (be_argument *node) - ctx.node (node); // save the argument node - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_arglist::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // os->indent (); // start with current indentation level - - // Different types have different mappings when used as in/out or - // inout parameters. Let this visitor deal with the type - - // end of be_visitor_args_arglist::visit_argument () - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); - break; - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_OTHERS: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_SH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "Bad context\n"), - -1); - } - } - - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "codegen for argument failed\n"), - -1); - } - delete visitor; - return 0; -} - -int -be_visitor_obv_operation_arglist::post_process (be_decl *bd) -// derived from be_visitor_operation_argument::post_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_OTHERS: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_SH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: - if (!this->last_node (bd)) - *os << ", "; // "\n"; - else - *os << ""; // "\n"; - break; - default: - break; - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ch.cpp deleted file mode 100644 index eb01d5ff6c4..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ch.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Concrete visitor for valuetypes. -// This one provides code generation for the CDR operators. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// based on code from Aniruddha Gokhale -// -// ============================================================================ - - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, cdr_op_ch, "$Id$") - -be_visitor_valuetype_cdr_op_ch::be_visitor_valuetype_cdr_op_ch -(be_visitor_context *ctx) - : be_visitor_valuetype (ctx) -{ -} - -be_visitor_valuetype_cdr_op_ch::~be_visitor_valuetype_cdr_op_ch (void) -{ -} - -int -be_visitor_valuetype_cdr_op_ch::visit_valuetype (be_valuetype *node) -{ - if (node->cli_hdr_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations (prototypes) - - os->indent (); - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const " << node->name () - << " *); // " << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, " - << node->name () << " *&);\n"; - - // set the substate as generating code for the types defined in our scope - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_cdr_op_ch::" - "visit_valuetype - " - "codegen for scope failed\n"), -1); - } - - - node->cli_hdr_cdr_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ci.cpp deleted file mode 100644 index 5c0b7513f77..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ci.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ci.cpp -// -// = DESCRIPTION -// Concrete visitor for valuetypes. -// This one provides code generation for the CDR operators. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// based on code from Aniruddha Gokhale -// -// ============================================================================ - - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" -// #include "be_visitor_field.h" - -ACE_RCSID(be_visitor_valuetype, cdr_op_ci, "$Id$") - -be_visitor_valuetype_cdr_op_ci::be_visitor_valuetype_cdr_op_ci -(be_visitor_context *ctx) - : be_visitor_valuetype (ctx) -{ -} - -be_visitor_valuetype_cdr_op_ci::~be_visitor_valuetype_cdr_op_ci (void) -{ -} - -int -be_visitor_valuetype_cdr_op_ci::visit_valuetype (be_valuetype *node) -{ - // already generated and/or we are imported. Don't do anything. - if (node->cli_inline_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // First generate code for our children. The reason we do this first is - // because the inlined code for our children must be available before we use - // it in our parent - - // set the substate as generating code for the types defined in our scope - //this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_cdr_op_ci" - "::visit_valuetype - " - "codegen for scope failed\n"), -1); - } - - // set the sub state as generating code for the output operator - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_OUTPUT); - os->indent (); - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator<< (TAO_OutputCDR &strm, const " - << node->name () - << " *_tao_valuetype)" << be_nl - << "{" << be_idt_nl; - *os << "return CORBA_ValueBase::_tao_marshal (strm," << be_idt_nl - << "ACE_const_cast (" << node->name () << "*, _tao_valuetype)," << be_nl - << "(ptr_arith_t) &" << node->name() <<"::_downcast);" - << be_uidt<< be_uidt_nl - << "}\n\n"; - - // set the substate as generating code for the input operator - //this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator>> (TAO_InputCDR &strm, " - << node->name () - << " *&_tao_valuetype)" << be_nl - << "{" << be_idt_nl; - *os << "return " << node->name() << "::_tao_unmarshal (strm, _tao_valuetype);" -#ifdef obv_marshal_old_version - *os << "CORBA::ValueBase *ptr;" << be_nl - << "int retval = CORBA_ValueBase::_tao_unmarshal (strm," - << be_idt_nl << "ptr, (ptr_arith_t) &" << node->name() <<"::_downcast);" - << be_uidt_nl - << "if (retval) {" << be_idt_nl - << "_tao_valuetype = " << node->name() << "::_downcast (ptr);" - << be_nl << "if (_tao_valuetype) retval = 1;" - << be_uidt_nl << "}" << be_idt_nl - << "return retval;" -#endif /* obv_marshal_old_version */ - << be_uidt_nl - << "}\n\n"; - - if (!node->is_abstract_valuetype ()) - { // functions that marshal state - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_valuetype_marshal_cs visitor (new_ctx); - visitor.visit_valuetype (node); - } - - node->cli_inline_cdr_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp deleted file mode 100644 index d8288c7af99..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp +++ /dev/null @@ -1,947 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// field_cdr_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Field in the client stubs file. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// derived from be_visitor_field/cdr_op_ci.cpp -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_valuetype, field_cdr_op_ci, "$Id$") - - -// ********************************************** -// visitor for field in the client stubs file -// ********************************************** - -// constructor -be_visitor_valuetype_field_cdr_ci::be_visitor_valuetype_field_cdr_ci (be_visitor_context *ctx) - : be_visitor_decl (ctx), - pre_ (""), post_ ("") -{ -} - -// destructor -be_visitor_valuetype_field_cdr_ci::~be_visitor_valuetype_field_cdr_ci (void) -{ -} - -// visit the field node -int -be_visitor_valuetype_field_cdr_ci::visit_field (be_field *node) -{ - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} - -// visit array -int -be_visitor_valuetype_field_cdr_ci::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "cannot retrieve field node\n" - ), -1); - } - - // for anonymous arrays, the type name has a _ prepended. We compute - // the fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - // save the node's local name and full name in a buffer for quick - // use later on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (!this->ctx_->alias () // not a typedef - && node->is_child (this->ctx_->scope ())) - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscore - // prepended to our local name. This needs to be inserted after - // the parents's name - - if (node->is_nested ()) - { - be_decl *parent = - be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - } - - // check what is the code generation substate. Are we generating - // code for the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " - << "_tao_" << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " - << "_tao_" << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef - && node->is_child (this->ctx_->scope ())) - { - // this is the case for anonymous arrays. Generate the <<, >> operators - // for the type defined by the anonymous array - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the declaration - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit enum type -int -be_visitor_valuetype_field_cdr_ci::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_enum - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the typcode for enums - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit interface type -int -be_visitor_valuetype_field_cdr_ci::visit_interface (be_interface *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_interface - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ".out ())"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an interface cannit be declared inside a - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_interface - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit interface forward type -int -be_visitor_valuetype_field_cdr_ci::visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_interface_fwd - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ").out ()"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ").in ()"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an interface cannit be declared inside a - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_interface_fwd - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit valuetype type -int -be_visitor_valuetype_field_cdr_ci::visit_valuetype (be_valuetype *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_valuetype - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ".out ())"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an valuetype cannit be declared inside a - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_valuetype - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit valuetype forward type -int -be_visitor_valuetype_field_cdr_ci::visit_valuetype_fwd (be_valuetype_fwd *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_valuetype_fwd - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ").out ()"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ").in ()"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an valuetype cannit be declared inside a - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_valuetype_fwd - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit predefined type -int -be_visitor_valuetype_field_cdr_ci::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_predefined_type - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - // is a psuedo obj - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm >> " << pre_ << f->local_name () << post_ - << ".out ())"; - else if (node->pt () == AST_PredefinedType::PT_char) - *os << "(strm >> CORBA::Any::to_char (" << pre_ - << f->local_name () << post_ << "))"; - else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "(strm >> CORBA::Any::to_wchar (" << pre_ - << f->local_name () << post_ << "))"; - else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "(strm >> CORBA::Any::to_octet (" << pre_ - << f->local_name () << post_ << "))"; - else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "(strm >> CORBA::Any::to_boolean (" << pre_ - << f->local_name () << post_ << "))"; - else - *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - // is a psuedo obj - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; - else if (node->pt () == AST_PredefinedType::PT_char) - *os << "(strm << CORBA::Any::from_char (" << pre_ - << f->local_name () << post_ << "))"; - else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "(strm << CORBA::Any::from_wchar (" << pre_ - << f->local_name () << post_ << "))"; - else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "(strm << CORBA::Any::from_octet (" << pre_ - << f->local_name () << post_ << "))"; - else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "(strm << CORBA::Any::from_boolean (" << pre_ - << f->local_name () << post_ << "))"; - else - *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - return 0; -} - -int -be_visitor_valuetype_field_cdr_ci::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_sequence - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_sequence - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef - && node->is_child (this->ctx_->scope ())) - // not a typedef AND - // node is defined inside the structure - { - // Anonymous sequence - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. - // The scope is still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit string type -int -be_visitor_valuetype_field_cdr_ci::visit_string (be_string *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_string - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ".out ())"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - return 0; -} - -// visit structure type -int -be_visitor_valuetype_field_cdr_ci::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_structure - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_structure - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_struct - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit typedef type -int -be_visitor_valuetype_field_cdr_ci::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_valuetype_field_cdr_ci::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_union - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_union - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_union - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - - -// **************************************************************** - -be_visitor_valuetype_field_cdr_decl:: - be_visitor_valuetype_field_cdr_decl (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -// This is a field, but the action depends on the type of the field, -// use this visitor to detect the type of the field. -// Notice that this is why the parent visitor (who create us) cannot -// do the job, because it may have another purpose for some or all of -// the visit_* methods; in other words, while running a visitor to -// generate CDR operators for structures we cannot use that one to -// generate the code of each field, because visit_struct already has a -// meaning in that visitor. -int -be_visitor_valuetype_field_cdr_decl::visit_field (be_field *node) -{ - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_decl::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - // @@ Shouldn't this be saved in the visitor and not the context?! - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_decl::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} - -// visit array -int -be_visitor_valuetype_field_cdr_decl::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_decl::" - "visit_array - " - "cannot retrieve field node\n" - ), -1); - } - - // retrieve the valuetype scope in which the code is generated - be_decl *sc = this->ctx_->scope (); - be_valuetype *vt = be_valuetype::narrow_from_decl (sc); - if (!vt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_decl::" - "visit_array - " - "cannot retrieve valuetype node\n" - ), -1); - } - - // for anonymous arrays, the type name has a _ prepended. We compute - // the fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (!this->ctx_->alias () // not a typedef - && node->is_child (this->ctx_->scope ())) - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope - // prepended to our local name. This needs to be inserted after - // the parents's name - - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - } - - // check what is the code generation substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << fname << "_forany " - << "_tao_" << vt->field_pd_prefix () << f->local_name () - << vt->field_pd_postfix () << be_idt << be_idt_nl - << "(ACE_const_cast (" << be_idt << be_idt_nl - << fname << "_slice*," << be_nl - << vt->field_pd_prefix () << f->local_name () - << vt->field_pd_postfix () << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_decl::" - "visit_array - " - "bad sub state\n" - ), -1); - } - ACE_NOTREACHED (return 0); -} - -// visit typedef type -int -be_visitor_valuetype_field_cdr_decl::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_cdr_op_field_decl::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp deleted file mode 100644 index e88495def71..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp +++ /dev/null @@ -1,748 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// field_ch.cpp -// -// = DESCRIPTION -// Visitor generating the accessor and modifier declarations -// for valuetype fields in the valuetype class (header). -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// derived from be_visitor_union_branch/public_ch.cpp -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be_visitor_valuetype, field_ch, "$Id$") - - -// constructor -be_visitor_valuetype_field_ch::be_visitor_valuetype_field_ch - (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ - setenclosings ("",";"); -} - -// destructor -be_visitor_valuetype_field_ch::~be_visitor_valuetype_field_ch (void) -{ -} - -// visit the field node -int -be_visitor_valuetype_field_ch::visit_field (be_field *node) -{ - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_union_branch - " - "Bad type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_union_branch - " - "codegen failed\n" - ), -1); - } - return 0; -} - -// =visit operations on all possible data types (valuetype state member) - -// visit array type -int -be_visitor_valuetype_field_ch::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union node - be_type *bt; - - // check if we are visiting this via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_array - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // this is the case of an anonymous array inside a union - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the array declaration - ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_array - " - "codegen failed\n" - ), -1); - } - delete visitor; - // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method - *os << pre_op() << "void " << ub->local_name () << " (" - << "_" << bt->local_name () << ")" - << post_op() << " // set" << be_nl; - // the get method - *os << pre_op() << "const _" << bt->local_name () - << "_slice * " << ub->local_name () - << " (void)" << post_op() << be_nl; - *os << pre_op() << "_" << bt->local_name () - << "_slice * " << ub->local_name () - << " (void)" << post_op(); - } - else - { - // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ")" << post_op() << " // set" - << be_nl; - // the get method - *os << pre_op() - << bt->nested_type_name (bu, "_slice *") << " " << ub->local_name () - << " (void)" << post_op() << be_nl; - // the get (read/write) method - *os << pre_op() << "const " - << bt->nested_type_name (bu, "_slice *") << " " << ub->local_name () - << " (void) const" << post_op() << "\n\n"; - } - - return 0; -} - -// visit enum type -int -be_visitor_valuetype_field_ch::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union node - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_enum - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // now use this enum as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ")" << post_op() << " // set" - << be_nl; - // the get method - *os << pre_op() << bt->nested_type_name (bu) << " " << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - - return 0; -} - -// visit interface type -int -be_visitor_valuetype_field_ch::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_interface - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "_ptr") - << ")" << post_op() << " // set" << be_nl; - // get method - *os << pre_op() - << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - return 0; -} - -// visit interface forward type -int -be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_interface_fwd - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "_ptr") - << ")" << post_op() << " // set" << be_nl; - // get method - *os << pre_op() - << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - return 0; -} - -// visit valuetype type -int -be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_valuetype - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "*") - << ")" << post_op() << " // set" << be_nl; - // get method - *os << pre_op() - << bt->nested_type_name (bu, "*") << " " << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - return 0; -} - -// visit valuetype forward type -int -be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_valuetype_fwd - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "*") - << ")" << post_op() << " // set" << be_nl; - // get method - *os << pre_op() - << bt->nested_type_name (bu, "*") << " " << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - return 0; -} - -// visit predefined type -int -be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_predefined_type - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - os->indent (); // start from current indentation - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - // set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "_ptr") << ")" - << post_op() << " // set" << be_nl; - // get method - *os << pre_op() - << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - break; - case AST_PredefinedType::PT_any: - // set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ")" - << post_op() << " // set" << be_nl; - // get method (read-only) - *os << pre_op() << "const " << bt->nested_type_name (bu) << " " - << ub->local_name () << " (void) const" - << post_op() << " // get method\n\n"; - // get method (read/write) - *os << pre_op() << bt->nested_type_name (bu) << " " - << ub->local_name () << " (void)" - << post_op() << " // get method\n\n"; - break; - case AST_PredefinedType::PT_void: - break; - default: - // set method - *os << pre_op() << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ")" - << post_op() << " // set" << be_nl; - // get method - *os << pre_op() << bt->nested_type_name (bu) << " " << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - } - return 0; -} - -// visit sequence type -int -be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_sequence - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - os->indent (); - // set method - *os << pre_op() << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &)" - << post_op() << " // set" << be_nl; - // read-only - *os << pre_op() << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const" - << post_op() << " // get method (read only)" << be_nl; - // read/write - *os << pre_op() << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void)" - << post_op() << " // get method (read/write only)\n\n"; - - return 0; -} - -// visit string type -int -be_visitor_valuetype_field_ch::visit_string (be_string *) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_string - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); - // three methods to set the string value - *os << pre_op() - << "void " << ub->local_name () << " (char *)" - << post_op() << " // set" << be_nl; - *os << pre_op() - << "void " << ub->local_name () << " (const char *)" - << post_op() << " // set" << be_nl; - *os << pre_op() - << "void " << ub->local_name () << " (const CORBA::String_var&)" - << post_op() << " // set" << be_nl; - //get method - *os << pre_op() << "const char *" << ub->local_name () - << " (void) const" << post_op() << " // get method\n\n"; - return 0; -} - -// visit structure type -int -be_visitor_valuetype_field_ch::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_structure - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_structure - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_structure - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - os->indent (); - // set method - *os << pre_op() << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &)" - << post_op() << " // set" << be_nl - // read-only - << pre_op() << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const" - << post_op() << " // get method (read only)" << be_nl - // read/write - << pre_op() << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void)" << post_op() << " // get method (read/write only)\n\n"; - - return 0; -} - -// visit typedefed type -int -be_visitor_valuetype_field_ch::visit_typedef (be_typedef *node) -{ - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - os->indent (); // start from current indentation level - this->ctx_->alias (node); // save the node for use in code generation and - // indicate that the union_branch of the union_branch node - // is a typedefed quantity - - // make a decision based on the primitive base type - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_spec_ch::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_valuetype_field_ch::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get state member - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_union - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_union - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - os->indent (); - // set method - *os << pre_op() << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &)" - << post_op() << " // set" << be_nl - // read-only - << pre_op() << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const" - << post_op() << " // get method (read only)" - << be_nl - // read/write - << pre_op() << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void)" << post_op() << " // get method (read/write only)\n\n"; - - return 0; -} - -void -be_visitor_valuetype_field_ch::setenclosings (const char *pre, const char *post) -{ - pre_op_ = pre; - post_op_ = post; -} - -const char* -be_visitor_valuetype_field_ch::pre_op () -{ - return pre_op_; -} - -const char* -be_visitor_valuetype_field_ch::post_op () -{ - return post_op_; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp deleted file mode 100644 index b052358eae7..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp +++ /dev/null @@ -1,1050 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// field_cs.cpp -// -// = DESCRIPTION -// Visitor for the Valuetype class. -// This one generates code for accessor and modifier functions of -// valuetype state members (in the stub or inline file). -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// derived from be_visitor_union_branch/public_ci.cpp -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, field_cs, "$Id$") - - -// constructor -be_visitor_valuetype_field_cs:: -be_visitor_valuetype_field_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx), - in_obv_space_ (0) -{ - setenclosings (""); -} - -// destructor -be_visitor_valuetype_field_cs:: -~be_visitor_valuetype_field_cs (void) -{ -} - -// visit the field node -int -be_visitor_valuetype_field_cs:: -visit_field (be_field *node) -{ - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} - -// =visit operations on all possible data types that a union_branch can be - -int -be_visitor_valuetype_field_cs::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_array - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous array type - ctx.state (TAO_CodeGen::TAO_ARRAY_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_array - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // for anonymous arrays, the type name has a _ prepended. We compute the - // fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - - if (bt->is_nested ()) - { - be_decl *parent = - be_scope::narrow_from_scope (bt->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - bt->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", bt->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->fullname ()); - } - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); *os << "::" << ub->local_name () << " (" << fname - << " val)// set" << be_nl - << "{" << be_idt_nl; - - *os << fname << "_copy (" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ", val);" << be_uidt_nl; - - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << "const " << fname << "_slice *" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void) const" << be_nl - << "{" << be_idt_nl; - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << ";" << be_uidt_nl - << "}\n" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << fname << "_slice *" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void)" << be_nl - << "{" << be_idt_nl; - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << ";" << be_uidt_nl; - *os << "}\n\n"; - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_enum - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << " val)// set" << be_nl - << "{\n"; - os->incr_indent (); - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;\n"; - os->decr_indent (); - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" - << be_nl - << "{\n"; - os->incr_indent (); - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl - << "{\n"; - os->incr_indent (); - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val->duplicate ();" << be_uidt_nl; - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "_ptr " << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" - << be_nl - << "{\n"; - os->incr_indent (); - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl - << "{\n"; - os->incr_indent (); - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val->duplicate ();" << be_uidt_nl; - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "_ptr " << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" - << be_nl - << "{\n"; - os->incr_indent (); - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_valuetype (be_valuetype *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << "* val)// set" << be_nl - << "{\n"; - os->incr_indent (); - *os << "if (val) val->_add_ref ();" << be_nl - << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;" << be_uidt_nl; - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "* " << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" - << be_nl - << "{\n"; - os->incr_indent (); - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_valuetype_fwd (be_valuetype_fwd *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << "* val)// set" << be_nl - << "{\n"; - os->incr_indent (); - *os << "if (val) val->_add_ref ();" << be_nl - << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;" << be_uidt_nl; - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "* " << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" - << be_nl - << "{\n"; - os->incr_indent (); - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_predef... - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (" << bt->name (); - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "_ptr"; - *os << " val) // set" << be_nl - << "{" << be_idt_nl; - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = " - << bt->name () << "::_duplicate (val);" << be_uidt_nl; - break; - - case AST_PredefinedType::PT_any: - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = new " - << bt->name () << " (val);" << be_uidt_nl; - break; - - case AST_PredefinedType::PT_void: - break; - - default: - *os << "// set the value" << be_nl - << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;" << be_uidt_nl; - } - *os << "}" << be_nl; - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "_ptr" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (void) const" << be_nl - << "{" << be_idt_nl - << "return this->u" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}\n\n"; - break; - case AST_PredefinedType::PT_any: - // get method with read-only access - *os << "// retrieve the member" << be_nl - << this->pre_op() << "const " << bt->name () << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (void) const" << be_nl - << "{" << be_idt_nl - << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}" << be_nl; - - // get method with read/write access - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (void)" << be_nl - << "{" << be_idt_nl - << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}\n\n"; - break; - case AST_PredefinedType::PT_void: - break; - default: - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (void) const" << be_nl - << "{" << be_idt_nl - << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}\n\n"; - } - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_sequence - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous sequence type - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // (1) set from a const - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (const " << bt->name () << " &val)" << be_nl - << "{" << be_idt_nl; - - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = new " - << bt->name () << " (val);" << be_uidt_nl; - - *os << "}" << be_nl; - - // readonly get method - *os << "// readonly get method " << be_nl - << this->pre_op() << "const " << bt->name () << " &" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (void) const" << be_nl - << "{" << be_idt_nl - << "return this->" // %! *this (seq_var, not seq member) - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}" << be_nl; - - // read/write get method - *os << "// read/write get method " << be_nl - << this->pre_op() << bt->name () << " &" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void)" << be_nl - << "{" << be_idt_nl - << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}\n\n"; - - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_string (be_string *) -{ - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_string - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - - // three methods to set the string value - - // (1) set method from char* - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (char *val)" - << be_nl - << "{" << be_idt_nl; - - *os << "// set the value" << be_nl - << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;" << be_uidt_nl - << "}" << be_nl; - - // (2) set method from const char * - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (const char *val)" << be_nl - << "{\n"; - os->incr_indent (); - - *os << "// set the value" << be_nl - << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = " - << "CORBA::string_dup (val);" << be_uidt_nl; - - *os << "}" << be_nl; - - // (3) set from const String_var& - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (const CORBA::String_var &val)" << be_nl - << "{" << be_idt_nl; - *os << ";" << be_nl; - - *os << "// set the value" << be_nl - << "CORBA::String_var " << ub->local_name () - << "_var = val;" << be_nl - << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - - *os << "}" << be_nl; - - // get method - *os << this->pre_op() << "const char *" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (void) const // get method" << be_nl - << "{" << be_idt_nl - << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}\n\n"; - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_structure - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_structure - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_structure - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // (1) set from a const - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (const " << bt->name () << " &val)" << be_nl - << "{" << be_idt_nl; - - if (0) // %! (bt->size_type () == be_type::VARIABLE) - { cerr <<"!t VARIABLE struct in field_cs\n"; - *os << "delete this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_nl; - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = new " - << bt->name () << " (val);" << be_uidt_nl; - } - else - { - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;" << be_uidt_nl; - } - - *os << "}" << be_nl; - - // readonly get method - *os << "// readonly get method " << be_nl - << this->pre_op() << "const " << bt->name () << " &" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void) const" << be_nl - << "{" << be_idt_nl; - if (0) // %! (bt->size_type () == be_type::VARIABLE) - *os << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; - else - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; - *os << "}" << be_nl; - - // read/write get method - *os << "// read/write get method " << be_nl - << this->pre_op() << bt->name () << " &" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void)" << be_nl - << "{" << be_idt_nl; - if (0) // %! (bt->size_type () == be_type::VARIABLE) - *os << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; - else - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_valuetype_field_cs::visit_union (be_union *node) -{ - cerr << "!u be_visitor_valuetype_field_cs::visit_union unimp.\n"; - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_union - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_UNION_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_union - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // (1) set from a const - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () - << " (const " << bt->name () << " &val)" << be_nl - << "{" << be_idt_nl; - - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << "_var = new " << bt->name () - << " (val);" << be_nl; - - *os << "}" << be_nl; - - // readonly get method - *os << "// readonly get method " << be_nl - << this->pre_op() << "const " << bt->name () << " &" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void) const" << be_nl - << "{" << be_idt_nl - << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}" << be_nl; - - // read/write get method - *os << "// read/write get method " << be_nl - << this->pre_op() << bt->name () << " &" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void)" << be_nl - << "{" << be_idt_nl - << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl - << "}\n\n"; - - return 0; -} - -void -be_visitor_valuetype_field_cs::setenclosings (const char *pre) -{ - pre_op_ = pre; -} - -const char* -be_visitor_valuetype_field_cs::pre_op () -{ - return pre_op_; -} - -// retrieve the fully scoped skeleton name -void -be_visitor_valuetype_field_cs::op_name (be_valuetype *node, - TAO_OutStream *os) -{ - if (this->in_obv_space_) - *os << node->full_obv_skel_name (); - else - *os << node->name (); -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp deleted file mode 100644 index 8fd36705682..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// marshal_ch.cpp -// -// = DESCRIPTION -// Concrete visitor for valuetypes. -// This one provides code generation for marshalling. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// based on code from Aniruddha Gokhale -// -// ============================================================================ - - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, marshal_ch, "$Id$") - -// *************************************************************************** -// Structure visitor for generating declarations -// *************************************************************************** - -be_visitor_valuetype_marshal_ch::be_visitor_valuetype_marshal_ch -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_valuetype_marshal_ch::~be_visitor_valuetype_marshal_ch (void) -{ -} - -int -be_visitor_valuetype_marshal_ch::visit_valuetype (be_valuetype *) -{ - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp deleted file mode 100644 index 1f7e5405a67..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// marshal_cs.cpp -// -// = DESCRIPTION -// Concrete visitor for valuetypes. -// This one provides code generation for marshalling. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// -// ============================================================================ - - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, marshal_cs, "$Id$") - - -be_visitor_valuetype_marshal_cs::be_visitor_valuetype_marshal_cs -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_valuetype_marshal_cs::~be_visitor_valuetype_marshal_cs (void) -{ -} - -int -be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_OUTPUT); - os->indent (); - *os << "ACE_INLINE CORBA::Boolean" << be_nl; - this->class_name (node, os); - *os << "::_tao_marshal_state (TAO_OutputCDR &strm)" << be_nl - << "{" << be_idt_nl; - be_valuetype *inh = node->statefull_inherit (); - if (inh) - { - if (inh->opt_accessor ()) - { - *os << "if (!"; - this->class_name (inh, os); - *os << "::_tao_marshal_state (strm)) return 0;" << be_nl; - } - else // only can access base class via virtual function - { - *os << "if (!this->_tao_marshal__" - << inh->flatname () - << " (strm)) return 0;" << be_nl; - } - } - - { // array _forany - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_valuetype_field_cdr_decl field_decl (new_ctx); - field_decl.visit_scope (node); - } - - *os << "if (" << be_idt_nl; - // all we have to do is to visit the scope and generate code - this->gen_fields (node, *this->ctx_); - - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; - - // set the substate as generating code for the input operator - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - os->indent (); - *os << "ACE_INLINE CORBA::Boolean" << be_nl; - this->class_name (node, os); - *os << "::_tao_unmarshal_state (TAO_InputCDR &strm)" << be_nl - << "{" << be_idt_nl; - inh = node->statefull_inherit (); - if (inh) - { - if (inh->opt_accessor ()) - { - *os << "if (!"; - this->class_name (inh, os); - *os << "::_tao_unmarshal_state (strm)) return 0;" << be_nl; - } - else // only can access base class via virtual function - { - *os << "if (!this->_tao_unmarshal__" - << inh->flatname () - << " (strm)) return 0;" << be_nl; - } - } - - { // array _forany - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_valuetype_field_cdr_decl field_decl (new_ctx); - field_decl.visit_scope (node); - } - - *os << "if (" << be_idt_nl; - // all we have to do is to visit the scope and generate code - this->gen_fields (node, *this->ctx_); - - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; - - return 0; -} - -// retrieve the fully scoped skeleton name -void -be_visitor_valuetype_marshal_cs::class_name (be_valuetype *node, - TAO_OutStream *os) -{ - if (node->opt_accessor ()) - *os << node->name (); - else - *os << node->full_obv_skel_name (); -} - -// ops for field marshal -int -be_visitor_valuetype_marshal_cs::gen_fields (be_valuetype *node, - be_visitor_context &ctx) -{ - int n_processed = 0; - - TAO_OutStream *os = ctx.stream (); - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each field is visited - for (;!si->is_done ();si->next()) - { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); - - } - be_field *field = be_field::narrow_from_decl (d); - if (field) - { - if (n_processed > 0) - *os << " &&" << be_nl; - ++n_processed; - be_visitor_context* new_ctx = - new be_visitor_context (ctx); - be_visitor_valuetype_field_cdr_ci visitor (new_ctx); - visitor.pre_ = node->field_pd_prefix (); - visitor.post_ = node->field_pd_postfix (); - if (visitor.visit_field (field) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_marshal_cs::" - "visit_valuetype - " - "codegen for scope failed\n"), -1); - } - - } - } // end of for loop - delete si; - } - if (n_processed == 0) - *os << "1"; - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp deleted file mode 100644 index 70806d09556..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// obv_module.cpp -// -// = DESCRIPTION -// Concrete visitor for the Module class -// This provides code generation for the module in the header -// for the OBV_ namespace (see C++ mapping OMG 20.17) -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be_visitor_obv_module, obv_module, "$Id$") - - -// ************************************************************ -// Module visitor for server header -// ************************************************************ - -be_visitor_obv_module::be_visitor_obv_module (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_obv_module::~be_visitor_obv_module (void) -{ -} - - - -// This states are processed: -// TAO_MODULE_OBV_CH -// TAO_MODULE_OBV_CI -// TAO_MODULE_OBV_CH - - -int -be_visitor_obv_module::visit_module (be_module *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - if (node->has_nested_valuetype ()) - { - if (this->ctx_->state () == TAO_CodeGen::TAO_MODULE_OBV_CH) - { - os->indent (); - - *os << "TAO_NAMESPACE "; // << idl_global->export_macro () - - if (!node->is_nested ()) - // we are outermost module, so prepend - *os << " OBV_" << node->local_name () << be_nl; - else - // we are inside another module - *os << " " << node->local_name () << be_nl; - - *os << "{" << be_nl - << be_idt; - } // client header - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_obv_module::" - "visit_module - " - "codegen for scope failed\n"), -1); - } - - if (this->ctx_->state () == TAO_CodeGen::TAO_MODULE_OBV_CH) - { - os->decr_indent (); - *os << "};\n\n"; - } - } - return 0; -} - - -int -be_visitor_obv_module::visit_valuetype (be_valuetype *node) -{ - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_MODULE_OBV_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_OBV_CH); - break; - case TAO_CodeGen::TAO_MODULE_OBV_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_OBV_CI); - break; - case TAO_CodeGen::TAO_MODULE_OBV_CS: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_OBV_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_obv_module::" - "visit_valuetype - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_obv_module::" - "visit_valuetype - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_obv_module::" - "visit_valuetype - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp deleted file mode 100644 index 41451082e2d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ /dev/null @@ -1,840 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// valuetype.cpp -// -// = DESCRIPTION -// Visitor generating code for Valuetypes. This is a generic visitor. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// based on interface.cpp from Aniruddha Gokhale -// -// ============================================================================ - -//#include "idl.h" -//#include "idl_extern.h" -//#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype, "$Id$") - - -be_visitor_valuetype::be_visitor_valuetype (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_valuetype::~be_visitor_valuetype (void) -{ -} - -// this method must be overridden by the derived valuetype visitors -int -be_visitor_valuetype::visit_valuetype (be_valuetype *) -{ -//! ACE_ASSERT (0); - return -1; -} - - -// visit the scope of the valuetype node -// (in public/private field order) -int -be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) -{ - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - int n_processed = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each element is visited - for (;!si->is_done ();si->next()) - { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - 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 && 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) - } - ++ n_processed; - if (n_processed == 1) - this->begin_public (); - 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 ()); - - // set the node to be visited - this->ctx_->node (bd); - this->elem_number_++; - - if (bd == 0 || bd->accept (this) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); - - } - } // end of for loop - delete si; - // next run with private fields only - n_processed = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each element is visited - for (;!si->is_done ();si->next()) - { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - 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 || - (field && field->visibility() != AST_Field::vis_PRIVATE)) - { - continue; // only private fields in this run - } - ++ n_processed; - if (n_processed == 1) - 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 ()); - - // set the node to be visited - this->ctx_->node (bd); - this->elem_number_++; - - if (bd == 0 || bd->accept (this) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); - - } - } // end of for loop - delete si; - } // end of if - return 0; -} - -// this two are called from visit_valuetype_scope() -void -be_visitor_valuetype::begin_public () -{ - // in derived visitors print "public:" in class definition -} - -void -be_visitor_valuetype::begin_private () -{ - // in derived visitors print "protected:" in class definition -} - -// =all common visit methods for valuetype visitor - -// visit an attribute -int -be_visitor_valuetype::visit_attribute (be_attribute *node) -// was be_visitor_attribute::visit_attribute (be_attribute *node) -{ - this->ctx_->node (node); // save the node - this->ctx_->attribute (node); // save this attribute node - - be_operation *op; - - // first the "get" operation - op = new be_operation (node->field_type (), AST_Operation::OP_noflags, - node->name (), 0); - op->set_name (node->name ()); - if (!op || this->visit_operation (op) == -1) - { - delete op; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_attribute::" - "visit_attribute - " - "codegen for get_attribute failed\n"), - -1); - } - delete op; - if (node->readonly ()) - return 0; // nothing else to do - - // the set method. - // the return type is "void" - be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName - (new Identifier - ("void", 1, 0, I_FALSE), 0), - 0); - // argument type is the same as the attribute type - be_argument *arg = new be_argument (AST_Argument::dir_IN, - node->field_type (), - node->name (), - 0); - arg->set_name (node->name ()); - // create the operation - op = new be_operation (rt, AST_Operation::OP_noflags, - node->name (), 0); - op->set_name (node->name ()); - op->add_argument_to_scope (arg); - - if (!op || this->visit_operation (op) == -1) - { - delete op; - delete arg; - delete rt; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_attribute::" - "visit_attribute - " - "codegen for set_attribute failed\n"), - -1); - } - delete op; - delete rt; - delete arg; - return 0; -} - - -// visit a constant -int -be_visitor_valuetype::visit_constant (be_constant *node) -{ - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - case TAO_CodeGen::TAO_VALUETYPE_CI: - case TAO_CodeGen::TAO_VALUETYPE_SH: - case TAO_CodeGen::TAO_VALUETYPE_IH: - case TAO_CodeGen::TAO_VALUETYPE_IS: - case TAO_CodeGen::TAO_VALUETYPE_SI: - case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_constant - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_constant - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_constant - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -//visit an enum -int -be_visitor_valuetype::visit_enum (be_enum *node) -{ - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: - case TAO_CodeGen::TAO_VALUETYPE_CI: - case TAO_CodeGen::TAO_VALUETYPE_SH: - case TAO_CodeGen::TAO_VALUETYPE_IH: - case TAO_CodeGen::TAO_VALUETYPE_IS: - case TAO_CodeGen::TAO_VALUETYPE_SI: - case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_enum - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_enum - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - - -// visit an operation -int -be_visitor_valuetype::visit_operation (be_operation *) -{ - // is overridden in derived visitors - return 0; -} - -// visit an exception (not used) -int -be_visitor_valuetype::visit_exception (be_exception *) -{ - cerr << "! be_visitor_valuetype::visit_exception() --- not allowed\n"; - ACE_ASSERT (0); - return 0; -} - -// visit an structure -int -be_visitor_valuetype::visit_structure (be_structure *node) -{ - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; - case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: - case TAO_CodeGen::TAO_VALUETYPE_SH: - case TAO_CodeGen::TAO_VALUETYPE_IH: - case TAO_CodeGen::TAO_VALUETYPE_IS: - case TAO_CodeGen::TAO_VALUETYPE_SI: - case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_structure - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_structure - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -// visit a union -int -be_visitor_valuetype::visit_union (be_union *node) -{ - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; - case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: - case TAO_CodeGen::TAO_VALUETYPE_SH: - case TAO_CodeGen::TAO_VALUETYPE_IH: - case TAO_CodeGen::TAO_VALUETYPE_IS: - case TAO_CodeGen::TAO_VALUETYPE_SI: - case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_union - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_union - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_union - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -// visit a typedef -int -be_visitor_valuetype::visit_typedef (be_typedef *node) -{ - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; - case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: - case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: - case TAO_CodeGen::TAO_VALUETYPE_SH: - case TAO_CodeGen::TAO_VALUETYPE_IH: - case TAO_CodeGen::TAO_VALUETYPE_IS: - case TAO_CodeGen::TAO_VALUETYPE_SI: - case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_typedef - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_typedef - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -int -be_visitor_valuetype::visit_field (be_field *) -{ - // is overridden in derived visitors - return 0; -} - - -// private data fields for scope -int -be_visitor_valuetype::gen_pd (be_valuetype *node) -{ - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - int n_processed = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each field is visited - for (;!si->is_done ();si->next()) - { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); - - } - be_field *field = be_field::narrow_from_decl (d); - if (!field) - { - continue; - } - ++ n_processed; - // 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 ()); - - // set the node to be visited - this->ctx_->node (field); - this->elem_number_++; - - if (this->gen_field_pd (field) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); - - } - } // end of for loop - delete si; - } - return 0; -} - -// private data for field -int -be_visitor_valuetype::gen_field_pd (be_field *node) -// derived from be_visitor_field_ch -{ - TAO_OutStream *os; // output stream - be_type *bt; // field's type - be_valuetype *vt; // field declared in this scope - - os = this->ctx_->stream (); - // first generate the type information - bt = be_type::narrow_from_decl (node->field_type ()); - vt = be_valuetype::narrow_from_scope (node->defined_in ()); - if (!bt || !vt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure::" - "visit_field - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - delete visitor; - - // now output the field name. - *os << " " << vt->field_pd_prefix () - << node->local_name () - << vt->field_pd_postfix() << ";\n"; - return 0; - -} - - -// generate the _init definition -int -be_visitor_valuetype::gen_init_defn (be_valuetype *node) -{ - if (node->is_abstract_valuetype ()) - return 0; // no instance of it can created - - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at - - *os << "class " << idl_global->export_macro () - << " " << node->local_name () - << "_init : public ACE_CORBA_1 (ValueFactoryBase)" << be_nl; - - // generate the body - - *os << "{" << be_nl - << "public:" << be_idt_nl - << "virtual ~" << node->local_name () << "_init ();" << be_nl; - - /* %! << "static " << node->local_name () << "* " - << "_downcast (CORBA::ValueFactoryBase* );" << be_nl */ - - *os << "virtual const char* tao_repository_id ();\n" << be_nl; - *os << "// create () goes here" << be_nl; // %! - - *os << be_uidt_nl << "};\n"; - - return 0; -} - -int -be_visitor_valuetype::gen_init_impl (be_valuetype *node) -{ - if (node->is_abstract_valuetype ()) - return 0; // no instance of it can created - - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at - - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local _out names - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_init", node->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_init", node->local_name ()->get_string ()); - - // destructor - *os << fname << "::~" << lname << " ()" << be_nl - << "{" << be_nl << "}\n\n"; - - *os << "const char* " << be_nl - << fname << "::tao_repository_id ()" << be_nl - << "{" << be_idt_nl - << "return " << node->name() - << "::_tao_obv_static_repository_id ();" - << be_uidt_nl << "}\n\n"; - - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp deleted file mode 100644 index e15b3aedea9..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp +++ /dev/null @@ -1,419 +0,0 @@ - -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// valuetype_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Valuetypes in the client header -// (see C++ mapping OMG 20.17) -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de>, -// based on interface_ch.cpp from Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_ch, "$Id$") - - -// ****************************************************** -// Valuetype visitor for client header -// ****************************************************** - -be_visitor_valuetype_ch::be_visitor_valuetype_ch (be_visitor_context *ctx) - : be_visitor_valuetype (ctx) -{ -} - -be_visitor_valuetype_ch::~be_visitor_valuetype_ch (void) -{ -} - -int -be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) -{ - TAO_OutStream *os; // output stream - - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported - { - - os = this->ctx_->stream (); - *os << "// valuetype class\n"; - - // == STEP 1: generate the class name and class names we inherit == - - os->indent (); // start with whatever indentation level we are at - // forward declaration - *os << "class " << node->local_name () << ";" << be_nl; - - // generate the ifdefined macro for the _var type - os->gen_ifdef_macro (node->flatname (), "_var"); - - // 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 (); - - // generate the ifdef macro for the _out class - os->gen_ifdef_macro (node->flatname (), "_out"); - - // generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec - 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); - } - // generate the endif macro - os->gen_endif (); - - // generate the ifdef macro for the _init class - os->gen_ifdef_macro (node->flatname (), "_init"); - - // generate the _init declaration - ptc/98-09-03 20.17.10 p.20-93 - if (this->gen_init_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "codegen for _init failed\n"), -1); - } - // generate the endif macro - os->gen_endif (); - - // now the valuetype definition itself - os->gen_ifdef_macro (node->flatname ()); - - // now generate the class definition - os->indent (); - *os << "class " << idl_global->export_macro () - << " " << node->local_name (); - - // node valuetype inherits from other valuetypes (OMG 20.17.9) - // (ordinary (not abstract) interfaces ignored) - - *os << " : "; - 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++) - { - // %! move is_nested() and nested_type_name() to - // AST_Interface, then type AST_Interface can be used - be_interface *inherited = - be_interface::narrow_from_decl (node->inherits ()[i]); - if (!inherited->is_valuetype() && - !inherited->is_abstract_interface()) - continue; - - ++ n_inherits_valuetypes; - if (inherited->is_valuetype()) - valuebase_inherited = 1; - if (n_inherits_valuetypes > 1) // node is the case of multiple - // inheritance, so put a comma - { - *os << ", "; - } - be_decl *scope = 0; - if (inherited->is_nested ()) - { - // inherited node is used in the scope of "node" node - scope = be_scope::narrow_from_scope (node->defined_in ()) - ->decl (); - } - - // dump the scoped name - *os << "public virtual "; - *os << inherited->nested_type_name (scope); - } // end of for loop - if (n_inherits_valuetypes > 0) - *os << be_nl; - } - if (!valuebase_inherited) - { - // we do not inherit from any valuetype, hence we do so from the base - // CORBA::ValueBase class - // Generate code that uses the macro. This is required to deal with - // the MSVC++ insanity - if (n_inherits_valuetypes > 1) // node is the case of multiple - // inheritance, so put a comma - { - *os << ", "; - } - *os << "public virtual ACE_CORBA_1 (ValueBase)" << be_nl; - } - - // generate the body - - *os << "{" << be_nl - << "public:" << be_nl - - // generate the _ptr_type and _var_type typedef - // but we must protect against certain versions of g++ - << "#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8" - << be_idt_nl - << "typedef " << node->local_name () << "* _ptr_type;" << be_nl - << "typedef " << node->local_name () << "_var _var_type;" - << be_uidt_nl - << "#endif /* __GNUC__ */\n" << be_idt_nl - - // 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" - << be_nl - - << "// (TAO extensions or internals)" << be_nl - << "static CORBA::Boolean _tao_unmarshal (TAO_InputCDR &, " - << node->local_name () << " *&);" << be_nl - << "virtual const char* " - << "_tao_obv_repository_id () const;" - << be_nl - << "static const char* " - << "_tao_obv_static_repository_id ();\n"; - - // generate code for the valuetype definition - if (this->visit_valuetype_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "codegen for scope failed\n"), -1); - } - - // protected member: - - // generate the "protected" constructor so that users cannot instantiate - // us - *os << be_uidt_nl << "protected:" << be_idt_nl - << node->local_name () - << " (); // default constructor" << be_nl - << "virtual ~" << node->local_name () << " ();\n" << be_nl; - - *os << "// TAO internals" << be_nl - << "virtual void *_tao_obv_narrow (ptr_arith_t);" << be_nl; - // support for marshalling - if (!node->is_abstract_valuetype ()) - { - *os << "virtual CORBA::Boolean " - << "_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 - } - - - // private member: - - // private copy constructor and assignment operator. These are not - // allowed, hence they are private. - *os << be_uidt_nl << "private:" << be_idt_nl; - *os << node->local_name () << " (const " << node->local_name () << " &);" - << be_nl - << "void operator= (const " << node->local_name () << " &);" - << be_nl; - - // map fields to private data (if optimizing) - if (node->opt_accessor ()) - { - *os << be_uidt_nl << "protected:" << be_idt_nl; - *os << "CORBA::Boolean " - << "_tao_marshal_state (TAO_OutputCDR &);" << be_nl - << "CORBA::Boolean " - << "_tao_unmarshal_state (TAO_InputCDR &);\n\n"; - *os << be_uidt_nl << "private:\n" << be_idt; - this->gen_pd (node); - } - else // need a way to access the state of derived OBV_ classes - { - if (!node->is_abstract_valuetype ()) - { - *os << be_uidt_nl << "protected:" << be_idt_nl; - *os << "virtual CORBA::Boolean _tao_marshal__" - << node->flatname () << " (TAO_OutputCDR &) = 0;" - << be_nl; - *os << "virtual CORBA::Boolean _tao_unmarshal__" - << node->flatname () << " (TAO_InputCDR &) = 0;" - << be_nl; - } - } - - *os << be_uidt_nl << "};\n"; - os->gen_endif (); - - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - // (see interface code how to do this. not yet impl.) - - node->cli_hdr_gen (I_TRUE); - } // if !cli_hdr_gen - return 0; -} - - -int -be_visitor_valuetype_ch::visit_operation (be_operation *node) -// derived from be_visitor_operation_ch::visit_operation -{ - TAO_OutStream *os; // output stream - be_type *bt; // type node - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node - - os->indent (); // start with the current indentation level - - // every operation is declared virtual in the client code - *os << "virtual "; - - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // 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); - } - - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - - // STEP 2: generate the operation name - *os << " " << node->local_name (); - - // STEP 3: generate the argument list with the appropriate mapping. For these - // 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); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ch::" - "visit_operation - " - "codegen for argument list failed\n"), - -1); - } - delete visitor; - - return 0; -} - -int -be_visitor_valuetype_ch::visit_field (be_field *node) -{ - be_valuetype *vt = be_valuetype::narrow_from_scope (node->defined_in ()); - if (!vt) - 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 = - 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); - } - - if (vt->opt_accessor ()) - visitor->setenclosings ("",";"); - else - visitor->setenclosings ("virtual "," = 0;"); - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_obv_ch::" - "visit_field - codegen failed\n"), - -1); - } - delete visitor; - return 0; -} - - -void -be_visitor_valuetype_ch::begin_public () -{ - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "public:\n" << be_idt; -} - -void -be_visitor_valuetype_ch::begin_private () -{ - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "protected:\n" << be_idt; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp deleted file mode 100644 index 368a53e1e71..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// valuetype_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Valuetypes in the client inline file -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// based on code from Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_ci, "$Id$") - - -// ************************************************** -// Valuetype visitor for client inline -// ************************************************** -be_visitor_valuetype_ci::be_visitor_valuetype_ci (be_visitor_context *ctx) - : be_visitor_valuetype (ctx), - opt_accessor_ (0) -{ -} - -be_visitor_valuetype_ci::~be_visitor_valuetype_ci (void) -{ -} - -int -be_visitor_valuetype_ci::visit_valuetype (be_valuetype *node) -{ - TAO_OutStream *os; // output stream - - if (node->cli_inline_gen () || node->imported ()) - return 0; - - // need to access it in visit_field () - if (node->opt_accessor ()) - this->opt_accessor_ = 1; - - os = this->ctx_->stream (); - - os->indent (); // start from the current indentation level - - // generate the constructors and destructor - *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::" << node->local_name () << - " () // default constructor" << be_nl; - *os << "{}" << be_nl << be_nl; - - *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::~" << node->local_name () << - " () // destructor" << be_nl; - *os << "{}\n" << be_nl; - - *os << "ACE_INLINE const char* " << be_nl - << node->name() << "::_tao_obv_static_repository_id ()" << be_nl - << "{" << be_idt_nl - << "return \"" << node->repoID () << "\";" << be_uidt_nl - << "}\n\n"; - - // generate the ifdefined macro for the _var type - os->gen_ifdef_macro (node->flatname (), "_var"); - if (node->gen_var_impl () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ci::" - "visit_valuetype - " - "codegen for _var failed\n"), -1); - } - os->gen_endif (); - - // generate the ifdefined macro for the _out type - os->gen_ifdef_macro (node->flatname (), "_out"); - if (node->gen_out_impl () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ci::" - "visit_valuetype - " - "codegen for _out failed\n"), -1); - } - os->gen_endif (); - - // generate inline methods for elements of our scope - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ci::" - "visit_valuetype - " - "codegen for scope failed\n"), -1); - } - - return 0; -} - - -int -be_visitor_valuetype_ci::visit_field (be_field *node) -{ - if (opt_accessor_) - { - be_visitor_context *ctx = new be_visitor_context (*this->ctx_); - be_visitor_valuetype_field_cs *visitor = - new be_visitor_valuetype_field_cs (ctx); - visitor->in_obv_space_ = 0; - visitor->setenclosings ("ACE_INLINE "); - if (visitor->visit_field (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ci::" - "visit_field - " - "visit_field failed\n" - ), -1); - } - delete visitor; - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp deleted file mode 100644 index 40b655a80b1..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// valuetype_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Valuetypes in the client stubs file. -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de> -// based on code from Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_cs, "$Id$") - - -// ************************************************************ -// Valuetype visitor for client stubs -// ************************************************************ - -be_visitor_valuetype_cs::be_visitor_valuetype_cs (be_visitor_context *ctx) - : be_visitor_valuetype (ctx) -{ -} - -be_visitor_valuetype_cs::~be_visitor_valuetype_cs (void) -{ -} - -int -be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) -{ - TAO_OutStream *os; // output stream - - if (node->cli_stub_gen () || node->imported ()) - return 0; - - os = this->ctx_->stream (); - - os->indent (); // start with whatever indentation level we are at - - // The _downcast method // %! use ACE_xxx_cast here ? - *os << node->name() << "* " << node->name() - << "::_downcast (CORBA::ValueBase* v)" << be_nl - << "{" << be_idt_nl - << "if (v == 0) return 0;" << be_nl - << "return (" << node->local_name() << "* ) " - << "v->_tao_obv_narrow ((ptr_arith_t) &_downcast);" << be_uidt_nl - << "}\n" << be_nl - - // The _tao_obv_repository_id method - << "const char* " << node->name() - << "::_tao_obv_repository_id () const" << be_nl - << "{" << be_idt_nl - << "return this->_tao_obv_static_repository_id ();" << be_uidt_nl - << "}\n" << be_nl - - // The _tao_obv_narrow method - << "void* " << node->name() - << "::_tao_obv_narrow (ptr_arith_t type_id)" << be_nl - << "{" << be_idt_nl - << "if (type_id == (ptr_arith_t) &_downcast)" << be_idt_nl - << "return this;" << be_uidt_nl - << "void *rval = 0;" << be_nl; - - // Find the possible base classes. - - int n_inherits_downcastable = 0; - for (int i = 0; i < node->n_inherits (); i++) - { - AST_Interface *inherited = - AST_Interface::narrow_from_decl (node->inherits ()[i]); - if (inherited->is_valuetype()) - { - ++n_inherits_downcastable; - *os << "if (rval == 0)" << be_idt_nl - << "rval = " << inherited->name() - << "::_tao_obv_narrow (type_id);" << be_uidt_nl; - } - } - - *os << "return rval;" << be_uidt_nl - << "}\n\n"; - - // Nothing to marshal if abstract valuetype. - if (!node->is_abstract_valuetype ()) - { - // The virtual _tao_marshal_v method - *os << "CORBA::Boolean " << node->name() - << "::_tao_marshal_v (TAO_OutputCDR & strm)" - << be_nl - << "{" << be_idt_nl - << "return "; - if (node->opt_accessor ()) - { - *os << node->name () - <<"::_tao_marshal_state (strm);" << be_uidt_nl; - } - else - { - *os << "this->_tao_marshal__" << node->flatname () - << " (strm);" << be_uidt_nl; - } - *os << "}\n" << be_nl; - - // The virtual _tao_unmarshal_v method - *os << "CORBA::Boolean " << node->name() - << "::_tao_unmarshal_v (TAO_InputCDR & strm)" - << be_nl - << "{" << be_idt_nl - << "return "; - if (node->opt_accessor ()) - { - *os << node->name () - <<"::_tao_unmarshal_state (strm);" << be_uidt_nl; - } - else - { - *os << "this->_tao_unmarshal__" << node->flatname () - << " (strm);" << be_uidt_nl; - } - *os << "}\n" << be_nl; - } // !node->is_abstract_valuetype () - - // The static T::_tao_unmarshal method ---------------------------- - - *os << "CORBA::Boolean " << node->name() - << "::_tao_unmarshal (TAO_InputCDR &strm, " - << node->name() <<" *&new_object)" << be_nl - << "{" << be_idt_nl - << "CORBA::Boolean retval = 1;" << be_nl - << "CORBA::ValueBase *base; // %! should be a _var" - << be_nl - << "CORBA::ValueFactory_ptr factory; // %! should be a _var" - << be_nl - - << "if (!CORBA::ValueBase::_tao_unmarshal_pre (strm, factory, base," << be_idt_nl - << " " << node->name () - << "::_tao_obv_static_repository_id ()) )" << be_nl - << "{" << be_idt_nl - << "return 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "if (factory != 0)" << be_idt_nl - << "{" << be_idt_nl - - << "base = factory->create_for_unmarshal ();" << be_nl - << "factory->_remove_ref ();" << be_nl - << "if (base == 0) return 0; // %! except.?" << be_nl - << "//%! ACE_DEBUG ((LM_DEBUG, \"" << node->name() - << "::_tao_unmarshal %s\\n\", " - << "base->_tao_obv_repository_id () ));" << be_nl - << "retval = base->_tao_unmarshal_v (strm);" << be_nl - << "//%! ACE_DEBUG ((LM_DEBUG, \"" << node->name() - << "::_tao_unmarshal retval unmarshal_v is %d\\n\", " - << "retval));" << be_nl - << "if (!retval) return 0;" - - << be_uidt_nl << "}" << be_uidt_nl - << "// Now base must be null or point to the unmarshaled object." - << be_nl - << "// Align the pointer to the right subobject." << be_nl - << "new_object = " << node->name () << "::_downcast (base);" << be_nl - << "// %! unmarshal_post" << be_nl - << "return 1;" << be_uidt_nl - << "}\n" << be_nl; - - // The static T::_tao_unmarshal method ------------------------ end - - // generate the ifdefined macro for the _init type - os->gen_ifdef_macro (node->flatname (), "_init"); - if (this->gen_init_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_cs::" - "visit_valuetype - " - "codegen for _init failed\n"), -1); - } - os->gen_endif (); - - // generate code for the elements of the valuetype - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_cs::" - "visit_valuetype - " - "codegen for scope failed\n"), -1); - } - - - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - // (see interface code how to do this. not yet impl.) - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp deleted file mode 100644 index 4cdee96d078..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp +++ /dev/null @@ -1,176 +0,0 @@ - -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// valuetype_obv__ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Valuetypes in the client header -// OBV_ class -// (see C++ mapping OMG 20.17) -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de>, -// based on interface_ch.cpp from Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype_obv_ch, valuetype_obv_ch, "$Id$") - - -// ****************************************************** -// Valuetype visitor for client header -// ****************************************************** - -be_visitor_valuetype_obv_ch::be_visitor_valuetype_obv_ch (be_visitor_context *ctx) - : be_visitor_valuetype (ctx) -{ -} - -be_visitor_valuetype_obv_ch::~be_visitor_valuetype_obv_ch (void) -{ -} - - -// OBV_ class must be in OBV_ namespace -int -be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) -{ - // only visit non-abstract valuetype - if (node->is_abstract_valuetype ()) - return 0; - - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - - // OBV_ class maps only to a typedef if we are optimizing accessors - if (node->opt_accessor ()) - { - os->indent (); - *os << "typedef " << node->fullname () << " "; - if (!node->is_nested ()) - *os << "OBV_"; - *os << node->local_name () << ";" << be_nl; - } - else - { - // == STEP 1: generate the class name and the class name we inherit == - - os->gen_ifdef_macro (node->flatname (), "_OBV"); - os->indent (); - - *os << "// OBV_ class" << be_nl; - *os << "class "; - if (!node->is_nested()) // we are in root ? - *os << "OBV_"; - *os << node->local_name () << " : public virtual " - << node->fullname () << be_nl; - - // == STEP 2: generate the body == - - *os << "{\n" << be_idt; - - // generate code for the OBV_ class definition - if (this->visit_valuetype_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_obv_ch::" - "visit_valuetype - " - "codegen for scope failed\n"), -1); - } - // map fields to private data - if (!node->opt_accessor ()) // check again (redundant) - { - *os << be_uidt_nl << "protected:" << be_idt_nl; - *os << "virtual CORBA::Boolean _tao_marshal__" - << node->flatname () << " (TAO_OutputCDR &);" << be_nl; - *os << "virtual CORBA::Boolean _tao_unmarshal__" - << node->flatname () << " (TAO_InputCDR &);" << be_nl; - *os << "CORBA::Boolean " - << "_tao_marshal_state (TAO_OutputCDR &);" << be_nl - << "CORBA::Boolean " - << "_tao_unmarshal_state (TAO_InputCDR &);\n\n"; - *os << be_uidt_nl << "private:" << be_idt_nl; - this->gen_pd (node); - } - *os << be_uidt; - os->indent (); - *os << "};\n"; - os->gen_endif (); - } // if !opt_accessor () - - return 0; -} - - -int -be_visitor_valuetype_obv_ch::visit_field (be_field *node) -{ - be_valuetype *vt = be_valuetype::narrow_from_scope (node->defined_in ()); - if (!vt) - return -1; - // only in OBV_ class, if we are not optimizing accessors (and modifiers) - if (!vt->opt_accessor ()) - { - 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); - } - - visitor->setenclosings ("virtual ",";"); - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_obv_ch::" - "visit_field - codegen failed\n"), - -1); - } - delete visitor; - } - return 0; -} - -void -be_visitor_valuetype_obv_ch::begin_public () -{ - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "public:\n" << be_idt; -} - -void -be_visitor_valuetype_obv_ch::begin_private () -{ - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "protected:\n" << be_idt; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ci.cpp deleted file mode 100644 index ca026ba9dfd..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ci.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// valuetype_obv_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Valuetypes -// OBV_ class implementation -// (see C++ mapping OMG 20.17) -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de>, -// based on interface_ch.cpp from Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype_obv_ci, valuetype_obv_ci, "$Id$") - - -// ****************************************************** -// Valuetype visitor for OBV_ class implementation -// ****************************************************** - -be_visitor_valuetype_obv_ci::be_visitor_valuetype_obv_ci (be_visitor_context *ctx) - : be_visitor_valuetype (ctx) -{ -} - -be_visitor_valuetype_obv_ci::~be_visitor_valuetype_obv_ci (void) -{ -} - - -// OBV_ class must be in OBV_ namespace -int -be_visitor_valuetype_obv_ci::visit_valuetype (be_valuetype *node) -{ -return 0; // %! dead code - // only visit non-abstract valuetype - if (node->is_abstract_valuetype ()) - return 0; - - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - os->indent (); - - // OBV_ class is only a typedef if we are optimizing accessors - if (node->opt_accessor ()) - { - } - else - { - } // if !opt_accessor () - return 0; -} - - -int -be_visitor_valuetype_obv_ci::visit_field (be_field *node) -{ - // dead code - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp deleted file mode 100644 index 4bcf4ef00ba..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp +++ /dev/null @@ -1,111 +0,0 @@ - -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// valuetype_obv_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Valuetypes -// OBV_ class implementation -// (see C++ mapping OMG 20.17) -// -// = AUTHOR -// Torsten Kuepper <kuepper2@lfa.uni-wuppertal.de>, -// derived from interface_ch.cpp from Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype_obv_cs, valuetype_obv_cs, "$Id$") - - -// ****************************************************** -// Valuetype visitor for OBV_ class implementation -// ****************************************************** - -be_visitor_valuetype_obv_cs::be_visitor_valuetype_obv_cs (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_valuetype_obv_cs::~be_visitor_valuetype_obv_cs (void) -{ -} - - -// OBV_ class must be in OBV_ namespace -int -be_visitor_valuetype_obv_cs::visit_valuetype (be_valuetype *node) -{ - // only visit non-abstract valuetype - if (node->is_abstract_valuetype ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // OBV_ class has no accessors or modifiers if we are optimizing - // or the valuetype is abstract. - if (!(node->opt_accessor () || node->is_abstract_valuetype () )) - { - os->indent (); - *os << "CORBA::Boolean " << be_nl - << node->full_obv_skel_name () - << "::_tao_marshal__" << node->flatname () - << " (TAO_OutputCDR &strm)" - << "{" << be_idt_nl - << "return " << node->full_obv_skel_name () - << "::_tao_marshal_state (strm);" << be_nl - << be_uidt_nl << "}\n"; - - *os << "CORBA::Boolean " - << node->full_obv_skel_name () - << "::_tao_unmarshal__" << node->flatname () - << " (TAO_InputCDR &strm)" - << "{" << be_idt_nl - << "return " << node->full_obv_skel_name () - << "::_tao_unmarshal_state (strm);" << be_nl - << be_uidt_nl << "}\n"; - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_obv_cs::" - "visit_valuetype - " - "visit_scope failed\n" - ), -1); - } - } - return 0; -} - -int -be_visitor_valuetype_obv_cs::visit_field (be_field *node) -{ - be_visitor_context *ctx = new be_visitor_context (*this->ctx_); - be_visitor_valuetype_field_cs *visitor = - new be_visitor_valuetype_field_cs (ctx); - visitor->in_obv_space_ = 1; - // visitor->setenclosings ("ACE_INLINE "); - if (visitor->visit_field (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_obv_cs::" - "visit_field - " - "visit_field failed\n" - ), -1); - } - delete visitor; - return 0; -} |