diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_array')
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/any_op_ch.cpp | 64 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp | 118 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/array.cpp | 152 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp | 517 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp | 641 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp | 309 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp | 115 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp | 646 |
8 files changed, 0 insertions, 2562 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_array/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/any_op_ch.cpp deleted file mode 100644 index 15237b1baf9..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/any_op_ch.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the Any operators in the client -// header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, any_op_ch, "$Id$") - - -// *************************************************************************** -// Array visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_array_any_op_ch::be_visitor_array_any_op_ch -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_any_op_ch::~be_visitor_array_any_op_ch (void) -{ -} - -int -be_visitor_array_any_op_ch::visit_array (be_array *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - os->indent (); - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, const " << node->name () - << "_forany &);" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << node->name () << "_forany &);\n"; - - node->cli_hdr_any_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp deleted file mode 100644 index 06584bc7ddb..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the Any operators in the client -// stubs. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, any_op_cs, "$Id$") - - -// *************************************************************************** -// Array visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_array_any_op_cs::be_visitor_array_any_op_cs -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_any_op_cs::~be_visitor_array_any_op_cs (void) -{ -} - -int -be_visitor_array_any_op_cs::visit_array (be_array *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - *os << "void operator<<= (CORBA::Any &_tao_any, const " - << node->name () << "_forany &_tao_elem)" << be_nl - << "{" << be_idt_nl - << "ACE_TRY_NEW_ENV" << be_nl - << "{" << be_idt_nl - << "if (_tao_elem.nocopy ()) // no copy" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " - << "_tao_elem.in (), 1, ACE_TRY_ENV); // consume it" << be_uidt_nl - << "else // copy" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " << node->name () - << "_dup (_tao_elem.in ()), 1, ACE_TRY_ENV);" << be_uidt_nl - << "ACE_TRY_CHECK;" << be_uidt_nl - << "}" << be_nl - << "ACE_CATCHANY {}" << be_nl - << "ACE_ENDTRY;" << be_uidt_nl - << "}\n\n"; - - os->indent (); - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << "_forany &_tao_elem)" << be_nl - << "{" << be_idt_nl - << "ACE_TRY_NEW_ENV" << be_nl - << "{" << be_idt_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", ACE_TRY_ENV)) return 0; // not equal" << be_nl - << "ACE_TRY_CHECK;" << be_nl - << "if (_tao_any.any_owns_data ())" << be_nl - << "{" << be_idt_nl - << "_tao_elem = (" << node->name () << "_slice *)_tao_any.value ();" - << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // else Any does not own the data - << "{" << be_idt_nl - << "_tao_elem.out () = " << node->name () << "_alloc ();" << be_nl - << "if (!_tao_elem.in ()) return 0;" << be_nl - << "TAO_InputCDR stream (_tao_any._tao_get_cdr ());" - << be_nl - << "if (stream.decode (" << node->tc_name () - << ", _tao_elem.inout (), 0, ACE_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->replace (" - << node->tc_name () << ", _tao_elem.inout (), 1, ACE_TRY_ENV);" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "ACE_TRY_CHECK;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "ACE_CATCHANY" << be_nl - << "{" << be_idt_nl - << node->name () << "_free (_tao_elem._retn ());" << be_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "ACE_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\n"; - - node->cli_stub_any_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/array.cpp b/TAO/TAO_IDL/be/be_visitor_array/array.cpp deleted file mode 100644 index a19959e36a1..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array.cpp -// -// = DESCRIPTION -// Generic visitor for code generation for Arrays -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array, "$Id$") - - -// ************************************************************************ -// generic visitor for array declaration -// ************************************************************************ - -be_visitor_array::be_visitor_array (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array::~be_visitor_array (void) -{ -} - -int be_visitor_array::visit_array (be_array *) -{ - // must be overloaded by derived visitors - return -1; -} - -int -be_visitor_array::visit_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); - else - *os << bt->name () << "_var"; - return 0; -} - -int -be_visitor_array::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); - else - *os << bt->name () << "_var"; - return 0; -} - -int -be_visitor_array::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << node->name () << "_var"; - else - *os << node->name (); - return 0; -} - -int -be_visitor_array::visit_sequence (be_sequence *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); - // *os << "CORBA::String_var"; - *os << "TAO_String_Manager"; - return 0; -} - -int -be_visitor_array::visit_structure (be_structure *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_union (be_union *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_typedef (be_typedef *node) -{ - return this->visit_node (node); -} - -// helper -int -be_visitor_array::visit_node (be_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *os << bt->name (); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp deleted file mode 100644 index c38780bdfdb..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp +++ /dev/null @@ -1,517 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array_ch.cpp -// -// = DESCRIPTION -// Visitor for Array code generation in client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_ch, "$Id$") - - -// ************************************************************************ -// visitor for array declaration in client header -// ************************************************************************ - -be_visitor_array_ch::be_visitor_array_ch (be_visitor_context *ctx) - : be_visitor_array (ctx) -{ -} - -be_visitor_array_ch::~be_visitor_array_ch (void) -{ -} - -int be_visitor_array_ch::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_type *bt; // base type - be_decl *scope = this->ctx_->scope (); // scope in which it is used - - // nothing to do if we are imported or code is already generated - if (node->imported () || (node->cli_hdr_gen ())) - return 0; - - this->ctx_->node (node); // save the array node - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_ch::" - "visit_array - " - "bad base type\n"), - -1); - } - - // generate the ifdefined macro - os->gen_ifdef_macro (node->flatname ()); - - // If we contain an anonymous sequence, - // generate code for the sequence here. - if (bt->node_type () == AST_Decl::NT_sequence) - { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CH) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_ch::" - "visit_array - " - "gen_anonymous_base_type failed\n"), - -1); - } - } - - os->indent (); - *os << "typedef "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "base type decl failed\n"), - -1); - } - *os << " "; - if (!this->ctx_->tdef ()) - { - // we are dealing with an anonymous array case. Generate a typedef with - // an _ prepended to the name - *os << "_"; - } - *os << node->local_name (); - - if (node->gen_dimensions (os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "gen dimensions failed\n"), - -1); - } - *os << ";" << be_nl; - - // now define the slice type and other required operations - *os << "typedef "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "base type decl failed\n"), - -1); - } - *os << " "; - if (!this->ctx_->tdef ()) - { - // we are dealing with an anonymous array case. Generate a typedef with - // an _ prepended to the name - *os << "_"; - } - *os << node->local_name () << "_slice"; - if (node->gen_dimensions (os, 1) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "gen slice dimensions failed\n"), - -1); - } - *os << ";\n"; - - // typedef the _var, _out, and _forany types - if (this->gen_var_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "var_defn failed\n"), - -1); - } - // a class is generated for an out defn only for a variable length struct - if (node->size_type () == be_decl::VARIABLE) - { - if (this->gen_out_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "out_defn failed\n"), - -1); - } - } - else - { - // fixed size - os->indent (); - // if we are a typedefed array, we can use the TYPE name to define an - // _out type. However, for anonymous arrays that do not give rise to a - // new type, we use the base type for defining an out type - if (this->ctx_->tdef ()) - { - *os << "typedef " << node->local_name () << " " - << node->local_name () << "_out;\n"; - } - else - { - *os << "typedef "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "base type decl failed\n"), - -1); - } - *os << " _" << node->local_name () << "_out"; - if (node->gen_dimensions (os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "gen dimensions failed\n"), - -1); - } - *os << ";\n"; - } - } - - if (this->gen_forany_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "forany_defn failed\n"), - -1); - } - // the _alloc, _dup, copy, and free methods. If the node is nested, the - // methods become static - os->indent (); - const char *storage_class = 0; - - if (node->is_nested ()) - { - if (scope->node_type () != AST_Decl::NT_module) - storage_class = "static "; - else - storage_class = "TAO_NAMESPACE_STORAGE_CLASS "; - } - else - storage_class = ""; - - if (this->ctx_->tdef ()) - { - // typedefed array - *os << storage_class << node->nested_type_name (scope, "_slice") << " *"; - *os << node->nested_type_name (scope, "_alloc") << " (void);" << be_nl; - *os << storage_class << "void " << node->nested_type_name (scope, "_free") << " ("; - *os << node->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl; - *os << storage_class << node->nested_type_name (scope, "_slice") << " *"; - *os << node->nested_type_name (scope, "_dup") << " (const "; - *os << node->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl; - *os << storage_class << "void " << node->nested_type_name (scope, "_copy") << " ("; - *os << node->nested_type_name (scope, "_slice") << " *_tao_to, const "; - *os << node->nested_type_name (scope, "_slice") << " *_tao_from);" << be_nl; - } - else - { - // anonymous array - *os << storage_class << node->nested_type_name (scope, "_slice", "_") << " *"; - *os << node->nested_type_name (scope, "_alloc", "_") << " (void);" << be_nl; - *os << storage_class << "void " - << node->nested_type_name (scope, "_free", "_") << " ("; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice);" << be_nl; - *os << storage_class << node->nested_type_name (scope, "_slice", "_") << " *"; - *os << node->nested_type_name (scope, "_dup", "_") << " (const "; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice);" << be_nl; - *os << storage_class << "void " - << node->nested_type_name (scope, "_copy", "_") << " ("; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_to, const "; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_from);" << be_nl; - } - - *os << "\n"; - -#if 0 - // Typecode for an anonymous array will not be required anywhere since we do - // not generate the Any operators for anonymous types - - // is this a typedefined array? if so, then let the typedef deal with - // generation of the typecode - if (!this->ctx_->tdef ()) - { - // 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 - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_ch::" - "visit_array - " - "TypeCode declaration failed\n" - ), -1); - } - delete visitor; - } -#endif /* 0 */ - - // generate the endif macro - os->gen_endif (); - - node->cli_hdr_gen (1); - return 0; -} - -// generate the var defn -int -be_visitor_array_ch::gen_var_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - char namebuf [NAMEBUFSIZE]; // names - char varnamebuf [NAMEBUFSIZE]; // var names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (varnamebuf, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed array - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (varnamebuf, "%s_var", node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (namebuf, "_%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (varnamebuf, "_%s_var", node->local_name ()->get_string ()); - } - - // generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - os->indent (); // start with whatever was our current indent level - *os << "class " << idl_global->export_macro () - << " " << varnamebuf << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - // default constr - *os << varnamebuf << " (void); // default constructor" << be_nl; - // constr from pointer to slice - *os << varnamebuf << " (" << namebuf << "_slice *);" << be_nl; - // copy constructor - *os << varnamebuf << " (const " << varnamebuf << - " &); // copy constructor" << be_nl; - // destructor - *os << "~" << varnamebuf << " (void); // destructor" << be_nl; - *os << be_nl; - // assignment operator from a pointer to slice - *os << varnamebuf << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // assignment from _var - *os << varnamebuf << " &operator= (const " << varnamebuf << " &);" << be_nl; - - // arrow operator - // nothing here - *os << be_nl; - - // other extra types (cast operators, [] operator, and others) - // overloaded [] operator - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" - << be_nl; - *os << "const " << namebuf - << "_slice &operator[] (CORBA::ULong index) const;" << be_nl; - - // cast operators - *os << "operator " << namebuf << "_slice * const &() const;" - << be_nl; - *os << "operator " << namebuf << "_slice *&();" << be_nl; - - // in, inout, out and _retn - *os << "// in, inout, out, _retn " << be_nl; - *os << "const " << namebuf << "_slice *in (void) const;" << be_nl; - *os << namebuf << "_slice *inout (void);" << be_nl; - *os << namebuf << "_slice *&out (void);" << be_nl; - *os << namebuf << "_slice *_retn (void);" << be_nl; - - // generate an additional member function that returns the underlying pointer - *os << namebuf << "_slice *ptr (void) const;" << be_uidt_nl; - - // generate the private section - *os << "private:" << be_idt_nl; - *os << namebuf << "_slice *ptr_;" << be_uidt_nl; - *os << "};\n\n"; - - return 0; -} - -// generate the _out definition -int -be_visitor_array_ch::gen_out_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - char namebuf [NAMEBUFSIZE]; // to hold the name - char outnamebuf [NAMEBUFSIZE]; // to hold the _out name - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (outnamebuf, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (outnamebuf, "%s_out", node->local_name ()->get_string ()); - } - else - { - // anonymous array - ACE_OS::sprintf (namebuf, "_%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (outnamebuf, "_%s_out", node->local_name ()->get_string ()); - } - - // generate the out definition (always in the client header) - os->indent (); // start with whatever was our current indent level - - *os << "class " << idl_global->export_macro () - << " " << outnamebuf << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - - // No default constructor - - // constructor from a pointer to slice - *os << outnamebuf << " (" << namebuf << "_slice *&);" << be_nl; - // constructor from a _var & - *os << outnamebuf << " (" << namebuf << "_var &);" << be_nl; - // constructor from a _out & - *os << outnamebuf << " (const " << outnamebuf << " &);" << be_nl; - // assignment operator from a _out & - *os << outnamebuf << " &operator= (const " << outnamebuf << " &);" << be_nl; - // assignment from slice * - *os << outnamebuf << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // cast - *os << "operator " << namebuf << "_slice *&();" << be_nl; - // ptr fn - *os << namebuf << "_slice *&ptr (void);" << be_nl; - // operator [] instead of -> - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" << be_nl; - *os << "const " << namebuf << "_slice &operator[] " - << "(CORBA::ULong index) const;" << be_uidt_nl; - - *os << "private:" << be_idt_nl; - *os << namebuf << "_slice *&ptr_;" << be_nl; - *os << "// assignment from T_var not allowed" << be_nl; - *os << "void operator= (const " << namebuf << "_var &);" << be_uidt_nl; - *os << "};\n\n"; - return 0; -} - -// generate the _var definition for ourself -int -be_visitor_array_ch::gen_forany_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - char namebuf [NAMEBUFSIZE]; // names - char foranyname [NAMEBUFSIZE]; // forany class names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (foranyname, '\0', NAMEBUFSIZE); - - if (this->ctx_->tdef ()) - { - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (foranyname, "%s_forany", node->local_name ()->get_string ()); - } - else - { - // anonymous array case - ACE_OS::sprintf (namebuf, "_%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (foranyname, "_%s_forany", - node->local_name ()->get_string ()); - } - - // generate the forany definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - os->indent (); // start with whatever was our current indent level - *os << "class " << idl_global->export_macro () - << " " << foranyname << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - - // default constr - *os << foranyname << " (void); // default constructor" << be_nl; - // constr from pointer to slice - *os << foranyname << " (" << namebuf << "_slice *, " - << "CORBA::Boolean nocopy=0);" << be_nl; - // copy constructor - *os << foranyname << " (const " << foranyname - << " &); // copy constructor" << be_nl; - // destructor - *os << "~" << foranyname << " (void); // destructor" << be_nl; - *os << be_nl; - // assignment operator from a pointer to slice - *os << foranyname << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // assignment from _var - *os << foranyname << " &operator= (const " << foranyname << " &);" << be_nl; - - // arrow operator - // nothing here - *os << be_nl; - - // other extra types (cast operators, [] operator, and others) - // overloaded [] operator - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" - << be_nl; - *os << "const " << namebuf - << "_slice &operator[] (CORBA::ULong index) const;" << be_nl; - - // cast operators - *os << "operator " << namebuf << "_slice * const &() const;" - << be_nl; - *os << "operator " << namebuf << "_slice *&();" << be_nl; - - // in, inout, out and _retn - *os << "// in, inout, out, _retn " << be_nl; - *os << "const " << namebuf << "_slice *in (void) const;" << be_nl; - *os << namebuf << "_slice *inout (void);" << be_nl; - *os << namebuf << "_slice *&out (void);" << be_nl; - *os << namebuf << "_slice *_retn (void);" << be_nl; - - // generate an additional member function that returns the underlying pointer - *os << namebuf << "_slice *ptr (void) const;" << be_nl; - - // additional member function that returns the NOCOPY flag - *os << "CORBA::Boolean nocopy (void) const;" << be_uidt_nl; - - // generate the private section - *os << "private:" << be_idt_nl; - *os << "/* friend class CORBA_Any; */" << be_nl; - *os << namebuf << "_slice *ptr_;" << be_nl; - *os << "CORBA::Boolean nocopy_;" << be_uidt_nl; - *os << "};\n\n"; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp deleted file mode 100644 index b08c960285d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp +++ /dev/null @@ -1,641 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Arrays in the client inline. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_ci, "$Id$") - - -// ************************************************************************ -// visitor for array declaration in client inline -// ************************************************************************ - -be_visitor_array_ci::be_visitor_array_ci (be_visitor_context *ctx) - : be_visitor_array (ctx) -{ -} - -be_visitor_array_ci::~be_visitor_array_ci (void) -{ -} - -int be_visitor_array_ci::visit_array (be_array *node) -{ - // nothing to do if we are imported or code is already generated - if (node->imported () || (node->cli_inline_gen ())) - return 0; - - this->ctx_->node (node); // save the array node - - // If we contain an anonymous sequence, generate code for it here. - - be_type *bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_array - " - "bad base type\n"), - -1); - } - - if (bt->node_type () == AST_Decl::NT_sequence) - { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CI) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_ci::" - "visit_array - " - "gen_anonymous_base_type failed\n"), - -1); - } - } - - // generate code for the _var, _out, and _forany types - if (this->gen_var_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "var_defn failed\n"), - -1); - } - if (node->size_type () == be_decl::VARIABLE) - { - if (this->gen_out_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "out_defn failed\n"), - -1); - } - } - - if (this->gen_forany_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "forany_defn failed\n"), - -1); - } - - node->cli_inline_gen (1); - return 0; -} - -// implementation of the _var class. All of these get generated in the inline -// file -int -be_visitor_array_ci::gen_var_impl (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - - char nodename [NAMEBUFSIZE]; // node name - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the var - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (nodename, '\0', NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_var", node->fullname ()); - ACE_OS::sprintf (lname, "%s_var", - node->local_name ()->get_string ()); - } - else - { - // 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 (nodename, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_var", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_var", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_var", node->fullname ()); - ACE_OS::sprintf (lname, "_%s_var", - node->local_name ()->get_string ()); - } - } - - // generate the var implementation in the inline file - - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // default constr - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << - " (void) // default constructor" << be_nl; - *os << " " << ": ptr_ (0)" << be_nl; - *os << "{}\n\n"; - - // constr from a _slice * - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename << "_slice *p)" << be_nl; - *os << " : ptr_ (p)" << be_nl; - *os << "{}\n\n"; - - // copy constructor (deep copy) - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname - << " &p) // copy constructor" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = " << nodename << "_dup (p.ptr_);" << be_uidt_nl; - *os << "}\n\n"; - - // destructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_free (this->ptr_);" << be_uidt_nl; - *os << "}\n\n"; - - // assignment operator - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << nodename - << "_slice *p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// is what we own the same that is being assigned to us?" - << be_nl; - *os << "if (this->ptr_ != p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// delete our stuff and assume ownership of p" << be_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = p;" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // assignment operator from _var - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname - << " &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "if (this != &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// not assigning to ourselves" << be_nl; - *os << nodename << "_free (this->ptr_); // free old stuff" << be_nl; - *os << "this->ptr_ = " << nodename - << "_dup (p.ptr_);// deep copy" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // other extra methods - cast operators () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice * const &() const // cast" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename << "_slice *&() // cast " << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // two operator []s instead of -> - os->indent (); - *os << "ACE_INLINE const " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - // in, inout, out, and _retn - os->indent (); - *os << "ACE_INLINE const " << nodename << "_slice *" << be_nl; - *os << fname << "::in (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::inout (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice * &" << be_nl; - *os << fname << "::out (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = (" << nodename << "_slice *)0;" << be_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::_retn (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_slice *tmp = this->ptr_;" << be_nl; - *os << "this->ptr_ = (" << nodename << "_slice *)0;" << be_nl; - *os << "return tmp;" << be_uidt_nl; - *os << "}\n\n"; - - // the additional ptr () member function - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::ptr (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_array_ci::gen_out_impl (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - - char nodename [NAMEBUFSIZE]; // node name - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the out class - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (nodename, '\0', NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_out", node->fullname ()); - ACE_OS::sprintf (lname, "%s_out", - node->local_name ()->get_string ()); - } - else - { - // 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 (nodename, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_out", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_out", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_out", node->fullname ()); - ACE_OS::sprintf (lname, "_%s_out", - node->local_name ()->get_string ()); - } - } - - // generate the out implementation in the inline file - - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // constr from a pointer to slice - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename << "_slice *&p)" << be_nl; - *os << " : ptr_ (p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = 0;" << be_uidt_nl; - *os << "}\n\n"; - - // constructor from _var & - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename - << "_var &p) // constructor from _var" << be_nl; - *os << " : ptr_ (p.out ())" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = 0;" << be_uidt_nl; - *os << "}\n\n"; - - // copy constructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname - << " &p) // copy constructor" << be_nl; - *os << " : ptr_ (ACE_const_cast (" - << fname << "&,p).ptr_)" << be_nl; - *os << "{}\n\n"; - - // assignment operator from _out & - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname - << " &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = ACE_const_cast (" - << fname << "&,p).ptr_;" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // assignment from _var is not allowed - - // assignment operator from _ptr - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << nodename - << "_slice *p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = p;" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // other extra methods - cast operator () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice *&() // cast" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // ptr function - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *&" << be_nl; - *os << fname << "::ptr (void) // ptr" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // operator [] instead of -> - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_array_ci::gen_forany_impl (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - - char nodename [NAMEBUFSIZE]; // node name - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the var - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (nodename, '\0', NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_forany", node->fullname ()); - ACE_OS::sprintf (lname, "%s_forany", - node->local_name ()->get_string ()); - } - else - { - // 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 (nodename, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_forany", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_forany", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_forany", node->fullname ()); - ACE_OS::sprintf (lname, "_%s_forany", - node->local_name ()->get_string ()); - } - } - - // generate the var implementation in the inline file - - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // default constr - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << - " (void) // default constructor" << be_nl; - *os << " " << ": ptr_ (0)," << be_nl; - *os << " nocopy_ (0)" << be_nl; - *os << "{}\n\n"; - - // constr from a _slice * - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename << "_slice *p, " - << "CORBA::Boolean nocopy)" << be_nl; - *os << " : ptr_ (p)," << be_nl; - *os << " nocopy_ (nocopy)" << be_nl; - *os << "{}\n\n"; - - // copy constructor (deep copy) - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname - << " &p) // copy constructor" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = " << nodename << "_dup (p.ptr_);" << be_nl; - *os << "this->nocopy_ = p.nocopy_;" << be_uidt_nl; - *os << "}\n\n"; - - // destructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; - *os << "{" << be_nl; - *os << " // don't do anything" << be_nl; - *os << "}\n\n"; - - // assignment operator - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << nodename - << "_slice *p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// is what we own the same that is being assigned to us?" << - be_nl; - *os << "if (this->ptr_ != p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// delete our stuff and assume ownership of p" << be_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = p;" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // assignment operator from _forany - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname - << " &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "if (this != &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// not assigning to ourselves" << be_nl; - *os << nodename << "_free (this->ptr_); // free old stuff" << be_nl; - *os << "this->ptr_ = " << nodename - << "_dup (p.ptr_);// deep copy" << be_nl; - *os << "this->nocopy_ = p.nocopy_;" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // other extra methods - cast operators () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice * const &() const // cast" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice *&() // cast " << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // two operator []s instead of -> - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice const &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - // in, inout, out, and _retn - os->indent (); - *os << "ACE_INLINE const " << nodename << "_slice *" << be_nl; - *os << fname << "::in (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::inout (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice * &" << be_nl; - *os << fname << "::out (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::_retn (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // the additional ptr () member function - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::ptr (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // the additional nocopy member function - os->indent (); - *os << "ACE_INLINE CORBA::Boolean" << be_nl; - *os << fname << "::nocopy (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->nocopy_;" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp deleted file mode 100644 index 981355135c5..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp +++ /dev/null @@ -1,309 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array_cs.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays in the client stubs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_cs, "$Id$") - - -// ************************************************************************ -// visitor for array declaration in client stubs -// ************************************************************************ - -be_visitor_array_cs::be_visitor_array_cs (be_visitor_context *ctx) - : be_visitor_array (ctx) -{ -} - -be_visitor_array_cs::~be_visitor_array_cs (void) -{ -} - -int be_visitor_array_cs::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_type *bt; // base type - unsigned long i; - - // nothing to do if we are imported or code is already generated - if (node->imported () || (node->cli_stub_gen ())) - return 0; - - this->ctx_->node (node); // save the array node - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "Bad base type\n"), - -1); - } - - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the var - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - ACE_OS::sprintf (lname, "%s", - node->local_name ()->get_string ()); - } - else - { - // 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 ()); - ACE_OS::sprintf (lname, "_%s", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - ACE_OS::sprintf (lname, "_%s", - node->local_name ()->get_string ()); - } - } - - // dup method - os->indent (); - *os << fname << "_slice *" << be_nl - << fname << "_dup (const " << fname - << "_slice *_tao_src_array)" << be_nl; - *os << "{" << be_idt_nl; - *os << fname << "_slice *_tao_dup_array = " << fname - << "_alloc ();" << be_nl; - *os << "if (!_tao_dup_array) return (" << fname - << "_slice *)0;" << be_nl; - *os << fname << "_copy (_tao_dup_array, _tao_src_array);" << be_nl; - *os << "return _tao_dup_array;" << be_uidt_nl; - *os << "}\n\n"; - - // alloc method - os->indent (); // start from current indentation - *os << fname << "_slice *" << be_nl; - *os << fname << "_alloc (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return new "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "base type decl failed\n"), - -1); - } - - if (node->gen_dimensions (os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "gen_client - " - "dimensions codegen failed\n"), - -1); - } - - *os << ";" << be_uidt_nl; - *os << "}\n\n"; - - // free method - os->indent (); - *os << "void" << be_nl - << fname << "_free (" << fname - << "_slice *_tao_slice)" << be_nl; - *os << "{" << be_idt_nl; - *os << "delete [] _tao_slice;" << be_uidt_nl; - *os << "}\n\n"; - - // copy method - os->indent (); - *os << "void " << be_nl; - *os << fname << "_copy (" << fname << "_slice * _tao_to, " - << "const " << fname << "_slice *_tao_from)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// copy each individual element" << be_nl; - - // generate nested loops for as many dimensions as there are - for (i = 0; i < node->n_dims (); i++) - { - // retrieve the ith dimension value - AST_Expression *expr = node->dims ()[i]; - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cs::" - "visit_array - " - "bad array dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - // generate a loop for each dimension - *os << "for (CORBA::ULong i" << i << " = 0; i" << i << " < " - << expr->ev ()->u.ulval << "; i" << i << "++)" << be_idt_nl; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cs::" - "visit_array - " - "bad array dimension value\n"), - -1); - } - } - - // now generate code such that every element of the array gets assigned - // inside the innermost level of the nested loops generated above - be_array *primitive_type = 0; - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // Base type of the array node is a typedef. We need to make sure that - // this typedef is not to another array type. If it is, then we cannot - // assign an array to another. We will have to invoke the underlying - // array type's copy method for every array dimension. - - // There may be more than one level of typedef. - be_type *tmp = bt; - - while (tmp->node_type () == AST_Decl::NT_typedef) - { - be_typedef *tdef = be_typedef::narrow_from_decl (tmp); - tmp = be_type::narrow_from_decl (tdef->base_type ()); - } - - primitive_type = be_array::narrow_from_decl (tmp); - } - - if (primitive_type) - { - // The base type is a typedef to another array type, so - // we use the base type's copy method. - *os << "// call the underlying _copy" << be_nl; - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cs::" - "visit_array - " - "base type decl failed\n"), - -1); - } - - *os << "_copy (_tao_to"; - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << ", "; - *os << "_tao_from"; // generate the rvalue - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << ");"; - } - else - { - // the base type is not a typedef to possibly another array type. In - // such a case, assign each element. - - *os << "_tao_to"; // generate the lvalue - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << " = "; - *os << "_tao_from"; // generate the rvalue - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << ";"; - } - for (i = 0; i < node->n_dims (); i++) - { - // decrement indentation as many times as the number of dimensions - *os << be_uidt; - } - *os << be_uidt_nl << "}\n\n"; - - // If we contain an anonymous sequence, - // generate code for the seuqence here. - if (bt->node_type () == AST_Decl::NT_sequence) - { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CS) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cs::" - "visit_array - " - "gen_anonymous_base_type failed\n"), - -1); - } - } - -#if 0 - // typecode for anonymous arrays is not required since we do not generate the - // Any operators for it and it cannot be used as a type - - // is this a typedefined array? if so, then let the typedef deal with - // generation of the typecode - if (!this->ctx_->tdef ()) - { - // 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 - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cs::" - "visit_array - " - "TypeCode definition failed\n" - ), -1); - } - delete visitor; - } -#endif /* 0 */ - - node->cli_stub_gen (1); - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp deleted file mode 100644 index 3af1abc3abd..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the Cdr operators in the client -// header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, cdr_op_ch, "$Id$") - - -// *************************************************************************** -// Array visitor for generating CDR operator declarations in the client header -// *************************************************************************** - -be_visitor_array_cdr_op_ch::be_visitor_array_cdr_op_ch -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_cdr_op_ch::~be_visitor_array_cdr_op_ch (void) -{ -} - -int -be_visitor_array_cdr_op_ch::visit_array (be_array *node) -{ - if (node->cli_hdr_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const "; - // @@ TODO: this should be done in the node, it is absurd to repeat - // this code all over the visitors!!!! - if (!this->ctx_->tdef ()) - { - be_scope* scope = be_scope::narrow_from_scope (node->defined_in ()); - be_decl* parent = scope->decl (); - *os << parent->fullname () - << "::_" << node->local_name () - << "_forany &);" << be_nl; - } - else - { - *os << node->name () << "_forany &);" << be_nl; - } - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, "; - if (!this->ctx_->tdef ()) - { - be_scope* scope = be_scope::narrow_from_scope (node->defined_in ()); - be_decl* parent = scope->decl (); - *os << parent->fullname () - << "::_" << node->local_name () - << "_forany &);" << be_nl; - } - else - { - *os << node->name () << "_forany &);" << be_nl; - } - - // If we contain an anonymous sequence, - // generate code for the sequence here. - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ch::" - "visit_array - " - "bad base type\n"), - -1); - } - - if (bt->node_type () == AST_Decl::NT_sequence) - { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ch::" - "visit_array - " - "gen_anonymous_base_type failed\n"), - -1); - } - } - - node->cli_hdr_cdr_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp deleted file mode 100644 index 5995c25313b..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp +++ /dev/null @@ -1,646 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ci.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the CDR operators in the client -// stubs. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, cdr_op_ci, "$Id$") - - -// *************************************************************************** -// Array visitor for generating CDR operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_array_cdr_op_ci::be_visitor_array_cdr_op_ci -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_cdr_op_ci::~be_visitor_array_cdr_op_ci (void) -{ -} - -int -be_visitor_array_cdr_op_ci::visit_array (be_array *node) -{ - if (this->ctx_->alias ()) - { - // we are here because the base type of the array node is itself an array - // i.e., this is a case of array of array - return this->visit_node (node); - } - else - { - TAO_OutStream *os = this->ctx_->stream (); - - be_type *bt; // base type of the array - - if (node->cli_inline_cdr_op_gen () || node->imported ()) - return 0; - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cdr_op_ci::" - "visit_array - " - "Bad base type\n"), - -1); - } - - // If we contain an anonymous sequence, - // generate code for the sequence here. - - if (bt->node_type () == AST_Decl::NT_sequence) - { - // @@ (JP) TODO - change state arg to _CI when the rest of - // the cdr_op files get unhacked. - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_array - " - "gen_anonymous_base_type failed\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_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - } - else - { - // 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 ()); - } - } - - // generate the CDR << and >> operator defns - - // save the array node for further use - this->ctx_->node (node); - - // set the sub state as generating code for the output operator - this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - *os << "ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &strm, " - << "const " << fname << "_forany &_tao_array)" << be_nl - << "{" << be_idt_nl; - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cdr_op_ci::" - "visit_array - " - "Base type codegen failed\n"), - -1); - } - *os << "}\n\n"; - - // set the sub state as generating code for the input operator - os->indent (); - this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_INPUT); - *os << "ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, " - << fname << "_forany &_tao_array)" << be_nl - << "{" << be_idt_nl; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cdr_op_ci::" - "visit_array - " - "Base type codegen failed\n"), - -1); - } - *os << "}\n\n"; - - node->cli_inline_cdr_op_gen (1); - } - return 0; -} - -// handle all the base types - -int -be_visitor_array_cdr_op_ci::visit_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_ci::visit_interface (be_interface *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_ci::visit_interface_fwd (be_interface_fwd *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_ci::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - case AST_PredefinedType::PT_any: - // let the helper handle this - return this->visit_node (node); - case AST_PredefinedType::PT_void: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "Bad primitive type\n" - ), -1); - default: - // all other primitive types. Handle them as shown below - break; - }; - - // we get here if the "type" of individual elements of the array is a - // primitive type. In this case, we treat the array as a single dimensional - // array (even though it was multi-dimensional), and pass the total length of - // the array as a cross product of the dimensions - - // index - unsigned long i; - - // grab the array node - be_array *array = this->ctx_->be_node_as_array (); - - if (!node) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad array node\n"), - -1); - } - - // we generate optimized code based on an optimized interface available from - // the CDR class. These optimizations are applicable only to primitive - // types. - *os << " return strm."; - - // based on our substate, we may be reading from a stream or writing into a - // stream - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "read_"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "write_"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad sub state\n"), - -1); - } - - // determine what kind of array are we reading/writing - switch (node->pt ()) - { - case AST_PredefinedType::PT_long: - *os << "long_array"; - break; - case AST_PredefinedType::PT_ulong: - *os << "ulong_array"; - break; - case AST_PredefinedType::PT_short: - *os << "short_array"; - break; - case AST_PredefinedType::PT_ushort: - *os << "ushort_array"; - break; - case AST_PredefinedType::PT_octet: - *os << "octet_array"; - break; - case AST_PredefinedType::PT_char: - *os << "char_array"; - break; - case AST_PredefinedType::PT_wchar: - *os << "wchar_array"; - break; - case AST_PredefinedType::PT_float: - *os << "float_array"; - break; - case AST_PredefinedType::PT_double: - *os << "double_array"; - break; - case AST_PredefinedType::PT_longlong: - *os << "longlong_array"; - break; - case AST_PredefinedType::PT_ulonglong: - *os << "ulonglong_array"; - break; - case AST_PredefinedType::PT_longdouble: - *os << "longdouble_array"; - break; - case AST_PredefinedType::PT_boolean: - *os << "boolean_array"; - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad primitive type for optimized code gen\n"), - -1); - } - - // handle special case to avoid compiler errors - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " (("; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << " ((const "; - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad substate in context\n"), - -1); - } - - switch (node->pt ()) - { - case AST_PredefinedType::PT_long: - *os << "ACE_CDR::Long *)"; - break; - case AST_PredefinedType::PT_ulong: - *os << "ACE_CDR::ULong *)"; - break; - case AST_PredefinedType::PT_short: - *os << "ACE_CDR::Short *)"; - break; - case AST_PredefinedType::PT_ushort: - *os << "ACE_CDR::UShort *)"; - break; - case AST_PredefinedType::PT_octet: - *os << "ACE_CDR::Octet *)"; - break; - case AST_PredefinedType::PT_char: - *os << "ACE_CDR::Char *)"; - break; - case AST_PredefinedType::PT_wchar: - *os << "ACE_CDR::WChar *)"; - break; - case AST_PredefinedType::PT_float: - *os << "ACE_CDR::Float *)"; - break; - case AST_PredefinedType::PT_double: - *os << "ACE_CDR::Double *)"; - break; - case AST_PredefinedType::PT_longlong: - *os << "ACE_CDR::LongLong *)"; - break; - case AST_PredefinedType::PT_ulonglong: - *os << "ACE_CDR::ULongLong *)"; - break; - case AST_PredefinedType::PT_longdouble: - *os << "ACE_CDR::LongDouble *)"; - break; - case AST_PredefinedType::PT_boolean: - *os << "ACE_CDR::Boolean *)"; - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad primitive type for optimized code gen\n"), - -1); - } - - // handle special case to avoid compiler errors - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " _tao_array.out (), "; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "_tao_array.in (), "; - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad substate in context\n"), - -1); - } - - // generate a product of all the dimensions. This will be the total length of - // the "unfolded" single dimensional array. - for (i = 0; i < array->n_dims (); i++) - { - // retrieve the ith dimension value - AST_Expression *expr = array->dims ()[i]; - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad array dimension\n"), - -1); - } - if (i != 0) - // do not generate the multiplication operator the first time in - *os << "*"; - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - // generate a loop for each dimension - *os << expr->ev ()->u.ulval; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_predefined_type - " - "bad array dimension value\n"), - -1); - } - } - *os << ");" << be_uidt_nl; - - return 0; -} - -int -be_visitor_array_cdr_op_ci::visit_sequence (be_sequence *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_ci::visit_string (be_string *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_ci::visit_structure (be_structure *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_ci::visit_union (be_union *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_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_array_cdr_op_ci::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -// helper -int -be_visitor_array_cdr_op_ci::visit_node (be_type *bt) -{ - TAO_OutStream *os = this->ctx_->stream (); - unsigned long i; - be_array *node = this->ctx_->be_node_as_array (); - - if (!node) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_node - " - "bad array node\n"), - -1); - } - - // initialize a boolean variable - *os << "CORBA::Boolean _tao_marshal_flag = 1;" << be_nl; - - // we get here if the "type" of individual elements of the array is not a - // primitive type. In this case, we are left with no other alternative but to - // encode/decode element by element - - // generate nested loops for as many dimensions as there are - for (i = 0; i < node->n_dims (); i++) - { - // retrieve the ith dimension value - AST_Expression *expr = node->dims ()[i]; - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_node - " - "bad array dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - // generate a loop for each dimension - *os << "for (CORBA::ULong i" << i << " = 0; i" << i << " < " - << expr->ev ()->u.ulval << " && _tao_marshal_flag; i" << i - << "++)" << be_idt_nl; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_node - " - "bad array dimension value\n"), - -1); - } - } - - // if the type was a string, an obj ref, or a pseudo-obj, we are dealing with - // the _var type and hence we must use the appropriate in () and out () methods - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "_tao_marshal_flag = (strm >> "; - // handle the array of array case in which case, we need to pass the - // forany type - if (bt->node_type () == AST_Decl::NT_array) - { - *os << bt->name () << "_forany ((" << bt->name () - << "_slice *) "; - } - *os << "_tao_array "; - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - switch (bt->node_type ()) - { - // the following have a _var type and must be handled in a special way - case AST_Decl::NT_string: - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - *os << ".out ()"; - break; - case AST_Decl::NT_pre_defined: - { - // we need to separately handle this case of pseudo objects because - // they have a _var type - be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); - if (!pt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_node - " - "bad predefined type node\n"), - -1); - } - if (pt->pt () == AST_PredefinedType::PT_pseudo) - { - *os << ".out ()"; - } - } - default: - break; - } - if (bt->node_type () == AST_Decl::NT_array) - { - *os << ")"; - } - *os << ");"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "_tao_marshal_flag = (strm << "; - // handle the array of array case in which case, we need to pass the - // forany type - if (bt->node_type () == AST_Decl::NT_array) - { - *os << bt->name () << "_forany ((" << bt->name () - << "_slice *) "; - } - *os << "_tao_array "; - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - switch (bt->node_type ()) - { - // the follwoing three have a _var type and must be handled in a - // special way - case AST_Decl::NT_string: - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - *os << ".in ()"; - break; - case AST_Decl::NT_pre_defined: - { - be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); - if (!pt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_node - " - "bad predefined type node\n"), - -1); - } - if (pt->pt () == AST_PredefinedType::PT_pseudo) - { - *os << ".in ()"; - } - } - break; - default: - break; - } - if (bt->node_type () == AST_Decl::NT_array) - { - // array of array case - *os << ")"; - } - *os << ");"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_ci::" - "visit_node - " - "bad sub state\n"), - -1); - } - - for (i = 0; i < node->n_dims (); i++) - { - // decrement indentation as many times as the number of dimensions - *os << be_uidt; - } - *os << be_nl; - *os << "return _tao_marshal_flag;" << be_uidt_nl; - - return 0; -} |