diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-07-01 13:49:23 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-07-01 13:49:23 +0000 |
commit | 0155b2254e16d6c9e5d0b6c0c101de84e4fe432f (patch) | |
tree | 3b973276984c17f2240b1724fe1c92026081e981 /TAO/TAO_IDL/be | |
parent | 23696f26059dd5f33b655db7be60db00400ba408 (diff) | |
download | ATCD-0155b2254e16d6c9e5d0b6c0c101de84e4fe432f.tar.gz |
ChangeLogTag: Mon Jul 1 08:31:04 2002 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO/TAO_IDL/be')
351 files changed, 21652 insertions, 19038 deletions
diff --git a/TAO/TAO_IDL/be/Makefile.am b/TAO/TAO_IDL/be/Makefile.am index 39e7c1f3b71..cf8ebeea9ae 100644 --- a/TAO/TAO_IDL/be/Makefile.am +++ b/TAO/TAO_IDL/be/Makefile.am @@ -24,6 +24,8 @@ libbe_la_SOURCES = \ be_array.cpp \ be_attribute.cpp \ be_codegen.cpp \ + be_component.cpp \ + be_component_fwd.cpp \ be_constant.cpp \ be_decl.cpp \ be_enum.cpp \ @@ -33,6 +35,7 @@ libbe_la_SOURCES = \ be_field.cpp \ be_generator.cpp \ be_helper.cpp \ + be_home.cpp \ be_init.cpp \ be_interface.cpp \ be_interface_fwd.cpp \ @@ -49,10 +52,12 @@ libbe_la_SOURCES = \ be_stream_factory.cpp \ be_string.cpp \ be_structure.cpp \ + be_structure_fwd.cpp \ be_sunsoft.cpp \ be_type.cpp \ be_typedef.cpp \ be_union.cpp \ + be_union_fwd.cpp \ be_union_branch.cpp \ be_union_label.cpp \ be_valuetype.cpp \ @@ -62,6 +67,8 @@ libbe_la_SOURCES = \ be_visitor_argument.cpp \ be_visitor_array.cpp \ be_visitor_attribute.cpp \ + be_visitor_component.cpp \ + be_visitor_component_fwd.cpp \ be_visitor_constant.cpp \ be_visitor_context.cpp \ be_visitor_decl.cpp \ @@ -69,6 +76,7 @@ libbe_la_SOURCES = \ be_visitor_exception.cpp \ be_visitor_factory.cpp \ be_visitor_field.cpp \ + be_visitor_home.cpp \ be_visitor_interface.cpp \ be_visitor_interface_fwd.cpp \ be_visitor_module.cpp \ diff --git a/TAO/TAO_IDL/be/be_argument.cpp b/TAO/TAO_IDL/be/be_argument.cpp index 82c9d2e64d1..0a4fc22ffc5 100644 --- a/TAO/TAO_IDL/be/be_argument.cpp +++ b/TAO/TAO_IDL/be/be_argument.cpp @@ -19,11 +19,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_argument.h" +#include "be_visitor.h" -ACE_RCSID(be, be_argument, "$Id$") +ACE_RCSID (be, + be_argument, + "$Id$") be_argument::be_argument (void) { diff --git a/TAO/TAO_IDL/be/be_array.cpp b/TAO/TAO_IDL/be/be_array.cpp index bc25a29ce0f..e598750ab63 100644 --- a/TAO/TAO_IDL/be/be_array.cpp +++ b/TAO/TAO_IDL/be/be_array.cpp @@ -19,14 +19,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_array, "$Id$") +#include "be_array.h" +#include "be_codegen.h" +#include "be_scope.h" +#include "be_helper.h" +#include "be_visitor.h" +#include "utl_identifier.h" +#include "idl_defines.h" + +ACE_RCSID (be, + be_array, + "$Id$") be_array::be_array (void) - : tao_name_ (0) { } @@ -48,76 +53,12 @@ be_array::be_array (UTL_ScopedName *n, n, I_TRUE), COMMON_Base (local, - abstract), - tao_name_ (0) + abstract) { } be_array::~be_array (void) { - if (this->tao_name_ == 0) - delete [] tao_name_; -} - -// Create a name for ourselves. -const char* -be_array::tao_name (void) -{ - if (this->tao_name_ != 0) - return this->tao_name_; - - be_type *bt = be_type::narrow_from_decl (this->base_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "tao_name - " - "bad base type\n"), - 0); - } - - const char prefix[] = "_tc_tao_array_"; - - int l = (ACE_OS::strlen (bt->local_name ()->get_string ()) - + ACE_OS::strlen (this->local_name ()->get_string ()) + 1 - + sizeof (prefix) - + 5 * this->n_dims ()); - - ACE_NEW_RETURN (this->tao_name_, char[l], 0); - - ACE_OS::sprintf (this->tao_name_, "%s%s_%s", - prefix, this->local_name ()->get_string (), - bt->local_name ()->get_string()); - - for (unsigned int i = 0; i < this->n_dims (); ++i) - { - AST_Expression *expr = this->dims ()[i]; // retrieve the ith - - // Dimension value. - if ((expr == 0) || ((expr != 0) && (expr->ev () == 0))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "tao_name - " - "bad array dimension\n"), - 0); - } - - if (expr->ev ()->et != AST_Expression::EV_ulong) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "tao_name - " - "bad dimension value\n"), - 0); - } - - char buf[16]; - ACE_OS::sprintf (buf, "_%4.4x", ((int) expr->ev ()->u.ulval)); - ACE_OS::strcat (this->tao_name_, buf); - } - return this->tao_name_; } int @@ -128,7 +69,9 @@ be_array::create_name (void) UTL_ScopedName *n = 0; be_decl *scope; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); // Retrieve the base type. // The name always starts this way. be_type *bt = be_type::narrow_from_decl (this->base_type ()); @@ -142,12 +85,14 @@ be_array::create_name (void) 0); } - ACE_OS::sprintf (namebuf, "_tao_array_%s", bt->local_name ()->get_string ()); + ACE_OS::sprintf (namebuf, + "_tao_array_%s", + bt->local_name ()->get_string ()); // Now append dimensions. - for (i = 0; i < this->n_dims (); i++) + for (i = 0; i < this->n_dims (); ++i) { - AST_Expression *expr = this->dims ()[i]; // retrieve the ith + AST_Expression *expr = this->dims ()[i]; // Dimension value. if ((expr == 0) || ((expr != 0) && (expr->ev () == 0))) @@ -160,7 +105,10 @@ be_array::create_name (void) } if (expr->ev ()->et == AST_Expression::EV_ulong) { - ACE_OS::sprintf (namebuf, "%s_%d", namebuf, ((int)expr->ev ()->u.ulval)); + ACE_OS::sprintf (namebuf, + "%s_%d", + namebuf, + ((int)expr->ev ()->u.ulval)); } else { @@ -174,21 +122,32 @@ be_array::create_name (void) // Now see if we have a fully scoped name and if so, generate one. scope = be_scope::narrow_from_scope (this->defined_in ())->decl (); + if (scope) { // Make a copy of the enclosing scope's name. - n = (UTL_ScopedName *)scope->name ()->copy () ; + n = (UTL_ScopedName *)scope->name ()->copy (); + + Identifier *id = 0; + ACE_NEW_RETURN (id, + Identifier (ACE_OS::strdup (namebuf)), + -1); + + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); // Add our local name as the last component. - n->nconc (new UTL_ScopedName (new Identifier (ACE_OS::strdup (namebuf)), - 0)); + n->nconc (sn); // Set the fully scoped name. this->set_name (n); } else { // We better be not here because we must be inside some scope, - // atleast the ROOT scope. + // at least the ROOT scope. return -1; } @@ -205,13 +164,13 @@ be_array::gen_dimensions (TAO_OutStream *os, unsigned long i; // Print our dimensions. - for (i = (slice ? 1 : 0); i < this->n_dims (); i++) + for (i = (slice ? 1 : 0); i < this->n_dims (); ++i) { // Retrieve the ith. AST_Expression *expr = this->dims ()[i]; // Dimension value. - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) + if ((expr == 0) || ((expr != 0) && (expr->ev () == 0))) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_array::" @@ -237,26 +196,6 @@ be_array::gen_dimensions (TAO_OutStream *os, return 0; } -// Compute the size type of the node in question. -int -be_array::compute_size_type (void) -{ - be_type *type = be_type::narrow_from_decl (this->base_type ()); - - if (!type) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::compute_size_type - " - "bad base type\n"), - -1); - } - - // Our size type is the same as our type. - this->size_type (type->size_type ()); - - return 0; -} - int be_array::accept (be_visitor *visitor) { diff --git a/TAO/TAO_IDL/be/be_attribute.cpp b/TAO/TAO_IDL/be/be_attribute.cpp index fe7f4e604bf..e13b6947ebd 100644 --- a/TAO/TAO_IDL/be/be_attribute.cpp +++ b/TAO/TAO_IDL/be/be_attribute.cpp @@ -19,11 +19,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_attribute.h" +#include "be_visitor.h" -ACE_RCSID(be, be_attribute, "$Id$") +ACE_RCSID (be, + be_attribute, + "$Id$") be_attribute::be_attribute (void) { diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index 4d4cd300709..7100402a37f 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -16,11 +16,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_codegen, "$Id$") +#include "be_codegen.h" +#include "be_helper.h" +#include "be_visitor_factory.h" +#include "be_stream_factory.h" +#include "be_extern.h" +#include "global_extern.h" +#include "utl_string.h" +#include "idl_defines.h" + +ACE_RCSID (be, + be_codegen, + "$Id$") TAO_IDL_BE_Export TAO_CodeGen *tao_cg = 0; @@ -57,6 +64,11 @@ TAO_CodeGen::~TAO_CodeGen (void) delete this->client_inline_; delete this->server_inline_; delete this->server_template_inline_; +#if !defined (linux) && !defined (__QNX__) + // This causes a seg fault on Linux RH 5.1. Let it leak . . . + delete this->gperf_input_stream_; +#endif /* ! linux */ + delete [] this->gperf_input_filename_; this->curr_os_ = 0; // delete this->visitor_factory_; } @@ -135,6 +147,10 @@ TAO_CodeGen::start_client_header (const char *fname) } else { + *this->client_header_ << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the #ident string, if any. this->gen_ident_string (this->client_header_); @@ -295,6 +311,10 @@ TAO_CodeGen::start_client_stubs (const char *fname) return -1; } + *this->client_stubs_ << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ident string, if any. this->gen_ident_string (this->client_stubs_); @@ -409,6 +429,10 @@ TAO_CodeGen::start_server_header (const char *fname) } else { + *this->server_header_ << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ident string, if any. this->gen_ident_string (this->server_header_); @@ -568,6 +592,11 @@ TAO_CodeGen::start_server_template_header (const char *fname) } else { + *this->server_template_header_ << be_nl << "// TAO_IDL - Generated from" + << be_nl + << "// " << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ident string, if any. this->gen_ident_string (this->server_template_header_); @@ -630,6 +659,10 @@ TAO_CodeGen::start_server_skeletons (const char *fname) return -1; } + *this->server_skeletons_ << be_nl << "// TAO_IDL - Generated from " + << be_nl << "// " << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ident string, if any. this->gen_ident_string (this->server_skeletons_); @@ -732,6 +765,11 @@ TAO_CodeGen::start_server_template_skeletons (const char *fname) } else { + *this->server_template_skeletons_ << be_nl << "// TAO_IDL - Generated from " + << be_nl << "// " + << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ident string, if any. this->gen_ident_string (this->server_template_skeletons_); @@ -865,6 +903,11 @@ TAO_CodeGen::start_implementation_header (const char *fname) } else { + *this->implementation_header_ << be_nl << "// TAO_IDL - Generated from " + << be_nl << "// " + << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ident string, if any. this->gen_ident_string (this->implementation_header_); @@ -923,6 +966,11 @@ TAO_CodeGen::start_implementation_skeleton (const char *fname) } else { + *this->implementation_skeleton_ << be_nl << "// TAO_IDL - Generated from " + << be_nl << "// " + << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ident string, if any. this->gen_ident_string (this->implementation_skeleton_); @@ -950,6 +998,10 @@ TAO_CodeGen::end_client_header (void) { // Generate the <<= and >>= operators here. + *this->client_header_ << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ + << be_nl; + // Insert the code to include the inline file. *this->client_header_ << "\n#if defined (__ACE_INLINE__)\n"; *this->client_header_ << "#include \"" @@ -982,6 +1034,10 @@ TAO_CodeGen::end_client_header (void) int TAO_CodeGen::end_server_header (void) { + *this->server_header_ << be_nl << "// TAO_IDL - Generated from " + << be_nl << "// " << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Insert the template header. if (be_global->gen_tie_classes ()) { @@ -1074,6 +1130,11 @@ TAO_CodeGen::end_implementation_header (const char *fname) int TAO_CodeGen::end_server_template_header (void) { + *this->server_template_header_ << be_nl << "// TAO_IDL - Generated from " + << be_nl << "// " + << __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Insert the code to include the inline file. *this->server_template_header_ << "\n#if defined (__ACE_INLINE__)\n"; *this->server_template_header_ @@ -1166,8 +1227,8 @@ TAO_CodeGen::gperf_input_stream (void) void TAO_CodeGen::gperf_input_filename (char *filename) { - delete [] this->gperf_input_filename_; - this->gperf_input_filename_ = ACE::strnew (filename); + delete [] this->gperf_input_filename_; + this->gperf_input_filename_ = filename; } char * @@ -1203,9 +1264,7 @@ TAO_CodeGen::node (void) void TAO_CodeGen::config_visitor_factory (void) { - // We have removed interpreted marshaling from TAO, so - // TAO_INTERPRETIVE_VISITOR_FACTORY is no more. - this->visitor_factory_ = TAO_COMPILED_VISITOR_FACTORY::instance (); + this->visitor_factory_ = TAO_VISITOR_FACTORY::instance (); } void @@ -1292,3 +1351,4 @@ TAO_CodeGen::gen_standard_include (TAO_OutStream *stream, << included_file << end_delimiter << "\n"; } + diff --git a/TAO/TAO_IDL/be/be_component.cpp b/TAO/TAO_IDL/be/be_component.cpp new file mode 100644 index 00000000000..96d6ee8ebcf --- /dev/null +++ b/TAO/TAO_IDL/be/be_component.cpp @@ -0,0 +1,91 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_component.cpp +// +// = DESCRIPTION +// Extension of class AST_Component that provides additional means for C++ +// mapping of an interface. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_component.h" +#include "be_visitor.h" + +ACE_RCSID (be, + be_component, + "$Id$") + +be_component::be_component (void) +{ + this->size_type (AST_Type::VARIABLE); + this->has_constructor (I_TRUE); +} + +be_component::be_component (UTL_ScopedName *n, + AST_Component *base_component, + AST_Interface **supports, + long n_supports, + AST_Interface **supports_flat, + long n_supports_flat) + : be_interface (n, + supports, + n_supports, + supports_flat, + n_supports_flat, + I_TRUE, + I_FALSE), + AST_Component (n, + base_component, + supports, + n_supports, + supports_flat, + n_supports_flat), + AST_Interface (n, + supports, + n_supports, + supports_flat, + n_supports_flat, + I_TRUE, + I_FALSE), + AST_Type (AST_Decl::NT_component, + n), + AST_Decl (AST_Decl::NT_component, + n), + UTL_Scope (AST_Decl::NT_component), + COMMON_Base (I_TRUE, + I_FALSE) +{ + this->size_type (AST_Type::VARIABLE); + this->has_constructor (I_TRUE); +} + +be_component::~be_component (void) +{ +} + +void +be_component::destroy () +{ + this->be_interface::destroy (); + this->AST_Component::destroy (); +} + +int +be_component::accept (be_visitor *visitor) +{ + return visitor->visit_component (this); +} + +// Narrowing. +IMPL_NARROW_METHODS2 (be_component, be_interface, AST_Component); +IMPL_NARROW_FROM_DECL (be_component); +IMPL_NARROW_FROM_SCOPE (be_component); diff --git a/TAO/TAO_IDL/be/be_component_fwd.cpp b/TAO/TAO_IDL/be/be_component_fwd.cpp new file mode 100644 index 00000000000..4b0f4b289b0 --- /dev/null +++ b/TAO/TAO_IDL/be/be_component_fwd.cpp @@ -0,0 +1,64 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_component_fwd.cpp +// +// = DESCRIPTION +// Extension of class AST_ComponentFwd that provides additional means for C++ +// mapping of a forward declared component. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_component_fwd.h" +#include "be_visitor.h" + +ACE_RCSID (be, + be_component_fwd, + "$Id$") + +be_component_fwd::be_component_fwd (void) +{ + this->size_type (AST_Type::VARIABLE); +} + +be_component_fwd::be_component_fwd (AST_Interface *dummy, + UTL_ScopedName *n) + : be_interface_fwd (dummy, + n), + AST_ComponentFwd (dummy, + n), + AST_InterfaceFwd (dummy, + n), + AST_Decl (AST_Decl::NT_component_fwd, + n) +{ + this->size_type (AST_Type::VARIABLE); +} + +be_component_fwd::~be_component_fwd (void) +{ +} + +void +be_component_fwd::destroy (void) +{ + this->AST_ComponentFwd::destroy (); +} + +int +be_component_fwd::accept (be_visitor *visitor) +{ + return visitor->visit_component_fwd (this); +} + +// Narrowing +IMPL_NARROW_METHODS2 (be_component_fwd, AST_ComponentFwd, be_interface_fwd) +IMPL_NARROW_FROM_DECL (be_component_fwd) diff --git a/TAO/TAO_IDL/be/be_constant.cpp b/TAO/TAO_IDL/be/be_constant.cpp index 96bf7c9c6ad..ef6b810c35e 100644 --- a/TAO/TAO_IDL/be/be_constant.cpp +++ b/TAO/TAO_IDL/be/be_constant.cpp @@ -19,15 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_constant.h" +#include "be_visitor.h" +#include "utl_scope.h" +#include "nr_extern.h" -ACE_RCSID(be, be_constant, "$Id$") +ACE_RCSID (be, + be_constant, + "$Id$") be_constant::be_constant (void) { - this->size_type (be_decl::FIXED); } be_constant::be_constant (AST_Expression::ExprType et, @@ -39,52 +41,6 @@ be_constant::be_constant (AST_Expression::ExprType et, AST_Decl (AST_Decl::NT_const, n) { - this->size_type (be_decl::FIXED); -} - -const char * -be_constant::exprtype_to_string (void) -{ - switch (this->et ()) - { - case AST_Expression::EV_short: - return "CORBA::Short"; - case AST_Expression::EV_ushort: - return "CORBA::UShort"; - case AST_Expression::EV_long: - return "CORBA::Long"; - case AST_Expression::EV_ulong: - return "CORBA::ULong"; - case AST_Expression::EV_float: - return "CORBA::Float"; - case AST_Expression::EV_double: - return "CORBA::Double"; - case AST_Expression::EV_char: - return "CORBA::Char"; - case AST_Expression::EV_octet: - return "CORBA::Octet"; - case AST_Expression::EV_bool: - return "CORBA::Boolean"; - case AST_Expression::EV_string: - return "char *const"; - case AST_Expression::EV_any: - return "CORBA::Any"; - case AST_Expression::EV_void: - return "void"; - case AST_Expression::EV_none: - return "none"; - case AST_Expression::EV_longlong: - return "CORBA::LongLong"; - case AST_Expression::EV_ulonglong: - return "CORBA::ULongLong"; - case AST_Expression::EV_wchar: - return "CORBA::WChar"; - case AST_Expression::EV_wstring: - return "CORBA::WChar *const"; - case AST_Expression::EV_longdouble: - return NULL; - } - return NULL; } int @@ -93,6 +49,13 @@ be_constant::accept (be_visitor *visitor) return visitor->visit_constant (this); } +void +be_constant::destroy (void) +{ + this->AST_Constant::destroy (); + this->be_decl::destroy (); +} + // Narrowing IMPL_NARROW_METHODS2 (be_constant, AST_Constant, be_decl) IMPL_NARROW_FROM_DECL (be_constant) diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index 99411cd454a..93c29cf2de7 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -19,11 +19,25 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_decl, "$Id$") +#include "be_decl.h" +#include "be_scope.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_module.h" +#include "be_root.h" +#include "be_exception.h" +#include "be_structure.h" +#include "be_union.h" +#include "be_enum.h" +#include "be_operation.h" +#include "be_factory.h" +#include "be_sequence.h" +#include "be_visitor.h" +#include "utl_identifier.h" + +ACE_RCSID (be, + be_decl, + "$Id$") // Default Constructor be_decl::be_decl (void) @@ -39,11 +53,7 @@ be_decl::be_decl (void) cli_stub_any_op_gen_ (I_FALSE), cli_hdr_cdr_op_gen_ (I_FALSE), cli_stub_cdr_op_gen_ (I_FALSE), - cli_inline_cdr_op_gen_ (I_FALSE), - cli_inline_cdr_decl_gen_ (I_FALSE), - flat_name_ (0), - size_type_ (be_decl::SIZE_UNKNOWN), - has_constructor_ (I_FALSE) + cli_inline_cdr_op_gen_ (I_FALSE) { } @@ -64,10 +74,7 @@ be_decl::be_decl (AST_Decl::NodeType type, cli_stub_any_op_gen_ (I_FALSE), cli_hdr_cdr_op_gen_ (I_FALSE), cli_stub_cdr_op_gen_ (I_FALSE), - cli_inline_cdr_op_gen_ (I_FALSE), - flat_name_ (0), - size_type_ (be_decl::SIZE_UNKNOWN), - has_constructor_ (I_FALSE) + cli_inline_cdr_op_gen_ (I_FALSE) { } @@ -76,40 +83,6 @@ be_decl::~be_decl (void) { } -// Return our size type. -be_decl::SIZE_TYPE -be_decl::size_type (void) -{ - if (this->size_type_ == be_decl::SIZE_UNKNOWN) - { - (void) this->compute_size_type (); - } - - return this->size_type_; -} - -// Set our size type and that of all our ancestors. -void -be_decl::size_type (be_decl::SIZE_TYPE st) -{ - // Precondition - you cannot set somebody's sizetype to unknown. - ACE_ASSERT (st != be_decl::SIZE_UNKNOWN); - - // Size type can be VARIABLE or FIXED. - if (this->size_type_ == be_decl::SIZE_UNKNOWN) // not set yet - { - this->size_type_ = st; // set it - } - else if ((this->size_type_ == be_decl::FIXED) - && (st == be_decl::VARIABLE)) - { - // Once we are VARIABLE, we cannot be FIXED. But if we were FIXED and then - // get overwritten to VARIABLE, it is fine. Such a situation occurs only - // when setting the sizes of structures and unions. - this->size_type_ = st; - } -} - void be_decl::compute_full_name (const char *prefix, const char *suffix, @@ -169,108 +142,6 @@ be_decl::compute_full_name (const char *prefix, name = result_str.rep (); } - -const char* -be_decl::flat_name (void) -{ - if (!this->flat_name_) - { - this->compute_flat_name (); - } - - return this->flat_name_; -} - - -// Compute stringified flattened fully scoped name. -void -be_decl::compute_flat_name (void) -{ - if (this->flat_name_ != 0) - { - return; - } - else - { - long namelen = 0; - long first = I_TRUE; - long second = I_FALSE; - char *item_name = 0; - - // In the first loop, compute the total length. - for (UTL_IdListActiveIterator i (this->name ()); - !i.is_done (); - i.next ()) - { - if (!first) - { - namelen += 1; // for "_" - } - else if (second) - { - first = second = I_FALSE; - } - - // Print the identifier. - item_name = i.item ()->get_string (); - namelen += ACE_OS::strlen (item_name); - - if (first) - { - if (ACE_OS::strcmp (item_name, "") != 0) - { - // Does not start with a "". - first = I_FALSE; - } - else - { - second = I_TRUE; - } - } - } - - ACE_NEW (this->flat_name_, - char[namelen + 1]); - - this->flat_name_[0] = '\0'; - first = I_TRUE; - second = I_FALSE; - - for (UTL_IdListActiveIterator j (this->name ()); - !j.is_done (); - j.next ()) - { - if (!first) - { - ACE_OS::strcat (this->flat_name_, "_"); - } - else if (second) - { - first = second = I_FALSE; - } - - // Print the identifier. - item_name = j.item ()->get_string (); - ACE_OS::strcat (this->flat_name_, item_name); - - if (first) - { - if (ACE_OS::strcmp (item_name, "") != 0) - { - // Does not start with a "". - first = I_FALSE; - } - else - { - second = I_TRUE; - } - } - } - } -} - - - void be_decl::compute_flat_name (const char *prefix, const char *suffix, @@ -336,35 +207,7 @@ be_decl::compute_flat_name (const char *prefix, void be_decl::destroy (void) { - if (this->flat_name_ != 0) - { - delete [] this->flat_name_; - this->flat_name_ = 0; - } -} - -idl_bool -be_decl::is_nested (void) -{ - be_decl *d; - - d = be_scope::narrow_from_scope (this->defined_in ())->decl (); - - // If we have an outermost scope and if that scope is not that of the Root, - // then we are defined at some nesting level. - if (d != 0 && d->node_type () != AST_Decl::NT_root) - { - return I_TRUE; - } - - return I_FALSE; -} - -// Compute the size type of the node in question -int -be_decl::compute_size_type (void) -{ - return 0; + this->AST_Decl::destroy (); } // Return the scope created by this node (if one exists, else NULL). @@ -579,24 +422,6 @@ be_decl::accept (be_visitor *visitor) return visitor->visit_decl (this); } -idl_bool -be_decl::has_constructor (void) -{ - return this->has_constructor_; -} - -void -be_decl::has_constructor (idl_bool value) -{ - // Similarly to be_decl::size_type_, once this - // gets set to I_TRUE, we don't want it to - // change back. - if (this->has_constructor_ == 0) - { - this->has_constructor_ = value; - } -} - // Narrowing methods. IMPL_NARROW_METHODS1 (be_decl, AST_Decl) IMPL_NARROW_FROM_DECL (be_decl) diff --git a/TAO/TAO_IDL/be/be_enum.cpp b/TAO/TAO_IDL/be/be_enum.cpp index 51b02972995..93adad15665 100644 --- a/TAO/TAO_IDL/be/be_enum.cpp +++ b/TAO/TAO_IDL/be/be_enum.cpp @@ -19,15 +19,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_enum.h" +#include "be_visitor.h" -ACE_RCSID(be, be_enum, "$Id$") +ACE_RCSID (be, + be_enum, + "$Id$") be_enum::be_enum (void) { - this->size_type (be_decl::FIXED); + this->size_type (AST_Type::FIXED); } be_enum::be_enum (UTL_ScopedName *n, @@ -42,15 +43,17 @@ be_enum::be_enum (UTL_ScopedName *n, COMMON_Base (local, abstract) { - this->size_type (be_decl::FIXED); + this->size_type (AST_Type::FIXED); } void be_enum::destroy (void) { // Call the destroy methods of our base classes. - be_scope::destroy (); -// be_type::destroy (); + // No need to call be_scope::destroy(). It has no + // allocated members, and AST_Enum::destroy() will + // call UTL_Scope::destroy(). + this->AST_Enum::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_enum_val.cpp b/TAO/TAO_IDL/be/be_enum_val.cpp index 84f0b1b7953..a0fe6574b54 100644 --- a/TAO/TAO_IDL/be/be_enum_val.cpp +++ b/TAO/TAO_IDL/be/be_enum_val.cpp @@ -19,11 +19,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_enum_val.h" +#include "be_visitor.h" -ACE_RCSID(be, be_enum_val, "$Id$") +ACE_RCSID (be, + be_enum_val, + "$Id$") be_enum_val::be_enum_val (void) { @@ -33,7 +34,7 @@ be_enum_val::be_enum_val (unsigned long v, UTL_ScopedName *n) : AST_Constant (AST_Expression::EV_ulong, AST_Decl::NT_enum_val, - new AST_Expression(v), + new AST_Expression (v), n), AST_Decl (AST_Decl::NT_enum_val, n) @@ -46,11 +47,11 @@ be_enum_val::accept (be_visitor *visitor) return visitor->visit_enum_val (this); } -int -be_enum_val::compute_size_type (void) +void +be_enum_val::destroy (void) { - this->size_type_ = be_decl::FIXED; - return 0; + this->AST_EnumVal::destroy (); + this->be_decl::destroy (); } // Narrowing diff --git a/TAO/TAO_IDL/be/be_exception.cpp b/TAO/TAO_IDL/be/be_exception.cpp index 1df3a76eeec..ebd3592ea33 100644 --- a/TAO/TAO_IDL/be/be_exception.cpp +++ b/TAO/TAO_IDL/be/be_exception.cpp @@ -20,15 +20,16 @@ // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_exception.h" +#include "be_visitor.h" -ACE_RCSID(be, be_exception, "$Id$") +ACE_RCSID (be, + be_exception, + "$Id$") be_exception::be_exception (void) { - this->size_type (be_decl::VARIABLE); // always the case + this->size_type (AST_Type::VARIABLE); // always the case } be_exception::be_exception (UTL_ScopedName *n, @@ -45,7 +46,7 @@ be_exception::be_exception (UTL_ScopedName *n, abstract) { // Always the case. - this->size_type (be_decl::VARIABLE); + this->size_type (AST_Type::VARIABLE); } void diff --git a/TAO/TAO_IDL/be/be_expression.cpp b/TAO/TAO_IDL/be/be_expression.cpp index 1510eb257cf..a8b7838099f 100644 --- a/TAO/TAO_IDL/be/be_expression.cpp +++ b/TAO/TAO_IDL/be/be_expression.cpp @@ -19,11 +19,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_expression.h" +#include "be_visitor.h" -ACE_RCSID(be, be_expression, "$Id$") +ACE_RCSID (be, + be_expression, + "$Id$") be_expression::be_expression (UTL_ScopedName *n) : AST_Expression (n) diff --git a/TAO/TAO_IDL/be/be_factory.cpp b/TAO/TAO_IDL/be/be_factory.cpp index 0729b1872eb..d09510860f6 100644 --- a/TAO/TAO_IDL/be/be_factory.cpp +++ b/TAO/TAO_IDL/be/be_factory.cpp @@ -19,11 +19,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_factory.h" +#include "be_visitor.h" -ACE_RCSID(be, be_factory, "$Id$") +ACE_RCSID (be, + be_factory, + "$Id$") be_factory::be_factory (void) { diff --git a/TAO/TAO_IDL/be/be_field.cpp b/TAO/TAO_IDL/be/be_field.cpp index 2eeaaba83ff..76b8aece9f0 100644 --- a/TAO/TAO_IDL/be/be_field.cpp +++ b/TAO/TAO_IDL/be/be_field.cpp @@ -19,11 +19,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_field.h" +#include "be_visitor.h" +#include "be_type.h" +#include "ace/Log_Msg.h" -ACE_RCSID(be, be_field, "$Id$") +ACE_RCSID (be, + be_field, + "$Id$") be_field::be_field (void) { @@ -42,29 +45,6 @@ be_field::be_field (AST_Type *ft, { } -// Compute the size type of the node in question. -int -be_field::compute_size_type (void) -{ - be_type *type = be_type::narrow_from_decl (this->field_type ()); - - if (type == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_field::compute_size_type - " - "bad field type\n"), -1); - } - - // Our size type is the same as our type. - this->size_type (type->size_type ()); // As a side effect, will also update - // the size type of parent. - - // While we're here, take care of has_constructor. - this->has_constructor (type->has_constructor ()); - - return 0; -} - int be_field::accept (be_visitor *visitor) { diff --git a/TAO/TAO_IDL/be/be_generator.cpp b/TAO/TAO_IDL/be/be_generator.cpp index 787cfa85bdb..9d9cf6cfce4 100644 --- a/TAO/TAO_IDL/be/be_generator.cpp +++ b/TAO/TAO_IDL/be/be_generator.cpp @@ -69,12 +69,43 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // This implements the same protocol as AST_Generator but creates instances // of the BE-subclassed classes instead of of AST classes. -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_generator.h" +#include "be_root.h" +#include "be_predefined_type.h" +#include "be_module.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_component.h" +#include "be_component_fwd.h" +#include "be_home.h" +#include "be_union.h" +#include "be_union_fwd.h" +#include "be_structure.h" +#include "be_structure_fwd.h" +#include "be_exception.h" +#include "be_operation.h" +#include "be_enum.h" +#include "be_field.h" +#include "be_argument.h" +#include "be_attribute.h" +#include "be_union_branch.h" +#include "be_union_label.h" +#include "be_constant.h" +#include "be_expression.h" +#include "be_enum_val.h" +#include "be_array.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_typedef.h" +#include "be_native.h" +#include "be_factory.h" +#include "utl_identifier.h" +#include "nr_extern.h" #include "ace/config-all.h" -ACE_RCSID(be, be_generator, "$Id$") +ACE_RCSID (be, + be_generator, + "$Id$") AST_Root * be_generator::create_root (UTL_ScopedName *n) @@ -200,50 +231,144 @@ be_generator::create_interface_fwd (UTL_ScopedName *n, idl_bool local, idl_bool abstract) { + AST_Interface *dummy = this->create_interface (n, + 0, + -1, + 0, + 0, + local, + abstract); + be_interface_fwd *retval = 0; ACE_NEW_RETURN (retval, - be_interface_fwd (this->create_interface (n, - 0, - -1, - 0, - 0, - local, - abstract), + be_interface_fwd (dummy, n), 0); return retval; } -AST_Interface * +AST_ValueType * be_generator::create_valuetype (UTL_ScopedName *n, - AST_Interface **ih, - long nih) + AST_Interface **inherits, + long n_inherits, + AST_ValueType *inherits_concrete, + AST_Interface **inherits_flat, + long n_inherits_flat, + AST_Interface **supports, + long n_supports, + AST_Interface *supports_concrete, + idl_bool abstract, + idl_bool truncatable) { be_valuetype *retval = 0; ACE_NEW_RETURN (retval, be_valuetype (n, - ih, - nih), + inherits, + n_inherits, + inherits_concrete, + inherits_flat, + n_inherits_flat, + supports, + n_supports, + supports_concrete, + abstract, + truncatable), 0); return retval; } -AST_InterfaceFwd * -be_generator::create_valuetype_fwd (UTL_ScopedName *n) +AST_ValueTypeFwd * +be_generator::create_valuetype_fwd (UTL_ScopedName *n, + idl_bool abstract) { + AST_ValueType *dummy = this->create_valuetype (n, + 0, + -1, + 0, + 0, + 0, + 0, + 0, + 0, + abstract, + 0); + be_valuetype_fwd *retval = 0; ACE_NEW_RETURN (retval, - be_valuetype_fwd (this->create_valuetype (n, - 0, - -1), + be_valuetype_fwd (dummy, + n), + 0); + + return retval; +} + +AST_Component * +be_generator::create_component (UTL_ScopedName *n, + AST_Component *base_component, + AST_Interface **supports, + long n_supports, + AST_Interface **supports_flat, + long n_supports_flat) +{ + be_component *retval = 0; + ACE_NEW_RETURN (retval, + be_component (n, + base_component, + supports, + n_supports, + supports_flat, + n_supports_flat), + 0); + + return retval; +} + +AST_ComponentFwd * +be_generator::create_component_fwd (UTL_ScopedName *n) +{ + AST_Component *dummy = this->create_component (n, + 0, + 0, + -1, + 0, + 0); + + be_component_fwd *retval = 0; + ACE_NEW_RETURN (retval, + be_component_fwd (dummy, n), 0); return retval; } +AST_Home * +be_generator::create_home (UTL_ScopedName *n, + AST_Home *base_home, + AST_Component *managed_component, + AST_ValueType *primary_key, + AST_Interface **supports, + long n_supports, + AST_Interface **supports_flat, + long n_supports_flat) +{ + be_home *retval = 0; + ACE_NEW_RETURN (retval, + be_home (n, + base_home, + managed_component, + primary_key, + supports, + n_supports, + supports_flat, + n_supports_flat), + 0); + + return retval; +} + AST_Exception * be_generator::create_exception (UTL_ScopedName *n, idl_bool local, @@ -274,6 +399,17 @@ be_generator::create_structure (UTL_ScopedName *n, return retval; } +AST_StructureFwd * +be_generator::create_structure_fwd (UTL_ScopedName *n) +{ + be_structure_fwd *retval = 0; + ACE_NEW_RETURN (retval, + be_structure_fwd (n), + 0); + + return retval; +} + AST_Enum * be_generator::create_enum (UTL_ScopedName *n, idl_bool local, @@ -374,6 +510,17 @@ be_generator::create_union (AST_ConcreteType *dt, return retval; } +AST_UnionFwd * +be_generator::create_union_fwd (UTL_ScopedName *n) +{ + be_union_fwd *retval = 0; + ACE_NEW_RETURN (retval, + be_union_fwd (n), + 0); + + return retval; +} + AST_UnionBranch * be_generator::create_union_branch (UTL_LabelList *ll, AST_Type *ft, @@ -581,6 +728,7 @@ be_generator::create_array (UTL_ScopedName *n, AST_Sequence * be_generator::create_sequence (AST_Expression *v, AST_Type *bt, + UTL_ScopedName *n, idl_bool local, idl_bool abstract) { @@ -588,6 +736,7 @@ be_generator::create_sequence (AST_Expression *v, ACE_NEW_RETURN (retval, be_sequence (v, bt, + n, local, abstract), 0); @@ -598,9 +747,16 @@ be_generator::create_sequence (AST_Expression *v, AST_String * be_generator::create_string (AST_Expression *v) { + Identifier id ("string"); + UTL_ScopedName n (&id, + 0); + be_string *retval = 0; ACE_NEW_RETURN (retval, - be_string (v), + be_string (AST_Decl::NT_string, + &n, + v, + 1), 0); return retval; @@ -609,9 +765,20 @@ be_generator::create_string (AST_Expression *v) AST_String * be_generator::create_wstring (AST_Expression *v) { + Identifier id (sizeof (ACE_CDR::WChar) == 1 + ? "string" + : "wstring"); + UTL_ScopedName n (&id, + 0); + AST_Decl::NodeType nt = sizeof (ACE_CDR::WChar) == 1 + ? AST_Decl::NT_string + : AST_Decl::NT_wstring; + be_string *retval = 0; ACE_NEW_RETURN (retval, - be_string (v, + be_string (nt, + &n, + v, sizeof (ACE_CDR::WChar)), 0); diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp index 5db3572a94c..4e3730d6030 100644 --- a/TAO/TAO_IDL/be/be_global.cpp +++ b/TAO/TAO_IDL/be/be_global.cpp @@ -17,62 +17,92 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_global.h" +#include "utl_string.h" +#include "global_extern.h" +#include "ace/ACE.h" -ACE_RCSID(be, be_global, "$Id$") +ACE_RCSID (be, + be_global, + "$Id$") TAO_IDL_BE_Export BE_GlobalData *be_global = 0; BE_GlobalData::BE_GlobalData (void) - : changing_standard_include_files_ (1), - skel_export_macro_ (0), - skel_export_include_ (0), - stub_export_macro_ (0), - stub_export_include_ (0), - pch_include_ (0), - pre_include_ (0), - post_include_ (0), - client_hdr_ending_ (ACE::strnew ("C.h")), - client_stub_ending_ (ACE::strnew ("C.cpp")), - client_inline_ending_ (ACE::strnew ("C.i")), - server_hdr_ending_ (ACE::strnew ("S.h")), - implementation_hdr_ending_ (ACE::strnew ("I.h")), - implementation_skel_ending_ (ACE::strnew ("I.cpp")), - impl_class_prefix_ (ACE::strnew ("")), - impl_class_suffix_ (ACE::strnew ("_i")), - server_template_hdr_ending_ (ACE::strnew ("S_T.h")), - server_skeleton_ending_ (ACE::strnew ("S.cpp")), - server_template_skeleton_ending_ (ACE::strnew ("S_T.cpp")), - server_inline_ending_ (ACE::strnew ("S.i")), - server_template_inline_ending_ (ACE::strnew ("S_T.i")), - output_dir_ (0), - any_support_ (I_TRUE), - tc_support_ (I_TRUE), - obv_opt_accessor_ (0), - gen_impl_files_ (I_FALSE), - gen_copy_ctor_ (I_FALSE), - gen_assign_op_ (I_FALSE), - gen_thru_poa_collocation_ (I_TRUE), // Default is thru_poa. - gen_direct_collocation_ (I_FALSE), + : changing_standard_include_files_ (1), + skel_export_macro_ (0), + skel_export_include_ (0), + stub_export_macro_ (0), + stub_export_include_ (0), + pch_include_ (0), + pre_include_ (0), + post_include_ (0), + client_hdr_ending_ (ACE::strnew ("C.h")), + client_stub_ending_ (ACE::strnew ("C.cpp")), + client_inline_ending_ (ACE::strnew ("C.i")), + server_hdr_ending_ (ACE::strnew ("S.h")), + implementation_hdr_ending_ (ACE::strnew ("I.h")), + implementation_skel_ending_ (ACE::strnew ("I.cpp")), + impl_class_prefix_ (ACE::strnew ("")), + impl_class_suffix_ (ACE::strnew ("_i")), + server_template_hdr_ending_ (ACE::strnew ("S_T.h")), + server_skeleton_ending_ (ACE::strnew ("S.cpp")), + server_template_skeleton_ending_ (ACE::strnew ("S_T.cpp")), + server_inline_ending_ (ACE::strnew ("S.i")), + server_template_inline_ending_ (ACE::strnew ("S_T.i")), + output_dir_ (0), + any_support_ (I_TRUE), + tc_support_ (I_TRUE), + obv_opt_accessor_ (0), + gen_impl_files_ (I_FALSE), + gen_copy_ctor_ (I_FALSE), + gen_assign_op_ (I_FALSE), + gen_thru_poa_collocation_ (I_TRUE), // Default is thru_poa. + gen_direct_collocation_ (I_FALSE), #ifdef ACE_HAS_EXCEPTIONS - exception_support_ (I_TRUE), + exception_support_ (I_TRUE), #else - exception_support_ (I_FALSE), + exception_support_ (I_FALSE), #endif /* ACE_HAS_EXCEPTIONS */ - use_raw_throw_ (I_FALSE), - opt_tc_ (I_FALSE), - ami_call_back_ (I_FALSE), - gen_amh_classes_ (I_FALSE), - gen_tie_classes_ (I_TRUE), - gen_smart_proxies_ (I_FALSE), - lookup_strategy_ (TAO_PERFECT_HASH) + use_raw_throw_ (I_FALSE), + opt_tc_ (I_FALSE), + ami_call_back_ (I_FALSE), + gen_amh_classes_ (I_FALSE), + gen_tie_classes_ (I_TRUE), + gen_smart_proxies_ (I_FALSE), + gen_inline_constants_ (I_FALSE), + lookup_strategy_ (TAO_PERFECT_HASH) { } BE_GlobalData::~BE_GlobalData (void) { + delete this->client_hdr_ending_; + this->client_hdr_ending_ = 0; + delete this->client_stub_ending_; + this->client_stub_ending_ = 0; + delete this->client_inline_ending_; + this->client_inline_ending_ = 0; + delete this->server_hdr_ending_; + this->server_hdr_ending_ = 0; + delete this->implementation_hdr_ending_; + this->implementation_hdr_ending_ = 0; + delete this->implementation_skel_ending_; + this->implementation_skel_ending_ = 0; + delete this->impl_class_prefix_; + this->impl_class_prefix_ = 0; + delete this->impl_class_suffix_; + this->impl_class_suffix_ = 0; + delete this->server_template_hdr_ending_; + this->server_template_hdr_ending_ = 0; + delete this->server_skeleton_ending_; + this->server_skeleton_ending_ = 0; + delete this->server_template_skeleton_ending_; + this->server_template_skeleton_ending_ = 0; + delete this->server_inline_ending_; + this->server_inline_ending_ = 0; + delete this->server_template_inline_ending_; + this->server_template_inline_ending_ = 0; } // To switch between changing or non-changing standard include files @@ -301,7 +331,6 @@ BE_GlobalData::be_get_implementation_skel_fname (int base_name_only) base_name_only); } - const char * BE_GlobalData::be_get_server_template_hdr_fname (int base_name_only) { @@ -315,21 +344,12 @@ BE_GlobalData::be_get_server_skeleton_fname () return be_get_server_skeleton (idl_global->stripped_filename ()); } -/* -const char * -BE_GlobalData::be_get_implementation_hdr_fname () -{ - return be_get_implementation_hdr (idl_global->stripped_filename ()); -} -*/ - const char * BE_GlobalData::be_get_implementation_skeleton_fname () { return be_get_implementation_skel (idl_global->stripped_filename ()); } - const char * BE_GlobalData::be_get_server_template_skeleton_fname (int base_name_only) { @@ -508,7 +528,6 @@ BE_GlobalData::implementation_skel_ending (const char* s) this->implementation_skel_ending_ = ACE::strnew (s); } - void BE_GlobalData::impl_class_prefix (const char* s) { @@ -535,7 +554,6 @@ BE_GlobalData::implementation_hdr_ending (void) const return this->implementation_hdr_ending_; } - const char* BE_GlobalData::impl_class_suffix (void) const { @@ -548,8 +566,6 @@ BE_GlobalData::implementation_skel_ending (void) const return this->implementation_skel_ending_; } - - void BE_GlobalData::server_template_hdr_ending (const char* s) { @@ -635,7 +651,7 @@ BE_GlobalData::any_support (idl_bool val) } idl_bool -BE_GlobalData::any_support (void) +BE_GlobalData::any_support (void) const { return this->any_support_; } @@ -647,7 +663,7 @@ BE_GlobalData::tc_support (idl_bool val) } idl_bool -BE_GlobalData::tc_support (void) +BE_GlobalData::tc_support (void) const { return this->tc_support_; } @@ -659,7 +675,7 @@ BE_GlobalData::obv_opt_accessor (idl_bool val) } idl_bool -BE_GlobalData::obv_opt_accessor (void) +BE_GlobalData::obv_opt_accessor (void) const { return this->obv_opt_accessor_; } @@ -671,7 +687,7 @@ BE_GlobalData::gen_impl_files (idl_bool val) } idl_bool -BE_GlobalData::gen_impl_files (void) +BE_GlobalData::gen_impl_files (void) const { return this->gen_impl_files_; } @@ -683,7 +699,7 @@ BE_GlobalData::gen_copy_ctor (idl_bool val) } idl_bool -BE_GlobalData::gen_copy_ctor (void) +BE_GlobalData::gen_copy_ctor (void) const { return this->gen_copy_ctor_; } @@ -695,7 +711,7 @@ BE_GlobalData::gen_assign_op (idl_bool val) } idl_bool -BE_GlobalData::gen_assign_op (void) +BE_GlobalData::gen_assign_op (void) const { return this->gen_assign_op_; } @@ -707,7 +723,7 @@ BE_GlobalData::gen_thru_poa_collocation (idl_bool val) } idl_bool -BE_GlobalData::gen_thru_poa_collocation (void) +BE_GlobalData::gen_thru_poa_collocation (void) const { return this->gen_thru_poa_collocation_; } @@ -719,7 +735,7 @@ BE_GlobalData::gen_direct_collocation (idl_bool val) } idl_bool -BE_GlobalData::gen_direct_collocation (void) +BE_GlobalData::gen_direct_collocation (void) const { return this->gen_direct_collocation_; } @@ -731,7 +747,7 @@ BE_GlobalData::exception_support (idl_bool val) } idl_bool -BE_GlobalData::exception_support (void) +BE_GlobalData::exception_support (void) const { return this->exception_support_; } @@ -743,7 +759,7 @@ BE_GlobalData::use_raw_throw (idl_bool val) } idl_bool -BE_GlobalData::use_raw_throw (void) +BE_GlobalData::use_raw_throw (void) const { return this->use_raw_throw_; } @@ -755,7 +771,7 @@ BE_GlobalData::opt_tc (idl_bool val) } idl_bool -BE_GlobalData::opt_tc (void) +BE_GlobalData::opt_tc (void) const { return this->opt_tc_; } @@ -767,7 +783,7 @@ BE_GlobalData::ami_call_back (idl_bool val) } idl_bool -BE_GlobalData::ami_call_back (void) +BE_GlobalData::ami_call_back (void) const { return this->ami_call_back_; } @@ -779,7 +795,7 @@ BE_GlobalData::gen_amh_classes (idl_bool val) } idl_bool -BE_GlobalData::gen_amh_classes (void) +BE_GlobalData::gen_amh_classes (void) const { return this->gen_amh_classes_; } @@ -791,7 +807,7 @@ BE_GlobalData::gen_tie_classes (idl_bool val) } idl_bool -BE_GlobalData::gen_tie_classes (void) +BE_GlobalData::gen_tie_classes (void) const { return this->gen_tie_classes_; } @@ -803,12 +819,24 @@ BE_GlobalData::gen_smart_proxies (idl_bool val) } idl_bool -BE_GlobalData::gen_smart_proxies (void) +BE_GlobalData::gen_smart_proxies (void) const { return this->gen_smart_proxies_; } void +BE_GlobalData::gen_inline_constants (idl_bool val) +{ + this->gen_inline_constants_ = val; +} + +idl_bool +BE_GlobalData::gen_inline_constants (void) const +{ + return this->gen_inline_constants_; +} + +void BE_GlobalData::lookup_strategy (LOOKUP_STRATEGY s) { this->lookup_strategy_ = s; diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp index 8a853af2476..3c523bcb806 100644 --- a/TAO/TAO_IDL/be/be_helper.cpp +++ b/TAO/TAO_IDL/be/be_helper.cpp @@ -19,11 +19,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_helper.h" +#include "be_codegen.h" +#include "idl_defines.h" -ACE_RCSID(be, be_helper, "$Id$") +ACE_RCSID (be, + be_helper, + "$Id$") static const char copyright[] = "// -*- C++ -*-\n" @@ -69,7 +71,7 @@ const TAO_UNINDENT be_uidt_nl (1); // Methods of the TAO_OutStream class. TAO_OutStream::TAO_OutStream (void) - : fp_ (NULL), + : fp_ (0), indent_level_ (0) { } @@ -122,7 +124,7 @@ TAO_OutStream::open (const char *fname, } } -// set and get the stream type +// Set and get the stream type. void TAO_OutStream::stream_type (TAO_OutStream::STREAM_TYPE st) { diff --git a/TAO/TAO_IDL/be/be_home.cpp b/TAO/TAO_IDL/be/be_home.cpp new file mode 100644 index 00000000000..516ef8c6573 --- /dev/null +++ b/TAO/TAO_IDL/be/be_home.cpp @@ -0,0 +1,93 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_home.cpp +// +// = DESCRIPTION +// Extension of class AST_Home that provides additional means for C++ +// mapping of a component home. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_home.h" +#include "be_visitor.h" + +ACE_RCSID (be, + be_home, + "$Id$") + +be_home::be_home (void) +{ + this->size_type (AST_Type::VARIABLE); +} + +be_home::be_home (UTL_ScopedName *n, + AST_Home *base_home, + AST_Component *managed_component, + AST_ValueType *primary_key, + AST_Interface **supports, + long n_supports, + AST_Interface **supports_flat, + long n_supports_flat) + : be_interface (n, + supports, + n_supports, + supports_flat, + n_supports_flat, + I_FALSE, + I_FALSE), + AST_Home (n, + base_home, + managed_component, + primary_key, + supports, + n_supports, + supports_flat, + n_supports_flat), + AST_Interface (n, + supports, + n_supports, + supports_flat, + n_supports_flat, + I_FALSE, + I_FALSE), + AST_Type (AST_Decl::NT_home, + n), + AST_Decl (AST_Decl::NT_home, + n), + UTL_Scope (AST_Decl::NT_home), + COMMON_Base (I_FALSE, + I_FALSE) +{ + this->size_type (AST_Type::VARIABLE); +} + +be_home::~be_home (void) +{ +} + +void +be_home::destroy (void) +{ + this->be_interface::destroy (); + this->AST_Home::destroy (); +} + +int +be_home::accept (be_visitor *visitor) +{ + return visitor->visit_home (this); +} + +// Narrowing +IMPL_NARROW_METHODS2 (be_home, be_interface, AST_Home); +IMPL_NARROW_FROM_DECL (be_home); +IMPL_NARROW_FROM_SCOPE (be_home); diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 8828a82244b..b8b9b898df5 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -20,23 +20,35 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be_visitor_interface.h" -#include "be.h" +#include "be_interface.h" #include "be_interface_strategy.h" - -ACE_RCSID(be, be_interface, "$Id$") +#include "be_attribute.h" +#include "be_operation.h" +#include "be_visitor.h" +#include "be_helper.h" +#include "be_stream_factory.h" +#include "be_extern.h" +#include "utl_identifier.h" +#include "ast_generator.h" +#include "global_extern.h" +#include "idl_defines.h" +#include "nr_extern.h" +#include "ace/Process.h" + +ACE_RCSID (be, + be_interface, + "$Id$") // Default constructor. be_interface::be_interface (void) : skel_count_ (0), in_mult_inheritance_ (-1), - original_interface_ (0) + original_interface_ (0), + has_mixed_parentage_ (I_FALSE) { ACE_NEW (this->strategy_, be_interface_default_strategy (this)); - this->size_type (be_decl::VARIABLE); // Always the case. + this->size_type (AST_Type::VARIABLE); // Always the case. this->has_constructor (I_TRUE); // Always the case. } @@ -62,12 +74,19 @@ be_interface::be_interface (UTL_ScopedName *n, abstract), skel_count_ (0), in_mult_inheritance_ (-1), - original_interface_ (0) + original_interface_ (0), + has_mixed_parentage_ (I_FALSE) { ACE_NEW (this->strategy_, be_interface_default_strategy (this)); - this->size_type (be_decl::VARIABLE); // always the case + this->size_type (AST_Type::VARIABLE); // always the case this->has_constructor (I_TRUE); // always the case + + if (! abstract && this->node_type () == AST_Decl::NT_interface) + { + this->analyze_parentage (ih, + nih); + } } be_interface::~be_interface (void) @@ -443,9 +462,9 @@ be_interface::gen_def_ctors_helper (be_interface* node, static int first = 0; - if(node != base) + if (node != base) { - if(first) + if (first) { *os << be_global->impl_class_prefix () << base->flat_name () << be_global->impl_class_suffix () << " ()"; @@ -481,13 +500,43 @@ be_interface::gen_stub_ctor (TAO_OutStream *os) << "TAO_Stub *objref," << be_nl << "CORBA::Boolean _tao_collocated," << be_nl << "TAO_Abstract_ServantBase *servant" << be_uidt_nl - << ")" // constructor + << ")" << be_nl; - *os << ": CORBA_Object (objref, _tao_collocated, servant)" << be_uidt_nl; - *os << "{" << be_idt_nl + *os << ": CORBA_Object (objref, _tao_collocated, servant)"; + + if (this->has_mixed_parentage_) + { + *os << be_idt; + + int status = + this->traverse_inheritance_graph ( + be_interface::gen_abstract_init_helper, + os, + I_TRUE + ); + + if (status == -1) + { + ACE_ERROR ((LM_ERROR, + "be_interface::gen_stub_ctor - " + "inheritance graph traversal failed\n")); + } + + *os << "," << be_nl + << "CORBA_AbstractBase (objref, _tao_collocated, servant)" + << be_uidt << be_uidt; + } + else + { + *os << be_uidt; + } + + *os << be_nl << "{" << be_idt_nl << "this->" << this->flat_name () - << "_setup_collocation (_tao_collocated);" << be_uidt_nl; - *os << "}" << be_nl << be_nl; + << "_setup_collocation (_tao_collocated);"; + + *os << be_uidt_nl + << "}" << be_nl << be_nl; } } @@ -520,6 +569,9 @@ be_interface::gen_var_defn (char *interface_name) // Depending upon the data type, there are some differences which we account // for over here. + *ch << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *ch << "class " << be_global->stub_export_macro () << " " << namebuf << " : public TAO_Base_var" << be_nl; @@ -583,12 +635,30 @@ be_interface::gen_var_defn (char *interface_name) << "static " << interface_name << "_ptr tao_nil (void);" << be_nl << "static " << interface_name - << "_ptr tao_narrow (" << be_idt << be_idt_nl - << "CORBA::Object *" << be_nl - << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl - << ");" << be_uidt_nl - << "static CORBA::Object * tao_upcast (void *);" - << be_uidt_nl << be_nl; + << "_ptr tao_narrow (" << be_idt << be_idt_nl; + + if (this->is_abstract ()) + { + *ch << "CORBA::AbstractBase *" << be_nl; + } + else + { + *ch << "CORBA::Object *" << be_nl; + } + + *ch << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ");" << be_uidt_nl; + + if (this->is_abstract ()) + { + *ch << "static CORBA::AbstractBase * tao_upcast (void *);"; + } + else + { + *ch << "static CORBA::Object * tao_upcast (void *);"; + } + + *ch << be_uidt_nl << be_nl; // Private. *ch << "private:" << be_idt_nl; @@ -772,7 +842,8 @@ be_interface::gen_var_impl (char *interface_local_name, *cs << "return val;" << be_uidt_nl; *cs << "}" << be_nl << be_nl; - // Hooks for the global static functions used by non-defined interfaces. + // Hooks for the flat name global functions used by references to + // non-defined interfaces. *cs << "::" << interface_full_name << "_ptr" << be_nl << fname << "::tao_duplicate (" @@ -798,9 +869,18 @@ be_interface::gen_var_impl (char *interface_local_name, << "}" << be_nl << be_nl; *cs << "::" << interface_full_name << "_ptr" << be_nl - << fname << "::tao_narrow (" << be_idt << be_idt_nl - << "CORBA::Object *p" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl + << fname << "::tao_narrow (" << be_idt << be_idt_nl; + + if (this->is_abstract ()) + { + *cs << "CORBA::AbstractBase *p" << be_nl; + } + else + { + *cs << "CORBA::Object *p" << be_nl; + } + + *cs << "ACE_ENV_ARG_DECL" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl << "return ::" << interface_full_name @@ -808,8 +888,16 @@ be_interface::gen_var_impl (char *interface_local_name, << be_uidt_nl << "}" << be_nl << be_nl; - *cs << "CORBA::Object *" << be_nl - << fname << "::tao_upcast (void *src)" << be_nl + if (this->is_abstract ()) + { + *cs << "CORBA::AbstractBase *" << be_nl; + } + else + { + *cs << "CORBA::Object *" << be_nl; + } + + *cs << fname << "::tao_upcast (void *src)" << be_nl << "{" << be_idt_nl << interface_local_name << " **tmp =" << be_idt_nl << "ACE_static_cast (" << interface_local_name @@ -841,6 +929,9 @@ be_interface::gen_out_defn (char *interface_name) TAO_OutStream *ch = tao_cg->client_header (); + *ch << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the out definition (always in the client header) *ch << "class " << be_global->stub_export_macro () << " " << namebuf << be_nl; @@ -1013,13 +1104,22 @@ be_interface::gen_out_impl (char *interface_local_name, *cs << fname << "::operator-> (void)" << be_nl; *cs << "{" << be_idt_nl; *cs << "return this->ptr_;" << be_uidt_nl; - *cs << "}\n\n"; + *cs << "}" << be_nl << be_nl; + + *cs << "// *************************************************************" + << "\n\n"; return 0; } // **************************************************************** +TAO_IDL_Inheritance_Hierarchy_Worker::~TAO_IDL_Inheritance_Hierarchy_Worker ( + void + ) +{ +} + class TAO_IDL_Gen_OpTable_Worker : public TAO_IDL_Inheritance_Hierarchy_Worker { public: @@ -1046,7 +1146,8 @@ TAO_IDL_Gen_OpTable_Worker::emit (be_interface * /* derived_interface */, { // Generate entries for the derived class using the properties of its // ancestors. - return base_interface->gen_optable_entries (this->skeleton_name_, os); + be_interface *bi = be_interface::narrow_from_decl (base_interface); + return bi->gen_optable_entries (this->skeleton_name_, os); } int @@ -1059,19 +1160,33 @@ be_interface::gen_operation_table (const char *flat_name, case BE_GlobalData::TAO_DYNAMIC_HASH: { // Init the outstream appropriately. - TAO_OutStream *os = - this->strategy_->get_out_stream (); + TAO_OutStream *os = this->strategy_->get_out_stream (); // Start from current indentation level. os->indent (); // Start the table generation. *os << "static const TAO_operation_db_entry " << flat_name << - "_operations [] = {\n"; + "_operations [] = {" << be_nl; + os->incr_indent (0); + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + // Insert ourselves in the queue. + if (insert_queue.enqueue_tail (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interface::gen_operation_table - " + "error generating entries\n"), + -1); + } + // Traverse the graph. TAO_IDL_Gen_OpTable_Worker worker (skeleton_class_name); + if (this->traverse_inheritance_graph (worker, os) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -1080,24 +1195,22 @@ be_interface::gen_operation_table (const char *flat_name, } // Generate the skeleton for the is_a method. - os->indent (); *os << "{\"_is_a\", &" << skeleton_class_name - << "::_is_a_skel},\n"; + << "::_is_a_skel}," << be_nl; + this->skel_count_++; - os->indent (); *os << "{\"_non_existent\", &" << skeleton_class_name - << "::_non_existent_skel},\n"; + << "::_non_existent_skel}," << be_nl; + this->skel_count_++; - os->indent (); *os << "{\"_interface\", &" << skeleton_class_name - << "::_interface_skel}\n"; + << "::_interface_skel}" << be_uidt_nl; + this->skel_count_++; - os->decr_indent (); *os << "};\n" << be_nl; - *os << "static const CORBA::Long _tao_" << flat_name << "_optable_size = sizeof (ACE_Hash_Map_Entry<const char *," << " TAO_Skeleton>) * (" << (3 * this->skel_count_) @@ -1130,9 +1243,10 @@ be_interface::gen_operation_table (const char *flat_name, // Temp file name. char *temp_file = 0; ACE_NEW_RETURN (temp_file, - char [ACE_OS::strlen (idl_global->temp_dir ()) + - ACE_OS::strlen (flat_name) + - ACE_OS::strlen (".gperf") + 1], + char [ACE_OS::strlen (idl_global->temp_dir ()) + + ACE_OS::strlen (flat_name) + + ACE_OS::strlen (".gperf") + + 1], -1); ACE_OS::sprintf (temp_file, @@ -1158,8 +1272,7 @@ be_interface::gen_operation_table (const char *flat_name, // interface. // Retrieve the singleton instance to the outstream factory. - TAO_OutStream_Factory *factory = - TAO_OUTSTREAM_FACTORY::instance (); + TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); // Get a new instance for the temp file. TAO_OutStream *os = factory->make_outstream (); @@ -1192,8 +1305,22 @@ be_interface::gen_operation_table (const char *flat_name, // Add the gperf input header. this->gen_gperf_input_header (os); + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + // Insert ourselves in the queue. + if (insert_queue.enqueue_tail (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interface::gen_operation_table - " + "error generating entries\n"), + -1); + } + // Traverse the graph. TAO_IDL_Gen_OpTable_Worker worker (skeleton_class_name); + if (this->traverse_inheritance_graph (worker, os) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -1204,27 +1331,28 @@ be_interface::gen_operation_table (const char *flat_name, // Generate the skeleton for the is_a method. os->indent (); + *os << "_is_a, &" << skeleton_class_name - << "::_is_a_skel\n"; + << "::_is_a_skel" << be_nl; + this->skel_count_++; - os->indent (); *os << "_non_existent, &" << skeleton_class_name - << "::_non_existent_skel\n"; + << "::_non_existent_skel" << be_nl; + this->skel_count_++; - os->indent (); *os << "_component, &" << skeleton_class_name - << "::_component_skel\n"; + << "::_component_skel" << be_nl; this->skel_count_++; - os->indent (); *os << "_interface, &" << skeleton_class_name - << "::_interface_skel\n"; + << "::_interface_skel" << be_nl; + this->skel_count_++; // Input to the gperf is ready. Run gperf and get things @@ -1412,20 +1540,26 @@ be_interface::gen_optable_entries (const char *full_skeleton_name, return 0; } -// **************************************************************** - -class be_code_emitter_wrapper : public TAO_IDL_Inheritance_Hierarchy_Worker +void +be_interface::analyze_parentage (AST_Interface **parents, + long n_parents) { -public: - be_code_emitter_wrapper (be_interface::tao_code_emitter emitter); + for (long i = 0; i < n_parents; ++i) + { + if (parents[i]->is_abstract ()) + { + this->has_mixed_parentage_ = I_TRUE; + break; + } + } - virtual int emit (be_interface *derived_interface, - TAO_OutStream *output_stream, - be_interface *base_interface); + if (this->has_mixed_parentage_) + { + be_global->mixed_parentage_interfaces.enqueue_tail (this); + } +} -private: - be_interface::tao_code_emitter emitter_; -}; +// **************************************************************** be_code_emitter_wrapper:: be_code_emitter_wrapper (be_interface::tao_code_emitter emitter) @@ -1448,34 +1582,15 @@ be_code_emitter_wrapper::emit (be_interface *derived_interface, // out by the function passed as argument. int be_interface::traverse_inheritance_graph (be_interface::tao_code_emitter gen, - TAO_OutStream *os) + TAO_OutStream *os, + idl_bool abstract_paths_only) { - be_code_emitter_wrapper wrapper (gen); - - return this->traverse_inheritance_graph (wrapper, os); -} - -int -be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker &worker, - TAO_OutStream *os) -{ - // Queue data structure needed for breadth-first traversal of - // inheritance tree. - ACE_Unbounded_Queue <be_interface*> queue; - - // For a special case of a deeply nested inheritance graph and one specific - // way of inheritance in which a node that was already visited, - // but is not present in - // the queue, gets inserted at the tail. This situation arises when a node - // multiply inherits from two or more interfaces in which the first parent is - // higher up in the tree than the second parent. In addition, if the second - // parent turns out to be a child of the first . - - // Queue of dequeued nodes to be searched for the above case. - ACE_Unbounded_Queue <be_interface*> del_queue; + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); // Insert ourselves in the queue. - if (queue.enqueue_tail (this) == -1) + if (insert_queue.enqueue_tail (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::traverse_inheritance_graph - " @@ -1483,19 +1598,33 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & -1); } + be_code_emitter_wrapper wrapper (gen); + + return this->traverse_inheritance_graph (wrapper, + os, + abstract_paths_only); +} + +int +be_interface::traverse_inheritance_graph ( + TAO_IDL_Inheritance_Hierarchy_Worker &worker, + TAO_OutStream *os, + idl_bool abstract_paths_only + ) +{ // Do until queue is empty. - while (!queue.is_empty ()) + while (!this->insert_queue.is_empty ()) { - be_interface *bi; // element inside the queue + AST_Interface *intf; // element inside the queue // Use breadth-first strategy i.e., first generate entries for ourselves, // followed by nodes that we immediately inherit from, and so on. In the // process make sure that we do not generate code for the same node more - // than once. Such a case may arise due to multiple inheritance forming a - // diamond like inheritance graph. + // than once. Such a case may arise due to multiple inheritance forming + // a diamond-like inheritance graph. // Dequeue the element at the head of the queue. - if (queue.dequeue_head (bi)) + if (this->insert_queue.dequeue_head (intf)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::traverse_graph - " @@ -1504,7 +1633,7 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & } // Insert the dequeued element in the del_queue. - if (del_queue.enqueue_tail (bi) == -1) + if (this->del_queue.enqueue_tail (intf) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::traverse_graph - " @@ -1512,6 +1641,8 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & -1); } + be_interface *bi = be_interface::narrow_from_decl (intf); + // Use the helper method to generate code for ourself using the // properties of the element dequeued. For the first iteration, the // element dequeued and "this" will be the same i.e., ourselves. @@ -1523,83 +1654,29 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & -1); } + long i; + // Now check if the dequeued element has any ancestors. If yes, insert // them inside the queue making sure that there are no duplicates. - for (long i = 0; i < bi->n_inherits (); i++) + for (i = 0; i < bi->n_inherits (); ++i) { // Retrieve the next parent from which the dequeued element inherits. - be_interface *parent = - be_interface::narrow_from_decl (bi->inherits ()[i]); + AST_Interface *parent = bi->inherits ()[i]; if (parent == 0) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::gen_server_skeletons -" + "(%N:%l) be_interface::traverse_graph -" " bad inherited interface\n"), -1); } - // Now insert this node at the tail of the queue, but make sure that - // it doesn't already exist in the queue. - int found = 0; - - // Initialize an iterator to search the queue for duplicates. - for (ACE_Unbounded_Queue_Iterator<be_interface*> q_iter (queue); - !q_iter.done (); - (void) q_iter.advance ()) - { - // Queue element. - be_interface **temp; - - (void) q_iter.next (temp); - if (!ACE_OS::strcmp (parent->full_name (), - (*temp)->full_name ())) - { - // We exist in this queue and cannot be inserted. - found = 1; - } - if (found) - { - break; - } - } - - // Initialize an iterator to search the del_queue for duplicates. - for (ACE_Unbounded_Queue_Iterator<be_interface*> del_q_iter ( - del_queue - ); - !found && !del_q_iter.done (); - (void) del_q_iter.advance ()) + if (abstract_paths_only && ! parent->is_abstract ()) { - // Queue element. - be_interface **temp; - - (void) del_q_iter.next (temp); - - if (!ACE_OS::strcmp (parent->full_name (), - (*temp)->full_name ())) - { - // We exist in this del_queue and cannot be inserted. - found = 1; - } - - if (found) - { - break; - } + continue; } - if (!found) - { - // Insert the parent in the queue. - if (queue.enqueue_tail (parent) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::gen_server_skeletons - " - "enqueue op failed\n"), - -1); - } - } + (void) this->insert_non_dup (parent); } // end of for loop } // end of while queue not empty @@ -1615,6 +1692,11 @@ be_interface::gen_gperf_things (const char *flat_name) // GPERF can give Binary search, Linear search and Perfect Hash // methods. Generate the class defintion according to that. + TAO_OutStream *os = this->strategy_->get_out_stream (); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the correct class definition for the operation lookup // strategy. Then, get the lookup method from GPERF. And then, // instantiate the correct class for the operation lookup strategy @@ -1971,16 +2053,16 @@ be_interface::gen_linear_search_instance (const char *flat_name) << ";\n" << be_nl; } - int be_interface::is_a_helper (be_interface * /*derived*/, be_interface *bi, TAO_OutStream *os) { // Emit the comparison code. - os->indent (); - *os << "(!ACE_OS::strcmp ((char *)value, \"" << bi->repoID () << - "\")) ||\n"; + *os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl + << "(char *)value," << be_nl + << "\"" << bi->repoID () << "\"" << be_uidt_nl + << ") ||" << be_uidt_nl; return 0; } @@ -1991,8 +2073,9 @@ be_interface::queryinterface_helper (be_interface *derived, TAO_OutStream *os) { // Emit the comparison code. - *os << "(type == ACE_reinterpret_cast" << be_idt_nl - << "(ptr_arith_t," << be_idt_nl; + *os << "(type == ACE_reinterpret_cast (" + << be_idt << be_idt <<be_idt << be_idt << be_idt << be_idt_nl + << "ptr_arith_t," << be_nl; be_decl *scope = be_scope::narrow_from_scope (ancestor->defined_in ())->decl (); @@ -2003,42 +2086,45 @@ be_interface::queryinterface_helper (be_interface *derived, // If the ancestor is in the root scope, we can use the local name. if (scope->node_type () == AST_Decl::NT_root) { - *os << "&" << ancestor->local_name () << "::_tao_class_id" << be_uidt - << "))" << be_nl; + *os << "&" << ancestor->local_name () << "::_tao_class_id)" + << be_uidt_nl; } // Or, if it's defined in a scope different than the child's, the // ACE_NESTED_CLASS macro won't work - we use the scoped name. else if (scope != derived_scope) { - *os << "&::" << ancestor->name () << "::_tao_class_id" << be_uidt - << "))" << be_nl; + *os << "&::" << ancestor->name () << "::_tao_class_id)" + << be_uidt_nl; } // The ACE_NESTED_CLASS macro is necessary in this case. else { *os << "&ACE_NESTED_CLASS (::" << scope->name () << ", " - << ancestor->local_name () << ")" << "::_tao_class_id" << be_uidt - << "))" << be_nl; + << ancestor->local_name () << ")" << "::_tao_class_id)" + << be_uidt_nl; } + *os << ")" << be_uidt << be_uidt << be_uidt << be_uidt_nl + << "{" << be_idt_nl; + if (derived == ancestor) { *os << "retv = ACE_reinterpret_cast (void*, this);" << be_uidt_nl; } else { - *os << "retv = ACE_reinterpret_cast" << be_idt_nl - << "(" << be_idt_nl + *os << "retv =" << be_idt_nl + << "ACE_reinterpret_cast (" << be_idt << be_idt_nl << "void *," << be_nl - << "ACE_static_cast" << be_idt_nl - << "(" << be_idt_nl + << "ACE_static_cast (" << be_idt << be_idt_nl << ancestor->full_name () << "_ptr," << be_nl << "this" << be_uidt_nl << ")" << be_uidt << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; + << ");" << be_uidt << be_uidt << be_uidt_nl; } - *os << "else if "; + *os << "}" << be_uidt_nl + << "else if "; return 0; } @@ -2050,10 +2136,19 @@ be_interface::downcast_helper (be_interface * /* derived */, be_interface *base, TAO_OutStream *os) { - *os << "if (ACE_OS::strcmp (logical_type_id, \"" + // Abstract interfaces have no code generated on the skeleton side. + if (base->is_abstract ()) + { + return 0; + } + + *os << "if (ACE_OS::strcmp (logical_type_id," << be_nl + << " \"" << base->repoID () << "\") == 0)" << be_idt_nl + << "{" << be_idt_nl << "return ACE_static_cast (" - << base->full_skel_name () << "_ptr, this);" << be_uidt_nl; + << base->full_skel_name () << "_ptr, this);" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; return 0; } @@ -2070,6 +2165,17 @@ be_interface::gen_skel_helper (be_interface *derived, return 0; } + // If an operation or an attribute is abstract (declared in an + // abstract interface), we will either generate the full + // definition (if there are no concrete interfaces between the + // abstract ancestor and us) or, if there is a concrete ancestor + // in between, we will catch its definition elsewhere in this + // traversal. + if (ancestor->is_abstract ()) + { + return 0; + } + // Else generate code that does the cast to the appropriate type. if (ancestor->nmembers () > 0) @@ -2085,11 +2191,15 @@ be_interface::gen_skel_helper (be_interface *derived, { // Get the next AST decl node AST_Decl *d = si.item (); + if (d->node_type () == AST_Decl::NT_op) { // Start from current indentation level. os->indent (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) { // Generate the static method corresponding to this method. @@ -2241,10 +2351,12 @@ be_interface::copy_ctor_helper (be_interface *derived, be_interface *base, TAO_OutStream *os) { - if (derived == base) - // We are the same. Don't do anything, otherwise we will end up calling - // ourself. - return 0; + // We can't call ourselves in a copy constructor, and + // abstract interfaces don't exist on the skeleton side. + if (derived == base || base->is_abstract ()) + { + return 0; + } if (base->is_nested ()) { @@ -2294,12 +2406,46 @@ be_interface::in_mult_inheritance_helper (be_interface *derived, return 0; } +int +be_interface::gen_abstract_init_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } + + *os << ","; + + if (base->is_nested ()) + { + UTL_Scope *parent_scope = base->defined_in (); + AST_Decl *parent_decl = ScopeAsDecl (parent_scope); + + *os << be_nl + << "ACE_NESTED_CLASS (" + << parent_decl->name () << ", " + << base->local_name () + << ") (objref, _tao_collocated, servant)"; + } + else + { + *os << be_nl + << base->name () + << " (objref, _tao_collocated, servant)"; + } + + return 0; +} + void be_interface::destroy (void) { // Call the destroy methods of our base classes. - be_scope::destroy (); - be_type::destroy (); + this->AST_Interface::destroy (); + this->be_scope::destroy (); + this->be_type::destroy (); } int @@ -2338,7 +2484,13 @@ be_interface::original_interface () be_interface * be_interface::replacement (void) { - return this->strategy_->replacement (); + return this->strategy_->replacement (); +} + +idl_bool +be_interface::has_mixed_parentage (void) const +{ + return this->has_mixed_parentage_; } const char * @@ -2453,8 +2605,3 @@ be_interface::server_enclosing_scope (void) IMPL_NARROW_METHODS3 (be_interface, AST_Interface, be_scope, be_type) IMPL_NARROW_FROM_DECL (be_interface) IMPL_NARROW_FROM_SCOPE (be_interface) - -TAO_IDL_Inheritance_Hierarchy_Worker:: -~TAO_IDL_Inheritance_Hierarchy_Worker () -{ -} diff --git a/TAO/TAO_IDL/be/be_interface_fwd.cpp b/TAO/TAO_IDL/be/be_interface_fwd.cpp index 00e1f623e9c..522e549f129 100644 --- a/TAO/TAO_IDL/be/be_interface_fwd.cpp +++ b/TAO/TAO_IDL/be/be_interface_fwd.cpp @@ -6,10 +6,10 @@ // TAO IDL // // = FILENAME -// be_interface.h +// be_interface_fwd.cpp // // = DESCRIPTION -// Extension of class AST_Interface_Fwd that provides additional means for C++ +// Extension of class AST_InterfaceFwd that provides additional means for C++ // mapping of an interface. // // = AUTHOR @@ -19,16 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_interface_fwd.h" +#include "be_visitor.h" -ACE_RCSID(be, be_interface_fwd, "$Id$") +ACE_RCSID (be, + be_interface_fwd, + "$Id$") be_interface_fwd::be_interface_fwd (void) { // Always the case. - this->size_type (be_decl::VARIABLE); + this->size_type (AST_Type::VARIABLE); } be_interface_fwd::be_interface_fwd (AST_Interface *dummy, @@ -39,7 +40,7 @@ be_interface_fwd::be_interface_fwd (AST_Interface *dummy, n) { // Always the case. - this->size_type (be_decl::VARIABLE); + this->size_type (AST_Type::VARIABLE); } be_interface_fwd::~be_interface_fwd (void) diff --git a/TAO/TAO_IDL/be/be_interface_strategy.cpp b/TAO/TAO_IDL/be/be_interface_strategy.cpp index 20bbbd231b8..11c35748ae8 100644 --- a/TAO/TAO_IDL/be/be_interface_strategy.cpp +++ b/TAO/TAO_IDL/be/be_interface_strategy.cpp @@ -17,11 +17,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_interface_strategy.h" +#include "be_interface.h" +#include "be_extern.h" +#include "utl_identifier.h" -ACE_RCSID(be, be_interface_strategy, "$Id$") +ACE_RCSID (be, + be_interface_strategy, + "$Id$") be_interface_strategy::be_interface_strategy (be_interface *node, @@ -43,21 +46,52 @@ be_interface_strategy::be_interface_strategy (be_interface *node, be_interface_strategy::~be_interface_strategy (void) { if (this->local_name_ != 0) - delete [] this->local_name_; + { + delete [] this->local_name_; + this->local_name_ = 0; + } + if (this->full_name_ != 0) - delete [] this->full_name_; + { + delete [] this->full_name_; + this->full_name_ = 0; + } + if (this->flat_name_ != 0) - delete [] this->flat_name_; + { + delete [] this->flat_name_; + this->flat_name_ = 0; + } + if (this->repoID_ != 0) - delete [] this->repoID_; + { + delete [] this->repoID_; + this->repoID_ = 0; + } + if (this->full_skel_name_ != 0) - delete [] this->full_skel_name_; + { + delete [] this->full_skel_name_; + this->full_skel_name_ = 0; + } + if (this->full_coll_name_ != 0) - delete [] this->full_coll_name_; + { + delete [] this->full_coll_name_; + this->full_coll_name_ = 0; + } + if (this->local_coll_name_ != 0) - delete [] this->local_coll_name_; + { + delete [] this->local_coll_name_; + this->local_coll_name_ = 0; + } + if (this->relative_skel_name_ != 0) - delete [] this->relative_skel_name_; + { + delete [] this->relative_skel_name_; + this->relative_skel_name_ = 0; + } } // Interface Type Strategy Base Class @@ -92,6 +126,7 @@ be_interface_strategy::compute_coll_names (int type, static const char *collocated_names[] = {"_tao_thru_poa_collocated_", "_tao_direct_collocated_"}; static const char *poa = "POA_"; + // Reserve enough room for the "POA_" prefix, the "_tao_collocated_" // prefix and the local name and the (optional) "::" const char *collocated = collocated_names[type]; @@ -347,8 +382,8 @@ be_interface_ami_handler_strategy::next_state ( // **************************************************************** // AMI Exception Holder Strategy -be_interface_ami_exception_holder_strategy -::be_interface_ami_exception_holder_strategy (be_interface *node) +be_interface_ami_exception_holder_strategy:: +be_interface_ami_exception_holder_strategy (be_interface *node) : be_interface_default_strategy (node, AMI_EXCEPTION_HOLDER) { @@ -514,6 +549,113 @@ be_interface_default_strategy::be_interface_default_strategy ( be_interface_default_strategy::~be_interface_default_strategy (void) { + if (this->base_proxy_impl_name_ != 0) + { + delete this->base_proxy_impl_name_; + this->base_proxy_impl_name_ = 0; + } + + if (this->remote_proxy_impl_name_ != 0) + { + delete this->remote_proxy_impl_name_; + this->remote_proxy_impl_name_ = 0; + } + + if (this->thruPOA_proxy_impl_name_ != 0) + { + delete this->thruPOA_proxy_impl_name_; + this->thruPOA_proxy_impl_name_ = 0; + } + + if (this->direct_proxy_impl_name_ != 0) + { + delete this->direct_proxy_impl_name_; + this->direct_proxy_impl_name_ = 0; + } + + if (this->full_base_proxy_impl_name_ != 0) + { + delete this->full_base_proxy_impl_name_; + this->full_base_proxy_impl_name_ = 0; + } + + if (this->full_remote_proxy_impl_name_ != 0) + { + delete this->full_remote_proxy_impl_name_; + this->full_remote_proxy_impl_name_ = 0; + } + + if (this->full_thruPOA_proxy_impl_name_ != 0) + { + delete this->full_thruPOA_proxy_impl_name_; + this->full_thruPOA_proxy_impl_name_ = 0; + } + + if (this->full_direct_proxy_impl_name_ != 0) + { + delete this->full_direct_proxy_impl_name_; + this->full_direct_proxy_impl_name_ = 0; + } + + if (this->base_proxy_broker_ != 0) + { + delete this->base_proxy_broker_; + this->base_proxy_broker_ = 0; + } + + if (this->remote_proxy_broker_ != 0) + { + delete this->remote_proxy_broker_; + this->remote_proxy_broker_ = 0; + } + + if (this->strategized_proxy_broker_ != 0) + { + delete this->strategized_proxy_broker_; + this->strategized_proxy_broker_ = 0; + } + + if (this->full_base_proxy_broker_name_ != 0) + { + delete this->full_base_proxy_broker_name_; + this->full_base_proxy_broker_name_ = 0; + } + + if (this->full_remote_proxy_broker_name_ != 0) + { + delete this->full_remote_proxy_broker_name_; + this->full_remote_proxy_broker_name_ = 0; + } + + if (this->full_strategized_proxy_broker_name_ != 0) + { + delete this->full_strategized_proxy_broker_name_; + this->full_strategized_proxy_broker_name_ = 0; + } + + if (this->client_scope_ != 0) + { + delete this->client_scope_; + this->client_scope_ = 0; + } + + if (this->flat_client_scope_ != 0) + { + delete this->flat_client_scope_; + this->flat_client_scope_ = 0; + } + + if (this->server_scope_ != 0) + { + delete this->server_scope_; + this->server_scope_ = 0; + } + + if (this->flat_server_scope_ != 0) + { + delete this->flat_server_scope_; + this->flat_server_scope_ = 0; + } } const char * @@ -639,7 +781,9 @@ be_interface_default_strategy::create_with_prefix_suffix ( ACE_OS::strlen (separator) + 1; // The '/0' - ACE_NEW_RETURN (cat_string, char[length], 0); + ACE_NEW_RETURN (cat_string, + char[length], + 0); ACE_OS::strcpy (cat_string, prefix); ACE_OS::strcat (cat_string, str); @@ -653,7 +797,9 @@ const char * be_interface_default_strategy::base_proxy_impl_name (void) { if (this->base_proxy_impl_name_ != 0) - return this->base_proxy_impl_name_; + { + return this->base_proxy_impl_name_; + } this->base_proxy_impl_name_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -668,14 +814,18 @@ const char * be_interface_default_strategy::client_scope (void) { if (this->client_scope_ != 0) - return this->client_scope_; + { + return this->client_scope_; + } const char *full_name = this->full_name (); const char *name = this->local_name (); int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->client_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->client_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->client_scope_, full_name, length); this->client_scope_[length] = '\0'; @@ -686,14 +836,18 @@ const char * be_interface_default_strategy::flat_client_scope (void) { if (this->flat_client_scope_ != 0) - return this->flat_client_scope_; + { + return this->flat_client_scope_; + } const char *full_name = this->flat_name (); const char *name = this->local_name (); int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->flat_client_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->flat_client_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->flat_client_scope_, full_name, length); this->flat_client_scope_[length] = '\0'; @@ -706,7 +860,9 @@ const char * be_interface_default_strategy::server_scope (void) { if (this->server_scope_ != 0) - return this->server_scope_; + { + return this->server_scope_; + } const char *full_name = this->node_->full_coll_name (be_interface::DIRECT); @@ -715,7 +871,9 @@ be_interface_default_strategy::server_scope (void) int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->server_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->server_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->server_scope_, full_name, length); this->server_scope_[length] = '\0'; @@ -727,14 +885,18 @@ const char * be_interface_default_strategy::flat_server_scope (void) { if (this->flat_server_scope_ != 0) - return this->flat_server_scope_; + { + return this->flat_server_scope_; + } const char *full_name = this->flat_name (); const char *name = this->local_name (); int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->flat_client_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->flat_client_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->flat_server_scope_, full_name, length); this->flat_server_scope_[length] = '\0'; @@ -748,12 +910,17 @@ const char * be_interface_default_strategy::full_base_proxy_impl_name (void) { if (this->full_base_proxy_impl_name_ != 0) - return this->full_base_proxy_impl_name_; + { + return this->full_base_proxy_impl_name_; + } const char *scope = this->client_scope (); const char *base_name = this->base_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_base_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_base_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_base_proxy_impl_name_, scope); ACE_OS::strcat (this->full_base_proxy_impl_name_, base_name); @@ -766,7 +933,9 @@ const char * be_interface_default_strategy::remote_proxy_impl_name (void) { if (this->remote_proxy_impl_name_ != 0) - return this->remote_proxy_impl_name_; + { + return this->remote_proxy_impl_name_; + } this->remote_proxy_impl_name_ = @@ -782,12 +951,17 @@ const char * be_interface_default_strategy::full_remote_proxy_impl_name (void) { if (this->full_remote_proxy_impl_name_ != 0) - return this->full_remote_proxy_impl_name_; + { + return this->full_remote_proxy_impl_name_; + } const char *scope = this->client_scope (); const char *base_name = this->remote_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_remote_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_remote_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_remote_proxy_impl_name_, scope); ACE_OS::strcat (this->full_remote_proxy_impl_name_, base_name); @@ -798,7 +972,9 @@ const char * be_interface_default_strategy::thru_poa_proxy_impl_name (void) { if (this->thruPOA_proxy_impl_name_ != 0) - return this->thruPOA_proxy_impl_name_; + { + return this->thruPOA_proxy_impl_name_; + } this->thruPOA_proxy_impl_name_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -813,12 +989,17 @@ const char * be_interface_default_strategy::full_thru_poa_proxy_impl_name (void) { if (this->full_thruPOA_proxy_impl_name_ != 0) - return this->full_thruPOA_proxy_impl_name_; + { + return this->full_thruPOA_proxy_impl_name_; + } const char *scope = this->server_scope (); const char *base_name = this->thru_poa_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_thruPOA_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_thruPOA_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_thruPOA_proxy_impl_name_, scope); ACE_OS::strcat (this->full_thruPOA_proxy_impl_name_, base_name); @@ -830,7 +1011,9 @@ const char * be_interface_default_strategy::direct_proxy_impl_name (void) { if (this->direct_proxy_impl_name_ != 0) - return this->direct_proxy_impl_name_; + { + return this->direct_proxy_impl_name_; + } this->direct_proxy_impl_name_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -846,13 +1029,18 @@ const char * be_interface_default_strategy::full_direct_proxy_impl_name (void) { if (this->full_direct_proxy_impl_name_ != 0) - return this->full_direct_proxy_impl_name_; + { + return this->full_direct_proxy_impl_name_; + } const char *scope = this->server_scope (); const char *base_name = this->direct_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_direct_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_direct_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_direct_proxy_impl_name_, scope); ACE_OS::strcat (this->full_direct_proxy_impl_name_, base_name); @@ -864,7 +1052,9 @@ const char * be_interface_default_strategy::base_proxy_broker_name (void) { if (this->base_proxy_broker_ != 0) - return this->base_proxy_broker_; + { + return this->base_proxy_broker_; + } this->base_proxy_broker_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -879,12 +1069,17 @@ const char * be_interface_default_strategy::full_base_proxy_broker_name (void) { if (this->full_base_proxy_broker_name_ != 0) - return this->full_base_proxy_broker_name_; + { + return this->full_base_proxy_broker_name_; + } const char *scope = this->client_scope (); const char *base_name = this->base_proxy_broker_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_base_proxy_broker_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_base_proxy_broker_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_base_proxy_broker_name_, scope); ACE_OS::strcat (this->full_base_proxy_broker_name_, base_name); @@ -895,7 +1090,9 @@ const char * be_interface_default_strategy::remote_proxy_broker_name (void) { if (this->remote_proxy_broker_ != 0) - return this->remote_proxy_broker_; + { + return this->remote_proxy_broker_; + } this->remote_proxy_broker_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -911,12 +1108,17 @@ const char * be_interface_default_strategy::full_remote_proxy_broker_name (void) { if (this->full_remote_proxy_broker_name_ != 0) - return this->full_remote_proxy_broker_name_; + { + return this->full_remote_proxy_broker_name_; + } const char *scope = this->client_scope (); const char *base_name = this->remote_proxy_broker_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_remote_proxy_broker_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_remote_proxy_broker_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_remote_proxy_broker_name_, scope); ACE_OS::strcat (this->full_remote_proxy_broker_name_, base_name); @@ -928,7 +1130,9 @@ const char * be_interface_default_strategy::strategized_proxy_broker_name (void) { if (this->strategized_proxy_broker_ != 0) - return this->strategized_proxy_broker_; + { + return this->strategized_proxy_broker_; + } this->strategized_proxy_broker_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -943,12 +1147,17 @@ const char * be_interface_default_strategy::full_strategized_proxy_broker_name (void) { if (this->full_strategized_proxy_broker_name_ != 0) - return this->full_strategized_proxy_broker_name_; + { + return this->full_strategized_proxy_broker_name_; + } const char *scope = this->server_scope (); const char *base_name = this->strategized_proxy_broker_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_strategized_proxy_broker_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_strategized_proxy_broker_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_strategized_proxy_broker_name_, scope); ACE_OS::strcat (this->full_strategized_proxy_broker_name_, base_name); diff --git a/TAO/TAO_IDL/be/be_module.cpp b/TAO/TAO_IDL/be/be_module.cpp index 043dab1f1a3..a7980972eaf 100644 --- a/TAO/TAO_IDL/be/be_module.cpp +++ b/TAO/TAO_IDL/be/be_module.cpp @@ -19,11 +19,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_module.h" +#include "be_visitor.h" -ACE_RCSID(be, be_module, "$Id$") +ACE_RCSID (be, + be_module, + "$Id$") be_module::be_module (void) { @@ -37,14 +38,6 @@ be_module::be_module (UTL_ScopedName *n) { } -// Compute the size type of the node in question. -int -be_module::compute_size_type (void) -{ - // Our size does not matter. - return 0; -} - void be_module::destroy (void) { diff --git a/TAO/TAO_IDL/be/be_native.cpp b/TAO/TAO_IDL/be/be_native.cpp index 93e3d1e3d1a..8aa14ed2d39 100644 --- a/TAO/TAO_IDL/be/be_native.cpp +++ b/TAO/TAO_IDL/be/be_native.cpp @@ -16,11 +16,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_native.h" +#include "be_visitor.h" -ACE_RCSID(be, be_native, "$Id$") +ACE_RCSID (be, + be_native, + "$Id$") be_native::be_native (void) diff --git a/TAO/TAO_IDL/be/be_operation.cpp b/TAO/TAO_IDL/be/be_operation.cpp index bcd210104c9..100027e3577 100644 --- a/TAO/TAO_IDL/be/be_operation.cpp +++ b/TAO/TAO_IDL/be/be_operation.cpp @@ -19,11 +19,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_operation.h" +#include "be_operation_strategy.h" +#include "be_predefined_type.h" +#include "be_argument.h" +#include "be_visitor.h" -ACE_RCSID(be, be_operation, "$Id$") +ACE_RCSID (be, + be_operation, + "$Id$") be_operation::be_operation (void) { @@ -56,71 +60,16 @@ be_operation::~be_operation (void) { } -int -be_operation::void_return_type (void) -{ - be_type* type = be_type::narrow_from_decl (this->return_type ()); - - if (type->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (type)->pt () - == AST_PredefinedType::PT_void)) - { - return 1; - } - else - { - return 0; - } -} - -be_argument * -be_operation::add_argument_to_scope (be_argument *arg) -{ - this->add_to_scope (arg); - this->add_to_referenced (arg, - 0, - 0); - return arg; -} - -// Compute the size type of the node in question. -int -be_operation::compute_size_type (void) -{ - - for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node - AST_Decl *d = si.item (); - be_decl *bd = be_decl::narrow_from_decl (d); - - if (bd != 0) - { - // Our sizetype depends on the sizetype of our members. Although - // previous value of sizetype may get overwritten, we are - // guaranteed by the "size_type" call that once the value reached - // be_decl::VARIABLE, nothing else can overwrite it. - this->size_type (bd->size_type ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_operation::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - } - - return 0; -} - void be_operation::destroy (void) { + delete this->strategy_; + this->strategy_ = 0; + // Call the destroy methods of our base classes. - be_scope::destroy (); - be_decl::destroy (); + this->be_scope::destroy (); + this->be_decl::destroy (); + this->AST_Operation::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_operation_strategy.cpp b/TAO/TAO_IDL/be/be_operation_strategy.cpp index d5bb6273e55..268a092ec3a 100644 --- a/TAO/TAO_IDL/be/be_operation_strategy.cpp +++ b/TAO/TAO_IDL/be/be_operation_strategy.cpp @@ -17,17 +17,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_operation_strategy.h" -ACE_RCSID(be, be_operation_strategy, "$Id$") +ACE_RCSID (be, + be_operation_strategy, + "$Id$") - be_operation_strategy::be_operation_strategy (be_operation *node, - Strategy_Kind strategy_type) - : node_ (node), - strategy_type_ (strategy_type) +be_operation_strategy::be_operation_strategy (be_operation *node, + Strategy_Kind strategy_type) + : node_ (node), + strategy_type_ (strategy_type) { } diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index ddab9500d21..b5520ef1995 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -19,11 +19,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_predefined_type.h" +#include "be_visitor.h" +#include "utl_identifier.h" +#include "ace/Log_Msg.h" +#include "ace/ACE.h" -ACE_RCSID(be, be_predefined_type, "$Id$") +ACE_RCSID (be, + be_predefined_type, + "$Id$") be_predefined_type::be_predefined_type (void) { @@ -37,108 +41,14 @@ be_predefined_type::be_predefined_type (AST_PredefinedType::PredefinedType t, n, I_TRUE) { - // Generate a new Scoped Name for us such that we belong to the CORBA - // namespace. - if (this->pt () != AST_PredefinedType::PT_void) - { - Identifier *corba_id = 0; - ACE_NEW (corba_id, - Identifier ("CORBA")); - - UTL_ScopedName *new_name = 0; - ACE_NEW (new_name, - UTL_ScopedName (corba_id, - 0)); - - Identifier *id = 0; - UTL_ScopedName *conc_name = 0; - - switch (this->pt ()) - { - case AST_PredefinedType::PT_long: - ACE_NEW (id, - Identifier ("Long")); - break; - case AST_PredefinedType::PT_ulong: - ACE_NEW (id, - Identifier ("ULong")); - break; - case AST_PredefinedType::PT_short: - ACE_NEW (id, - Identifier ("Short")); - break; - case AST_PredefinedType::PT_ushort: - ACE_NEW (id, - Identifier ("UShort")); - break; - case AST_PredefinedType::PT_float: - ACE_NEW (id, - Identifier ("Float")); - break; - case AST_PredefinedType::PT_double: - ACE_NEW (id, - Identifier ("Double")); - break; - case AST_PredefinedType::PT_char: - ACE_NEW (id, - Identifier ("Char")); - break; - case AST_PredefinedType::PT_octet: - ACE_NEW (id, - Identifier ("Octet")); - break; - case AST_PredefinedType::PT_wchar: - ACE_NEW (id, - Identifier ("WChar")); - break; - case AST_PredefinedType::PT_boolean: - ACE_NEW (id, - Identifier ("Boolean")); - break; - case AST_PredefinedType::PT_longlong: - ACE_NEW (id, - Identifier ("LongLong")); - break; - case AST_PredefinedType::PT_ulonglong: - ACE_NEW (id, - Identifier ("ULongLong")); - break; - case AST_PredefinedType::PT_longdouble: - ACE_NEW (id, - Identifier ("LongDouble")); - break; - case AST_PredefinedType::PT_any: - ACE_NEW (id, - Identifier ("Any")); - break; - case AST_PredefinedType::PT_pseudo: - ACE_NEW (id, - Identifier (n->last_component ()->get_string ())); - break; - default: - ACE_NEW (id, - Identifier (this->local_name ()->get_string ())); - } - - ACE_NEW (conc_name, - UTL_ScopedName (id, - 0)); - - new_name->nconc (conc_name); - this->set_name (new_name); - } - // Computes the repoID. this->compute_repoID (); - // Computes the fully scoped name. - AST_Decl::compute_full_name (); - // Computes the fully scoped typecode name. this->compute_tc_name (); // Compute the flattened fully scoped name. - this->compute_flat_name (); + this->AST_Decl::compute_flat_name (); } // Overriden method. @@ -219,6 +129,10 @@ be_predefined_type::compute_tc_name (void) ACE_NEW (id, Identifier ("_tc_any")); break; + case AST_PredefinedType::PT_object: + ACE_NEW (id, + Identifier ("_tc_Object")); + break; case AST_PredefinedType::PT_pseudo: { char tcname [100]; @@ -242,23 +156,6 @@ be_predefined_type::compute_tc_name (void) this->tc_name_->nconc (conc_name); } -// Compute the size type of the node in question. -int -be_predefined_type::compute_size_type (void) -{ - if (this->pt () == AST_PredefinedType::PT_any - || this->pt () == AST_PredefinedType::PT_pseudo) - { - this->size_type (be_decl::VARIABLE); - } - else - { - this->size_type (be_decl::FIXED); - } - - return 0; -} - void be_predefined_type::compute_repoID (void) { @@ -287,6 +184,13 @@ be_predefined_type::accept (be_visitor *visitor) return visitor->visit_predefined_type (this); } +void +be_predefined_type::destroy (void) +{ + this->AST_PredefinedType::destroy (); + this->be_type::destroy (); +} + // Narrowing IMPL_NARROW_METHODS2 (be_predefined_type, AST_PredefinedType, be_type) IMPL_NARROW_FROM_DECL (be_predefined_type) diff --git a/TAO/TAO_IDL/be/be_produce.cpp b/TAO/TAO_IDL/be/be_produce.cpp index ad7b39a558c..8d993bd5747 100644 --- a/TAO/TAO_IDL/be/be_produce.cpp +++ b/TAO/TAO_IDL/be/be_produce.cpp @@ -62,33 +62,30 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -// BE_produce.cc - Produce the work of the BE - does nothing in the -// dummy BE - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" #include "be_visitor_root.h" -#include "TAO_IDL_BE_Export.h" +#include "be_visitor_ami_pre_proc.h" +#include "be_visitor_amh_pre_proc.h" +#include "be_visitor_context.h" +#include "be_root.h" +#include "be_extern.h" +#include "global_extern.h" -ACE_RCSID(be, be_produce, "$Id$") +ACE_RCSID (be, + be_produce, + "$Id$") // Clean up before exit, whether successful or not. TAO_IDL_BE_Export void BE_cleanup (void) { - AST_Decl *d = idl_global->root (); - be_root *root = be_root::narrow_from_decl (d); - - root->destroy (); - delete root; - root = 0; - idl_global->destroy (); delete idl_global; idl_global = 0; + + delete be_global; + be_global = 0; } // Abort this run of the BE. @@ -110,9 +107,6 @@ BE_produce (void) // Root of the AST made up of BE nodes. be_root *root = 0; - // Visitor for root. - be_visitor *visitor = 0; - // Context information for the visitor root. be_visitor_context ctx; @@ -136,158 +130,143 @@ BE_produce (void) { // Make a first pass over the AST and introduce // AMI specific interfaces, methods and valuetypes. - be_visitor_context *local_ctx = 0; - ACE_NEW (local_ctx, - be_visitor_context (ctx)); - - ACE_NEW (visitor, - be_visitor_ami_pre_proc (local_ctx)); + be_visitor_ami_pre_proc ami_preproc_visitor (&ctx); - if (root->accept (visitor) == -1) + if (root->accept (&ami_preproc_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " "client header for Root failed\n")); BE_abort (); } - - delete visitor; } if (be_global->gen_amh_classes () == I_TRUE) { // Make a first pass over the AST and introduce // AMH specific code - be_visitor_context *local_ctx = 0; - ACE_NEW (local_ctx, - be_visitor_context (ctx)); - - ACE_NEW (visitor, - be_visitor_amh_pre_proc (local_ctx)); + be_visitor_amh_pre_proc amh_pre_proc_visitor (&ctx); - if (root->accept (visitor) == -1) + if (root->accept (&amh_pre_proc_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " "client header for Root failed\n")); BE_abort (); } - - delete visitor; } // Code generation involves six steps because of the six files that we // generate. - // (1) Generate client header, - // instantiate a visitor context, and set the codegen state - ctx.state (TAO_CodeGen::TAO_ROOT_CH); - - // Get a root visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the client header - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "client header for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (2) Generate client inline and - // set the context information. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_CI); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the client inline file. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "client inline for Root failed\n")); - BE_abort (); - } - - delete visitor; - - - // (3) Generate client stubs. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_CS); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the client stubs. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "client stubs for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (4) Generate server header. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_SH); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the server header file. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "server header for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (5) Generate server inline. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_SI); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the server inline file. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "server inline for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (6) Generate server skeletons - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_SS); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the server skeletons. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "server skeletons for Root failed\n")); - BE_abort (); - } - - delete visitor; + { + // (1) Generate client header, + // instantiate a visitor context, and set the codegen state + ctx.state (TAO_CodeGen::TAO_ROOT_CH); + + // Get a root visitor. + be_visitor_root_ch root_ch_visitor (&ctx); + + // Generate code for the client header + if (root->accept (&root_ch_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "client header for Root failed\n")); + BE_abort (); + } + } + + { + // (2) Generate client inline and + // set the context information. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_CI); + + // Create a visitor. + be_visitor_root_ci root_ci_visitor (&ctx); + + // Generate code for the client inline file. + if (root->accept (&root_ci_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "client inline for Root failed\n")); + BE_abort (); + } + } + + { + // (3) Generate client stubs. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_CS); + + // Create a visitor. + be_visitor_root_cs root_cs_visitor (&ctx); + + // Generate code for the client stubs. + if (root->accept (&root_cs_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "client stubs for Root failed\n")); + BE_abort (); + } + } + + { + // (4) Generate server header. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_SH); + + // Create a visitor. + be_visitor_root_sh root_sh_visitor (&ctx); + + // Generate code for the server header file. + if (root->accept (&root_sh_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "server header for Root failed\n")); + BE_abort (); + } + } + + { + // (5) Generate server inline. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_SI); + + // Create a visitor. + be_visitor_root_si root_si_visitor (&ctx); + + // Generate code for the server inline file. + if (root->accept (&root_si_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "server inline for Root failed\n")); + BE_abort (); + } + } + + { + // (6) Generate server skeletons + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_SS); + + // Create a visitor. + be_visitor_root_ss root_ss_visitor (&ctx); + + // Generate code for the server skeletons. + if (root->accept (&root_ss_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "server skeletons for Root failed\n")); + BE_abort (); + } + } // (7) Generated server template header. if (be_global->gen_tie_classes ()) @@ -317,10 +296,10 @@ BE_produce (void) ctx.state (TAO_CodeGen::TAO_ROOT_IH); // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); + be_visitor_root_ih root_ih_visitor (&ctx); // Generate code for the implementation header. - if (root->accept (visitor) == -1) + if (root->accept (&root_ih_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " @@ -328,25 +307,21 @@ BE_produce (void) BE_abort (); } - delete visitor; - // (9) Generate implementation source. ctx.reset (); ctx.state (TAO_CodeGen::TAO_ROOT_IS); // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); + be_visitor_root_is root_is_visitor (&ctx); // Generate code for the implementation source. - if (root->accept (visitor) == -1) + if (root->accept (&root_is_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " "implementation skeletons for Root failed\n")); BE_abort (); } - - delete visitor; } // Clean up. diff --git a/TAO/TAO_IDL/be/be_root.cpp b/TAO/TAO_IDL/be/be_root.cpp index 65385b6255c..0e8b89b68fb 100644 --- a/TAO/TAO_IDL/be/be_root.cpp +++ b/TAO/TAO_IDL/be/be_root.cpp @@ -19,11 +19,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_root.h" +#include "be_visitor.h" +#include "ast_sequence.h" +#include "ast_string.h" +#include "ast_array.h" -ACE_RCSID(be, be_root, "$Id$") +ACE_RCSID (be, + be_root, + "$Id$") // Default Constructor. be_root::be_root (void) @@ -52,7 +56,7 @@ be_root::fe_add_sequence (AST_Sequence *t) return 0; } - add_to_local_types(t); + add_to_local_types (t); return t; } @@ -88,6 +92,7 @@ be_root::destroy (void) // Call the destroy methods of our base classes. be_scope::destroy (); be_decl::destroy (); + AST_Root::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_scope.cpp b/TAO/TAO_IDL/be/be_scope.cpp index c7fde75337d..128ae41716d 100644 --- a/TAO/TAO_IDL/be/be_scope.cpp +++ b/TAO/TAO_IDL/be/be_scope.cpp @@ -1,12 +1,23 @@ // // $Id$ // -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_scope, "$Id$") +#include "be_scope.h" +#include "be_valuetype.h" +#include "be_component.h" +#include "be_home.h" +#include "be_module.h" +#include "be_exception.h" +#include "be_union.h" +#include "be_structure.h" +#include "be_enum.h" +#include "be_operation.h" +#include "be_factory.h" +#include "be_root.h" +#include "be_visitor.h" +ACE_RCSID (be, + be_scope, + "$Id$") // Default Constructor. be_scope::be_scope (void) @@ -43,10 +54,16 @@ be_scope::comma (void) const be_decl * be_scope::decl (void) { - switch (this->scope_node_type()) + switch (this->scope_node_type ()) { case AST_Decl::NT_interface: return be_interface::narrow_from_scope (this); + case AST_Decl::NT_valuetype: + return be_valuetype::narrow_from_scope (this); + case AST_Decl::NT_component: + return be_component::narrow_from_scope (this); + case AST_Decl::NT_home: + return be_home::narrow_from_scope (this); case AST_Decl::NT_module: return be_module::narrow_from_scope (this); case AST_Decl::NT_root: @@ -71,18 +88,7 @@ be_scope::decl (void) void be_scope::destroy (void) { - for (UTL_ScopeActiveIterator iter (this, IK_decls); - !iter.is_done (); - iter.next ()) - { - AST_Decl *i = iter.item (); - i->destroy (); - delete i; - i = 0; - } - // Still some glitches, but the call should eventually - // be made here. - // UTL_Scope::destroy (); + UTL_Scope::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index a26d1ebd8f8..89b440663da 100644 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ b/TAO/TAO_IDL/be/be_sequence.cpp @@ -19,50 +19,54 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_sequence.h" +#include "be_sequence.h" +#include "be_typedef.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_predefined_type.h" +#include "be_visitor.h" +#include "utl_identifier.h" +#include "idl_defines.h" -ACE_RCSID(be, be_sequence, "$Id$") +ACE_RCSID (be, + be_sequence, + "$Id$") be_sequence::be_sequence (void) : mt_ (be_sequence::MNG_UNKNOWN) { // Always the case. - this->size_type (be_decl::VARIABLE); this->has_constructor (I_TRUE); } be_sequence::be_sequence (AST_Expression *v, AST_Type *t, + UTL_ScopedName *n, idl_bool local, idl_bool abstract) : be_scope (AST_Decl::NT_sequence), be_type (AST_Decl::NT_sequence, - 0), + n), be_decl (AST_Decl::NT_sequence, - 0), + n), UTL_Scope (AST_Decl::NT_sequence), AST_Sequence (v, t, + n, t->is_local () || local, abstract), AST_ConcreteType (AST_Decl::NT_sequence, - 0), + n), AST_Type (AST_Decl::NT_sequence, - 0), + n), AST_Decl (AST_Decl::NT_sequence, - 0, + n, I_TRUE), COMMON_Base (t->is_local () || local, abstract), mt_ (be_sequence::MNG_UNKNOWN) { - // A sequence data type is always VARIABLE. - this->size_type (be_decl::VARIABLE); - // Always the case. this->has_constructor (I_TRUE); } @@ -135,7 +139,8 @@ be_sequence::gen_name (void) ACE_OS::sprintf (ulval_str, "_%lu", this->max_size ()->ev ()->u.ulval); - ACE_OS::strcat (namebuf, ulval_str); + ACE_OS::strcat (namebuf, + ulval_str); } return ACE_OS::strdup (namebuf); @@ -228,28 +233,23 @@ be_sequence::managed_type (void) switch (prim_type->node_type ()) { case AST_Decl::NT_interface: + if (prim_type->is_abstract ()) + { + this->mt_ = be_sequence::MNG_ABSTRACT; + } + else + { + this->mt_ = be_sequence::MNG_OBJREF; + } + + break; case AST_Decl::NT_interface_fwd: - { - int is_valuetype = 0; - be_interface *bf = be_interface::narrow_from_decl (prim_type); - if (bf != 0) - is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (prim_type); - if (bff != 0) - is_valuetype = bff->is_valuetype (); - } - if (is_valuetype) - { - this->mt_ = be_sequence::MNG_VALUE; - } - else - { this->mt_ = be_sequence::MNG_OBJREF; - } break; - } + case AST_Decl::NT_valuetype: + case AST_Decl::NT_valuetype_fwd: + this->mt_ = be_sequence::MNG_VALUE; + break; case AST_Decl::NT_string: this->mt_ = be_sequence::MNG_STRING; break; @@ -260,20 +260,15 @@ be_sequence::managed_type (void) { be_predefined_type *bpd = be_predefined_type::narrow_from_decl (prim_type); + AST_PredefinedType::PredefinedType pt = bpd->pt (); - if (bpd->pt () == AST_PredefinedType::PT_pseudo) + if (pt == AST_PredefinedType::PT_pseudo) { - // If this pseudo is a CORBA::Object, then the managed type is - // an objref. - if (!ACE_OS::strcmp (bpd->local_name ()->get_string (), - "Object")) - { - this->mt_ = be_sequence::MNG_OBJREF; - } - else - { - this->mt_ = be_sequence::MNG_PSEUDO; - } + this->mt_ = be_sequence::MNG_PSEUDO; + } + else if (pt == AST_PredefinedType::PT_object) + { + this->mt_ = be_sequence::MNG_OBJREF; } else { @@ -367,6 +362,23 @@ be_sequence::instance_name () this->flat_name (), this->max_size ()->ev ()->u.ulval); } + + break; + case be_sequence::MNG_ABSTRACT: + if (this->unbounded ()) + { + ACE_OS::sprintf (namebuf, + "_TAO_Unbounded_Abstract_Sequence_%s", + this->flat_name ()); + } + else + { + ACE_OS::sprintf (namebuf, + "_TAO_Bounded_Abstract_Sequence_%s_%lu", + this->flat_name (), + this->max_size ()->ev ()->u.ulval); + } + break; case be_sequence::MNG_VALUE: if (this->unbounded ()) @@ -382,6 +394,7 @@ be_sequence::instance_name () this->flat_name (), this->max_size ()->ev ()->u.ulval); } + break; case be_sequence::MNG_STRING: if (this->unbounded ()) @@ -395,6 +408,7 @@ be_sequence::instance_name () "_TAO_Bounded_String_Sequence_%s", this->flat_name ()); } + break; case be_sequence::MNG_WSTRING: if (this->unbounded ()) @@ -408,6 +422,7 @@ be_sequence::instance_name () "_TAO_Bounded_WString_Sequence_%s", this->flat_name ()); } + break; default: // Not a managed type. if (this->unbounded ()) @@ -437,6 +452,7 @@ be_sequence::instance_name () this->flat_name (), this->max_size ()->ev ()->u.ulval); } + break; } diff --git a/TAO/TAO_IDL/be/be_stream_factory.cpp b/TAO/TAO_IDL/be/be_stream_factory.cpp index 9a4c6e2317d..ef327ecd30e 100644 --- a/TAO/TAO_IDL/be/be_stream_factory.cpp +++ b/TAO/TAO_IDL/be/be_stream_factory.cpp @@ -1,11 +1,11 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_stream_factory.h" #include "be_sunsoft.h" -ACE_RCSID(be, be_factory, "$Id$") +ACE_RCSID (be, + be_streamfactory, + "$Id$") // Constructor. TAO_OutStream_Factory::TAO_OutStream_Factory (void) diff --git a/TAO/TAO_IDL/be/be_string.cpp b/TAO/TAO_IDL/be/be_string.cpp index d2f5dff0608..f16196e015b 100644 --- a/TAO/TAO_IDL/be/be_string.cpp +++ b/TAO/TAO_IDL/be/be_string.cpp @@ -9,7 +9,7 @@ // be_string.cpp // // = DESCRIPTION -// Extension of class AST_Array that provides additional means for C++ +// Extension of class AST_String that provides additional means for C++ // mapping. // // = AUTHOR @@ -19,44 +19,34 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_string.h" +#include "be_visitor.h" +#include "utl_identifier.h" -ACE_RCSID(be, be_string, "$Id$") +ACE_RCSID (be, + be_string, + "$Id$") be_string::be_string (void) { // Always the case. - this->size_type (be_decl::VARIABLE); + this->size_type (AST_Type::VARIABLE); } -be_string::be_string (AST_Expression *v) - : AST_String (v), - AST_Decl (AST_Decl::NT_string, - new UTL_ScopedName (new Identifier ("string"), - 0), +be_string::be_string (AST_Decl::NodeType nt, + UTL_ScopedName *n, + AST_Expression *v, + long width) + : AST_String (nt, + n, + v, + width), + AST_Decl (nt, + n, I_TRUE) { // Always the case. - this->size_type (be_decl::VARIABLE); -} - -be_string::be_string (AST_Expression *v, - long wide) - : AST_String (v, wide), - AST_Decl (wide == (long) sizeof (char) - ? AST_Decl::NT_string - : AST_Decl::NT_wstring, - wide == (long) sizeof (char) - ? new UTL_ScopedName (new Identifier ("string"), - 0) - : new UTL_ScopedName (new Identifier ("wstring"), - 0), - I_TRUE) -{ - // Always the case. - this->size_type (be_decl::VARIABLE); + this->size_type (AST_Type::VARIABLE); } // Overriden method. @@ -90,6 +80,13 @@ be_string::accept (be_visitor *visitor) return visitor->visit_string (this); } +void +be_string::destroy (void) +{ + this->be_type::destroy (); + this->AST_String::destroy (); +} + // Narrowing. IMPL_NARROW_METHODS2 (be_string, AST_String, be_type) IMPL_NARROW_FROM_DECL (be_string) diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index 02d193c2380..f4a41acbf30 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -19,11 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_structure, "$Id$") +#include "be_structure.h" +#include "be_codegen.h" +#include "be_helper.h" +#include "be_visitor.h" +#include "be_extern.h" +#include "ast_field.h" +#include "utl_identifier.h" +#include "idl_defines.h" + +ACE_RCSID (be, + be_structure, + "$Id$") be_structure::be_structure (void) { @@ -44,8 +51,6 @@ be_structure::be_structure (UTL_ScopedName *n, int be_structure::gen_var_defn (char *) { - TAO_OutStream *ch = 0; - TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; ACE_OS::memset (namebuf, @@ -56,7 +61,7 @@ be_structure::gen_var_defn (char *) "%s_var", this->local_name ()->get_string ()); - ch = tao_cg->client_header (); + TAO_OutStream *ch = tao_cg->client_header (); // Generate the var definition (always in the client header). // Depending upon the data type, there are some differences which @@ -78,7 +83,7 @@ be_structure::gen_var_defn (char *) *ch << namebuf << " (const " << namebuf << " &);" << be_nl; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ch << "// Fixed-size types only." << be_nl; *ch << namebuf << " (const " << this->local_name () @@ -97,7 +102,7 @@ be_structure::gen_var_defn (char *) *ch << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ch << "// Fixed-size types only." << be_nl; *ch << namebuf << " &operator= (const " << this->local_name () @@ -115,7 +120,7 @@ be_structure::gen_var_defn (char *) *ch << "operator " << this->local_name () << " &();" << be_nl; *ch << "operator " << this->local_name () << " &() const;" << be_nl; - if (this->size_type () == be_decl::VARIABLE) + if (this->size_type () == AST_Type::VARIABLE) { *ch << "// Variable-size types only." << be_nl; *ch << "operator " << this->local_name () @@ -127,7 +132,7 @@ be_structure::gen_var_defn (char *) // The return types of in, out, inout, and _retn are based on the // parameter passing rules and the base type. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ch << "const " << this->local_name () << " &in (void) const;" << be_nl; *ch << this->local_name () << " &inout (void);" << be_nl; @@ -220,7 +225,7 @@ be_structure::gen_var_impl (char *, *ci << "}\n\n"; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ci << "// fixed-size types only" << be_nl; *ci << "ACE_INLINE" << be_nl; @@ -288,7 +293,7 @@ be_structure::gen_var_impl (char *, << "}\n\n"; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { ci->indent (); *ci << "// fixed-size types only" << be_nl; @@ -361,7 +366,7 @@ be_structure::gen_var_impl (char *, *ci << "}\n\n"; // Variable-size types only. - if (this->size_type () == be_decl::VARIABLE) + if (this->size_type () == AST_Type::VARIABLE) { ci->indent (); *ci << "// variable-size types only" << be_nl; @@ -396,7 +401,7 @@ be_structure::gen_var_impl (char *, // The out is handled differently based on our size type. ci->indent (); - if (this->size_type () == be_decl::VARIABLE) + if (this->size_type () == AST_Type::VARIABLE) { *ci << "// mapping for variable size " << be_nl; *ci << "ACE_INLINE " << "::" << this->name () << " *&" << be_nl; @@ -651,41 +656,6 @@ be_structure::gen_out_impl (char *, return 0; } -// Compute the size type of the node in question. -int -be_structure::compute_size_type (void) -{ - for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node. - AST_Decl *d = si.item (); - be_decl *bd = be_decl::narrow_from_decl (d); - - if (bd != 0) - { - // Our sizetype depends on the sizetype of our - // members. Although previous value of sizetype may get - // overwritten, we are guaranteed by the "size_type" call - // that once the value reached be_decl::VARIABLE, nothing - // else can overwrite it. - this->size_type (bd->size_type ()); - - // While we're iterating, we might as well do this one too. - this->has_constructor (bd->has_constructor ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_structure::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - } - - return 0; -} - void be_structure::destroy (void) { diff --git a/TAO/TAO_IDL/be/be_structure_fwd.cpp b/TAO/TAO_IDL/be/be_structure_fwd.cpp new file mode 100644 index 00000000000..872eb2f094a --- /dev/null +++ b/TAO/TAO_IDL/be/be_structure_fwd.cpp @@ -0,0 +1,60 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_structure_fwd.cpp +// +// = DESCRIPTION +// Extension of class AST_StructureFwd that provides additional means for C++ +// mapping of a struct. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_structure_fwd.h" +#include "be_visitor.h" + +ACE_RCSID (be, + be_structure_fwd, + "$Id$") + +be_structure_fwd::be_structure_fwd (void) +{ +} + +be_structure_fwd::be_structure_fwd (UTL_ScopedName *n) + : be_type (AST_Decl::NT_struct_fwd, + n), + AST_StructureFwd (n), + AST_Type (AST_Decl::NT_struct_fwd, + n), + AST_Decl (AST_Decl::NT_struct_fwd, + n) +{ +} + +be_structure_fwd::~be_structure_fwd (void) +{ +} + +void +be_structure_fwd::destroy (void) +{ + // Do nothing. +} + +int +be_structure_fwd::accept (be_visitor *visitor) +{ + return visitor->visit_structure_fwd (this); +} + +// Narrowing +IMPL_NARROW_METHODS2 (be_structure_fwd, AST_StructureFwd, be_type) +IMPL_NARROW_FROM_DECL (be_structure_fwd) diff --git a/TAO/TAO_IDL/be/be_sunsoft.cpp b/TAO/TAO_IDL/be/be_sunsoft.cpp index 0364348c8ce..08f6588da15 100644 --- a/TAO/TAO_IDL/be/be_sunsoft.cpp +++ b/TAO/TAO_IDL/be/be_sunsoft.cpp @@ -1,11 +1,14 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" #include "be_sunsoft.h" +#include "ast_expression.h" +#include "utl_identifier.h" +#include "utl_idlist.h" +#include "utl_string.h" -ACE_RCSID(be, be_sunsoft, "$Id$") +ACE_RCSID (be, + be_sunsoft, + "$Id$") TAO_SunSoft_OutStream::TAO_SunSoft_OutStream (void) : TAO_OutStream () @@ -168,6 +171,9 @@ TAO_SunSoft_OutStream::print (AST_Expression *expr) case AST_Expression::EV_wstring: this->TAO_OutStream::print ("L\"%s\"", ev->u.wstrval); break; + case AST_Expression::EV_enum: + this->print (expr->n ()); + break; default: break; } diff --git a/TAO/TAO_IDL/be/be_tmplinst.cpp b/TAO/TAO_IDL/be/be_tmplinst.cpp index b288ffdb3c6..9a301cb332d 100644 --- a/TAO/TAO_IDL/be/be_tmplinst.cpp +++ b/TAO/TAO_IDL/be/be_tmplinst.cpp @@ -1,21 +1,26 @@ // $Id$ -#include "ace/ACE.h" #include "be_visitor_typecode/typecode_defn.h" #include "be_stream_factory.h" #include "be_visitor_factory.h" +#include "ace/Singleton.h" +#include "ace/Synch.h" +#include "ace/Unbounded_Queue.h" #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton<TAO_CodeGen, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Singleton<TAO_OutStream_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Singleton<TAO_Common_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Singleton<TAO_Compiled_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; +template class ACE_Singleton<TAO_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; template class ACE_Node <be_interface *>; template class ACE_Unbounded_Queue <be_interface *>; template class ACE_Unbounded_Queue_Iterator <be_interface *>; +template class ACE_Node <AST_Interface *>; +template class ACE_Unbounded_Queue <AST_Interface *>; +template class ACE_Unbounded_Queue_Iterator <AST_Interface *>; + template class ACE_Node<be_visitor_typecode_defn::QNode*>; template class ACE_Unbounded_Queue<be_visitor_typecode_defn::QNode*>; template class ACE_Unbounded_Queue_Iterator<be_visitor_typecode_defn::QNode*>; @@ -28,13 +33,16 @@ template class ACE_Unbounded_Queue_Iterator <be_interface_fwd *>; #pragma instantiate ACE_Singleton<TAO_CodeGen, ACE_SYNCH_RECURSIVE_MUTEX> #pragma instantiate ACE_Singleton<TAO_OutStream_Factory, ACE_SYNCH_RECURSIVE_MUTEX> -#pragma instantiate ACE_Singleton<TAO_Common_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX> -#pragma instantiate ACE_Singleton<TAO_Compiled_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX> +#pragma instantiate ACE_Singleton<TAO_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX> #pragma instantiate ACE_Node <be_interface *> #pragma instantiate ACE_Unbounded_Queue <be_interface *> #pragma instantiate ACE_Unbounded_Queue_Iterator <be_interface *> +#pragma instantiate ACE_Node <AST_Interface *> +#pragma instantiate ACE_Unbounded_Queue <AST_Interface *> +#pragma instantiate ACE_Unbounded_Queue_Iterator <AST_Interface *> + #pragma instantiate ACE_Node<be_visitor_typecode_defn::QNode*> #pragma instantiate ACE_Unbounded_Queue<be_visitor_typecode_defn::QNode*> #pragma instantiate ACE_Unbounded_Queue_Iterator<be_visitor_typecode_defn::QNode*> diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp index 8e495d578a4..e6726ad85c3 100644 --- a/TAO/TAO_IDL/be/be_type.cpp +++ b/TAO/TAO_IDL/be/be_type.cpp @@ -19,15 +19,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_type.h" +#include "be_scope.h" +#include "be_visitor.h" +#include "be_codegen.h" +#include "utl_identifier.h" +#include "idl_defines.h" -ACE_RCSID(be, be_type, "$Id$") +ACE_RCSID (be, + be_type, + "$Id$") be_type::be_type (void) - : tc_name_ (0), - nested_type_name_ (0) + : tc_name_ (0) { } @@ -39,8 +43,7 @@ be_type::be_type (AST_Decl::NodeType nt, n), AST_Decl (nt, n), - tc_name_ (0), - nested_type_name_ (0) + tc_name_ (0) { } @@ -126,29 +129,6 @@ be_type::tc_name (void) return this->tc_name_; } -// This code works. However, whether we should generate the -// ACE_NESTED_CLASS macro or not should be based on an option to the -// compiler. The previous version generated a relative path. -// This version always generates ACE_NESTED_CLASS, (leave ace/ACE.h and friends -// do the porting) -// -// Caution: returns the same buffer pointer even if the contents may change -// in the next call. (return std::string anyone?) -// -// Return the type name using the ACE_NESTED_CLASS macro - -const char * -be_type::nested_type_name (be_decl *use_scope, - const char *suffix, - const char *prefix) -{ - return nested_name (this->local_name()->get_string(), - this->full_name(), - use_scope, - suffix, - prefix); -} - // This works for the "special" names generated for smart proxy // classes. The form of these names is // scope'TAO_'+flat_name+'_Smart_Proxy_Base'. @@ -200,275 +180,6 @@ be_type::nested_sp_type_name (be_decl *use_scope, prefix); } -// This is the real thing used by the two other methods above. -const char * -be_type::nested_name (const char* local_name, - const char* full_name, - be_decl *use_scope, - const char *suffix, - const char *prefix) -{ - // Some compilers do not like generating a fully scoped name for a type that - // was defined in the same enclosing scope in which it was defined. For such, - // we emit a macro defined in the ACE library. - // - - // The tricky part here is that it is not enough to check if the - // typename we are using was defined in the current scope. But we - // need to ensure that it was not defined in any of our ancestor - // scopes as well. If that is the case, then we can generate a fully - // scoped name for that type, else we use the ACE_NESTED_CLASS macro. - - // Thus we need some sort of relative name to be generated. - - if (this->nested_type_name_ == 0) - { - ACE_NEW_RETURN (this->nested_type_name_, - char[NAMEBUFSIZE], - 0); - } - - // Our defining scope. - be_decl *def_scope = 0; - - // Hold the fully scoped name. - char def_name [NAMEBUFSIZE]; - char use_name [NAMEBUFSIZE]; - - // These point to the prev, curr and next component in the scope. - char *def_curr = def_name; - char *def_next = 0; - char *use_curr = use_name; - char *use_next = 0; - - // How many chars to compare. - int len_to_match = 0; - - // Initialize the buffers. - ACE_OS::memset (this->nested_type_name_, - '\0', - NAMEBUFSIZE); - - ACE_OS::memset (def_name, - '\0', - NAMEBUFSIZE); - - ACE_OS::memset (use_name, - '\0', - NAMEBUFSIZE); - - // Traverse every component of the def_scope and use_scope beginning at the - // root and proceeding towards the leaf trying to see if the components - // match. Continue until there is a match and keep accumulating the path - // traversed. This forms the first argument to the ACE_NESTED_CLASS - // macro. Whenever there is no match, the remaining components of the - // def_scope form the second argument. - - def_scope = this->defined_in () - ? be_scope::narrow_from_scope (this->defined_in ())->decl () - : 0; - - if (def_scope - && def_scope->node_type () != AST_Decl::NT_root - && use_scope) - // If both scopes exist and that we are not in the root scope. - { - ACE_OS::strcpy (def_name, - def_scope->full_name ()); - - ACE_OS::strcpy (use_name, - use_scope->full_name ()); - - // Find the first occurrence of a :: and advance - // the next pointers accordingly. - def_next = ACE_OS::strstr (def_curr, "::"); - use_next = ACE_OS::strstr (use_curr, "::"); - - // If the scopes are identical, don't supply them. - if (ACE_OS::strcmp (def_name, - use_name) - == 0) - { - if (prefix != 0) - { - ACE_OS::strcat (this->nested_type_name_, - prefix); - } - - ACE_OS::strcat (this->nested_type_name_, - local_name); - if (suffix != 0) - { - ACE_OS::strcat (this->nested_type_name_, - suffix); - } - - return this->nested_type_name_; - } - - if (def_next != 0) - { - len_to_match = - ACE_OS::strlen (def_curr) - ACE_OS::strlen (def_next); - } - else - { - len_to_match = ACE_OS::strlen (def_curr); - } - - if (use_next != 0) - { - int len = - ACE_OS::strlen (use_curr) - ACE_OS::strlen (use_next); - - if (len > len_to_match) - { - len_to_match = len; - } - } - else - { - int len = ACE_OS::strlen (use_curr); - - if (len > len_to_match) - { - len_to_match = len; - } - } - - if (ACE_OS::strncmp (def_curr, - use_curr, - len_to_match) - == 0) - { - // Initial prefix matches i.e., they have a common root. - // Start by initializing the macro. - ACE_OS::sprintf (this->nested_type_name_, - "ACE_NESTED_CLASS ("); - - // Initialize the first argument. - ACE_OS::strncat (this->nested_type_name_, - def_curr, - len_to_match); - - // Shift the current scopes to the next level. - def_curr = (def_next ? (def_next + 2) : 0); // Skip the :: - use_curr = (use_next ? (use_next + 2) : 0); // Skip the :: - - while (def_curr && use_curr) - { - // Find the first occurrence of a :: and advance the - // next pointers accordingly. - def_next = ACE_OS::strstr (def_curr, "::"); - use_next = ACE_OS::strstr (use_curr, "::"); - - if (def_next != 0) - { - len_to_match = - ACE_OS::strlen (def_curr) - ACE_OS::strlen (def_next); - } - else - { - len_to_match = ACE_OS::strlen (def_curr); - } - - if (use_next != 0) - { - int len = - ACE_OS::strlen (use_curr) - ACE_OS::strlen (use_next); - - if (len > len_to_match) - { - len_to_match = len; - } - } - else - { - int len = ACE_OS::strlen (use_curr); - - if (len > len_to_match) - { - len_to_match = len; - } - } - - if (ACE_OS::strncmp (def_curr, - use_curr, - len_to_match) - == 0) - { - // They have same prefix, append to arg1. - ACE_OS::strcat (this->nested_type_name_, - "::"); - - ACE_OS::strncat (this->nested_type_name_, - def_curr, - len_to_match); - - def_curr = (def_next ? (def_next + 2) : 0); // Skip the :: - use_curr = (use_next ? (use_next + 2) : 0); // Skip the :: - } - else - { - // No match. This is the end of the first argument. Get out - // of the loop as no more comparisons are necessary. - break; - } - } - - // Start the 2nd argument of the macro. - ACE_OS::strcat (this->nested_type_name_, ", "); - - // Copy the remaining def_name (if any are left). - if (def_curr != 0) - { - ACE_OS::strcat (this->nested_type_name_, - def_curr); - - ACE_OS::strcat (this->nested_type_name_, - "::"); - } - - // Append our local name. - if (prefix != 0) - { - ACE_OS::strcat (this->nested_type_name_, prefix); - } - - ACE_OS::strcat (this->nested_type_name_, - local_name); - - if (suffix != 0) - { - ACE_OS::strcat (this->nested_type_name_, - suffix); - } - - ACE_OS::strcat (this->nested_type_name_, - ")"); - - return this->nested_type_name_; - } // End of if the root prefixes match. - } - - // Otherwise just emit our full_name. - if (prefix != 0) - { - ACE_OS::strcat (this->nested_type_name_, prefix); - } - - ACE_OS::strcat (this->nested_type_name_, - full_name); - - if (suffix != 0) - { - ACE_OS::strcat (this->nested_type_name_, - suffix); - } - - return this->nested_type_name_; -} - // ***************************** // CODE GENERATION // ***************************** @@ -522,7 +233,7 @@ be_type::destroy (void) if (this->nested_type_name_ != 0) { - delete this->nested_type_name_; + delete [] this->nested_type_name_; this->nested_type_name_ = 0; } } diff --git a/TAO/TAO_IDL/be/be_typedef.cpp b/TAO/TAO_IDL/be/be_typedef.cpp index 85ab37e8eee..3a9a71562bf 100644 --- a/TAO/TAO_IDL/be/be_typedef.cpp +++ b/TAO/TAO_IDL/be/be_typedef.cpp @@ -19,9 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_typedef.h" +#include "be_visitor.h" +#include "ace/Log_Msg.h" ACE_RCSID (be, be_typedef, @@ -69,29 +69,6 @@ be_typedef::primitive_base_type (void) return d; } -// Compute the size type of the node in question. -int -be_typedef::compute_size_type (void) -{ - be_type *type = be_type::narrow_from_decl (this->base_type ()); - - if (type == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_typedef::compute_size_type - " - "bad base type\n"), - -1); - } - - // Our size type is the same as our type. - this->size_type (type->size_type ()); - - //While we're here, take care of has_constructor. - this->has_constructor (type->has_constructor ()); - - return 0; -} - AST_Decl::NodeType be_typedef::base_node_type (void) const { @@ -105,7 +82,8 @@ be_typedef::base_node_type (void) const void be_typedef::destroy (void) { - // Do nothing + this->AST_Typedef::destroy (); + this->be_type::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index d9a2d2461b1..4477c463d60 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -19,11 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_union.h" +#include "be_visitor.h" +#include "be_codegen.h" +#include "be_helper.h" +#include "be_extern.h" +#include "ast_union_branch.h" +#include "utl_identifier.h" +#include "idl_defines.h" -ACE_RCSID(be, be_union, "$Id$") +ACE_RCSID (be, + be_union, + "$Id$") be_union::be_union (void) @@ -58,8 +65,6 @@ be_union::be_union (AST_ConcreteType *dt, int be_union::gen_var_defn (char *) { - TAO_OutStream *ch = 0; - TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; ACE_OS::memset (namebuf, @@ -70,7 +75,7 @@ be_union::gen_var_defn (char *) "%s_var", this->local_name ()->get_string ()); - ch = tao_cg->client_header (); + TAO_OutStream *ch = tao_cg->client_header (); // Generate the var definition (always in the client header). // Depending upon the data type, there are some differences which we account @@ -92,7 +97,7 @@ be_union::gen_var_defn (char *) << " &);" << be_nl; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ch << namebuf << " (const " << this->local_name () << " &); // fixed-size types only" << be_nl; @@ -110,7 +115,7 @@ be_union::gen_var_defn (char *) *ch << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ch << namebuf << " &operator= (const " << this->local_name () << " &); // fixed-size types only" << be_nl; @@ -127,7 +132,7 @@ be_union::gen_var_defn (char *) *ch << "operator " << this->local_name () << " &();" << be_nl; *ch << "operator " << this->local_name () << " &() const;" << be_nl; - if (this->size_type () == be_decl::VARIABLE) + if (this->size_type () == AST_Type::VARIABLE) { *ch << " // Variable size types only." << be_nl; *ch << "operator " << this->local_name () @@ -139,7 +144,7 @@ be_union::gen_var_defn (char *) // The return types of in, out, inout, and _retn are based on the parameter // passing rules and the base type. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ch << "const " << local_name () << " &in (void) const;" << be_nl; *ch << this->local_name () << " &inout (void);" << be_nl; @@ -237,7 +242,7 @@ be_union::gen_var_impl (char *, *ci << "}\n\n"; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { *ci << "// fixed-size types only" << be_nl; *ci << "ACE_INLINE" << be_nl; @@ -305,7 +310,7 @@ be_union::gen_var_impl (char *, << "}\n\n"; // Fixed-size types only. - if (this->size_type () == be_decl::FIXED) + if (this->size_type () == AST_Type::FIXED) { ci->indent (); *ci << "// fixed-size types only" << be_nl; @@ -378,7 +383,7 @@ be_union::gen_var_impl (char *, *ci << "}\n\n"; // Variable-size types only. - if (this->size_type () == be_decl::VARIABLE) + if (this->size_type () == AST_Type::VARIABLE) { ci->indent (); *ci << "// variable-size types only" << be_nl; @@ -413,7 +418,7 @@ be_union::gen_var_impl (char *, // The out and _retn are handled differently based on our size type. ci->indent (); - if (this->size_type () == be_decl::VARIABLE) + if (this->size_type () == AST_Type::VARIABLE) { *ci << "// mapping for variable size " << be_nl; *ci << "ACE_INLINE ::" << this->name () << " *&" << be_nl; @@ -671,37 +676,6 @@ be_union::gen_out_impl (char *, return 0; } -// Compute the size type of the node in question. -int -be_union::compute_size_type (void) -{ - for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node. - AST_Decl *d = si.item (); - be_decl *bd = be_decl::narrow_from_decl (d); - - if (bd != 0) - { - // Our sizetype depends on the sizetype of our members. Although - // previous value of sizetype may get overwritten, we are - // guaranteed by the "size_type" call that once the value reached - // be_decl::VARIABLE, nothing else can overwrite it. - this->size_type (bd->size_type ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_union::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - } - - return 0; -} - idl_bool be_union::has_duplicate_case_labels (void) { diff --git a/TAO/TAO_IDL/be/be_union_branch.cpp b/TAO/TAO_IDL/be/be_union_branch.cpp index 71c9cc6e445..9e5a934b76b 100644 --- a/TAO/TAO_IDL/be/be_union_branch.cpp +++ b/TAO/TAO_IDL/be/be_union_branch.cpp @@ -19,11 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_union_branch, "$Id$") +#include "be_union_branch.h" +#include "be_union.h" +#include "be_type.h" +#include "be_enum.h" +#include "be_visitor.h" +#include "be_helper.h" +#include "ast_union_label.h" + +ACE_RCSID (be, + be_union_branch, + "$Id$") be_union_branch::be_union_branch (void) { @@ -45,27 +51,6 @@ be_union_branch::be_union_branch (UTL_LabelList *ll, { } -// Compute the size type of the node in question. -int -be_union_branch::compute_size_type (void) -{ - be_type *type = be_type::narrow_from_decl (this->field_type ()); - - if (type == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_field::compute_size_type - " - "bad field type\n"), - -1); - } - - // Our size type is the same as our type. - // As a side effect will also update the size type of parent. - this->size_type (type->size_type ()); - - return 0; -} - int be_union_branch::gen_label_value (TAO_OutStream *os, unsigned long index) { @@ -161,7 +146,7 @@ be_union_branch::gen_default_label_value (TAO_OutStream *os, case AST_Expression::EV_bool: *os << dv.u.bool_val; break; - case AST_Expression::EV_any: + case AST_Expression::EV_enum: // The discriminant is an enum. Some compilers will // not accept a numeric value assigned to this // discriminant, so we must generate the string name. diff --git a/TAO/TAO_IDL/be/be_union_fwd.cpp b/TAO/TAO_IDL/be/be_union_fwd.cpp new file mode 100644 index 00000000000..0bdcf6ac257 --- /dev/null +++ b/TAO/TAO_IDL/be/be_union_fwd.cpp @@ -0,0 +1,60 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_union_fwd.cpp +// +// = DESCRIPTION +// Extension of class AST_UnionFwd that provides additional means for C++ +// mapping of a union. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_union_fwd.h" +#include "be_visitor.h" + +ACE_RCSID (be, + be_union_fwd, + "$Id$") + +be_union_fwd::be_union_fwd (void) +{ +} + +be_union_fwd::be_union_fwd (UTL_ScopedName *n) + : be_type (AST_Decl::NT_union_fwd, + n), + AST_UnionFwd (n), + AST_Type (AST_Decl::NT_union_fwd, + n), + AST_Decl (AST_Decl::NT_union_fwd, + n) +{ +} + +be_union_fwd::~be_union_fwd (void) +{ +} + +void +be_union_fwd::destroy (void) +{ + // Do nothing. +} + +int +be_union_fwd::accept (be_visitor *visitor) +{ + return visitor->visit_union_fwd (this); +} + +// Narrowing +IMPL_NARROW_METHODS2 (be_union_fwd, AST_UnionFwd, be_type) +IMPL_NARROW_FROM_DECL (be_union_fwd) diff --git a/TAO/TAO_IDL/be/be_union_label.cpp b/TAO/TAO_IDL/be/be_union_label.cpp index ff9ee596a3c..a6889166db1 100644 --- a/TAO/TAO_IDL/be/be_union_label.cpp +++ b/TAO/TAO_IDL/be/be_union_label.cpp @@ -1,17 +1,20 @@ // // $Id$ // -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -ACE_RCSID(be, be_union_label, "$Id$") +#include "be_union_label.h" +#include "be_visitor.h" -be_union_label::be_union_label() +ACE_RCSID (be, + be_union_label, + "$Id$") + +be_union_label::be_union_label (void) { } + be_union_label::be_union_label (AST_UnionLabel::UnionLabel ul, - AST_Expression *v) + AST_Expression *v) : AST_UnionLabel (ul, v) { diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index 279a4c2ae13..112b060e3e6 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -19,18 +19,24 @@ // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_valuetype, "$Id$") +#include "be_valuetype.h" +#include "be_visitor.h" +#include "be_extern.h" +#include "be_helper.h" +#include "ast_module.h" +#include "idl_defines.h" +#include "nr_extern.h" + +ACE_RCSID (be, + be_valuetype, + "$Id$") // Default constructor. be_valuetype::be_valuetype (void) : full_obv_skel_name_ (0) { // Always the case. - this->size_type (be_decl::VARIABLE); + this->size_type (AST_Type::VARIABLE); AST_Module *m = AST_Module::narrow_from_scope (this->defined_in ()); @@ -41,41 +47,57 @@ be_valuetype::be_valuetype (void) // Always the case. this->has_constructor (I_TRUE); - - // Set the base (AST_Interface) class member. - this->set_valuetype (); } // Constructor used to build the AST. be_valuetype::be_valuetype (UTL_ScopedName *n, - AST_Interface **ih, - long nih, - idl_bool set_abstract) + AST_Interface **inherits, + long n_inherits, + AST_ValueType *inherits_concrete, + AST_Interface **inherits_flat, + long n_inherits_flat, + AST_Interface **supports, + long n_supports, + AST_Interface *supports_concrete, + idl_bool abstract, + idl_bool truncatable) : be_interface (n, - ih, - nih, - 0, + inherits, + n_inherits, + inherits_flat, + n_inherits_flat, 0, - 0, - set_abstract), + abstract), + AST_ValueType (n, + inherits, + n_inherits, + inherits_concrete, + inherits_flat, + n_inherits_flat, + supports, + n_supports, + supports_concrete, + abstract, + truncatable), AST_Interface (n, - ih, - nih, - 0, - 0, + inherits, + n_inherits, + inherits_flat, + n_inherits_flat, 0, - set_abstract), - AST_Decl (AST_Decl::NT_interface, // It's like an interface. + abstract), + AST_Decl (AST_Decl::NT_valuetype, n), - UTL_Scope (AST_Decl::NT_interface), + UTL_Scope (AST_Decl::NT_valuetype), COMMON_Base (0, - set_abstract), - full_obv_skel_name_ (0) + abstract), + full_obv_skel_name_ (0), + supports_abstract_ (0) { // Check that redefine() copies all members. // Always the case. - this->size_type (be_decl::VARIABLE); + this->size_type (AST_Type::VARIABLE); AST_Module *m = AST_Module::narrow_from_scope (this->defined_in ()); @@ -87,21 +109,24 @@ be_valuetype::be_valuetype (UTL_ScopedName *n, // Always the case. this->has_constructor (I_TRUE); - // Set the base (AST_Interface) class member. - this->set_valuetype (); + for (long i = 0; i < this->pd_n_supports; ++i) + { + if (this->pd_supports[i]->is_abstract ()) + { + this->supports_abstract_ = I_TRUE; + break; + } + } } be_valuetype::~be_valuetype (void) { - } void -be_valuetype::redefine (AST_Interface *from) +be_valuetype::redefine (AST_ValueType *from) { - this->AST_Interface::redefine (from); - - this->is_abstract_ = from->is_abstract_valuetype (); + this->AST_ValueType::redefine (from); } // Is true if non-virtual accessor and modifier should be generated @@ -134,48 +159,53 @@ be_valuetype::full_obv_skel_name (void) // Generate the var definition. int -be_valuetype::gen_var_defn (char *) +be_valuetype::gen_var_defn (char *local_name) { - TAO_OutStream *ch = 0; - TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; + if (local_name == 0) + { + local_name = (char *) this->local_name (); + } + ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); ACE_OS::sprintf (namebuf, "%s_var", - this->local_name ()); + local_name); - ch = tao_cg->client_header (); + TAO_OutStream *ch = tao_cg->client_header (); + + *ch << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Generate the var definition (always in the client header). // Depending upon the data type, there are some differences which we account // for over here. - // Start with whatever was our current indent level. *ch << "class " << be_global->stub_export_macro () << " " << namebuf << be_nl; *ch << "{" << be_nl; *ch << "public:" << be_idt_nl; // Default constructor. - *ch << namebuf << " (void); // default constructor" << be_nl; - *ch << namebuf << " (" << this->local_name () << "*);" << be_nl; - *ch << namebuf << " (const " << this->local_name () + *ch << namebuf << " (void);" << be_nl; + *ch << namebuf << " (" << local_name << "*);" << be_nl; + *ch << namebuf << " (const " << local_name << "*); // (TAO extension)" << be_nl; // Copy constructor. *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << be_nl; + " &);" << be_nl; // Destructor. - *ch << "~" << namebuf << " (void); // destructor" << be_nl; + *ch << "~" << namebuf << " (void);" << be_nl; *ch << be_nl; // Assignment operator from a pointer. - *ch << namebuf << " &operator= (" << this->local_name () + *ch << namebuf << " &operator= (" << local_name << "*);" << be_nl; // Assignment from _var. @@ -183,32 +213,38 @@ be_valuetype::gen_var_defn (char *) " &);" << be_nl; // Arrow operator. - *ch << local_name () << "* operator-> (void) const;" << be_nl; + *ch << local_name << "* operator-> (void) const;" << be_nl; *ch << be_nl; // Other extra types (cast operators, [] operator, and others). - *ch << "operator const " << this->local_name () + *ch << "operator const " << local_name << "* () const;" << be_nl; - *ch << "operator " << this->local_name () << "* ();" << be_nl; + *ch << "operator " << local_name << "* ();" << be_nl; *ch << "// in, inout, out, _retn " << be_nl; // The return types of in, out, inout, and _retn are based on the parameter // passing rules and the base type. - *ch << this->local_name () << "* in (void) const;" << be_nl; - *ch << this->local_name () << "* &inout (void);" << be_nl; - *ch << this->local_name () << "* &out (void);" << be_nl; - *ch << this->local_name () << "* _retn (void);" << be_nl; + *ch << local_name << "* in (void) const;" << be_nl; + *ch << local_name << "*& inout (void);" << be_nl; + *ch << local_name << "*& out (void);" << be_nl; + *ch << local_name << "* _retn (void);" << be_nl; // Generate an additional member function that returns // the underlying pointer. - *ch << this->local_name () << "* ptr (void) const;"; + *ch << local_name << "* ptr (void) const;" << be_nl << be_nl; - *ch << be_uidt_nl << be_nl; + // Hooks for non-defined forward declared interfaces. + *ch << "// Hooks used by template sequence and valuetype manager classes" + << be_nl + << "// for non-defined forward declared valuetypes." << be_nl + << "static void tao_add_ref (" << local_name << " *);" << be_nl + << "static void tao_remove_ref (" << local_name << " *);" + << be_uidt_nl << be_nl; // Private. *ch << "private:" << be_idt_nl; - *ch << this->local_name () << "* ptr_;" << be_uidt_nl; + *ch << local_name << "* ptr_;" << be_uidt_nl; *ch << "};" << be_nl << be_nl; @@ -218,12 +254,21 @@ be_valuetype::gen_var_defn (char *) // Implementation of the _var class. All of these get generated in the stubs // file. int -be_valuetype::gen_var_impl (char *, - char *) +be_valuetype::gen_var_impl (char *local_name, + char *full_name) { TAO_OutStream *cs = 0; TAO_NL be_nl; + // Decide on the names to use. + // Even if one argument is 0, there is no point using the + // arguments. Let us then use the name in this node. + if (local_name == 0 || full_name == 0) + { + local_name = (char *) this->local_name (); + full_name = (char *) this->full_name (); + } + // To hold the full and local _var names. char fname [NAMEBUFSIZE]; char lname [NAMEBUFSIZE]; @@ -234,7 +279,7 @@ be_valuetype::gen_var_impl (char *, ACE_OS::sprintf (fname, "%s_var", - this->full_name ()); + full_name); ACE_OS::memset (lname, '\0', @@ -242,7 +287,7 @@ be_valuetype::gen_var_impl (char *, ACE_OS::sprintf (lname, "%s_var", - this->local_name ()); + local_name); cs = tao_cg->client_stubs (); @@ -250,170 +295,176 @@ be_valuetype::gen_var_impl (char *, // Depending upon the data type, there are some differences which we account // for over here. - cs->indent (); // start with whatever was our current indent level + *cs << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *cs << "// *************************************************************" << be_nl; *cs << "// Operations for class " << fname << be_nl; - *cs << "// *************************************************************\n\n"; + *cs << "// *************************************************************" + << be_nl << be_nl; // Default constructor. *cs << fname << "::" << lname << - " (void) // default constructor" << be_nl; + " (void)" << be_nl; *cs << " " << ": ptr_ (0)" << be_nl; - *cs << "{}\n\n"; + *cs << "{}" << be_nl << be_nl; // Constructor from a pointer. - cs->indent (); *cs << fname << "::" << lname << " (" - << this->local_name () << "* p)" << be_nl; + << local_name << "* p)" << be_nl; *cs << " : ptr_ (p)" << be_nl; - *cs << "{}\n\n"; + *cs << "{}" << be_nl << be_nl; // Constructor from a const pointer. // TAO extension - it appears that there are problems with at least g++ // which reclaims amguity between T(T*) and T(const T_var &) - cs->indent (); *cs << fname << "::" << lname << " (const " - << this->local_name () << "* p)" << be_nl; - *cs << " : ptr_ (ACE_const_cast(" - << this->local_name () << "*, p))" << be_nl; - *cs << "{}\n\n"; + << local_name << "* p)" << be_nl; + *cs << " : ptr_ (ACE_const_cast (" + << local_name << " *, p))" << be_nl; + *cs << "{}" << be_nl << be_nl; // The additional ptr () member function. This member function must be // defined before the remaining member functions including the copy // constructor because this inline function is used elsewhere. Hence to make // inlining of this function possible, we must define it before its use. - cs->indent (); - *cs << this->name () << "* " << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::ptr (void) const" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Copy constructor. - cs->indent (); *cs << fname << "::" << lname << " (const " << lname << - " &p) // copy constructor" << be_nl; + " &p)" << be_nl; *cs << "{" << be_idt_nl << "CORBA::add_ref (p.ptr ());" << be_nl << "this->ptr_ = p.ptr ();" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; // Destructor. - cs->indent (); *cs << fname << "::~" << lname << " (void) // destructor" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "CORBA::remove_ref (this->ptr_);\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "CORBA::remove_ref (this->ptr_);" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator. - cs->indent (); *cs << fname << " &" << be_nl; - *cs << fname << "::operator= (" << this->local_name () - << "* p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << fname << "::operator= (" << local_name + << " *p)" << be_nl; + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl; *cs << "this->ptr_ = p;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator from _var. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (const " << lname << " &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "if (this != &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl - << this->local_name() << "* tmp = p.ptr ();" << be_nl + << local_name << " *tmp = p.ptr ();" << be_nl << "CORBA::add_ref (tmp);" << be_nl - << "this->ptr_ = tmp;\n"; - cs->decr_indent (); - *cs << "}" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + << "this->ptr_ = tmp;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Other extra methods - cast operator (). - cs->indent (); - *cs << fname << "::operator const " << this->name () + *cs << fname << "::operator const " << full_name << "* () const // cast" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; - cs->indent (); - *cs << fname << "::operator " << this->name () + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; + + *cs << fname << "::operator " << full_name << "* () // cast " << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // operator-> - cs->indent (); - *cs << this->name () << "* " << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::operator-> (void) const" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // in, inout, out, and _retn. - cs->indent (); - *cs << this->name () << "*" << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::in (void) const" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; - - cs->indent (); - *cs << this->name () << "* &" << be_nl; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; + + *cs << full_name << " *&" << be_nl; *cs << fname << "::inout (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; - - cs->indent (); - *cs << this->name () << "* &" << be_nl; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; + + *cs << full_name << " *&" << be_nl; *cs << fname << "::out (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl; *cs << "this->ptr_ = 0;" << be_nl; - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; - cs->indent (); - *cs << this->name () << "* " << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::_retn (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "// yield ownership of managed obj reference" << be_nl; - *cs << this->local_name () << "* tmp = this->ptr_;" << be_nl; + *cs << local_name << "* tmp = this->ptr_;" << be_nl; *cs << "this->ptr_ = 0;" << be_nl; - *cs << "return tmp;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return tmp;" << be_uidt_nl; + *cs << "}" << be_nl << be_nl; + + // Hooks for the flat name global functions used by references to + // non-defined valuetypes. + *cs << "void" << be_nl + << fname << "::tao_add_ref (" << be_idt << be_idt_nl + << local_name << " *p" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "CORBA::add_ref (p);" + << be_uidt_nl + << "}" << be_nl << be_nl; + + *cs << "void" << be_nl + << fname << "::tao_remove_ref (" << be_idt << be_idt_nl + << local_name << " *p" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "CORBA::remove_ref (p);" << be_uidt_nl + << "}" << be_nl << be_nl; return 0; } @@ -436,6 +487,9 @@ be_valuetype::gen_out_defn (char *) ch = tao_cg->client_header (); + *ch << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the out definition (always in the client header). *ch << "class " << be_global->stub_export_macro () @@ -466,10 +520,10 @@ be_valuetype::gen_out_defn (char *) << "*);" << be_nl; // Cast. - *ch << "operator " << this->local_name () << "* &();" << be_nl; + *ch << "operator " << this->local_name () << "*& ();" << be_nl; // ptr function. - *ch << this->local_name () << "* &ptr (void);" << be_nl; + *ch << this->local_name () << "*& ptr (void);" << be_nl; // operator -> *ch << this->local_name () << "* operator-> (void);" << be_nl; @@ -511,144 +565,142 @@ be_valuetype::gen_out_impl (char *, cs = tao_cg->client_stubs (); + *cs << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the var implementation in the inline file // Depending upon the data type, there are some differences which we account // for over here. - // Start with whatever was our current indent level. - cs->indent (); - *cs << "// *************************************************************" << be_nl; *cs << "// Operations for class " << fname << be_nl; - *cs << "// *************************************************************\n\n"; + *cs << "// *************************************************************" + << be_nl << be_nl; // Constructor from a pointer. - cs->indent (); *cs << fname << "::" << lname << " (" << this->local_name () - << "* &p)" << be_nl; + << " *&p)" << be_nl; *cs << " : ptr_ (p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "this->ptr_ = 0;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "this->ptr_ = 0;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Constructor from _var &. - cs->indent (); *cs << fname << "::" << lname << " (" << this->local_name () - << "_var &p) // constructor from _var" << be_nl; + << "_var &p)" << be_nl; *cs << " : ptr_ (p.out ())" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + *cs << "{" << be_idt_nl; + *cs << "CORBA::remove_ref (this->ptr_);" << be_nl; - *cs << "this->ptr_ = 0;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "this->ptr_ = 0;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Copy constructor. - cs->indent (); *cs << fname << "::" << lname << " (const " << lname - << " &p) // copy constructor" << be_nl; - *cs << " : ptr_ (ACE_const_cast (" << lname << "&,p).ptr_)" << be_nl; - *cs << "{}\n\n"; + << " &p)" << be_nl; + *cs << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << be_nl; + *cs << "{}" << be_nl << be_nl; // Assignment operator from _out &. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (const " << lname << " &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "this->ptr_ = ACE_const_cast (" << lname << "&,p).ptr_;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << be_nl; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator from _var. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (const " << this->local_name () << "_var &p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << this->local_name () << "* tmp = p.ptr ();" << be_nl + *cs << "{" << be_idt_nl; + + *cs << this->local_name () << " *tmp = p.ptr ();" << be_nl << "CORBA::add_ref (tmp);" << be_nl << "this->ptr_ = tmp;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Assignment operator from *. - cs->indent (); *cs << fname << " &" << be_nl; *cs << fname << "::operator= (" << this->local_name () - << "* p)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); + << " *p)" << be_nl; + *cs << "{" << be_idt_nl; + *cs << "this->ptr_ = p;" << be_nl; - *cs << "return *this;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "return *this;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // Other extra methods - cast operator (). - cs->indent (); *cs << fname << "::operator " << this->name () - << "* &() // cast" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + << "*& () // cast" << be_nl; + *cs << "{" << be_idt_nl; + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // ptr function. - cs->indent (); - *cs << this->name () << "* &" << be_nl; + *cs << this->name () << " *&" << be_nl; *cs << fname << "::ptr (void) // ptr" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; // operator-> - cs->indent (); - *cs << this->name () << "* " << be_nl; + *cs << this->name () << " *" << be_nl; *cs << fname << "::operator-> (void)" << be_nl; - *cs << "{\n"; - cs->incr_indent (); - *cs << "return this->ptr_;\n"; - cs->decr_indent (); - *cs << "}\n\n"; + *cs << "{" << be_idt_nl; + + *cs << "return this->ptr_;" << be_uidt_nl; + + *cs << "}" << be_nl << be_nl; + + *cs << "// *************************************************************" + << be_nl << be_nl; return 0; } int -be_valuetype::gen_helper_header (char* , - char* ) +be_valuetype::gen_helper_header (char*, + char*) { TAO_OutStream *os = 0; os = tao_cg->client_header (); - *os << "//@@ Boris: begin experimental" << be_nl - << "TAO_NAMESPACE CORBA" << be_nl + *os << be_nl + << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "TAO_NAMESPACE CORBA" << be_nl << "{" << be_idt_nl - << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" << this->full_name () << " *);" << be_nl - << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" << this->full_name () << " *);" - << be_uidt_nl + << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" + << this->full_name () << " *);" << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" + << this->full_name () << " *);"; + + *os << be_uidt_nl << "}" << be_nl - << "TAO_NAMESPACE_CLOSE" << be_nl - << "//@@ Boris: end experimental" << be_nl << be_nl; + << "TAO_NAMESPACE_CLOSE" << be_nl << be_nl; return 0; } int -be_valuetype::gen_helper_inline (char* , - char* ) +be_valuetype::gen_helper_inline (char*, + char*) { TAO_OutStream *os = 0; @@ -658,17 +710,20 @@ be_valuetype::gen_helper_inline (char* , // is not getting generated... Actually this is a much bigger // problem. Just hacking it up for the timebeing.. + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "#if defined (__ACE_INLINE__)" << be_nl - << "//@@ Boris: begin experimental" << be_nl << "TAO_NAMESPACE CORBA" << be_nl << "{" << be_idt_nl - << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" << this->full_name () << " *);" << be_nl - << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" << this->full_name () << " *);" + << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" + << this->full_name () << " *);" << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" + << this->full_name () << " *);" << be_uidt_nl << "}" << be_nl << "TAO_NAMESPACE_CLOSE" << be_nl - << "//@@ Boris: end experimental" << be_nl << "#endif /*__ACE_INLINE__*/"<< be_nl; return 0; @@ -683,68 +738,54 @@ be_valuetype::gen_helper_stubs (char* , os = tao_cg->client_stubs (); - *os << "//@@ Boris: begin experimental" << be_nl - // add_ref - << "void" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "void" << be_nl << "CORBA::add_ref (" << this->full_name () << " * vt)" << be_nl - << "{" - << be_idt_nl - << "if (vt != 0)" << be_nl - << "{" - << be_idt_nl - << "vt->_add_ref ();" - << be_uidt_nl - << "}" - << be_uidt_nl - << "}" << be_nl << be_nl - // remove_ref - << "void" << be_nl + << "{" << be_idt_nl + << "if (vt != 0)" << be_idt_nl + << "{" << be_idt_nl + << "vt->_add_ref ();" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "void" << be_nl << "CORBA::remove_ref (" << this->full_name () << " * vt)" << be_nl - << "{" - << be_idt_nl - << "if (vt != 0)" << be_nl - << "{" - << be_idt_nl - << "vt->_remove_ref ();" - << be_uidt_nl - << "}" - << be_uidt_nl - << "}" << be_nl << be_nl - << "//@@ Boris: end experimental" << be_nl; + << "{" << be_idt_nl + << "if (vt != 0)" << be_idt_nl + << "{" << be_idt_nl + << "vt->_remove_ref ();" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; return 0; } // For building the pre and postfix of private data fields. -const char* +const char * be_valuetype::field_pd_prefix (void) { return "_pd_"; } -const char* +const char * be_valuetype::field_pd_postfix (void) { return ""; } -be_valuetype* +be_valuetype * be_valuetype::statefull_inherit (void) { - be_valuetype *rval = 0; - - if (this->n_inherits () > 0) + if (this->pd_inherits_concrete != 0) { - rval = be_valuetype::narrow_from_decl (this->inherits ()[0]); - - if (rval && (rval->is_valuetype ()) - && (!rval->is_abstract_valuetype ())) - { - return rval; - } + return be_valuetype::narrow_from_decl (this->pd_inherits_concrete); + } + else + { + return 0; } - - return 0; } // Accept a visitor. @@ -754,6 +795,12 @@ be_valuetype::accept (be_visitor *visitor) return visitor->visit_valuetype (this); } +void +be_valuetype::destroy (void) +{ + this->be_interface::destroy (); +} + ACE_CDR::ULong be_valuetype::data_members_count (AST_Field::Visibility vis) { @@ -860,8 +907,226 @@ be_valuetype::in_recursion (AST_Type *node) return 0; } +idl_bool +be_valuetype::supports_abstract (void) const +{ + return this->supports_abstract_; +} + +// Template method that traverses the inheritance graph in a breadth-first +// style. The actual work on each element in the inheritance graph is carried +// out by the function passed as argument. +int +be_valuetype::traverse_supports_list_graphs ( + be_interface::tao_code_emitter gen, + TAO_OutStream *os, + idl_bool abstract_paths_only + ) +{ + long n_supports = this->n_supports (); + + if (n_supports == 0) + { + return 0; + } + + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + be_interface *supported_interface = 0; + + for (long i = 0; i < n_supports; ++i) + { + if (abstract_paths_only + && ! this->pd_supports[i]->is_abstract ()) + { + continue; + } + + supported_interface = + be_interface::narrow_from_decl (this->pd_supports[i]); + + // Insert a supported interface in the queue. + if (this->insert_queue.enqueue_tail (supported_interface) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_valuetype::" + "traverse_supports_graph_list - " + "error generating entries\n"), + -1); + } + } + + be_code_emitter_wrapper wrapper (gen); + + return this->traverse_inheritance_graph (wrapper, + os, + abstract_paths_only); +} + +int +be_valuetype::traverse_concrete_inheritance_graph (tao_code_emitter gen, + TAO_OutStream *os) +{ + AST_Interface *supported = this->supports_concrete (); + + if (supported == 0) + { + return 0; + } + + be_interface *concrete = be_interface::narrow_from_decl (supported); + + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + // Insert the supported concrete interface in the queue. + if (this->insert_queue.enqueue_tail (concrete) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_valuetype::" + "traverse_concrete_inheritance_graph - " + "error generating entries\n"), + -1); + } + + be_code_emitter_wrapper wrapper (gen); + + return this->traverse_inheritance_graph (wrapper, + os); +} + +int +be_valuetype::abstract_supports_helper (be_interface *, + be_interface *base, + TAO_OutStream *os) +{ + *os << "," << be_nl + << "public virtual "; + + if (base->is_nested ()) + { + UTL_Scope *parent_scope = base->defined_in (); + AST_Decl *parent_decl = ScopeAsDecl (parent_scope); + + *os << "ACE_NESTED_CLASS (" + << parent_decl->name () << ", " + << base->local_name () << ")"; + } + else + { + *os << base->local_name (); + } + + return 0; +} + +int +be_valuetype::gen_abstract_init_helper (be_interface *, + be_interface *, + TAO_OutStream *os) +{ +// *os << be_nl +// << "this->value_ = this;"; + + return 0; +} + +int +be_valuetype::gen_skel_helper (be_interface *concrete, + be_interface *ancestor, + TAO_OutStream *os) +{ + // If derived and ancestor are same, skip it. + if (concrete == ancestor) + { + return 0; + } + + // If an operation or an attribute is abstract (declared in an + // abstract interface), we will either generate the full + // definition (if there are no concrete interfaces between the + // abstract ancestor and us) or, if there is a concrete ancestor + // in between, we will catch its definition elsewhere in this + // traversal. + if (ancestor->is_abstract ()) + { + return 0; + } + + // Else generate code that does the cast to the appropriate type. + + if (ancestor->nmembers () > 0) + { + // If there are elements in ancestor scope i.e., any operations and + // attributes defined by "ancestor", become methods on the derived class + // which call the corresponding method of the base class by doing the + // proper casting. + + for (UTL_ScopeActiveIterator si (ancestor, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + // Get the next AST decl node + AST_Decl *d = si.item (); + + if (d->node_type () == AST_Decl::NT_op) + { + // Start from current indentation level. + os->indent (); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) + { + // Generate the static method corresponding to this method. + *os << "static void " << d->local_name () + << "_skel (" << be_idt << be_idt_nl + << "TAO_ServerRequest &req, " << be_nl + << "void *obj," << be_nl + << "void *context" << be_nl + << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt << "\n\n"; + } + else + { // Generate code in the inline file. + // Generate the static method corresponding to this method. + *os << "ACE_INLINE void " + << concrete->full_skel_name () << "::" + << d->local_name () + << "_skel (" << be_idt << be_idt_nl + << "TAO_ServerRequest &req," << be_nl + << "void *obj," << be_nl + << "void *context" << be_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl; + *os << ancestor->full_skel_name () + << "_ptr impl = (" + << concrete->full_skel_name () + << "_ptr) obj;" << be_nl; + *os << ancestor->full_skel_name () + << "::" << d->local_name () + << "_skel (" << be_idt << be_idt_nl + << "req," << be_nl + << "(" << ancestor->full_skel_name () + << "_ptr) impl," << be_nl + << "context" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}\n"; + } + } + } // End of scope iterator. + } + + return 0; +} // Narrowing. -IMPL_NARROW_METHODS1 (be_valuetype, be_interface) +IMPL_NARROW_METHODS2 (be_valuetype, be_interface, AST_ValueType) IMPL_NARROW_FROM_DECL (be_valuetype) IMPL_NARROW_FROM_SCOPE (be_valuetype) diff --git a/TAO/TAO_IDL/be/be_valuetype_fwd.cpp b/TAO/TAO_IDL/be/be_valuetype_fwd.cpp index 7a40580c295..b62641c922b 100644 --- a/TAO/TAO_IDL/be/be_valuetype_fwd.cpp +++ b/TAO/TAO_IDL/be/be_valuetype_fwd.cpp @@ -21,11 +21,13 @@ // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_valuetype_fwd.h" +#include "be_visitor.h" +#include "ast_interface.h" -ACE_RCSID(be, be_valuetype_fwd, "$Id$") +ACE_RCSID (be, + be_valuetype_fwd, + "$Id$") be_valuetype_fwd::be_valuetype_fwd (void) { @@ -35,9 +37,11 @@ be_valuetype_fwd::be_valuetype_fwd (AST_Interface *dummy, UTL_ScopedName *n) : be_interface_fwd (dummy, n), + AST_ValueTypeFwd (dummy, + n), AST_InterfaceFwd (dummy, n), - AST_Decl (AST_Decl::NT_interface_fwd, + AST_Decl (AST_Decl::NT_valuetype_fwd, n) { } @@ -46,20 +50,19 @@ be_valuetype_fwd::~be_valuetype_fwd (void) { } - -void -be_valuetype_fwd::set_abstract_valuetype (void) -{ - this->full_definition ()->set_abstract_valuetype (); -} - int be_valuetype_fwd::accept (be_visitor *visitor) { return visitor->visit_valuetype_fwd (this); } +void +be_valuetype_fwd::destroy (void) +{ + this->be_interface_fwd::destroy (); +} + // Narrowing. -IMPL_NARROW_METHODS1 (be_valuetype_fwd, be_interface_fwd) +IMPL_NARROW_METHODS2 (be_valuetype_fwd, be_interface_fwd, AST_ValueTypeFwd) IMPL_NARROW_FROM_DECL (be_valuetype_fwd) diff --git a/TAO/TAO_IDL/be/be_visitor.cpp b/TAO/TAO_IDL/be/be_visitor.cpp index 440c1f9a3b3..b25f89f7914 100644 --- a/TAO/TAO_IDL/be/be_visitor.cpp +++ b/TAO/TAO_IDL/be/be_visitor.cpp @@ -21,11 +21,12 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" #include "be_visitor.h" -#include "be_visitor_valuetype.h" -ACE_RCSID(be, be_visitor, "$Id$") +#include "ace/config-all.h" + +ACE_RCSID (be, + be_visitor, + "$Id$") be_visitor::be_visitor (void) { @@ -81,6 +82,21 @@ int be_visitor::visit_valuetype_fwd (be_valuetype_fwd *) return 0; } +int be_visitor::visit_component (be_component *) +{ + return 0; +} + +int be_visitor::visit_component_fwd (be_component_fwd *) +{ + return 0; +} + +int be_visitor::visit_home (be_home *) +{ + return 0; +} + int be_visitor::visit_factory (be_factory *) { return 0; @@ -91,6 +107,11 @@ int be_visitor::visit_structure (be_structure *) return 0; } +int be_visitor::visit_structure_fwd (be_structure_fwd *) +{ + return 0; +} + int be_visitor::visit_exception (be_exception *) { return 0; @@ -131,6 +152,11 @@ int be_visitor::visit_union (be_union *) return 0; } +int be_visitor::visit_union_fwd (be_union_fwd *) +{ + return 0; +} + int be_visitor::visit_union_branch (be_union_branch *) { return 0; @@ -180,3 +206,4 @@ int be_visitor::visit_native (be_native *) { return 0; } + diff --git a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp index 25ccb84e649..a38874c9b05 100644 --- a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp @@ -1,4 +1,3 @@ -//============================================================================= /** * @file be_visitor_amh_pre_proc.cpp * @@ -15,20 +14,26 @@ //============================================================================= #include "be_visitor_amh_pre_proc.h" +#include "be_visitor_context.h" +#include "be_root.h" +#include "be_module.h" +#include "be_interface.h" +#include "be_valuetype.h" +#include "be_attribute.h" +#include "be_operation.h" +#include "be_predefined_type.h" +#include "be_argument.h" +#include "utl_identifier.h" be_visitor_amh_pre_proc::be_visitor_amh_pre_proc (be_visitor_context *ctx) : be_visitor_scope (ctx) { } - - be_visitor_amh_pre_proc::~be_visitor_amh_pre_proc (void) { } - - int be_visitor_amh_pre_proc::visit_root (be_root *node) { @@ -43,8 +48,6 @@ be_visitor_amh_pre_proc::visit_root (be_root *node) return 0; } - - int be_visitor_amh_pre_proc::visit_module (be_module *node) { @@ -59,8 +62,6 @@ be_visitor_amh_pre_proc::visit_module (be_module *node) return 0; } - - int be_visitor_amh_pre_proc::visit_interface (be_interface *node) { @@ -70,13 +71,13 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node) return 0; } - // don't generate AMH classes for imported or local interfaces + // Don't generate AMH classes for imported, local or abstract interfaces // either... // @@ Mayur, maybe we do want to insert the AMH node for imported // interfaces, not because we want to generate code for them, but // because the (imported-AMH-) node could be needed to generate a // non-imported, AMH node, for example, for a derived interface. - if (node->imported () || node->is_local ()) + if (node->imported () || node->is_local () || node->is_abstract ()) { return 0; } @@ -128,7 +129,6 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node) return 0; } - be_interface * be_visitor_amh_pre_proc::create_response_handler ( be_interface *node, @@ -174,7 +174,6 @@ be_visitor_amh_pre_proc::create_response_handler ( return response_handler; } - int be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node, be_interface *response_handler, @@ -201,7 +200,9 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node, 0); } - if (d->node_type () == AST_Decl::NT_attr) + AST_Decl::NodeType nt = d->node_type (); + + if (nt == AST_Decl::NT_attr) { be_attribute *attribute = be_attribute::narrow_from_decl (d); @@ -210,7 +211,7 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node, return 0; } } - else + else if (nt == AST_Decl::NT_op) { be_operation* operation = be_operation::narrow_from_decl (d); @@ -221,12 +222,15 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node, exception_holder); } } + else + { + continue; + } } return 1; } - int be_visitor_amh_pre_proc::create_response_handler_operation ( be_operation *node, @@ -263,7 +267,7 @@ be_visitor_amh_pre_proc::add_exception_reply (be_operation *node, be_interface *response_handler, be_valuetype *exception_holder) { - Identifier *id = 0; + Identifier *id = 0; UTL_ScopedName *sn = 0; ACE_NEW_RETURN (id, @@ -312,7 +316,7 @@ be_visitor_amh_pre_proc::add_exception_reply (be_operation *node, -1); argument->set_defined_in (node_excep); - node_excep->add_argument_to_scope (argument); + node_excep->be_add_argument (argument); node_excep->set_defined_in (response_handler); response_handler->be_add_operation (node_excep); @@ -395,7 +399,7 @@ be_visitor_amh_pre_proc::add_normal_reply (be_operation *node, -1); // Add the response handler to the argument list - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); } // Iterate over the arguments and put all the out and inout arguments @@ -430,7 +434,7 @@ be_visitor_amh_pre_proc::add_normal_reply (be_operation *node, original_arg->name ()), -1); - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); } } @@ -446,7 +450,6 @@ be_visitor_amh_pre_proc::add_normal_reply (be_operation *node, return 0; } - int be_visitor_amh_pre_proc::visit_operation (be_operation *node) { @@ -476,7 +479,6 @@ be_visitor_amh_pre_proc::visit_operation (be_operation *node) return 0; } - int be_visitor_amh_pre_proc::visit_attribute (be_attribute *node) { @@ -616,14 +618,22 @@ be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) AST_Interface **p_intf = 0; UTL_ScopedName *excep_holder_name = - node->compute_name ("AMH_", "ExceptionHolder"); + node->compute_name ("AMH_", + "ExceptionHolder"); be_valuetype *excep_holder = 0; ACE_NEW_RETURN (excep_holder, - be_valuetype (excep_holder_name, // name - p_intf, // list of inherited - inherit_count, // number of inherited - 1), // set not abstract + be_valuetype (excep_holder_name, + p_intf, + inherit_count, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0), 0); excep_holder->set_name (excep_holder_name); @@ -648,8 +658,9 @@ be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) } be_decl *op = be_decl::narrow_from_decl (d); + AST_Decl::NodeType nt = d->node_type (); - if (d->node_type () == AST_Decl::NT_attr) + if (nt == AST_Decl::NT_attr) { AST_Attribute *attribute = AST_Attribute::narrow_from_decl (d); @@ -669,12 +680,16 @@ be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) SET_OPERATION); } } - else + else if (nt == AST_Decl::NT_op) { this->create_raise_operation (op, excep_holder, NORMAL); } + else + { + continue; + } } return excep_holder; @@ -780,9 +795,11 @@ be_visitor_amh_pre_proc::create_raise_operation ( // Set the proper strategy. be_operation_ami_exception_holder_raise_strategy *ehrs = 0; - ACE_NEW_RETURN (ehrs, - be_operation_ami_exception_holder_raise_strategy (operation), - -1); + ACE_NEW_RETURN ( + ehrs, + be_operation_ami_exception_holder_raise_strategy (operation), + -1 + ); be_operation_strategy *old_strategy = operation->set_strategy (ehrs); @@ -846,7 +863,9 @@ be_visitor_amh_pre_proc::generate_get_operation (be_attribute *node) be_operation * be_visitor_amh_pre_proc::generate_set_operation (be_attribute *node) { - ACE_CString original_op_name (node->name ()->last_component ()->get_string ()); + ACE_CString original_op_name ( + node->name ()->last_component ()->get_string () + ); ACE_CString new_op_name = ACE_CString ("set_") + original_op_name; UTL_ScopedName *set_name = ACE_static_cast (UTL_ScopedName *, @@ -894,7 +913,7 @@ be_visitor_amh_pre_proc::generate_set_operation (be_attribute *node) operation->set_name (set_name); operation->set_defined_in (node->defined_in ()); - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); return operation; } diff --git a/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp index ed55e812afe..4b8035eac7b 100644 --- a/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp @@ -22,11 +22,23 @@ // // ============================================================================ - #include "be_visitor_ami_pre_proc.h" - - -ACE_RCSID(be, be_visitor_ami_pre_proc, "$Id$") +#include "be_visitor_context.h" +#include "be_root.h" +#include "be_module.h" +#include "be_interface.h" +#include "be_interface_strategy.h" +#include "be_valuetype.h" +#include "be_operation.h" +#include "be_operation_strategy.h" +#include "be_attribute.h" +#include "be_predefined_type.h" +#include "be_argument.h" +#include "utl_identifier.h" + +ACE_RCSID (be, + be_visitor_ami_pre_proc, + "$Id$") be_visitor_ami_pre_proc::be_visitor_ami_pre_proc (be_visitor_context *ctx) @@ -35,13 +47,11 @@ be_visitor_ami_pre_proc::be_visitor_ami_pre_proc (be_visitor_context *ctx) } - // constructor is protected be_visitor_ami_pre_proc::~be_visitor_ami_pre_proc (void) { } - int be_visitor_ami_pre_proc::visit_root (be_root *node) { @@ -78,105 +88,106 @@ be_visitor_ami_pre_proc::visit_module (be_module *node) int be_visitor_ami_pre_proc::visit_interface (be_interface *node) { - if (!node->imported () && !node->is_local ()) + if (node->imported () || node->is_local () || node->is_abstract ()) { - AST_Module *module = - AST_Module::narrow_from_scope (node->defined_in ()); + return 0; + } - if (!module) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_pre_proc::" - "visit_interface - " - "module is null\n"), - -1); - } + AST_Module *module = + AST_Module::narrow_from_scope (node->defined_in ()); - be_valuetype *excep_holder = this->create_exception_holder (node); + if (!module) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_pre_proc::" + "visit_interface - " + "module is null\n"), + -1); + } + be_valuetype *excep_holder = this->create_exception_holder (node); - be_interface *reply_handler = this->create_reply_handler (node, - excep_holder); - if (reply_handler) - { - reply_handler->set_defined_in (node->defined_in ()); + be_interface *reply_handler = this->create_reply_handler (node, + excep_holder); + if (reply_handler) + { + reply_handler->set_defined_in (node->defined_in ()); - // Insert the ami handler after the node, the - // exception holder will be placed between these two later. - module->be_add_interface (reply_handler, node); + // Insert the ami handler after the node, the + // exception holder will be placed between these two later. + module->be_add_interface (reply_handler, node); - // Remember from whom we were cloned - reply_handler->original_interface (node); - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_pre_proc::" - "visit_interface - " - "creating the reply handler failed\n"), - -1); - } + // Remember from whom we were cloned + reply_handler->original_interface (node); + } + else + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_pre_proc::" + "visit_interface - " + "creating the reply handler failed\n"), + -1); + } + + // Set the proper strategy. + be_interface_ami_strategy *bias = 0; + ACE_NEW_RETURN (bias, + be_interface_ami_strategy (node, + reply_handler), + -1); + be_interface_strategy *old_strategy = node->set_strategy (bias); + + if (old_strategy) + { + delete old_strategy; + old_strategy = 0; + } - // Set the proper strategy. - be_interface_ami_strategy *bias = 0; - ACE_NEW_RETURN (bias, - be_interface_ami_strategy (node, - reply_handler), + if (excep_holder) + { + excep_holder->set_defined_in (node->defined_in ()); + // Insert the exception holder after the original node, + // this way we ensure that it is *before* the + // ami handler, which is the way we want to have it. + module->be_add_interface (excep_holder, node); + module->set_has_nested_valuetype (); + // Remember from whom we were cloned. + excep_holder->original_interface (node); + + // Set the strategy. + be_interface_ami_exception_holder_strategy *biaehs = 0; + ACE_NEW_RETURN (biaehs, + be_interface_ami_exception_holder_strategy ( + excep_holder + ), -1); - be_interface_strategy *old_strategy = node->set_strategy (bias); + + be_interface_strategy *old_strategy = + excep_holder->set_strategy (biaehs); if (old_strategy) { delete old_strategy; old_strategy = 0; } - - if (excep_holder) - { - excep_holder->set_defined_in (node->defined_in ()); - // Insert the exception holder after the original node, - // this way we ensure that it is *before* the - // ami handler, which is the way we want to have it. - module->be_add_interface (excep_holder, node); - module->set_has_nested_valuetype (); - // Remember from whom we were cloned. - excep_holder->original_interface (node); - - // Set the strategy. - be_interface_ami_exception_holder_strategy *biaehs = 0; - ACE_NEW_RETURN (biaehs, - be_interface_ami_exception_holder_strategy ( - excep_holder - ), - -1); - - be_interface_strategy *old_strategy = - excep_holder->set_strategy (biaehs); - - if (old_strategy) - { - delete old_strategy; - old_strategy = 0; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_pre_proc::" - "visit_interface - " - "creating the exception holder failed\n"), - -1); - } + } + else + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_pre_proc::" + "visit_interface - " + "creating the exception holder failed\n"), + -1); + } - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_pre_proc::" - "visit_interface - " - "visit scope failed\n"), - -1); - } + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_pre_proc::" + "visit_interface - " + "visit scope failed\n"), + -1); } return 0; @@ -210,7 +221,7 @@ be_visitor_ami_pre_proc::visit_operation (be_operation *node) // Set the proper strategy, and store the specialized // marshaling and arguments operations in it. - be_operation_ami_sendc_strategy * boass= 0; + be_operation_ami_sendc_strategy * boass = 0; ACE_NEW_RETURN (boass, be_operation_ami_sendc_strategy (node, sendc_marshaling, @@ -229,7 +240,6 @@ be_visitor_ami_pre_proc::visit_operation (be_operation *node) return 0; } - int be_visitor_ami_pre_proc::visit_attribute (be_attribute *node) { @@ -281,11 +291,6 @@ be_visitor_ami_pre_proc::visit_attribute (be_attribute *node) return 0; } - - - - - be_valuetype * be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) { @@ -319,6 +324,13 @@ be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) be_valuetype (inherit_name, 0, 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0), 0); @@ -360,15 +372,21 @@ be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) AST_Interface_ptr[1], 0); - p_intf[0] = ACE_static_cast (AST_Interface *, - inherit_vt); + p_intf[0] = inherit_vt; be_valuetype *excep_holder = 0; ACE_NEW_RETURN (excep_holder, - be_valuetype (excep_holder_name, // name - p_intf, // list of inherited - 1, // number of inherited - 0), // set abstract + be_valuetype (0, + p_intf, + 1, + inherit_vt, + 0, + 0, + 0, + 0, + 0, + 0, + 0), 0); excep_holder->set_name (excep_holder_name); @@ -395,8 +413,9 @@ be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) } be_decl *op = be_decl::narrow_from_decl (d); + AST_Decl::NodeType nt = d->node_type (); - if (d->node_type () == AST_Decl::NT_attr) + if (nt == AST_Decl::NT_attr) { AST_Attribute *attribute = AST_Attribute::narrow_from_decl (d); @@ -417,19 +436,22 @@ be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) } } - else + else if (nt == AST_Decl::NT_op) { this->create_raise_operation (op, excep_holder, NORMAL); } + else + { + continue; + } } // end of while loop } // end of if return excep_holder; } - be_interface * be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, be_valuetype *excep_holder) @@ -518,8 +540,8 @@ be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, be_interface (reply_handler_name, // name p_intf, // list of inherited 1, // number of inherited - p_intf, // list of ancestors - 1, // number of ancestors + 0, // list of all ancestors + 0, // number of ancestors 0, // non-local 0), // non-abstract 0); @@ -600,7 +622,6 @@ be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, return reply_handler; } - int be_visitor_ami_pre_proc::create_raise_operation ( be_decl *node, @@ -819,7 +840,7 @@ be_visitor_ami_pre_proc::create_sendc_operation (be_operation *node, 0); // Add the reply handler to the argument list - op->add_argument_to_scope (arg); + op->be_add_argument (arg); } // Iterate over the arguments and put all the in and inout @@ -858,7 +879,7 @@ be_visitor_ami_pre_proc::create_sendc_operation (be_operation *node, original_arg->name ()), 0); - op->add_argument_to_scope (arg); + op->be_add_argument (arg); } } // end of while loop } // end of if @@ -955,7 +976,7 @@ be_visitor_ami_pre_proc::create_reply_handler_operation ( -1); // Add the reply handler to the argument list. - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); } // Iterate over the arguments and put all the in and inout @@ -992,7 +1013,7 @@ be_visitor_ami_pre_proc::create_reply_handler_operation ( original_arg->name ()), -1); - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); } } // end of while loop } // end of if @@ -1107,7 +1128,7 @@ be_visitor_ami_pre_proc::create_excep_operation (be_operation *node, -1); operation->set_name (op_name); - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); operation->set_defined_in (reply_handler); @@ -1121,7 +1142,6 @@ be_visitor_ami_pre_proc::create_excep_operation (be_operation *node, return 0; } - // Visit the scope and its elements. int be_visitor_ami_pre_proc::visit_scope (be_scope *node) @@ -1222,8 +1242,6 @@ be_visitor_ami_pre_proc::generate_name (ACE_CString &destination, return 0; } - - be_operation * be_visitor_ami_pre_proc::generate_get_operation (be_attribute *node) { @@ -1304,7 +1322,7 @@ be_visitor_ami_pre_proc::generate_set_operation (be_attribute *node) operation->set_name (set_name); operation->set_defined_in (node->defined_in ()); - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); return operation; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument.cpp index 2d436b89bae..1ffec9f5654 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument.cpp @@ -18,11 +18,27 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" #include "be_visitor_argument.h" +#include "be_visitor_context.h" +#include "be_argument.h" +#include "be_type.h" +#include "be_array.h" +#include "be_enum.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_native.h" +#include "be_predefined_type.h" +#include "be_string.h" +#include "be_typedef.h" +#include "be_structure.h" +#include "be_union.h" +#include "be_sequence.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_operation.h" +#include "be_helper.h" +#include "utl_identifier.h" -// include all the individual files #include "be_visitor_argument/arglist.cpp" #include "be_visitor_argument/argument.cpp" #include "be_visitor_argument/marshal_ss.cpp" @@ -40,4 +56,6 @@ #include "be_visitor_argument/request_info_result.cpp" #include "be_visitor_argument/request_info_arglist.cpp" -ACE_RCSID(be, be_visitor_argument, "$Id$") +ACE_RCSID (be, + be_visitor_argument, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp index 8ab31451328..33f70ae17a0 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, arglist, "$Id$") +ACE_RCSID (be_visitor_argument, + arglist, + "$Id$") // ************************************************************ @@ -41,10 +39,10 @@ be_visitor_args_arglist::~be_visitor_args_arglist (void) int be_visitor_args_arglist::visit_argument (be_argument *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - this->ctx_->node (node); // save the argument node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - // retrieve the type + // Retrieve the type. be_type *bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) @@ -153,7 +151,7 @@ int be_visitor_args_arglist::visit_interface_fwd (be_interface_fwd *node) int be_visitor_args_arglist::visit_native (be_native *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -167,15 +165,16 @@ int be_visitor_args_arglist::visit_native (be_native *node) *os << this->type_name (node) << " &"; break; } + return 0; } int be_visitor_args_arglist::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); + AST_PredefinedType::PredefinedType pt = node->pt (); - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) + if (pt == AST_PredefinedType::PT_any) { switch (this->direction ()) { @@ -188,9 +187,10 @@ int be_visitor_args_arglist::visit_predefined_type (be_predefined_type *node) case AST_Argument::dir_OUT: *os << this->type_name (node, "_out"); break; - } // end switch direction - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + } + } + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { // The only PT_pseudo that doesn't take a _ptr suffix. idl_bool is_tckind = @@ -223,9 +223,9 @@ int be_visitor_args_arglist::visit_predefined_type (be_predefined_type *node) case AST_Argument::dir_OUT: *os << this->type_name (node, "_out"); break; - } // end switch direction - } // end else if - else // simple predefined types + } + } + else { switch (this->direction ()) { @@ -238,15 +238,15 @@ int be_visitor_args_arglist::visit_predefined_type (be_predefined_type *node) case AST_Argument::dir_OUT: *os << this->type_name (node, "_out"); break; - } // end switch direction - } // end of else + } + } return 0; } int be_visitor_args_arglist::visit_sequence (be_sequence *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -266,7 +266,7 @@ int be_visitor_args_arglist::visit_sequence (be_sequence *node) int be_visitor_args_arglist::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); if (node->width () == (long) sizeof (char)) { @@ -304,7 +304,7 @@ int be_visitor_args_arglist::visit_string (be_string *node) int be_visitor_args_arglist::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -324,7 +324,7 @@ int be_visitor_args_arglist::visit_structure (be_structure *node) int be_visitor_args_arglist::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -362,7 +362,7 @@ int be_visitor_args_arglist::visit_typedef (be_typedef *node) int be_visitor_args_arglist::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { diff --git a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp index c172a002252..74090920d4a 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp @@ -18,15 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, argument, "$Id$") +ACE_RCSID (be_visitor_argument, + argument, + "$Id$") be_visitor_args::be_visitor_args (be_visitor_context *ctx) - : be_visitor_decl (ctx) - , fixed_direction_ (-1) + : be_visitor_decl (ctx), + fixed_direction_ (-1) { } @@ -47,23 +45,31 @@ be_visitor_args::type_name (be_type *node, const char *suffix) { static char namebuf [NAMEBUFSIZE]; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); - be_type *bt; // type to use + be_type *bt; - // use the typedefed name if that is the one used in the IDL defn + // Use the typedefed name if that is the one used in the IDL defn. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } ACE_OS::sprintf (namebuf, "%s", bt->full_name ()); if (suffix) - ACE_OS::strcat (namebuf, - suffix); + { + ACE_OS::strcat (namebuf, + suffix); + } return namebuf; } @@ -73,7 +79,9 @@ AST_Argument::Direction be_visitor_args::direction (void) { if (this->fixed_direction_ != -1) - return AST_Argument::Direction (this->fixed_direction_); + { + return AST_Argument::Direction (this->fixed_direction_); + } // grab the argument node. We know that our context has stored the right // argument node diff --git a/TAO/TAO_IDL/be/be_visitor_argument/invoke_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/invoke_cs.cpp index e24a84e9ce0..59672368f62 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/invoke_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/invoke_cs.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, invoke_cs, "$Id$") +ACE_RCSID (be_visitor_argument, + invoke_cs, + "$Id$") // **************************************************************************** @@ -43,9 +41,8 @@ be_visitor_args_invoke_cs:: int be_visitor_args_invoke_cs::visit_argument (be_argument *node) { this->ctx_->node (node); // save the argument node - - // retrieve the type of the argument be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -60,8 +57,6 @@ int be_visitor_args_invoke_cs::visit_argument (be_argument *node) TAO_OutStream *os = this->ctx_->stream (); // get output stream - os->indent (); - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { switch (this->direction ()) @@ -142,9 +137,8 @@ int be_visitor_args_invoke_cs::visit_argument (be_argument *node) int be_visitor_args_invoke_cs::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -158,7 +152,7 @@ int be_visitor_args_invoke_cs::visit_array (be_array *node) case AST_Argument::dir_INOUT: *os << node->name () << "_forany (" << arg->local_name () << ")"; - break; + break; case AST_Argument::dir_OUT: break; } @@ -170,17 +164,8 @@ int be_visitor_args_invoke_cs::visit_array (be_array *node) case AST_Argument::dir_IN: break; case AST_Argument::dir_INOUT: - *os << "_tao_argument_" << arg->local_name (); - break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - { - *os << "_tao_argument_" << arg->local_name (); - } - else - { - *os << "_tao_argument_" << arg->local_name (); - } + *os << "_tao_argument_" << arg->local_name (); break; } } @@ -192,14 +177,14 @@ int be_visitor_args_invoke_cs::visit_array (be_array *node) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_enum (be_enum *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -233,14 +218,14 @@ int be_visitor_args_invoke_cs::visit_enum (be_enum *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_interface (be_interface *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -276,14 +261,14 @@ int be_visitor_args_invoke_cs::visit_interface (be_interface *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_interface_fwd (be_interface_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -369,9 +354,8 @@ int be_visitor_args_invoke_cs::visit_valuetype (be_valuetype *) int be_visitor_args_invoke_cs::visit_valuetype_fwd (be_valuetype_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -407,13 +391,14 @@ be_visitor_args_invoke_cs::visit_valuetype_fwd (be_valuetype_fwd *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get argument node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -424,6 +409,7 @@ int be_visitor_args_invoke_cs::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: case AST_PredefinedType::PT_any: case AST_PredefinedType::PT_long: case AST_PredefinedType::PT_ulong: @@ -470,6 +456,7 @@ int be_visitor_args_invoke_cs::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: case AST_PredefinedType::PT_any: case AST_PredefinedType::PT_long: case AST_PredefinedType::PT_ulong: @@ -506,6 +493,7 @@ int be_visitor_args_invoke_cs::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << arg->local_name () << ".ptr ()"; break; case AST_PredefinedType::PT_any: @@ -552,14 +540,14 @@ int be_visitor_args_invoke_cs::visit_predefined_type (be_predefined_type *node) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_sequence (be_sequence *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -595,14 +583,14 @@ int be_visitor_args_invoke_cs::visit_sequence (be_sequence *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -618,10 +606,10 @@ int be_visitor_args_invoke_cs::visit_string (be_string *node) } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { - // we need to make a distinction between bounded and unbounded strings + // We need to make a distinction between bounded and unbounded strings. if (node->max_size ()->ev ()->u.ulval == 0) { - // unbounded + // Unbounded. switch (this->direction ()) { case AST_Argument::dir_IN: @@ -636,7 +624,7 @@ int be_visitor_args_invoke_cs::visit_string (be_string *node) } else { - // bounded + // Bounded. switch (this->direction ()) { case AST_Argument::dir_IN: @@ -678,14 +666,14 @@ int be_visitor_args_invoke_cs::visit_string (be_string *node) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -709,7 +697,7 @@ int be_visitor_args_invoke_cs::visit_structure (be_structure *node) *os << arg->local_name (); break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << "*" << arg->local_name () << ".ptr ()"; else *os << arg->local_name (); @@ -724,14 +712,14 @@ int be_visitor_args_invoke_cs::visit_structure (be_structure *node) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_invoke_cs::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { @@ -755,7 +743,7 @@ int be_visitor_args_invoke_cs::visit_union (be_union *node) *os << arg->local_name (); break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << "*" << arg->local_name () << ".ptr ()"; else *os << arg->local_name (); @@ -777,6 +765,7 @@ int be_visitor_args_invoke_cs::visit_union (be_union *node) int be_visitor_args_invoke_cs::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -785,6 +774,7 @@ int be_visitor_args_invoke_cs::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/marshal_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/marshal_ss.cpp index 8842e708c3f..0be2a5f206d 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/marshal_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/marshal_ss.cpp @@ -19,11 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, marshal_ss, "$Id$") +ACE_RCSID (be_visitor_argument, + marshal_ss, + "$Id$") // ************************************************************************ @@ -44,10 +42,9 @@ be_visitor_args_marshal_ss:: int be_visitor_args_marshal_ss::visit_argument (be_argument *node) { - this->ctx_->node (node); // save the argument node - - // retrieve the type of the argument + this->ctx_->node (node); be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -144,9 +141,8 @@ int be_visitor_args_marshal_ss::visit_argument (be_argument *node) int be_visitor_args_marshal_ss::visit_array (be_array *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -184,14 +180,14 @@ int be_visitor_args_marshal_ss::visit_array (be_array *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_enum (be_enum *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -225,14 +221,14 @@ int be_visitor_args_marshal_ss::visit_enum (be_enum *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_interface (be_interface *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -266,14 +262,14 @@ int be_visitor_args_marshal_ss::visit_interface (be_interface *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_interface_fwd (be_interface_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -307,14 +303,14 @@ int be_visitor_args_marshal_ss::visit_interface_fwd (be_interface_fwd *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_valuetype (be_valuetype *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -348,14 +344,14 @@ int be_visitor_args_marshal_ss::visit_valuetype (be_valuetype *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_valuetype_fwd (be_valuetype_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -389,13 +385,16 @@ int be_visitor_args_marshal_ss::visit_valuetype_fwd (be_valuetype_fwd *) "Bad substate\n"), -1); } + return 0; } -int be_visitor_args_marshal_ss::visit_predefined_type (be_predefined_type *node) +int be_visitor_args_marshal_ss::visit_predefined_type ( + be_predefined_type *node + ) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get argument node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -406,6 +405,7 @@ int be_visitor_args_marshal_ss::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << arg->local_name () << ".out ()"; break; case AST_PredefinedType::PT_any: @@ -454,6 +454,7 @@ int be_visitor_args_marshal_ss::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << arg->local_name () << ".in ()"; break; case AST_PredefinedType::PT_any: @@ -494,6 +495,7 @@ int be_visitor_args_marshal_ss::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << arg->local_name () << ".in ()"; break; case AST_PredefinedType::PT_any: @@ -523,11 +525,14 @@ int be_visitor_args_marshal_ss::visit_predefined_type (be_predefined_type *node) *os << "CORBA::Any::from_octet (" << arg->local_name () << ")"; break; default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal_ss::" - "visit_array - " - "Bad predefined type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "be_visitor_operation_rettype_compiled_marshal_ss::" + "visit_array - " + "Bad predefined type\n" + ), + -1 + ); } break; } @@ -540,14 +545,14 @@ int be_visitor_args_marshal_ss::visit_predefined_type (be_predefined_type *node) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_sequence (be_sequence *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -583,14 +588,14 @@ int be_visitor_args_marshal_ss::visit_sequence (be_sequence *) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -671,14 +676,14 @@ int be_visitor_args_marshal_ss::visit_string (be_string *node) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -702,7 +707,7 @@ int be_visitor_args_marshal_ss::visit_structure (be_structure *node) *os << arg->local_name (); break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << arg->local_name () << ".in ()"; else *os << arg->local_name (); @@ -717,14 +722,14 @@ int be_visitor_args_marshal_ss::visit_structure (be_structure *node) "Bad substate\n"), -1); } + return 0; } int be_visitor_args_marshal_ss::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -748,7 +753,7 @@ int be_visitor_args_marshal_ss::visit_union (be_union *node) *os << arg->local_name (); break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << arg->local_name () << ".in ()"; else *os << arg->local_name (); @@ -770,6 +775,7 @@ int be_visitor_args_marshal_ss::visit_union (be_union *node) int be_visitor_args_marshal_ss::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -778,6 +784,7 @@ int be_visitor_args_marshal_ss::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/paramlist.cpp b/TAO/TAO_IDL/be/be_visitor_argument/paramlist.cpp index cc952c4c0f9..7dea1734128 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/paramlist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/paramlist.cpp @@ -19,10 +19,6 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - ACE_RCSID (be_visitor_argument, paramlist, "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_argument/post_invoke_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_invoke_cs.cpp index 865425354cd..2e8ebf3f89e 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_invoke_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/post_invoke_cs.cpp @@ -19,11 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, post_invoke_cs, "$Id$") +ACE_RCSID (be_visitor_argument, + post_invoke_cs, + "$Id$") // ************************************************************************* @@ -33,8 +31,9 @@ ACE_RCSID(be_visitor_argument, post_invoke_cs, "$Id$") // type and vice versa. // ************************************************************************* -be_visitor_args_post_invoke_cs::be_visitor_args_post_invoke_cs -(be_visitor_context *ctx) +be_visitor_args_post_invoke_cs::be_visitor_args_post_invoke_cs ( + be_visitor_context *ctx + ) : be_visitor_args (ctx) { } @@ -46,10 +45,11 @@ be_visitor_args_post_invoke_cs::~be_visitor_args_post_invoke_cs (void) int be_visitor_args_post_invoke_cs::visit_argument (be_argument *node) { - this->ctx_->node (node); // save the argument node + this->ctx_->node (node); - // retrieve the type of the argument + // Retrieve the type of the argument. be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -77,10 +77,9 @@ be_visitor_args_post_invoke_cs::visit_argument (be_argument *node) int be_visitor_args_post_invoke_cs::visit_interface (be_interface *node) { - // we must narrow the out object reference to the appropriate type - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + // We must narrow the out object reference to the appropriate type. + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); switch (this->direction ()) { @@ -101,16 +100,16 @@ be_visitor_args_post_invoke_cs::visit_interface (be_interface *node) default: break; } + return 0; } int be_visitor_args_post_invoke_cs::visit_interface_fwd (be_interface_fwd *node) { - // we must narrow the out object reference to the appropriate type - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + // We must narrow the out object reference to the appropriate type. + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); switch (this->direction ()) { @@ -131,16 +130,16 @@ be_visitor_args_post_invoke_cs::visit_interface_fwd (be_interface_fwd *node) default: break; } + return 0; } int be_visitor_args_post_invoke_cs::visit_valuetype (be_valuetype *) { - // we must narrow the out object reference to the appropriate type - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + // We must narrow the out object reference to the appropriate type. + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); switch (this->direction ()) { @@ -154,16 +153,16 @@ be_visitor_args_post_invoke_cs::visit_valuetype (be_valuetype *) default: break; } + return 0; } int be_visitor_args_post_invoke_cs::visit_valuetype_fwd (be_valuetype_fwd *) { - // we must narrow the out object reference to the appropriate type - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + // We must narrow the out object reference to the appropriate type. + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); switch (this->direction ()) { @@ -177,15 +176,16 @@ be_visitor_args_post_invoke_cs::visit_valuetype_fwd (be_valuetype_fwd *) default: break; } + return 0; } int be_visitor_args_post_invoke_cs::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -208,6 +208,7 @@ be_visitor_args_post_invoke_cs::visit_string (be_string *node) case AST_Argument::dir_OUT: break; } + return 0; } @@ -215,6 +216,7 @@ int be_visitor_args_post_invoke_cs::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -223,6 +225,7 @@ be_visitor_args_post_invoke_cs::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/post_marshal_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_marshal_ss.cpp index a532881930a..e3362d2bf16 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_marshal_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/post_marshal_ss.cpp @@ -19,12 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, post_marshal_ss, "$Id$") - +ACE_RCSID (be_visitor_argument, + post_marshal_ss, + "$Id$") // ************************************************************************ // visitor for doing any post-processing after the marshaling is done @@ -45,6 +42,7 @@ int be_visitor_args_post_marshal_ss::visit_argument (be_argument *node) // retrieve the type be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -69,160 +67,10 @@ int be_visitor_args_post_marshal_ss::visit_argument (be_argument *node) return 0; } -int be_visitor_args_post_marshal_ss::visit_array (be_array *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_enum (be_enum *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_interface (be_interface *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: // inout - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_interface_fwd (be_interface_fwd *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: // inout - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_predefined_type (be_predefined_type *node) -{ - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } // end switch direction - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } // end switch direction - } // end else if - else // simple predefined types - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } // end switch direction - } // end of else - - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_sequence (be_sequence *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_string (be_string *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_structure (be_structure *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_post_marshal_ss::visit_union (be_union *) -{ - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - int be_visitor_args_post_marshal_ss::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -231,6 +79,7 @@ int be_visitor_args_post_marshal_ss::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp index 06cfa4d0cce..41c9e5b9d10 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp @@ -19,17 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, post_upcall_ss, "$Id$") +ACE_RCSID (be_visitor_argument, + post_upcall_ss, + "$Id$") // ************************************************************************ // visitor for doing any post-processing after the upcall is made // ************************************************************************ -be_visitor_args_post_upcall_ss::be_visitor_args_post_upcall_ss (be_visitor_context *ctx) +be_visitor_args_post_upcall_ss::be_visitor_args_post_upcall_ss ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -50,10 +50,11 @@ int be_visitor_args_post_upcall_ss::visit_argument (be_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_compiled_args_post_upcall::" + "be_visitor_args_post_upcall::" "visit_argument - " "Bad argument type\n"), -1); @@ -65,7 +66,7 @@ int be_visitor_args_post_upcall_ss::visit_argument (be_argument *node) if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_compiled_args_post_upcall::" + "be_visitor_args_post_upcall::" "visit_argument - " "cannot accept visitor\n"), -1); @@ -81,8 +82,11 @@ int be_visitor_args_post_upcall_ss::visit_array (be_array *node) // if the current type is an alias, use that be_type *bt = node; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } switch (arg->direction ()) { @@ -105,6 +109,7 @@ int be_visitor_args_post_upcall_ss::visit_array (be_array *node) << arg->local_name () << be_uidt_nl << ");\n" << be_uidt; } + break; } return 0; @@ -113,14 +118,16 @@ int be_visitor_args_post_upcall_ss::visit_array (be_array *node) int be_visitor_args_post_upcall_ss::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_compiled_args_post_upcall::" + "be_visitor_args_post_upcall::" "visit_typedef - " "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp index 43c173b574d..2c322980928 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp @@ -19,11 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, pre_invoke_cs, "$Id$") +ACE_RCSID (be_visitor_argument, + pre_invoke_cs, + "$Id$") // ************************************************************************* @@ -78,7 +76,7 @@ be_visitor_args_pre_invoke_cs::cannot_return_zero (void) return 1; } else if (bt->base_node_type () == AST_Decl::NT_struct - && bt->size_type () == be_decl::FIXED) + && bt->size_type () == AST_Type::FIXED) { return 1; } @@ -139,7 +137,7 @@ be_visitor_args_pre_invoke_cs::visit_array (be_array *node) switch (this->direction ()) { case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { os->indent (); @@ -199,6 +197,7 @@ be_visitor_args_pre_invoke_cs::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: { switch (this->direction ()) { diff --git a/TAO/TAO_IDL/be/be_visitor_argument/request_info_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_argument/request_info_arglist.cpp index 8ccd92cb024..e4c9831a881 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/request_info_arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/request_info_arglist.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, request_info_arglist, "$Id$") +ACE_RCSID (be_visitor_argument, + request_info_arglist, + "$Id$") // ************************************************************ @@ -150,6 +148,7 @@ int be_visitor_args_request_info_arglist::visit_interface (be_interface *node) *os << this->type_name (node, "_out"); break; } + return 0; } @@ -171,6 +170,7 @@ int be_visitor_args_request_info_arglist::visit_interface_fwd ( *os << this->type_name (node, "_out"); break; } + return 0; } @@ -190,6 +190,7 @@ int be_visitor_args_request_info_arglist::visit_native (be_native *node) *os << this->type_name (node) << " &"; break; } + return 0; } @@ -198,9 +199,9 @@ int be_visitor_args_request_info_arglist::visit_predefined_type ( ) { TAO_OutStream *os = this->ctx_->stream (); + AST_PredefinedType::PredefinedType pt = node->pt (); - // Check if the type is an any. - if (node->pt () == AST_PredefinedType::PT_any) + if (pt == AST_PredefinedType::PT_any) { switch (this->direction ()) { @@ -222,9 +223,10 @@ int be_visitor_args_request_info_arglist::visit_predefined_type ( break; } - } // end switch direction - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g. CORBA::Object + } + } + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { switch (this->direction ()) { @@ -237,9 +239,9 @@ int be_visitor_args_request_info_arglist::visit_predefined_type ( case AST_Argument::dir_OUT: *os << this->type_name (node, "_out"); break; - } // end switch direction - } // end else if - else // Simple predefined types. + } + } + else { switch (this->direction ()) { diff --git a/TAO/TAO_IDL/be/be_visitor_argument/request_info_ch.cpp b/TAO/TAO_IDL/be/be_visitor_argument/request_info_ch.cpp index e2e0b7496e7..993c3d44b18 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/request_info_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/request_info_ch.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, request_info_ch, "$Id$") +ACE_RCSID (be_visitor_argument, + request_info_ch, + "$Id$") // ************************************************************ @@ -41,8 +39,8 @@ be_visitor_args_request_info_ch::~be_visitor_args_request_info_ch (void) int be_visitor_args_request_info_ch::visit_argument (be_argument *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - this->ctx_->node (node); // save the argument node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // retrieve the type be_type *bt = be_type::narrow_from_decl (node->field_type ()); @@ -75,7 +73,7 @@ int be_visitor_args_request_info_ch::visit_argument (be_argument *node) int be_visitor_args_request_info_ch::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -104,7 +102,7 @@ int be_visitor_args_request_info_ch::visit_array (be_array *node) int be_visitor_args_request_info_ch::visit_enum (be_enum *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -134,7 +132,7 @@ int be_visitor_args_request_info_ch::visit_enum (be_enum *node) int be_visitor_args_request_info_ch::visit_interface (be_interface *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -148,6 +146,7 @@ int be_visitor_args_request_info_ch::visit_interface (be_interface *node) *os << this->type_name (node, "_out"); break; } + return 0; } @@ -155,7 +154,7 @@ int be_visitor_args_request_info_ch::visit_interface_fwd ( be_interface_fwd *node ) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -169,12 +168,13 @@ int be_visitor_args_request_info_ch::visit_interface_fwd ( *os << this->type_name (node, "_out"); break; } + return 0; } int be_visitor_args_request_info_ch::visit_native (be_native *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -188,6 +188,7 @@ int be_visitor_args_request_info_ch::visit_native (be_native *node) *os << this->type_name (node) << " &"; break; } + return 0; } @@ -195,10 +196,10 @@ int be_visitor_args_request_info_ch::visit_predefined_type ( be_predefined_type *node ) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); + AST_PredefinedType::PredefinedType pt = node-> pt (); - // Check if the type is an any. - if (node->pt () == AST_PredefinedType::PT_any) + if (pt == AST_PredefinedType::PT_any) { switch (this->direction ()) { @@ -220,9 +221,10 @@ int be_visitor_args_request_info_ch::visit_predefined_type ( break; } - } // end switch direction - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + } + } + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { switch (this->direction ()) { @@ -235,9 +237,9 @@ int be_visitor_args_request_info_ch::visit_predefined_type ( case AST_Argument::dir_OUT: *os << this->type_name (node, "_out"); break; - } // end switch direction - } // end else if - else // Simple predefined types. + } + } + else { switch (this->direction ()) { @@ -267,7 +269,7 @@ int be_visitor_args_request_info_ch::visit_predefined_type ( int be_visitor_args_request_info_ch::visit_sequence (be_sequence *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -294,7 +296,7 @@ int be_visitor_args_request_info_ch::visit_sequence (be_sequence *node) int be_visitor_args_request_info_ch::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); if (node->width () == 1) { @@ -332,7 +334,7 @@ int be_visitor_args_request_info_ch::visit_string (be_string *node) int be_visitor_args_request_info_ch::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -354,14 +356,14 @@ int be_visitor_args_request_info_ch::visit_structure (be_structure *node) break; } - } + return 0; } int be_visitor_args_request_info_ch::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -383,8 +385,8 @@ int be_visitor_args_request_info_ch::visit_union (be_union *node) break; } - } + return 0; } @@ -408,7 +410,7 @@ int be_visitor_args_request_info_ch::visit_typedef (be_typedef *node) int be_visitor_args_request_info_ch::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -422,6 +424,7 @@ int be_visitor_args_request_info_ch::visit_valuetype (be_valuetype *node) *os << this->type_name (node, "_out"); break; } + return 0; } @@ -429,7 +432,7 @@ int be_visitor_args_request_info_ch::visit_valuetype_fwd ( be_valuetype_fwd *node ) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -443,6 +446,7 @@ int be_visitor_args_request_info_ch::visit_valuetype_fwd ( *os << this->type_name (node, "_out"); break; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/request_info_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/request_info_cs.cpp index 09d7050b34e..07650498daf 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/request_info_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/request_info_cs.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, request_info_cs, "$Id$") +ACE_RCSID (be_visitor_argument, + request_info_cs, + "$Id$") // ************************************************************ @@ -30,7 +28,9 @@ ACE_RCSID(be_visitor_argument, request_info_cs, "$Id$") // definitions // ************************************************************ -be_visitor_args_request_info_cs::be_visitor_args_request_info_cs (be_visitor_context *ctx) +be_visitor_args_request_info_cs::be_visitor_args_request_info_cs ( + be_visitor_context *ctx + ) : be_visitor_args (ctx) { } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/request_info_result.cpp b/TAO/TAO_IDL/be/be_visitor_argument/request_info_result.cpp index 1d1ef00aa91..ea9a7062592 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/request_info_result.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/request_info_result.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, request_info_result, "$Id$") +ACE_RCSID (be_visitor_argument, + request_info_result, + "$Id$") // ************************************************************ @@ -30,25 +28,27 @@ ACE_RCSID(be_visitor_argument, request_info_result, "$Id$") // stored in the request info for interceptors // ************************************************************ -be_visitor_args_request_info_result::be_visitor_args_request_info_result (be_visitor_context *ctx) +be_visitor_args_request_info_result::be_visitor_args_request_info_result ( + be_visitor_context *ctx + ) : be_visitor_args (ctx) { } -be_visitor_args_request_info_result::~be_visitor_args_request_info_result (void) +be_visitor_args_request_info_result::~be_visitor_args_request_info_result ( + void + ) { } int be_visitor_args_request_info_result::visit_argument (be_argument *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - this->ctx_->node (node); // save the argument node - be_type *bt; + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); os->indent (); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); - // retrieve the type - bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -59,40 +59,47 @@ int be_visitor_args_request_info_result::visit_argument (be_argument *node) } if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_vardecl_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_args_vardecl_ss::" + "visit_argument - " + "cannot accept visitor\n"), + -1); + } *os << be_nl; + // Set the appropriate mode for each parameter. return 0; } int be_visitor_args_request_info_result::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); - // if the current type is an alias, use that be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); + *os << bt->name () << "_forany _tao_forany_result" << " (this->result_);" << be_nl - << "this->result_val_ <<= _tao_forany_result;"<< be_nl; + << "this->result_val_ <<= _tao_forany_result;" << be_nl; + return 0; } int be_visitor_args_request_info_result::visit_enum (be_enum *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); os->indent (); *os << "this->result_val_ <<= this->result_;"; @@ -102,7 +109,7 @@ int be_visitor_args_request_info_result::visit_enum (be_enum *) int be_visitor_args_request_info_result::visit_interface (be_interface *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); os->indent (); *os << "this->result_val_ <<= this->result_;"; @@ -110,90 +117,98 @@ int be_visitor_args_request_info_result::visit_interface (be_interface *) return 0; } -int be_visitor_args_request_info_result::visit_interface_fwd (be_interface_fwd *) +int be_visitor_args_request_info_result::visit_interface_fwd ( + be_interface_fwd * + ) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); os->indent (); *os << "this->result_val_ <<= this->result_;"; return 0; - } int be_visitor_args_request_info_result::visit_valuetype (be_valuetype *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); os->indent (); *os << "this->result_val_ <<= this->result_;"; return 0; - } -int be_visitor_args_request_info_result::visit_valuetype_fwd (be_valuetype_fwd *) +int be_visitor_args_request_info_result::visit_valuetype_fwd ( + be_valuetype_fwd * + ) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); os->indent (); *os << "this->result_val_ <<= this->result_;"; return 0; - } int -be_visitor_args_request_info_result::visit_predefined_type (be_predefined_type *node) +be_visitor_args_request_info_result::visit_predefined_type ( + be_predefined_type *node + ) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); os->indent (); + *os << "this->result_val_ <<= "; + switch (node->pt ()) { case AST_PredefinedType::PT_boolean: *os << "CORBA::Any::from_boolean (this->result_);" << be_nl; + break; case AST_PredefinedType::PT_char: *os << "CORBA::Any::from_char (this->result_);"<<be_nl; + break; case AST_PredefinedType::PT_wchar: *os << "CORBA::Any::from_wchar (this->result_);"<<be_nl; + break; case AST_PredefinedType::PT_octet: *os << "CORBA::Any::from_octet (this->result_);"<<be_nl; - break; + break; default: *os << "this->result_;"<<be_nl; + break; } - return 0; + return 0; } int be_visitor_args_request_info_result::visit_sequence (be_sequence *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - + TAO_OutStream *os = this->ctx_->stream (); os->indent (); + *os << "this->result_val_ <<= this->result_;"; return 0; - } int be_visitor_args_request_info_result::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - + TAO_OutStream *os = this->ctx_->stream (); os->indent (); + *os << "this->result_val_ <<= "; - // we need to make a distinction between bounded and unbounded strings + + // We need to make a distinction between bounded and unbounded strings. if (node->max_size ()->ev ()->u.ulval != 0) { - // bounded strings if (node->width () == (long) sizeof (char)) { *os << "CORBA::Any::from_string ((char *)"; @@ -202,44 +217,45 @@ be_visitor_args_request_info_result::visit_string (be_string *node) { *os << "CORBA::Any::from_wstring ((CORBA::WChar *)"; } + *os <<"this->result_, " << node->max_size ()->ev ()->u.ulval << ");"; } else + { *os << "this->result_; "; -return 0; + } + + return 0; } int be_visitor_args_request_info_result::visit_structure (be_structure *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - + TAO_OutStream *os = this->ctx_->stream (); os->indent (); + *os << "this->result_val_ <<= this->result_;"; return 0; - } int be_visitor_args_request_info_result::visit_union (be_union *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - + TAO_OutStream *os = this->ctx_->stream (); os->indent (); + *os << "this->result_val_ <<= this->result_;"; return 0; - } int be_visitor_args_request_info_result::visit_typedef (be_typedef *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - + TAO_OutStream *os = this->ctx_->stream (); os->indent (); + *os << "this->result_val_ <<= this->result_;"; return 0; - } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/request_info_sh.cpp b/TAO/TAO_IDL/be/be_visitor_argument/request_info_sh.cpp index 07ffc2bf17a..049d3e7d874 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/request_info_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/request_info_sh.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, request_info_sh, "$Id$") +ACE_RCSID (be_visitor_argument, + request_info_sh, + "$Id$") // ************************************************************ @@ -30,7 +28,9 @@ ACE_RCSID(be_visitor_argument, request_info_sh, "$Id$") // definitions // ************************************************************ -be_visitor_args_request_info_sh::be_visitor_args_request_info_sh (be_visitor_context *ctx) +be_visitor_args_request_info_sh::be_visitor_args_request_info_sh ( + be_visitor_context *ctx + ) : be_visitor_args (ctx) { } @@ -43,8 +43,6 @@ int be_visitor_args_request_info_sh::visit_argument (be_argument *node) { TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); - - // retrieve the type be_type *bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) @@ -70,8 +68,10 @@ int be_visitor_args_request_info_sh::visit_argument (be_argument *node) // As we visit each type we print out the &. *os <<" "<< node->local_name () << "_;" << be_nl; + return 0; } + int be_visitor_args_request_info_sh::visit_array (be_array *node) { TAO_OutStream *os = this->ctx_->stream (); @@ -88,12 +88,13 @@ int be_visitor_args_request_info_sh::visit_array (be_array *node) *os << this->type_name (node, "_out"); break; } + return 0; } int be_visitor_args_request_info_sh::visit_enum (be_enum *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -107,12 +108,13 @@ int be_visitor_args_request_info_sh::visit_enum (be_enum *node) *os << this->type_name (node, "_out"); break; } + return 0; } int be_visitor_args_request_info_sh::visit_interface (be_interface *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -126,12 +128,13 @@ int be_visitor_args_request_info_sh::visit_interface (be_interface *node) *os << this->type_name (node, "_out"); break; } + return 0; } int be_visitor_args_request_info_sh::visit_interface_fwd (be_interface_fwd *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -145,12 +148,13 @@ int be_visitor_args_request_info_sh::visit_interface_fwd (be_interface_fwd *node *os << this->type_name (node, "_out"); break; } + return 0; } int be_visitor_args_request_info_sh::visit_native (be_native *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -164,15 +168,18 @@ int be_visitor_args_request_info_sh::visit_native (be_native *node) *os << this->type_name (node) << " &"; break; } + return 0; } -int be_visitor_args_request_info_sh::visit_predefined_type (be_predefined_type *node) +int be_visitor_args_request_info_sh::visit_predefined_type ( + be_predefined_type *node + ) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); + AST_PredefinedType::PredefinedType pt = node->pt (); - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) + if (pt == AST_PredefinedType::PT_any) { switch (this->direction ()) { @@ -185,9 +192,10 @@ int be_visitor_args_request_info_sh::visit_predefined_type (be_predefined_type * case AST_Argument::dir_OUT: *os << this->type_name (node, "_out"); break; - } // end switch direction - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + } + } + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { switch (this->direction ()) { @@ -200,9 +208,9 @@ int be_visitor_args_request_info_sh::visit_predefined_type (be_predefined_type * case AST_Argument::dir_OUT: *os << this->type_name (node, "_out"); break; - } // end switch direction - } // end else if - else // simple predefined types + } + } + else { switch (this->direction ()) { @@ -223,7 +231,7 @@ int be_visitor_args_request_info_sh::visit_predefined_type (be_predefined_type * int be_visitor_args_request_info_sh::visit_sequence (be_sequence *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -237,12 +245,13 @@ int be_visitor_args_request_info_sh::visit_sequence (be_sequence *node) *os << this->type_name (node, "_out"); break; } + return 0; } int be_visitor_args_request_info_sh::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); if (node->width () == 1) { @@ -280,7 +289,7 @@ int be_visitor_args_request_info_sh::visit_string (be_string *node) int be_visitor_args_request_info_sh::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -294,6 +303,7 @@ int be_visitor_args_request_info_sh::visit_structure (be_structure *node) *os << this->type_name (node, "_out"); break; } + return 0; } @@ -313,12 +323,14 @@ int be_visitor_args_request_info_sh::visit_union (be_union *node) *os << this->type_name (node, "_out"); break; } + return 0; } int be_visitor_args_request_info_sh::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -327,6 +339,7 @@ int be_visitor_args_request_info_sh::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } @@ -334,7 +347,7 @@ int be_visitor_args_request_info_sh::visit_typedef (be_typedef *node) int be_visitor_args_request_info_sh::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -348,12 +361,15 @@ int be_visitor_args_request_info_sh::visit_valuetype (be_valuetype *node) *os << this->type_name (node, "_out"); break; } + return 0; } -int be_visitor_args_request_info_sh::visit_valuetype_fwd (be_valuetype_fwd *node) +int be_visitor_args_request_info_sh::visit_valuetype_fwd ( + be_valuetype_fwd *node + ) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream + TAO_OutStream *os = this->ctx_->stream (); switch (this->direction ()) { @@ -367,6 +383,7 @@ int be_visitor_args_request_info_sh::visit_valuetype_fwd (be_valuetype_fwd *node *os << this->type_name (node, "_out"); break; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/request_info_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/request_info_ss.cpp index e68b5b16c07..024686018c7 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/request_info_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/request_info_ss.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, request_info_ss, "$Id$") +ACE_RCSID (be_visitor_argument, + request_info_ss, + "$Id$") // ************************************************************ @@ -30,7 +28,9 @@ ACE_RCSID(be_visitor_argument, request_info_ss, "$Id$") // definitions // ************************************************************ -be_visitor_args_request_info_ss::be_visitor_args_request_info_ss (be_visitor_context *ctx) +be_visitor_args_request_info_ss::be_visitor_args_request_info_ss ( + be_visitor_context *ctx + ) : be_visitor_args (ctx) { } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp index 857d33a1896..434f4f02025 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp @@ -19,11 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, upcall_ss, "$Id$") +ACE_RCSID (be_visitor_argument, + upcall_ss, + "$Id$") // ************************************************************************ @@ -41,10 +39,9 @@ be_visitor_args_upcall_ss::~be_visitor_args_upcall_ss (void) int be_visitor_args_upcall_ss::visit_argument (be_argument *node) { - this->ctx_->node (node); // save the argument node - - // retrieve the type + this->ctx_->node (node); be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -70,9 +67,8 @@ int be_visitor_args_upcall_ss::visit_argument (be_argument *node) int be_visitor_args_upcall_ss::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); switch (this->direction ()) { @@ -85,29 +81,40 @@ int be_visitor_args_upcall_ss::visit_array (be_array *node) } *os << arg->local_name (); + break; case AST_Argument::dir_INOUT: *os << arg->local_name (); + break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *os << arg->local_name () << ".out ()"; + if (node->size_type () == AST_Type::VARIABLE) + { + if (this->ctx_->state () + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } + else + { + *os << arg->local_name () << ".out ()"; + } + } else - *os << arg->local_name (); + { + *os << arg->local_name (); + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_enum (be_enum *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); switch (this->direction ()) { @@ -115,190 +122,278 @@ int be_visitor_args_upcall_ss::visit_enum (be_enum *) case AST_Argument::dir_INOUT: case AST_Argument::dir_OUT: *os << arg->local_name (); + break; } + return 0; } int be_visitor_args_upcall_ss::visit_interface (be_interface *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".in ()"; + { + *os << arg->local_name () << ".in ()"; + } + break; case AST_Argument::dir_INOUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".inout ()"; + { + *os << arg->local_name () << ".inout ()"; + } + break; case AST_Argument::dir_OUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_interface_fwd (be_interface_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".in ()"; + { + *os << arg->local_name () << ".in ()"; + } + break; case AST_Argument::dir_INOUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".inout ()"; + { + *os << arg->local_name () << ".inout ()"; + } + break; case AST_Argument::dir_OUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_valuetype (be_valuetype *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".in ()"; + { + *os << arg->local_name () << ".in ()"; + } + break; case AST_Argument::dir_INOUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".inout ()"; + { + *os << arg->local_name () << ".inout ()"; + } + break; case AST_Argument::dir_OUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_valuetype_fwd (be_valuetype_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".in ()"; + { + *os << arg->local_name () << ".in ()"; + } + break; case AST_Argument::dir_INOUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".inout ()"; + { + *os << arg->local_name () << ".inout ()"; + } + break; case AST_Argument::dir_OUT: if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + AST_PredefinedType::PredefinedType pt = node->pt (); + + if (pt == AST_PredefinedType::PT_any) { switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: *os << arg->local_name (); + break; case AST_Argument::dir_OUT: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; - } // end switch direction - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + } + } + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { switch (this->direction ()) { case AST_Argument::dir_IN: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".in ()"; + { + *os << arg->local_name () << ".in ()"; + } + break; case AST_Argument::dir_INOUT: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".inout ()"; + { + *os << arg->local_name () << ".inout ()"; + } + break; case AST_Argument::dir_OUT: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; - } // end switch direction - } // end else if - else // simple predefined types + } + } + else { switch (this->direction ()) { @@ -306,6 +401,7 @@ int be_visitor_args_upcall_ss::visit_predefined_type (be_predefined_type *node) case AST_Argument::dir_INOUT: case AST_Argument::dir_OUT: *os << arg->local_name (); + break; } // end switch direction } // end of else @@ -315,111 +411,157 @@ int be_visitor_args_upcall_ss::visit_predefined_type (be_predefined_type *node) int be_visitor_args_upcall_ss::visit_sequence (be_sequence *) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: *os << arg->local_name (); + break; case AST_Argument::dir_OUT: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_string (be_string *) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".in ()"; + { + *os << arg->local_name () << ".in ()"; + } + break; case AST_Argument::dir_INOUT: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else + { *os << arg->local_name () << ".inout ()"; + } + break; case AST_Argument::dir_OUT: if (this->ctx_->state () == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); + { + *os << arg->local_name (); + } else - *os << arg->local_name () << ".out ()"; + { + *os << arg->local_name () << ".out ()"; + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: *os << arg->local_name (); + break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *os << arg->local_name () << ".out ()"; + if (node->size_type () == AST_Type::VARIABLE) + { + if (this->ctx_->state () + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } + else + { + *os << arg->local_name () << ".out ()"; + } + } else - *os << arg->local_name (); + { + *os << arg->local_name (); + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // get the stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: *os << arg->local_name (); + break; case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *os << arg->local_name () << ".out ()"; + if (node->size_type () == AST_Type::VARIABLE) + { + if (this->ctx_->state () + == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) + { + *os << arg->local_name (); + } + else + { + *os << arg->local_name () << ".out ()"; + } + } else - *os << arg->local_name (); + { + *os << arg->local_name (); + } + break; } + return 0; } int be_visitor_args_upcall_ss::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -428,6 +570,7 @@ int be_visitor_args_upcall_ss::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp index 6113da06ab4..b6d69df63d6 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp @@ -19,18 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, vardecl_ss, "$Id$") +ACE_RCSID (be_visitor_argument, + vardecl_ss, + "$Id$") // ************************************************************************ // Visitor to generate code for argument variable declaration // ************************************************************************ -be_visitor_args_vardecl_ss::be_visitor_args_vardecl_ss (be_visitor_context *ctx) +be_visitor_args_vardecl_ss::be_visitor_args_vardecl_ss ( + be_visitor_context *ctx + ) : be_visitor_args (ctx) { } @@ -41,10 +41,9 @@ be_visitor_args_vardecl_ss::~be_visitor_args_vardecl_ss (void) int be_visitor_args_vardecl_ss::visit_argument (be_argument *node) { - this->ctx_->node (node); // save the argument node - - // retrieve the type + this->ctx_->node (node); be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -56,7 +55,6 @@ int be_visitor_args_vardecl_ss::visit_argument (be_argument *node) // Different types have different mappings when used as in/out or // inout parameters. Let this visitor deal with the type - if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -71,30 +69,35 @@ int be_visitor_args_vardecl_ss::visit_argument (be_argument *node) int be_visitor_args_vardecl_ss::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << " " << arg->local_name () << ";" << be_nl << bt->name () << "_forany _tao_forany_" << arg->local_name () << " (" << be_idt << be_idt_nl << arg->local_name () << be_uidt_nl << ");\n" << be_uidt; - break; + break; case AST_Argument::dir_OUT: os->indent (); + if (node->size_type () == be_type::VARIABLE) { *os << bt->name () << "_var " << arg->local_name () @@ -105,22 +108,27 @@ int be_visitor_args_vardecl_ss::visit_array (be_array *node) *os << bt->name () << " " << arg->local_name () << ";\n\n"; } + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_enum (be_enum *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { @@ -128,172 +136,220 @@ int be_visitor_args_vardecl_ss::visit_enum (be_enum *node) case AST_Argument::dir_INOUT: case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << " " << arg->local_name () << ";\n"; + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_interface (be_interface *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_interface_fwd (be_interface_fwd *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_valuetype_fwd (be_valuetype_fwd *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } + + AST_PredefinedType::PredefinedType pt = node->pt (); - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) + if (pt == AST_PredefinedType::PT_any) { switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << " " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; - } // end switch direction - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + } + } + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () + << ";\n"; break; case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";\n"; + break; - } // end switch direction - } // end else if - else // simple predefined types + } + } + else { switch (this->direction ()) { @@ -301,47 +357,57 @@ int be_visitor_args_vardecl_ss::visit_predefined_type (be_predefined_type *node) case AST_Argument::dir_INOUT: case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << " " << arg->local_name () << ";\n"; + break; - } // end switch direction - } // end of else + } + } return 0; } int be_visitor_args_vardecl_ss::visit_sequence (be_sequence *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << " " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); + *os << bt->name () << "_var " << arg->local_name () << ";" << be_nl; + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -372,65 +438,80 @@ int be_visitor_args_vardecl_ss::visit_string (be_string *node) break; } + return 0; } int be_visitor_args_vardecl_ss::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << " " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); - // check if it is variable sized + if (node->size_type () == be_type::VARIABLE) { *os << bt->name () << "_var " << arg->local_name () << ";\n"; } else - *os << bt->name () << " " << arg->local_name () << ";\n"; + { + *os << bt->name () << " " << arg->local_name () << ";\n"; + } + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); + be_argument *arg = this->ctx_->be_node_as_argument (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (this->direction ()) { case AST_Argument::dir_IN: case AST_Argument::dir_INOUT: os->indent (); + *os << bt->name () << " " << arg->local_name () << ";\n"; + break; case AST_Argument::dir_OUT: os->indent (); - // check if it is variable sized + if (node->size_type () == be_type::VARIABLE) { *os << bt->name () << "_var " @@ -438,15 +519,20 @@ int be_visitor_args_vardecl_ss::visit_union (be_union *node) } else - *os << bt->name () << " " << arg->local_name () << ";\n"; + { + *os << bt->name () << " " << arg->local_name () << ";\n"; + } + break; } + return 0; } int be_visitor_args_vardecl_ss::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -455,6 +541,7 @@ int be_visitor_args_vardecl_ss::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_array.cpp b/TAO/TAO_IDL/be/be_visitor_array.cpp index 3e09618fa28..5b425c96a6e 100644 --- a/TAO/TAO_IDL/be/be_visitor_array.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array.cpp @@ -18,13 +18,26 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_enum.h" +#include "be_type.h" +#include "be_typedef.h" +#include "be_predefined_type.h" +#include "be_array.h" +#include "be_string.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_structure.h" +#include "be_union.h" +#include "be_sequence.h" +#include "be_helper.h" +#include "be_extern.h" +#include "utl_identifier.h" #include "be_visitor_array.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_array/array.cpp" #include "be_visitor_array/array_ch.cpp" #include "be_visitor_array/array_ci.cpp" @@ -35,4 +48,6 @@ #include "be_visitor_array/cdr_op_ci.cpp" #include "be_visitor_array/cdr_op_cs.cpp" -ACE_RCSID(be, be_visitor_array, "$Id$") +ACE_RCSID (be, + be_visitor_array, + "$Id$") 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 index c06cd148e8b..d91076f394f 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/any_op_ch.cpp @@ -19,13 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_array, + any_op_ch, + "$Id$") // *************************************************************************** // Array visitor for generating Any operator declarations in the client header 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 index f61e08092f5..d54682fa490 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp @@ -19,12 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, any_op_cs, "$Id$") +ACE_RCSID (be_visitor_array, + any_op_cs, + "$Id$") // *************************************************************************** diff --git a/TAO/TAO_IDL/be/be_visitor_array/array.cpp b/TAO/TAO_IDL/be/be_visitor_array/array.cpp index b591c362a4f..96bf2fcb913 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_array, array, "$Id$") +ACE_RCSID (be_visitor_array, + array, + "$Id$") // ************************************************************************ @@ -43,7 +38,7 @@ be_visitor_array::~be_visitor_array (void) int be_visitor_array::visit_array (be_array *) { - // must be overloaded by derived visitors + // Must be overloaded by derived visitors. return -1; } @@ -60,14 +55,23 @@ be_visitor_array::visit_interface (be_interface *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + { + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + } else - *os << bt->name () << "_var"; + { + *os << bt->name () << "_var"; + } + return 0; } @@ -78,14 +82,77 @@ be_visitor_array::visit_interface_fwd (be_interface_fwd *node) be_type *bt; if (this->ctx_->alias ()) - bt = 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_valuetype (be_valuetype *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_valuetype_fwd (be_valuetype_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; + + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + { + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + } else - *os << bt->name () << "_var"; + { + *os << bt->name () << "_var"; + } + return 0; } @@ -93,10 +160,18 @@ 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"; + AST_PredefinedType::PredefinedType pt = node->pt (); + + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) + { + *os << node->name () << "_var"; + } else - *os << node->name (); + { + *os << node->name (); + } + return 0; } @@ -139,7 +214,6 @@ int be_visitor_array::visit_typedef (be_typedef *node) { int result = this->visit_node (node); - TAO_OutStream *os = this->ctx_->stream (); AST_Decl::NodeType nt = node->primitive_base_type ()->node_type (); @@ -159,13 +233,22 @@ be_visitor_array::visit_node (be_type *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *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 index 62cc817c917..1825b00443e 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_ch, "$Id$") - +ACE_RCSID (be_visitor_array, + array_ch, + "$Id$") // ************************************************************************ // visitor for array declaration in client header @@ -43,7 +38,6 @@ 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 (); - be_type *bt; be_decl *scope = this->ctx_->scope (); // Nothing to do if we are imported or code is already generated. @@ -55,7 +49,7 @@ int be_visitor_array_ch::visit_array (be_array *node) this->ctx_->node (node); // Retrieve the type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -66,6 +60,10 @@ int be_visitor_array_ch::visit_array (be_array *node) -1); } + *os << be_nl << "// TAO_IDL - Generated from " << be_nl + << "// " __FILE__ << ":" << __LINE__ + << be_nl << be_nl; + // Generate the ifdefined macro. os->gen_ifdef_macro (node->flat_name ()); @@ -98,7 +96,9 @@ int be_visitor_array_ch::visit_array (be_array *node) *os << " "; - if (!this->ctx_->tdef ()) + be_typedef *td = this->ctx_->tdef (); + + if (td == 0) { // We are dealing with an anonymous array case. Generate a typedef with // an _ prepended to the name. @@ -166,7 +166,7 @@ int be_visitor_array_ch::visit_array (be_array *node) } // An out defn is generated only for a variable size array. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { if (this->gen_out_defn (node) == -1) { @@ -217,22 +217,24 @@ int be_visitor_array_ch::visit_array (be_array *node) { // 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 " + << " *" << be_nl; + *os << node->nested_type_name (scope, "_alloc") << " (void);" + << be_nl << be_nl; + *os << storage_class << "void" << be_nl << node->nested_type_name (scope, "_free") << " (" << be_idt << be_idt_nl; *os << node->nested_type_name (scope, "_slice") << " *_tao_slice " << be_uidt_nl - << ");" << be_uidt_nl; - *os << storage_class << node->nested_type_name (scope, "_slice") << " *"; + << ");" << be_uidt_nl << be_nl; + *os << storage_class << node->nested_type_name (scope, "_slice") + << " *" << be_nl; *os << node->nested_type_name (scope, "_dup") << " (" << be_idt << be_idt_nl << "const "; *os << node->nested_type_name (scope, "_slice") << " *_tao_slice" << be_uidt_nl - << ");" << be_uidt_nl; - *os << storage_class << "void " + << ");" << be_uidt_nl << be_nl; + *os << storage_class << "void" << be_nl << node->nested_type_name (scope, "_copy") << " (" << be_idt << be_idt_nl; *os << node->nested_type_name (scope, "_slice") << " *_tao_to," << be_nl @@ -245,24 +247,24 @@ int be_visitor_array_ch::visit_array (be_array *node) { // Anonymous array. *os << storage_class << node->nested_type_name (scope, "_slice", "_") - << " *"; + << " *" << be_nl; *os << node->nested_type_name (scope, "_alloc", "_") - << " (void);" << be_nl; - *os << storage_class << "void " + << " (void);" << be_nl << be_nl; + *os << storage_class << "void" << be_nl << node->nested_type_name (scope, "_free", "_") << " (" << be_idt << be_idt_nl; *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice" << be_uidt_nl - << ");" << be_uidt_nl; + << ");" << be_uidt_nl << be_nl; *os << storage_class << node->nested_type_name (scope, "_slice", "_") - << " *"; + << " *" << be_nl; *os << node->nested_type_name (scope, "_dup", "_") << " (" << be_idt << be_idt_nl << "const "; *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice" << be_uidt_nl - << ");" << be_uidt_nl; - *os << storage_class << "void " + << ");" << be_uidt_nl << be_nl; + *os << storage_class << "void" << be_nl << node->nested_type_name (scope, "_copy", "_") << " (" << be_idt << be_idt_nl; *os << node->nested_type_name (scope, "_slice", "_") @@ -356,7 +358,7 @@ be_visitor_array_ch::gen_var_defn (be_array *node) *os << "operator " << namebuf << "_slice * const &() const;" << be_nl; - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << "operator " << namebuf << "_slice *&();" << be_nl; } @@ -375,7 +377,7 @@ be_visitor_array_ch::gen_var_defn (be_array *node) *os << "// in, inout, out, _retn " << be_nl; *os << "const " << namebuf << "_slice *in (void) const;" << be_nl; - if (node->size_type () == be_decl::FIXED) + if (node->size_type () == AST_Type::FIXED) { *os << namebuf << "_slice *inout (void);" << be_nl; } diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp index e89dc21302f..d5dc7a1647c 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_ci, "$Id$") +ACE_RCSID (be_visitor_array, + array_ci, + "$Id$") // ************************************************************************ @@ -42,15 +38,17 @@ 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 + // Nothing to do if we are imported or code is already generated. if (node->imported () || (node->cli_inline_gen ())) - return 0; + { + 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, @@ -86,7 +84,7 @@ int be_visitor_array_ci::visit_array (be_array *node) "var_defn failed\n"), -1); } - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { if (this->gen_out_impl (node) == -1) { @@ -118,22 +116,33 @@ int be_visitor_array_ci::visit_array (be_array *node) int be_visitor_array_ci::gen_var_impl (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // output stream + TAO_OutStream *os = this->ctx_->stream (); + + char nodename [NAMEBUFSIZE]; + char fname [NAMEBUFSIZE]; + char lname [NAMEBUFSIZE]; + + ACE_OS::memset (nodename, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (lname, + '\0', + NAMEBUFSIZE); - 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->full_name ()); - ACE_OS::sprintf (fname, "%s_var", node->full_name ()); - ACE_OS::sprintf (lname, "%s_var", + ACE_OS::sprintf (nodename, + "%s", + node->full_name ()); + ACE_OS::sprintf (fname, + "%s_var", + node->full_name ()); + ACE_OS::sprintf (lname, + "%s_var", node->local_name ()->get_string ()); } else @@ -143,26 +152,40 @@ be_visitor_array_ci::gen_var_impl (be_array *node) // 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->full_name (), + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + ACE_OS::sprintf (nodename, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_var", parent->full_name (), + ACE_OS::sprintf (fname, + "%s::_%s_var", + parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_var", + ACE_OS::sprintf (lname, + "_%s_var", node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (nodename, "_%s", node->full_name ()); - ACE_OS::sprintf (fname, "_%s_var", node->full_name ()); - ACE_OS::sprintf (lname, "_%s_var", + ACE_OS::sprintf (nodename, + "_%s", + node->full_name ()); + ACE_OS::sprintf (fname, + "_%s_var", + node->full_name ()); + ACE_OS::sprintf (lname, + "_%s_var", node->local_name ()->get_string ()); } } - // generate the var implementation in the inline file + // Generate the var implementation in the inline file. - os->indent (); // start with whatever was our current indent level + os->indent (); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *os << "// *************************************************************" << be_nl; @@ -172,134 +195,140 @@ be_visitor_array_ci::gen_var_impl (be_array *node) // default constr *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << - " (void) // default constructor" << be_nl; + " (void)" << be_nl; *os << " " << ": ptr_ (0)" << be_nl; - *os << "{}\n\n"; + *os << "{}" << be_nl << be_nl; // 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"; + *os << "{}" << be_nl << be_nl; // copy constructor (deep copy) - os->indent (); *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << " (const " << fname - << " &p) // copy constructor" << be_nl; + << " &p)" << be_nl; *os << "{" << be_idt_nl; - *os << "this->ptr_ = " << nodename << "_dup " << "(ACE_const_cast (const " - << nodename << "_slice *, p.ptr_));" << be_uidt_nl; - *os << "}\n\n"; + *os << "this->ptr_ =" << be_idt_nl << nodename << "_dup " << "(" + << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << "const " + << nodename << "_slice *," << be_nl + << "p.ptr_" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl; + *os << "}" << be_nl << be_nl; // destructor - os->indent (); *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; + *os << fname << "::~" << lname << " (void)" << be_nl; *os << "{" << be_idt_nl; *os << nodename << "_free (this->ptr_);" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // 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?" + *os << "// Is what we own the same that is being assigned to us?" << be_nl; - *os << "if (this->ptr_ != p)" << be_nl; + *os << "if (this->ptr_ != p)" << be_idt_nl; *os << "{" << be_idt_nl; - *os << "// delete our stuff and assume ownership of p" << be_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 << "}" << be_uidt_nl << be_nl; *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // 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 << "if (this != &p)" << be_idt_nl; *os << "{" << be_idt_nl; - *os << "// not assigning to ourselves" << be_nl; - *os << nodename << "_free (this->ptr_); // free old stuff" << be_nl; - *os << "// deep copy" << be_nl; - *os << "this->ptr_ = " << nodename << "_dup (ACE_const_cast (const " - << nodename << "_slice *, p.ptr_));" << be_uidt_nl; - *os << "}" << be_nl; + *os << nodename << "_free (this->ptr_);" << be_nl; + *os << "// Deep copy." << be_nl; + *os << "this->ptr_ =" << be_idt_nl + << nodename << "_dup (" << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << "const " << nodename << "_slice *," << be_nl\ + << "p.ptr_" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl; + *os << "}" << be_uidt_nl << be_nl; *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // other extra methods - cast operators () - os->indent (); *os << "ACE_INLINE " << be_nl; *os << fname << "::operator " << nodename - << "_slice * const &() const // cast" << be_nl; + << "_slice * const &() const" << be_nl; *os << "{" << be_idt_nl; *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { - 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"; + *os << "}" << be_nl << be_nl; } // two operator []s instead of -> - os->indent (); *os << "ACE_INLINE " << be_nl; *os << "const " << nodename << "_slice &" << be_nl; *os << fname << "::operator[] (CORBA::ULong index) const" << be_nl; *os << "{" << be_nl; *os << "#if defined (ACE_HAS_BROKEN_IMPLICIT_CONST_CAST)" << be_idt_nl; - *os << "return ACE_const_cast (const " << nodename - << "_slice &, this->ptr_[index]);" << be_uidt_nl; + *os << "return ACE_const_cast (" << be_idt << be_idt_nl + << "const " << nodename + << "_slice &," << be_nl + << "this->ptr_[index]" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; *os << "#else" << be_idt_nl; *os << "const " << nodename << "_slice &tmp = this->ptr_[index];" << be_nl; *os << "return tmp;" << be_uidt_nl; *os << "#endif /* ACE_HAS_BROKEN_IMPLICIT_CONST_CAST */" << be_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; - os->indent (); *os << "ACE_INLINE " << be_nl; *os << 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"; + *os << "}" << be_nl << be_nl; // copy (in case we are a sequence element) - os->indent (); *os << "ACE_INLINE void" << be_nl; - *os << fname << "::copy (" << nodename << "_slice *_tao_to, " - << "const " << nodename << "_slice *_tao_from)" << be_nl; + *os << fname << "::copy (" << be_idt << be_idt_nl + << nodename << "_slice *_tao_to," << be_nl + << "const " << nodename << "_slice *_tao_from" << be_uidt_nl + << ")" << be_uidt_nl; *os << "{" << be_idt_nl; *os << nodename << "_copy (_tao_to, _tao_from);" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // 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 ACE_const_cast (const " << nodename - << "_slice *, this->ptr_);" << be_uidt_nl; - *os << "}\n\n"; + *os << "return ACE_const_cast (" << be_idt << be_idt_nl + << "const " << nodename + << "_slice *," << be_nl + << "this->ptr_" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + *os << "}" << be_nl << be_nl; - os->indent (); - if (node->size_type () == be_decl::FIXED) + if (node->size_type () == AST_Type::FIXED) { *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; } @@ -311,28 +340,25 @@ be_visitor_array_ci::gen_var_impl (be_array *node) *os << fname << "::inout (void)" << be_nl; *os << "{" << be_idt_nl; *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; - 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 << "}" << be_nl << be_nl; - 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"; + *os << "}" << be_nl << be_nl; // 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; @@ -352,15 +378,26 @@ be_visitor_array_ci::gen_out_impl (be_array *node) 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); + 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->full_name ()); - ACE_OS::sprintf (fname, "%s_out", node->full_name ()); - ACE_OS::sprintf (lname, "%s_out", + ACE_OS::sprintf (nodename, + "%s", + node->full_name ()); + ACE_OS::sprintf (fname, + "%s_out", + node->full_name ()); + ACE_OS::sprintf (lname, + "%s_out", node->local_name ()->get_string ()); } else @@ -370,43 +407,56 @@ be_visitor_array_ci::gen_out_impl (be_array *node) // 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->full_name (), + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + ACE_OS::sprintf (nodename, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_out", parent->full_name (), + ACE_OS::sprintf (fname, + "%s::_%s_out", + parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_out", + ACE_OS::sprintf (lname, + "_%s_out", node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (nodename, "_%s", node->full_name ()); - ACE_OS::sprintf (fname, "_%s_out", node->full_name ()); - ACE_OS::sprintf (lname, "_%s_out", + ACE_OS::sprintf (nodename, + "_%s", + node->full_name ()); + ACE_OS::sprintf (fname, + "_%s_out", + node->full_name ()); + ACE_OS::sprintf (lname, + "_%s_out", node->local_name ()->get_string ()); } } - // generate the out implementation in the inline file + // Generate the out implementation in the inline file. - os->indent (); // start with whatever was our current indent level + os->indent (); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *os << "// *************************************************************" << be_nl; *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; + *os << "// *************************************************************" + << be_nl << be_nl; - // constr from a pointer to slice - os->indent (); + // Constructor from a pointer to slice. *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"; + *os << "}" << be_nl << be_nl; // constructor from _var & - os->indent (); *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << " (" << nodename << "_var &p) // constructor from _var" << be_nl; @@ -414,19 +464,17 @@ be_visitor_array_ci::gen_out_impl (be_array *node) *os << "{" << be_idt_nl; *os << nodename << "_free (this->ptr_);" << be_nl; *os << "this->ptr_ = 0;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // 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"; + *os << "{}" << be_nl << be_nl; // assignment operator from _out & - os->indent (); *os << "ACE_INLINE " << fname << " &" << be_nl; *os << fname << "::operator= (const " << fname << " &p)" << be_nl; @@ -434,39 +482,35 @@ be_visitor_array_ci::gen_out_impl (be_array *node) *os << "this->ptr_ = ACE_const_cast (" << fname << "&,p).ptr_;" << be_nl; *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // 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"; + *os << "}" << be_nl << be_nl; // 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"; + *os << "}" << be_nl << be_nl; // 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"; + *os << "}" << be_nl << be_nl; // operator [] instead of -> - os->indent (); *os << "ACE_INLINE " << nodename << "_slice &" << be_nl; *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; *os << "{" << be_idt_nl; @@ -482,22 +526,35 @@ be_visitor_array_ci::gen_forany_impl (be_array *node) if (node->is_local ()) return 0; - TAO_OutStream *os = this->ctx_->stream (); // output stream + TAO_OutStream *os = this->ctx_->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 + char lname [NAMEBUFSIZE]; // local names of the forany + + // 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); + 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->full_name ()); - ACE_OS::sprintf (fname, "%s_forany", node->full_name ()); - ACE_OS::sprintf (lname, "%s_forany", + ACE_OS::sprintf (nodename, + "%s", + node->full_name ()); + ACE_OS::sprintf (fname, + "%s_forany", + node->full_name ()); + ACE_OS::sprintf (lname, + "%s_forany", node->local_name ()->get_string ()); } else @@ -507,19 +564,30 @@ be_visitor_array_ci::gen_forany_impl (be_array *node) // 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->full_name (), + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + ACE_OS::sprintf (nodename, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_forany", parent->full_name (), + ACE_OS::sprintf (fname, + "%s::_%s_forany", + parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_forany", + ACE_OS::sprintf (lname, + "_%s_forany", node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (nodename, "_%s", node->full_name ()); - ACE_OS::sprintf (fname, "_%s_forany", node->full_name ()); - ACE_OS::sprintf (lname, "_%s_forany", + ACE_OS::sprintf (nodename, + "_%s", + node->full_name ()); + ACE_OS::sprintf (fname, + "_%s_forany", + node->full_name ()); + ACE_OS::sprintf (lname, + "_%s_forany", node->local_name ()->get_string ()); } } @@ -528,101 +596,109 @@ be_visitor_array_ci::gen_forany_impl (be_array *node) os->indent (); // start with whatever was our current indent level + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// *************************************************************" << be_nl; *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; + *os << "// *************************************************************" + << be_nl << be_nl; // default constr *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << - " (void) // default constructor" << be_nl; + " (void)" << be_nl; *os << " " << ": ptr_ (0)," << be_nl; *os << " nocopy_ (0)" << be_nl; - *os << "{}\n\n"; + *os << "{}" << be_nl << be_nl; // constr from a _slice * - os->indent (); *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename << "_slice *p, " - << "CORBA::Boolean nocopy)" << be_nl; + *os << fname << "::" << lname << " (" << be_idt << be_idt_nl + << nodename << "_slice *p," << be_nl + << "CORBA::Boolean nocopy" << be_uidt_nl + << ")" << be_uidt_nl; *os << " : ptr_ (p)," << be_nl; *os << " nocopy_ (nocopy)" << be_nl; - *os << "{}\n\n"; + *os << "{}" << be_nl << be_nl; // 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 (ACE_const_cast (const " - << nodename << "_slice *, p.ptr_));" << be_nl; + *os << fname << "::" << lname << " (" << be_idt << be_idt_nl + << "const " << fname << " &p" << be_uidt_nl + << ")" << be_uidt_nl; + *os << "{" << be_idt_nl; + *os << "this->ptr_ =" << be_idt_nl + << nodename << "_dup (" << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << "const " << nodename << "_slice *," << be_nl + << "p.ptr_" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; *os << "this->nocopy_ = p.nocopy_;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // 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"; + *os << fname << "::~" << lname << " (void)" << be_nl; + *os << "{" << be_idt_nl; + *os << "// don't do anything" << be_uidt_nl; + *os << "}" << be_nl << be_nl; // 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?" + *os << "// Is what we own the same that is being assigned to us?" << be_nl; - *os << "if (this->ptr_ != p)" << be_nl; + *os << "if (this->ptr_ != p)" << be_idt_nl; *os << "{" << be_idt_nl; - *os << "// delete our stuff and assume ownership of p" << be_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 << "}" << be_uidt_nl << be_nl; *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // 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 << "if (this != &p)" << be_idt_nl; *os << "{" << be_idt_nl; - *os << "// not assigning to ourselves" << be_nl; - *os << nodename << "_free (this->ptr_); // free old stuff" << be_nl; - *os << "// deep copy" << be_nl; - *os << "this->ptr_ = " << nodename << "_dup (ACE_const_cast (const " - << nodename << "_slice *, p.ptr_));" << be_nl; + *os << nodename << "_free (this->ptr_);" << be_nl; + *os << "// Deep copy." << be_nl; + *os << "this->ptr_ =" << be_idt_nl + << nodename << "_dup (" << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << "const " << nodename << "_slice *," << be_nl + << "p.ptr_" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; *os << "this->nocopy_ = p.nocopy_;" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_uidt_nl << be_nl; *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // other extra methods - cast operators () - os->indent (); *os << "ACE_INLINE " << be_nl; *os << fname << "::operator " << nodename - << "_slice * const &() const // cast" << be_nl; + << "_slice * const &() const" << be_nl; *os << "{" << be_idt_nl; *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; - os->indent (); *os << "ACE_INLINE " << be_nl; *os << fname << "::operator " << nodename - << "_slice *&() // cast " << be_nl; + << "_slice *&()" << be_nl; *os << "{" << be_idt_nl; *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; // two operator []s instead of -> - os->indent (); *os << "ACE_INLINE " << be_nl; *os << "const " << nodename << "_slice &" << be_nl; *os << fname << "::operator[] (CORBA::ULong index) const" << be_nl; @@ -632,63 +708,60 @@ be_visitor_array_ci::gen_forany_impl (be_array *node) // not accept one, but will do it implicitly with a temporary. // It's only a problem with multidimensional arrays. #if defined (ACE_HAS_BROKEN_IMPLICIT_CONST_CAST) - *os << "return ACE_const_cast (const " << nodename - << "_slice &, this->ptr_[index]);" << be_uidt_nl; + *os << "return ACE_const_cast (" << be_idt << be_idt_nl + << "const " << nodename << "_slice &," << be_nl + << "this->ptr_[index]" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; #else *os << "const " << nodename << "_slice &tmp = this->ptr_[index];" << be_nl; *os << "return tmp;" << be_uidt_nl; #endif /* ACE_HAS_BROKEN_IMPLICIT_CONST_CAST */ - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; - os->indent (); *os << "ACE_INLINE " << be_nl; *os << 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"; + *os << "}" << be_nl << be_nl; // 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 ACE_const_cast (const " << nodename - << "_slice *, this->ptr_);" << be_uidt_nl; - *os << "}\n\n"; + *os << "return ACE_const_cast (" << be_idt << be_idt_nl + << "const " << nodename << "_slice *," << be_nl + << "this->ptr_" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + *os << "}" << be_nl << be_nl; - 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 << "}" << be_nl << be_nl; - 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 << "}" << be_nl << be_nl; - 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"; + *os << "}" << be_nl << be_nl; // 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"; + *os << "}" << be_nl << be_nl; // 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; diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp index 23048045acc..8040f161617 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_cs, "$Id$") - +ACE_RCSID (be_visitor_array, + array_cs, + "$Id$") // ************************************************************************ // visitor for array declaration in client stubs @@ -43,7 +38,6 @@ 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 (); - be_type *bt; unsigned long i; // Nothing to do if we are imported or code is already generated. @@ -55,7 +49,7 @@ int be_visitor_array_cs::visit_array (be_array *node) this->ctx_->node (node); // Retrieve the type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -114,23 +108,32 @@ int be_visitor_array_cs::visit_array (be_array *node) os->indent (); - *os << "void " << fname << "_forany" - << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl - << "{" << be_idt_nl - << lname << "_slice *tmp = ACE_static_cast (" - << lname << "_slice*, _tao_void_pointer);" << be_nl - << lname << "_free (tmp);" << be_uidt_nl - << "}\n\n"; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + if (!node->is_local ()) + { + *os << "void " << fname << "_forany" + << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl + << "{" << be_idt_nl + << lname << "_slice *tmp = ACE_static_cast (" + << lname << "_slice*, _tao_void_pointer);" << be_nl + << lname << "_free (tmp);" << be_uidt_nl + << "}" << be_nl << be_nl; + } // dup method. *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 << "_slice *_tao_dup_array =" << be_idt_nl + << fname << "_alloc ();" << be_uidt_nl << be_nl; + *os << "if (!_tao_dup_array)" << be_idt_nl + << "{" << be_idt_nl + << "return (" << fname + << "_slice *)0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; *os << fname << "_copy (_tao_dup_array, _tao_src_array);" << be_nl; *os << "return _tao_dup_array;" << be_uidt_nl; *os << "}\n\n"; @@ -177,13 +180,17 @@ int be_visitor_array_cs::visit_array (be_array *node) // copy method. os->indent (); *os << "void " << be_nl; - *os << fname << "_copy (" << fname << "_slice * _tao_to, " - << "const " << fname << "_slice *_tao_from)" << be_nl; + *os << fname << "_copy (" << be_idt << be_idt_nl + << fname << "_slice * _tao_to," << be_nl + << "const " << fname << "_slice *_tao_from" << be_uidt_nl + << ")" << be_uidt_nl; *os << "{" << be_idt_nl; - *os << "// copy each individual element" << be_nl; + *os << "// Copy each individual element." << be_nl; + + unsigned long ndims = node->n_dims (); // Generate nested loops for as many dimensions as there are. - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { // Retrieve the ith dimension value. AST_Expression *expr = node->dims ()[i]; @@ -201,7 +208,8 @@ int be_visitor_array_cs::visit_array (be_array *node) { // Generate a loop for each dimension. *os << "for (CORBA::ULong i" << i << " = 0; i" << i << " < " - << expr->ev ()->u.ulval << "; i" << i << "++)" << be_idt_nl; + << expr->ev ()->u.ulval << "; ++i" << i << ")" << be_idt_nl + << "{" << be_idt_nl; } else { @@ -253,7 +261,7 @@ int be_visitor_array_cs::visit_array (be_array *node) *os << "_copy (_tao_to"; - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { *os << "[i" << i << "]"; } @@ -261,7 +269,7 @@ int be_visitor_array_cs::visit_array (be_array *node) *os << ", "; *os << "_tao_from"; - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { *os << "[i" << i << "]"; } @@ -275,7 +283,7 @@ int be_visitor_array_cs::visit_array (be_array *node) *os << "_tao_to"; - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { *os << "[i" << i << "]"; } @@ -283,18 +291,20 @@ int be_visitor_array_cs::visit_array (be_array *node) *os << " = "; *os << "_tao_from"; - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { *os << "[i" << i << "]"; } *os << ";"; } - for (i = 0; i < node->n_dims (); i++) + + for (i = 0; i < ndims; ++i) { - // Decrement indentation as many times as the number of dimensions. - *os << be_uidt; + // Add closing braces as many times as the number of dimensions. + *os << be_uidt_nl << "}" << be_uidt; } + *os << be_uidt_nl << "}\n\n"; // If we contain an anonymous sequence, @@ -314,6 +324,5 @@ int be_visitor_array_cs::visit_array (be_array *node) } 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 index 26c010a1011..551ff95a687 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp @@ -19,15 +19,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_array, cdr_op_ch, "$Id$") +#include "be_visitor_sequence/cdr_op_ch.h" +ACE_RCSID (be_visitor_array, + cdr_op_ch, + "$Id$") // *************************************************************************** // Array visitor for generating CDR operator declarations in the client header @@ -77,8 +73,7 @@ be_visitor_array_cdr_op_ch::visit_array (be_array *node) // Generate the CDR << and >> operator declarations. *os << be_global->stub_export_macro () << " CORBA::Boolean" << " 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 ()); 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 index d013f66bf35..1d781d2d4b5 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp @@ -19,14 +19,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_array, + cdr_op_ci, + "$Id$") +#include "be_visitor_sequence/cdr_op_ci.h" // *************************************************************************** // Array visitor for generating CDR operator declarations in the client @@ -60,15 +57,13 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) } else { - TAO_OutStream *os = this->ctx_->stream (); - if (node->cli_inline_cdr_op_gen () || node->imported ()) { return 0; } - // Retrieve the base type. be_type *bt = be_type::narrow_from_decl (node->base_type ()); + TAO_OutStream *os = this->ctx_->stream (); if (!bt) { @@ -117,18 +112,24 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) 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. + // 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->full_name (), + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + node->full_name ()); } } @@ -139,9 +140,10 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *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 + *os << "ACE_INLINE CORBA::Boolean operator<< (" << be_idt << be_idt_nl + << "TAO_OutputCDR &strm," << be_nl + << "const " << fname << "_forany &_tao_array" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; if (bt->accept (this) == -1) @@ -159,9 +161,10 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) 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 + *os << "ACE_INLINE CORBA::Boolean operator>> (" << be_idt << be_idt_nl + << "TAO_InputCDR &strm," << be_nl + << fname << "_forany &_tao_array" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; if (bt->accept (this) == -1) @@ -202,6 +205,18 @@ be_visitor_array_cdr_op_ci::visit_interface_fwd (be_interface_fwd *node) } int +be_visitor_array_cdr_op_ci::visit_valuetype (be_valuetype *node) +{ + return this->visit_node (node); +} + +int +be_visitor_array_cdr_op_ci::visit_valuetype_fwd (be_valuetype_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 (); @@ -209,6 +224,7 @@ be_visitor_array_cdr_op_ci::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: case AST_PredefinedType::PT_any: // Let the helper handle this. return this->visit_node (node); @@ -217,8 +233,8 @@ be_visitor_array_cdr_op_ci::visit_predefined_type (be_predefined_type *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_array_cdr_op_ci::" "visit_predefined_type - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); default: // All other primitive types. Handle them as shown below. break; @@ -226,8 +242,8 @@ be_visitor_array_cdr_op_ci::visit_predefined_type (be_predefined_type *node) // 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. + // array (even though it was multi-dimensional), and pass the total length + // of the array as a cross product of the dimensions. unsigned long i; @@ -399,14 +415,16 @@ be_visitor_array_cdr_op_ci::visit_predefined_type (be_predefined_type *node) -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) + unsigned long ndims = array->n_dims (); + + // Generate a product of all the dimensions. This will be the total length + // of the "unfolded" single dimensional array. + for (i = 0; i < ndims; ++i) { // Retrieve the ith dimension value. AST_Expression *expr = array->dims ()[i]; - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) + if ((expr == 0) || ((expr != 0) && (expr->ev () == 0))) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_array_cdr_op_ci::" @@ -506,12 +524,14 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) // Initialize a boolean variable. *os << "CORBA::Boolean _tao_marshal_flag = 1;" << be_nl; + unsigned long ndims = node->n_dims (); + // 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++) + // generate nested loops for as many dimensions as there are + for (i = 0; i < ndims; ++i) { // Retrieve the ith dimension value. AST_Expression *expr = node->dims ()[i]; @@ -528,8 +548,8 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) if (expr->ev ()->et == AST_Expression::EV_ulong) { // Generate a loop for each dimension. - *os << be_nl << "for (CORBA::ULong i" << i << " = 0; i" - << i << " < " + *os << be_nl << "for (CORBA::ULong i" << i + << " = 0; i" << i << " < " << expr->ev ()->u.ulval << " && _tao_marshal_flag; i" << i << "++)" << be_idt_nl; } @@ -558,7 +578,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) *os << "_tao_marshal_flag = (strm >> tmp);" << be_nl; *os << bt->name () << "_copy (_tao_array"; - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { *os << "[i" << i << "]"; } @@ -584,6 +604,8 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) case AST_Decl::NT_wstring: case AST_Decl::NT_interface: case AST_Decl::NT_interface_fwd: + case AST_Decl::NT_valuetype: + case AST_Decl::NT_valuetype_fwd: *os << ".out ()"; break; case AST_Decl::NT_pre_defined: @@ -602,7 +624,10 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) -1); } - if (pt->pt () == AST_PredefinedType::PT_pseudo) + AST_PredefinedType::PredefinedType pdt = pt->pt (); + + if (pdt == AST_PredefinedType::PT_pseudo + || pdt == AST_PredefinedType::PT_object) { *os << ".out ()"; } @@ -627,7 +652,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) *os << bt->name () << "_var tmp_var (" << bt->name () << "_dup (_tao_array"; - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { *os << "[i" << i << "]"; } @@ -641,7 +666,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) *os << "_tao_marshal_flag = (strm << "; *os << "_tao_array "; - for (i = 0; i < node->n_dims (); i++) + for (i = 0; i < ndims; ++i) { *os << "[i" << i << "]"; } @@ -654,6 +679,8 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) case AST_Decl::NT_wstring: case AST_Decl::NT_interface: case AST_Decl::NT_interface_fwd: + case AST_Decl::NT_valuetype: + case AST_Decl::NT_valuetype_fwd: *os << ".in ()"; break; case AST_Decl::NT_pre_defined: @@ -672,7 +699,10 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) -1); } - if (pt->pt () == AST_PredefinedType::PT_pseudo) + AST_PredefinedType::PredefinedType pdt = pt->pt (); + + if (pdt == AST_PredefinedType::PT_pseudo + || pdt == AST_PredefinedType::PT_object) { *os << ".in ()"; } @@ -695,7 +725,7 @@ be_visitor_array_cdr_op_ci::visit_node (be_type *bt) -1); } - for (i = 0; i < node->n_dims (); ++i) + for (i = 0; i < ndims; ++i) { // Decrement indentation as many times as the number of dimensions. *os << be_uidt; diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp index 32ab61bb987..750f5f9bcfd 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp @@ -19,11 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" +ACE_RCSID (be_visitor_array, + cdr_op_cs, + "$Id$") // *************************************************************************** // Array visitor for generating CDR operator declarations in the client diff --git a/TAO/TAO_IDL/be/be_visitor_attribute.cpp b/TAO/TAO_IDL/be/be_visitor_attribute.cpp index 7b11a6294c2..b85b330d9a0 100644 --- a/TAO/TAO_IDL/be/be_visitor_attribute.cpp +++ b/TAO/TAO_IDL/be/be_visitor_attribute.cpp @@ -18,14 +18,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_attribute.h" +#include "be_operation.h" +#include "be_predefined_type.h" +#include "be_argument.h" +#include "utl_identifier.h" #include "be_visitor_attribute.h" +#include "be_visitor_context.h" +#include "be_visitor_operation.h" -// include all the individual files #include "be_visitor_attribute/attribute.cpp" -ACE_RCSID(be, be_visitor_attribute, "$Id$") +ACE_RCSID (be, + be_visitor_attribute, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp b/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp index d888053524e..6c9264184ce 100644 --- a/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp +++ b/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_attribute.h" - -ACE_RCSID(be_visitor_attribute, attribute, "$Id$") - +ACE_RCSID (be_visitor_attribute, + attribute, + "$Id$") // Attribute gets mapped to one or possibly two operations based on whether // it is readonly or not. The two operations "get" and "set" the value of the @@ -65,29 +60,30 @@ be_visitor_attribute::~be_visitor_attribute (void) int be_visitor_attribute::visit_attribute (be_attribute *node) { - this->ctx_->node (node); // save the node - this->ctx_->attribute (node); // save this attribute node + this->ctx_->node (node); + this->ctx_->attribute (node); // first the "get" operation - be_operation *op = new be_operation (node->field_type (), - AST_Operation::OP_noflags, - node->name (), - node->is_local (), - node->is_abstract ()); - op->set_name ((UTL_IdList *) node->name ()->copy ()); - op->set_defined_in (node->defined_in ()); + be_operation get_op (node->field_type (), + AST_Operation::OP_noflags, + node->name (), + node->is_local (), + node->is_abstract ()); + + get_op.set_name ((UTL_IdList *) node->name ()->copy ()); + get_op.set_defined_in (node->defined_in ()); // Get the strategy from the attribute and hand it over - // to the operation - delete op->set_strategy (node->get_get_strategy ()); + // to the operation. + delete get_op.set_strategy (node->get_get_strategy ()); be_visitor_context ctx (*this->ctx_); + int status = 1; - // this switch statement eliminates the need for different classes that have - // exactly the same code except different states. switch (this->ctx_->state ()) { + // These two cases are the only ones that could involved a strategy. case TAO_CodeGen::TAO_ATTRIBUTE_CH: ctx.state (TAO_CodeGen::TAO_OPERATION_CH); break; @@ -95,61 +91,119 @@ be_visitor_attribute::visit_attribute (be_attribute *node) ctx.state (TAO_CodeGen::TAO_OPERATION_CS); break; case TAO_CodeGen::TAO_ATTRIBUTE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SH); + be_visitor_operation_sh visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_IH: - ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_IH); + be_visitor_operation_ih visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SS); + be_visitor_operation_ss visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_IS: - ctx.state (TAO_CodeGen::TAO_OPERATION_IS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_IS); + be_visitor_operation_is visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_BASE_PROXY_IMPL_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); + be_visitor_operation_base_proxy_impl_ch visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_PROXY_IMPL_XH: - ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); + be_visitor_operation_proxy_impl_xh visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_REMOTE_PROXY_IMPL_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); + be_visitor_operation_remote_proxy_impl_cs visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_THRU_POA_PROXY_IMPL_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS); + be_visitor_operation_thru_poa_proxy_impl_ss visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_DIRECT_PROXY_IMPL_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS); + be_visitor_operation_direct_proxy_impl_ss visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CH); + be_visitor_operation_smart_proxy_ch visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS); + be_visitor_operation_smart_proxy_cs visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); + be_visitor_operation_interceptors_cs visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SH); + be_visitor_operation_interceptors_sh visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); + be_visitor_operation_interceptors_ss visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SH); + be_visitor_operation_tie_sh visitor (&ctx); + status = get_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SI); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SI); + be_visitor_operation_tie_si visitor (&ctx); + status = get_op.accept (&visitor); + break; + } default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -157,34 +211,24 @@ be_visitor_attribute::visit_attribute (be_attribute *node) -1); } - // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state ())); - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + if (status == -1) { - delete visitor; - delete op; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for get_attribute failed\n"), -1); } - - delete visitor; - visitor = 0; - - if (op->has_extra_code_generation (ctx.state ())) + else if (status == 1) { - // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state (), 1)); + // Change the state depending on the kind of node strategy. + ctx.state (get_op.next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + + if (!visitor || (get_op.accept (visitor) == -1)) { delete visitor; - delete op; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -194,45 +238,69 @@ be_visitor_attribute::visit_attribute (be_attribute *node) delete visitor; visitor = 0; - } - delete op; + if (get_op.has_extra_code_generation (ctx.state ())) + { + // Change the state depending on the kind of node strategy. + ctx.state (get_op.next_state (ctx.state (), 1)); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + + if (!visitor || (get_op.accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_attribute::" + "visit_attribute - " + "codegen for get_attribute failed\n"), + -1); + } + + delete visitor; + visitor = 0; + } + } // Do nothing for readonly attributes. if (node->readonly ()) - return 0; + { + return 0; + } - // Create the set method. + status = 1; - // the return type is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 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 ()); - arg->set_name ((UTL_IdList *) node->name ()->copy ()); - // create the operation - op = new be_operation (rt, - AST_Operation::OP_noflags, - node->name (), - node->is_local (), - node->is_abstract ()); - op->set_name ((UTL_IdList *) node->name ()->copy ()); - op->set_defined_in (node->defined_in ()); - op->add_argument_to_scope (arg); + // Create the set method. + Identifier id ("void"); + UTL_ScopedName sn (&id, + 0); + + // The return type is "void". + be_predefined_type rt (AST_PredefinedType::PT_void, + &sn); + // Argument type is the same as the attribute type. + be_argument arg (AST_Argument::dir_IN, + node->field_type (), + node->name ()); + arg.set_name ((UTL_IdList *) node->name ()->copy ()); + // Create the operation. + be_operation set_op (&rt, + AST_Operation::OP_noflags, + node->name (), + node->is_local (), + node->is_abstract ()); + set_op.set_name ((UTL_IdList *) node->name ()->copy ()); + set_op.set_defined_in (node->defined_in ()); + set_op.be_add_argument (&arg); // Get the strategy from the attribute and hand it over // to the operation, thereby deleting the old one. - delete op->set_strategy (node->get_set_strategy ()); + delete set_op.set_strategy (node->get_set_strategy ()); ctx = *this->ctx_; - // this switch statement eliminates the need for different classes that have - // exactly the same code except different states. + status = 1; + switch (this->ctx_->state ()) { + // These two cases are the only ones that could involved a strategy. case TAO_CodeGen::TAO_ATTRIBUTE_CH: ctx.state (TAO_CodeGen::TAO_OPERATION_CH); break; @@ -240,60 +308,119 @@ be_visitor_attribute::visit_attribute (be_attribute *node) ctx.state (TAO_CodeGen::TAO_OPERATION_CS); break; case TAO_CodeGen::TAO_ATTRIBUTE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SH); + be_visitor_operation_sh visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_IH: - ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_IH); + be_visitor_operation_ih visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SS); + be_visitor_operation_ss visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_IS: - ctx.state (TAO_CodeGen::TAO_OPERATION_IS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_IS); + be_visitor_operation_is visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_BASE_PROXY_IMPL_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); + be_visitor_operation_base_proxy_impl_ch visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_PROXY_IMPL_XH: - ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); + be_visitor_operation_proxy_impl_xh visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_REMOTE_PROXY_IMPL_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); + be_visitor_operation_remote_proxy_impl_cs visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_THRU_POA_PROXY_IMPL_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS); + be_visitor_operation_thru_poa_proxy_impl_ss visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_DIRECT_PROXY_IMPL_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SI); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS); + be_visitor_operation_direct_proxy_impl_ss visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CH); + be_visitor_operation_smart_proxy_ch visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS); + be_visitor_operation_smart_proxy_cs visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); + be_visitor_operation_interceptors_cs visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SH); + be_visitor_operation_interceptors_sh visitor (&ctx); + status = set_op.accept (&visitor); + break; + } case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); + be_visitor_operation_interceptors_ss visitor (&ctx); + status = set_op.accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SH: + { + ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SH); + be_visitor_operation_tie_sh visitor (&ctx); + status = set_op.accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI: + { + ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SI); + be_visitor_operation_tie_si visitor (&ctx); + status = set_op.accept (&visitor); + break; + } default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -301,51 +428,56 @@ be_visitor_attribute::visit_attribute (be_attribute *node) -1); } + if (status == 0) + { + return 0; + } + else if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_attribute::" + "visit_attribute - " + "codegen for get_attribute failed\n"), + -1); + } // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state ())); + ctx.state (set_op.next_state (ctx.state ())); + be_visitor *visitor = tao_cg->make_visitor (&ctx); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + if (!visitor || (set_op.accept (visitor) == -1)) { delete visitor; - 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 visitor; visitor = 0; - if (op->has_extra_code_generation (ctx.state ())) + if (set_op.has_extra_code_generation (ctx.state ())) { // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state (), 1)); + ctx.state (set_op.next_state (ctx.state (), 1)); visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + + if (!visitor || (set_op.accept (visitor) == -1)) { delete visitor; - 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 visitor; visitor = 0; } - - delete op; - delete rt; - delete arg; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_component.cpp b/TAO/TAO_IDL/be/be_visitor_component.cpp new file mode 100644 index 00000000000..baa86583374 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_component.cpp @@ -0,0 +1,27 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_visitor_component.cpp +// +// = DESCRIPTION +// Visitors for generation of code for Component +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_visitor_component.h" +#include "be_visitor_context.h" + +ACE_RCSID (be, + be_visitor_component, + "$Id$") + diff --git a/TAO/TAO_IDL/be/be_visitor_component_fwd.cpp b/TAO/TAO_IDL/be/be_visitor_component_fwd.cpp new file mode 100644 index 00000000000..97746d88aa2 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_component_fwd.cpp @@ -0,0 +1,27 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_visitor_component_fwd.cpp +// +// = DESCRIPTION +// Visitors for generation of code for forward declared Component +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_visitor_component_fwd.h" +#include "be_visitor_context.h" + +ACE_RCSID (be, + be_visitor_component_fwd, + "$Id$") + diff --git a/TAO/TAO_IDL/be/be_visitor_constant.cpp b/TAO/TAO_IDL/be/be_visitor_constant.cpp index 0281cbccf4d..9144be5d367 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant.cpp +++ b/TAO/TAO_IDL/be/be_visitor_constant.cpp @@ -18,15 +18,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_constant.h" +#include "be_module.h" +#include "be_helper.h" +#include "be_extern.h" +#include "utl_identifier.h" #include "be_visitor_constant.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_constant/constant_ch.cpp" #include "be_visitor_constant/constant_cs.cpp" -ACE_RCSID(be, be_visitor_constant, "$Id$") +ACE_RCSID (be, + be_visitor_constant, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp index 89879fdbb8c..a0a8c24240e 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_constant.h" - -ACE_RCSID(be_visitor_constant, constant_ch, "$Id$") +ACE_RCSID (be_visitor_constant, + constant_ch, + "$Id$") // ******************************************************************** @@ -45,18 +41,42 @@ be_visitor_constant_ch::~be_visitor_constant_ch (void) int be_visitor_constant_ch::visit_constant (be_constant *node) { + if (node->cli_hdr_gen () || node->imported ()) + { + return 0; + } + TAO_OutStream *os = this->ctx_->stream (); - if (!node->cli_hdr_gen () && !node->imported ()) + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // If we are defined in the outermost scope, then the value is assigned + // to us here itself, else it will be in the *.cpp file. + + if (be_global->gen_inline_constants ()) + { + if (node->et () == AST_Expression::EV_enum) + { + *os << node->enum_full_name (); + } + else + { + *os << node->exprtype_to_string (); + } + + *os << " const " + << node->local_name () << " = " + << node->constant_value (); + } + // Is our enclosing scope a module? We need this check because for + // platforms that support namespaces, the constant must be declared + // extern. + else { - // If we are defined in the outermost scope, then the value is assigned - // to us here itself, else it will be in the *.cpp file. - - // Is our enclosing scope a module? We need this check because for - // platforms that support namespaces, the typecode must be declared - // extern. - if (node->is_nested () && - (node->defined_in ()->scope_node_type () == AST_Decl::NT_module)) + AST_Decl::NodeType nt = node->defined_in ()->scope_node_type (); + + if (node->is_nested () && nt == AST_Decl::NT_module) { *os << "TAO_NAMESPACE_STORAGE_CLASS "; } @@ -65,20 +85,29 @@ be_visitor_constant_ch::visit_constant (be_constant *node) *os << "static "; } - *os << "const " << node->exprtype_to_string () - << " " << node->local_name (); + *os << "const "; - if (!node->is_nested ()) + if (node->et () == AST_Expression::EV_enum) { - // We were defined at the outermost scope. So we put the value in the - // header itself. - *os << " = " << node->constant_value (); + *os << node->enum_full_name (); + } + else + { + *os << node->exprtype_to_string (); } - *os << ";" << be_nl << be_nl; + *os << " " << node->local_name (); - node->cli_hdr_gen (I_TRUE); + if (!node->is_nested ()) + { + // We were defined at the outermost scope. So we put the value + // in the header itself. + *os << " = " << node->constant_value (); + } } + *os << ";" << be_nl << be_nl; + + node->cli_hdr_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp index 90f67a8af36..db20c61b3c8 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_constant.h" - -ACE_RCSID(be_visitor_constant, constant_cs, "$Id$") +ACE_RCSID (be_visitor_constant, + constant_cs, + "$Id$") // ******************************************************************** @@ -47,7 +43,9 @@ be_visitor_constant_cs::visit_constant (be_constant *node) { TAO_OutStream *os = this->ctx_->stream (); - if (!node->cli_stub_gen () && !node->imported ()) + if (!node->cli_stub_gen () + && !node->imported () + && !be_global->gen_inline_constants ()) { if (node->is_nested ()) { @@ -55,32 +53,59 @@ be_visitor_constant_cs::visit_constant (be_constant *node) { *os << "TAO_NAMESPACE_TYPE (const " << node->exprtype_to_string () << ")" << be_nl; - be_module *module = be_module::narrow_from_scope (node->defined_in ()); - if (!module || (this->gen_nested_namespace_begin (module) == -1)) + be_module *module = + be_module::narrow_from_scope (node->defined_in ()); + + if (!module || this->gen_nested_namespace_begin (module) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_constant_cs::visit_constant - " + "be_visitor_constant_cs::" + "visit_constant - " "Error parsing nested name\n"), -1); } - *os << "TAO_NAMESPACE_DEFINE (const " - << node->exprtype_to_string () << ", " - << node->local_name () << ", " + + *os << "TAO_NAMESPACE_DEFINE (const "; + + if (node->et () == AST_Expression::EV_enum) + { + *os << node->enum_full_name (); + } + else + { + *os << node->exprtype_to_string (); + } + + *os << ", " << node->local_name () << ", " << node->constant_value () << ")" << be_nl; + if (this->gen_nested_namespace_end (module) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_constant_cs::visit_constant - " + "be_visitor_constant_cs::" + "visit_constant - " "Error parsing nested name\n"), -1); } } else { - // for those constants not defined in the outer most scope, they get - // assigned to their values in the impl file - os->indent (); // start from whatever indentation level we were at - *os << "const " << node->exprtype_to_string () << " " + // For those constants not defined in the outer most scope, + // they get assigned to their values in the impl file. + os->indent (); + + *os << "const "; + + if (node->et () == AST_Expression::EV_enum) + { + *os << node->enum_full_name (); + } + else + { + *os << node->exprtype_to_string (); + } + + *os << " " << node->name () << " = " << node->constant_value () << ";\n\n"; } diff --git a/TAO/TAO_IDL/be/be_visitor_context.cpp b/TAO/TAO_IDL/be/be_visitor_context.cpp index 8102f332f78..42b0791edc4 100644 --- a/TAO/TAO_IDL/be/be_visitor_context.cpp +++ b/TAO/TAO_IDL/be/be_visitor_context.cpp @@ -18,11 +18,32 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_visitor_context, "$Id$") +#include "be_argument.h" +#include "be_array.h" +#include "be_attribute.h" +#include "be_constant.h" +#include "be_enum.h" +#include "be_enum_val.h" +#include "be_exception.h" +#include "be_field.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_module.h" +#include "be_operation.h" +#include "be_predefined_type.h" +#include "be_root.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_union_branch.h" + +#include "be_visitor_context.h" + +ACE_RCSID (be, + be_visitor_context, + "$Id$") // constructor @@ -231,284 +252,368 @@ be_visitor_context::interface (void) const // **************************************************************** -// return the node as argument if possible be_argument * be_visitor_context::be_node_as_argument (void) { - if (this->node_) - return be_argument::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_argument::narrow_from_decl (this->node_); + } else - return (be_argument *)0; + { + return 0; + } } -// return the node as array if possible be_array * be_visitor_context::be_node_as_array (void) { - if (this->node_) - return be_array::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_array::narrow_from_decl (this->node_); + } else - return (be_array *)0; + { + return 0; + } } -// return the node as attribute if possible be_attribute * be_visitor_context::be_node_as_attribute (void) { - if (this->node_) - return be_attribute::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_attribute::narrow_from_decl (this->node_); + } else - return (be_attribute *)0; + { + return 0; + } } -// return the node as constant if possible be_constant * be_visitor_context::be_node_as_constant (void) { - if (this->node_) - return be_constant::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_constant::narrow_from_decl (this->node_); + } else - return (be_constant *)0; + { + return 0; + } } -// return the node as enum if possible be_enum * be_visitor_context::be_node_as_enum (void) { - if (this->node_) - return be_enum::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_enum::narrow_from_decl (this->node_); + } else - return (be_enum *)0; + { + return 0; + } } -// return the node as enum_val if possible be_enum_val * be_visitor_context::be_node_as_enum_val (void) { - if (this->node_) - return be_enum_val::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_enum_val::narrow_from_decl (this->node_); + } else + { + return 0; + } return (be_enum_val *)0; } -// return the node as exception if possible be_exception * be_visitor_context::be_node_as_exception (void) { - if (this->node_) - return be_exception::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_exception::narrow_from_decl (this->node_); + } else - return (be_exception *)0; + { + return 0; + } } -// return the node as field if possible be_field * be_visitor_context::be_node_as_field (void) { - if (this->node_) - return be_field::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_field::narrow_from_decl (this->node_); + } else - return (be_field *)0; + { + return 0; + } } -// return the node as interface if possible be_interface * be_visitor_context::be_node_as_interface (void) { - if (this->node_) - return be_interface::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_interface::narrow_from_decl (this->node_); + } else - return (be_interface *)0; + { + return 0; + } } -// return the node as interface_fwd if possible be_interface_fwd * be_visitor_context::be_node_as_interface_fwd (void) { - if (this->node_) - return be_interface_fwd::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_interface_fwd::narrow_from_decl (this->node_); + } else - return (be_interface_fwd *)0; + { + return 0; + } } -// return the node as module if possible be_module * be_visitor_context::be_node_as_module (void) { - if (this->node_) - return be_module::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_module::narrow_from_decl (this->node_); + } else - return (be_module *)0; + { + return 0; + } } -// return the node as operation if possible be_operation * be_visitor_context::be_node_as_operation (void) { - if (this->node_) - return be_operation::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_operation::narrow_from_decl (this->node_); + } else - return (be_operation *)0; + { + return 0; + } } -// return the node as predefined_type if possible be_predefined_type * be_visitor_context::be_node_as_predefined_type (void) { - if (this->node_) - return be_predefined_type::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_predefined_type::narrow_from_decl (this->node_); + } else - return (be_predefined_type *)0; + { + return 0; + } } -// return the node as root if possible be_root * be_visitor_context::be_node_as_root (void) { - if (this->node_) - return be_root::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_root::narrow_from_decl (this->node_); + } else - return (be_root *)0; + { + return 0; + } } -// return the node as sequence if possible be_sequence * be_visitor_context::be_node_as_sequence (void) { - if (this->node_) - return be_sequence::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_sequence::narrow_from_decl (this->node_); + } else - return (be_sequence *)0; + { + return 0; + } } -// return the node as string if possible be_string * be_visitor_context::be_node_as_string (void) { - if (this->node_) - return be_string::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_string::narrow_from_decl (this->node_); + } else - return (be_string *)0; + { + return 0; + } } -// return the node as structure if possible be_structure * be_visitor_context::be_node_as_structure (void) { - if (this->node_) - return be_structure::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_structure::narrow_from_decl (this->node_); + } else - return (be_structure *)0; + { + return 0; + } } -// return the node as typedef if possible be_typedef * be_visitor_context::be_node_as_typedef (void) { - if (this->node_) - return be_typedef::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_typedef::narrow_from_decl (this->node_); + } else - return (be_typedef *)0; + { + return 0; + } } -// return the node as union if possible be_union * be_visitor_context::be_node_as_union (void) { - if (this->node_) - return be_union::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_union::narrow_from_decl (this->node_); + } else - return (be_union *)0; + { + return 0; + } } -// return the node as union_branch if possible be_union_branch * be_visitor_context::be_node_as_union_branch (void) { - if (this->node_) - return be_union_branch::narrow_from_decl (this->node_); + if (this->node_ != 0) + { + return be_union_branch::narrow_from_decl (this->node_); + } else - return (be_union_branch *)0; + { + return 0; + } } -// for scope - -// return the scope as enum if possible be_enum * be_visitor_context::be_scope_as_enum (void) { - if (this->scope_) - return be_enum::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_enum::narrow_from_decl (this->scope_); + } else - return (be_enum *)0; + { + return 0; + } } -// return the scope as exception if possible be_exception * be_visitor_context::be_scope_as_exception (void) { - if (this->scope_) - return be_exception::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_exception::narrow_from_decl (this->scope_); + } else - return (be_exception *)0; + { + return 0; + } } -// return the scope as interface if possible be_interface * be_visitor_context::be_scope_as_interface (void) { - if (this->scope_) - return be_interface::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_interface::narrow_from_decl (this->scope_); + } else + { + return 0; + } return (be_interface *)0; } -// return the scope as module if possible be_module * be_visitor_context::be_scope_as_module (void) { - if (this->scope_) - return be_module::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_module::narrow_from_decl (this->scope_); + } else - return (be_module *)0; + { + return 0; + } } -// return the scope as operation if possible be_operation * be_visitor_context::be_scope_as_operation (void) { - if (this->scope_) - return be_operation::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_operation::narrow_from_decl (this->scope_); + } else - return (be_operation *)0; + { + return 0; + } } -// return the scope as root if possible be_root * be_visitor_context::be_scope_as_root (void) { - if (this->scope_) - return be_root::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_root::narrow_from_decl (this->scope_); + } else - return (be_root *)0; + { + return 0; + } } -// return the scope as structure if possible be_structure * be_visitor_context::be_scope_as_structure (void) { - if (this->scope_) - return be_structure::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_structure::narrow_from_decl (this->scope_); + } else - return (be_structure *)0; + { + return 0; + } } -// return the scope as union if possible be_union * be_visitor_context::be_scope_as_union (void) { - if (this->scope_) - return be_union::narrow_from_decl (this->scope_); + if (this->scope_ != 0) + { + return be_union::narrow_from_decl (this->scope_); + } else - return (be_union *)0; + { + return 0; + } } diff --git a/TAO/TAO_IDL/be/be_visitor_decl.cpp b/TAO/TAO_IDL/be/be_visitor_decl.cpp index d2c25510d90..5fc92908f1b 100644 --- a/TAO/TAO_IDL/be/be_visitor_decl.cpp +++ b/TAO/TAO_IDL/be/be_visitor_decl.cpp @@ -19,13 +19,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - #include "be_visitor_decl.h" +#include "be_visitor_sequence.h" +#include "be_visitor_context.h" +#include "be_typedef.h" +#include "be_type.h" -ACE_RCSID(be, be_visitor_decl, "$Id$") +ACE_RCSID (be, + be_visitor_decl, + "$Id$") // Root visitor for client header @@ -52,28 +54,51 @@ be_visitor_decl::gen_anonymous_base_type (be_type *bt, // In case our container was typedef'd. ctx.tdef (0); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { + int status = 0; + + switch (cg_state) + { + case TAO_CodeGen::TAO_SEQUENCE_CH: + { + be_visitor_sequence_ch visitor (&ctx); + status = bt->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_SEQUENCE_CI: + { + be_visitor_sequence_ci visitor (&ctx); + status = bt->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_SEQUENCE_CS: + { + be_visitor_sequence_cs visitor (&ctx); + status = bt->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS: + { + be_visitor_sequence_cdr_op_cs visitor (&ctx); + status = bt->accept (&visitor); + break; + } + default: ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_decl::" "gen_anonymous_base_type - " - "bad visitor to anonymous abase type\n"), + "bad context state\n"), -1); - } + } - if (bt->accept (visitor) == -1) + if (status == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_decl::" "gen_anonymous_base_type - " "anonymous base type codegen failed\n"), -1); } - - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_enum.cpp b/TAO/TAO_IDL/be/be_visitor_enum.cpp index aaef1a06f60..152bd0f7d54 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum.cpp @@ -18,13 +18,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_enum.h" +#include "be_enum_val.h" +#include "be_helper.h" +#include "be_extern.h" #include "be_visitor_enum.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_enum/enum_ch.cpp" #include "be_visitor_enum/enum_cs.cpp" #include "be_visitor_enum/any_op_ch.cpp" @@ -32,4 +33,6 @@ #include "be_visitor_enum/cdr_op_ch.cpp" #include "be_visitor_enum/cdr_op_ci.cpp" -ACE_RCSID(be, be_visitor_enum, "$Id$") +ACE_RCSID (be, + be_visitor_enum, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_enum/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_enum/any_op_ch.cpp index a81ec6f40c5..39c00c5a786 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/any_op_ch.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_enum, + any_op_ch, + "$Id$") // *************************************************************************** // Enum visitor for generating Any operator declarations in the client header @@ -51,14 +47,16 @@ be_visitor_enum_any_op_ch::visit_enum (be_enum *node) TAO_OutStream *os = this->ctx_->stream (); - // generate the Any <<= and >>= operators - os->indent (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Generate the Any <<= and >>= operators. *os << be_global->stub_export_macro () << " void" << " operator<<= (CORBA::Any &, " << node->name () << ");" << be_nl; *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator>>= (const CORBA::Any &, " - << node->name () << " &);\n"; + << node->name () << " &);" << be_nl << be_nl; node->cli_hdr_any_op_gen (1); return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp index f49d76d9de4..334c8cccd83 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_enum, + any_op_cs, + "$Id$") // *************************************************************************** // Enum visitor for generating Any operator declarations in the client @@ -52,8 +48,8 @@ be_visitor_enum_any_op_cs::visit_enum (be_enum *node) TAO_OutStream *os = this->ctx_->stream (); - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators + // Generate the Any <<= and >>= operator declarations + // Any <<= and >>= operators. os->indent (); *os << "void operator<<= (CORBA::Any &_tao_any, " << node->name () << " _tao_elem)" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ch.cpp index c0c2e045d92..a0161e9cb06 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ch.cpp @@ -18,22 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_enum, + cdr_op_ch, + "$Id$") // *************************************************************************** // Enum visitor for generating Cdr operator declarations in the client header // *************************************************************************** -be_visitor_enum_cdr_op_ch::be_visitor_enum_cdr_op_ch -(be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_enum_cdr_op_ch::be_visitor_enum_cdr_op_ch (be_visitor_context *ctx) + : be_visitor_decl (ctx) { } @@ -45,7 +40,9 @@ int be_visitor_enum_cdr_op_ch::visit_enum (be_enum *node) { if (node->cli_hdr_cdr_op_gen () || node->imported ()) - return 0; + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); @@ -54,7 +51,7 @@ be_visitor_enum_cdr_op_ch::visit_enum (be_enum *node) os->indent (); *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator<< (TAO_OutputCDR &, const " << node->name () - << " &); // " << be_nl; + << " &);" << be_nl; *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator>> (TAO_InputCDR &, " << node->name () << " &);\n"; diff --git a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ci.cpp index e8c9f0c5bc8..cab73d5328c 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ci.cpp @@ -18,12 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_enum, + cdr_op_ci, + "$Id$") // *************************************************************************** @@ -32,7 +29,7 @@ ACE_RCSID(be_visitor_enum, cdr_op_ci, "$Id$") // *************************************************************************** be_visitor_enum_cdr_op_ci::be_visitor_enum_cdr_op_ci (be_visitor_context *ctx) - : be_visitor_scope (ctx) + : be_visitor_decl (ctx) { } diff --git a/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp b/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp index e6c6bd01342..61cae521526 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp @@ -18,13 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_visitor_typecode/typecode_decl.h" -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, enum_ch, "$Id$") +ACE_RCSID (be_visitor_enum, + enum_ch, + "$Id$") // ******************************************************************** @@ -45,56 +43,60 @@ be_visitor_enum_ch::~be_visitor_enum_ch (void) int be_visitor_enum_ch::visit_enum (be_enum *node) { + if (node->cli_hdr_gen () || node->imported ()) + { + return 0; + } + TAO_OutStream *os = this->ctx_->stream (); // Comma to be generated by the scope visitor. this->ctx_->comma (1); - if (!node->cli_hdr_gen () && !node->imported ()) + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "enum " << node->local_name () << be_nl; + *os << "{" << be_idt_nl; + + if (this->visit_scope (node) == 1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_enum_ch::" + "visit_enum - " + "scope generation failed\n" + ), + -1); + } + + *os << be_uidt_nl; + *os << "};" << be_nl << be_nl; + + // As per the ORBOS spec, we need the following typedef + *os << "typedef " << node->local_name () << " &" << node->local_name () + << "_out;" << be_nl << be_nl; + + if (!node->is_local ()) { - *os << "enum " << node->local_name () << be_nl; - *os << "{" << be_idt_nl; - - if (this->visit_scope (node) == 1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_enum_ch::" - "visit_enum - " - "scope generation failed\n" - ), - -1); - } - - *os << be_uidt_nl; - *os << "};" << be_nl << be_nl; - - // As per the ORBOS spec, we need the following typedef - *os << "typedef " << node->local_name () << " &" << node->local_name () - << "_out;" << be_nl; - - if (!node->is_local ()) + // 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_typecode_decl visitor (&ctx); + + if (node->accept (&visitor) == -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. - 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_enum_ch::" - "visit_enum - " - "TypeCode declaration failed\n" - ), - -1); - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_enum_ch::" + "visit_enum - " + "TypeCode declaration failed\n" + ), + -1); } - - node->cli_hdr_gen (I_TRUE); } + node->cli_hdr_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp b/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp index e846ec8b439..72ef3b80356 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp @@ -18,13 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_visitor_typecode/typecode_defn.h" -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, enum_cs, "$Id$") +ACE_RCSID (be_visitor_enum, + enum_cs, + "$Id$") // ******************************************************************** @@ -47,24 +45,22 @@ be_visitor_enum_cs::visit_enum (be_enum *node) { if (!node->cli_stub_gen () && !node->imported () && !node->is_local ()) { - // 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 *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_typecode_defn visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_enum_cs::" "visit_enum - " - "TypeCode definition failed\n" - ), -1); + "TypeCode definition failed\n"), + -1); } node->cli_stub_gen (I_TRUE); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception.cpp b/TAO/TAO_IDL/be/be_visitor_exception.cpp index 953fae623d1..872abd3895f 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception.cpp @@ -18,13 +18,27 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_field.h" +#include "be_exception.h" +#include "be_typedef.h" +#include "be_enum.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_array.h" +#include "be_predefined_type.h" +#include "be_string.h" +#include "be_sequence.h" +#include "be_structure.h" +#include "be_union.h" +#include "be_helper.h" +#include "be_extern.h" #include "be_visitor_exception.h" +#include "be_visitor_context.h" +#include "be_visitor_field.h" -// include all the individual files #include "be_visitor_exception/exception.cpp" #include "be_visitor_exception/exception_ch.cpp" #include "be_visitor_exception/exception_ci.cpp" @@ -37,4 +51,6 @@ #include "be_visitor_exception/cdr_op_ci.cpp" #include "be_visitor_exception/cdr_op_cs.cpp" -ACE_RCSID(be, be_visitor_exception, "$Id$") +ACE_RCSID (be, + be_visitor_exception, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_exception/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_exception/any_op_ch.cpp index 996f9714687..4a1c5f1b35a 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/any_op_ch.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_exception, + any_op_ch, + "$Id$") // *************************************************************************** // Exception visitor for generating Any operator declarations in the client header diff --git a/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp index e5289aa8d14..d53cb630aa0 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_exception, + any_op_cs, + "$Id$") // *************************************************************************** // Exception visitor for generating Any operator declarations in the client @@ -53,8 +49,6 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - *os << be_nl << "// TAO_IDL - Generated from " << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ch.cpp index 342fcc6a103..4fb5a4f291f 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ch.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_exception, + cdr_op_ch, + "$Id$") // *************************************************************************** // Exception visitor for generating CDR operator declarations in the client header // *************************************************************************** -be_visitor_exception_cdr_op_ch::be_visitor_exception_cdr_op_ch -(be_visitor_context *ctx) +be_visitor_exception_cdr_op_ch::be_visitor_exception_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_exception (ctx) { } @@ -44,15 +41,16 @@ be_visitor_exception_cdr_op_ch::~be_visitor_exception_cdr_op_ch (void) int be_visitor_exception_cdr_op_ch::visit_exception (be_exception *node) { - if (node->cli_hdr_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_hdr_cdr_op_gen () || node->imported () || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); - // generate the CDR << and >> operator declarations + // Generate the CDR << and >> operator declarations. os->indent (); + *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator<< (TAO_OutputCDR &, const " << node->name () << " &);" << be_nl; @@ -61,15 +59,16 @@ be_visitor_exception_cdr_op_ch::visit_exception (be_exception *node) << node->name () << " &);\n"; - // set the substate as generating code for the types defined in our scope + // 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_exception_cdr_op_ch::" "visit_exception - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } *os << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp index d658c19371c..0d7b253b307 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_exception, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_exception, + cdr_op_ci, + "$Id$") // *************************************************************************** // Exception visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_exception_cdr_op_ci::be_visitor_exception_cdr_op_ci -(be_visitor_context *ctx) +be_visitor_exception_cdr_op_ci::be_visitor_exception_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_exception (ctx) { } @@ -46,8 +42,8 @@ int be_visitor_exception_cdr_op_ci::visit_exception (be_exception *node) { // already generated and/or we are imported. Don't do anything. - if (node->cli_inline_cdr_op_gen () - || node->imported () + if (node->cli_inline_cdr_op_gen () + || node->imported () || node->is_local ()) { return 0; @@ -62,7 +58,6 @@ be_visitor_exception_cdr_op_ci::visit_exception (be_exception *node) // 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, @@ -74,67 +69,86 @@ be_visitor_exception_cdr_op_ci::visit_exception (be_exception *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 " << node->name () << " &_tao_aggregate)" << be_nl + + *os << "ACE_INLINE" << be_nl + << "CORBA::Boolean operator<< (" << be_idt << be_idt_nl + << "TAO_OutputCDR &strm," << be_nl + << "const " << node->name () << " &_tao_aggregate" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; // Do we have any members? if (node->nmembers () > 0) { - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_cdr_op_field_decl field_decl (new_ctx); + be_visitor_context new_ctx (*this->ctx_); + be_visitor_cdr_op_field_decl field_decl (&new_ctx); field_decl.visit_scope (node); // some members - *os << "// first marshal the repository ID" << be_nl - << "if (strm << _tao_aggregate._rep_id ())" << be_nl + *os << "// First marshal the repository ID." << be_nl + << "if (strm << _tao_aggregate._rep_id ())" << be_idt_nl << "{" << be_idt_nl - << "// now marshal the members (if any)" << be_nl + << "// Now marshal the members (if any)." << be_nl << "if (" << be_idt_nl; - // 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_exception_cdr_op_ci::" "visit_exception - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - *os << be_uidt_nl << ")" + + *os << be_uidt_nl << " )" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl - << "}" << be_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl; } else { - // no members - *os << "// first marshal the repository ID" << be_nl + // No members. + *os << "// First marshal the repository ID." << be_nl << "if (strm << _tao_aggregate._rep_id ())" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl; } - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; - // set the substate as generating code for the input operator + // Set the substate as generating code for the input operator. this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - *os << "ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &"; + + *os << "ACE_INLINE" << be_nl + << "CORBA::Boolean operator>> (" << be_idt << be_idt_nl + << "TAO_InputCDR &"; if (node->nmembers () > 0) { - *os << "strm," - << node->name () << " &_tao_aggregate)" << be_nl; + *os << "strm," << be_nl + << node->name () << " &_tao_aggregate" << be_uidt_nl + << ")" << be_uidt_nl; } else { - *os << "," - << node->name () << "&)" << be_nl; + *os << "," << be_nl + << node->name () << "&" << be_uidt_nl + << ")" << be_uidt_nl; } *os << "{" << be_idt_nl; @@ -145,19 +159,17 @@ be_visitor_exception_cdr_op_ci::visit_exception (be_exception *node) // caller, and they invoke this method only to demarshal the // members. While the marshaling method encodes both... - // do we have any members? + // Do we have any members? if (node->nmembers () > 0) { - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_cdr_op_field_decl field_decl (new_ctx); + be_visitor_context new_ctx (*this->ctx_); + be_visitor_cdr_op_field_decl field_decl (&new_ctx); field_decl.visit_scope (node); - // some members - *os << "// now marshal the members" << be_nl + // Some members. + *os << "// Demarshal the members." << be_nl << "if (" << be_idt_nl; - // all we have to do is to visit the scope and generate code if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -169,16 +181,20 @@ be_visitor_exception_cdr_op_ci::visit_exception (be_exception *node) *os << be_uidt_nl << ")" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl; } else { *os << "return 1;" << be_uidt_nl; } - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; node->cli_inline_cdr_op_gen (1); return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_cs.cpp index fe2f0d85230..117cb7a9dc5 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_cs.cpp @@ -18,16 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_exception, + cdr_op_cs, + "$Id$") -#include "be_visitor_exception.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_exception, cdr_op_cs, "$Id$") - -be_visitor_exception_cdr_op_cs::be_visitor_exception_cdr_op_cs (be_visitor_context *ctx) +be_visitor_exception_cdr_op_cs::be_visitor_exception_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_exception (ctx) { } @@ -39,24 +36,24 @@ be_visitor_exception_cdr_op_cs::~be_visitor_exception_cdr_op_cs (void) int be_visitor_exception_cdr_op_cs::visit_exception (be_exception *node) { - if (node->cli_stub_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_stub_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } - // 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_exception_cdr_op_cs::" "visit_exception - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - node->cli_stub_cdr_op_gen (1); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp b/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp index 78725dac850..314fdec7bbe 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp @@ -19,13 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, ctor_assign, "$Id$") - +ACE_RCSID (be_visitor_exception, + ctor_assign, + "$Id$") // ************************************************************************ // Used for the body of the assignment operator and the copy constructor. @@ -99,7 +95,7 @@ be_visitor_exception_ctor_assign::visit_array (be_array *node) TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (ACE_OS::strcmp (bd->flat_name (), node->flat_name ()) != 0) { @@ -116,13 +112,13 @@ be_visitor_exception_ctor_assign::visit_array (be_array *node) { // Constructor from member args. *os << "_copy (this->" << bd->local_name () - << ", _tao_" << bd->local_name () << ");\n"; + << ", _tao_" << bd->local_name () << ");"; } else { // Copy constructor and assignment operator. *os << "_copy (this->" << bd->local_name () - << ", _tao_excp." << bd->local_name () << ");\n"; + << ", _tao_excp." << bd->local_name () << ");"; } return 0; @@ -134,17 +130,17 @@ be_visitor_exception_ctor_assign::visit_enum (be_enum *) TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = _tao_" - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } else { *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } return 0; @@ -156,17 +152,17 @@ be_visitor_exception_ctor_assign::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_" << bd->local_name () << ");\n"; + << "::_duplicate (_tao_" << bd->local_name () << ");"; } else { *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_excp." << bd->local_name () << ".in ());\n"; + << "::_duplicate (_tao_excp." << bd->local_name () << ".in ());"; } return 0; @@ -179,18 +175,87 @@ int be_visitor_exception_ctor_assign::visit_interface_fwd ( TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_" << bd->local_name () << ");\n"; + << "::_duplicate (_tao_" << bd->local_name () << ");"; } else { *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_excp." << bd->local_name () << ".in ());\n"; + << "::_duplicate (_tao_excp." << bd->local_name () << ".in ());"; + } + return 0; +} + +int +be_visitor_exception_ctor_assign::visit_valuetype (be_valuetype *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_decl *bd = this->ctx_->node (); + + *os << be_nl; + + if (this->ctx_->exception ()) // Special constructor. + { + *os << "CORBA::add_ref (" << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->name () << " *," << be_nl + << "_tao_" << bd->local_name () << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt_nl; + *os << "this->" << bd->local_name () << " = _tao_" + << bd->local_name () << ";"; + } + else + { + *os << "CORBA::add_ref (" << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->name () << " *," << be_nl + << "_tao_excp." << bd->local_name () << ".in ()" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt_nl; + *os << "this->" << bd->local_name () << " = _tao_excp." + << bd->local_name () << ".in ();"; } + + return 0; +} + +int be_visitor_exception_ctor_assign::visit_valuetype_fwd ( + be_valuetype_fwd *node + ) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_decl *bd = this->ctx_->node (); + + *os << be_nl; + + if (this->ctx_->exception ()) // Special constructor. + { + *os << "CORBA::add_ref (" << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->name () << " *," << be_nl + << "_tao_" << bd->local_name () << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt_nl; + *os << "this->" << bd->local_name () << " = _tao_" + << bd->local_name () << ";"; + } + else + { + *os << "CORBA::add_ref (" << be_idt << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->name () << " *," << be_nl + << "_tao_excp." << bd->local_name () << ".in ()" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt_nl; + *os << "this->" << bd->local_name () << " = _tao_excp." + << bd->local_name () << ".in ();"; + } + return 0; } @@ -200,36 +265,38 @@ int be_visitor_exception_ctor_assign::visit_predefined_type ( { TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); + AST_PredefinedType::PredefinedType pt = node->pt (); - os->indent (); + *os << be_nl; // Check if the type is an any. - if (node->pt () == AST_PredefinedType::PT_any) + if (pt == AST_PredefinedType::PT_any) { if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = _tao_" - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } else { *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } } - else if (node->pt () == AST_PredefinedType::PT_pseudo) + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = " << node->name () << "::_duplicate (_tao_" - << bd->local_name () << ");\n"; + << bd->local_name () << ");"; } else { *os << "this->" << bd->local_name () << " = " << node->name () << "::_duplicate (_tao_excp." - << bd->local_name () << ".in ());\n"; + << bd->local_name () << ".in ());"; } } else // Simple predefined types. @@ -237,12 +304,12 @@ int be_visitor_exception_ctor_assign::visit_predefined_type ( if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = _tao_" - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } else { *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } } @@ -254,17 +321,17 @@ int be_visitor_exception_ctor_assign::visit_sequence (be_sequence *) TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; + << ";"; } else { *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } return 0; @@ -275,7 +342,7 @@ int be_visitor_exception_ctor_assign::visit_string (be_string *node) TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (this->ctx_->exception ()) // Special constructor. { @@ -283,13 +350,13 @@ int be_visitor_exception_ctor_assign::visit_string (be_string *node) { *os << "this->" << bd->local_name () << " = CORBA::string_dup (_tao_" - << bd->local_name () << ");\n"; + << bd->local_name () << ");"; } else { *os << "this->" << bd->local_name () << " = CORBA::wstring_dup (_tao_" - << bd->local_name () << ");\n"; + << bd->local_name () << ");"; } } else @@ -298,13 +365,13 @@ int be_visitor_exception_ctor_assign::visit_string (be_string *node) { *os << "this->" << bd->local_name () << " = CORBA::string_dup (_tao_excp." - << bd->local_name () << ".in ());\n"; + << bd->local_name () << ".in ());"; } else { *os << "this->" << bd->local_name () << " = CORBA::wstring_dup (_tao_excp." - << bd->local_name () << ".in ());\n"; + << bd->local_name () << ".in ());"; } } @@ -316,17 +383,17 @@ int be_visitor_exception_ctor_assign::visit_structure (be_structure *) TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; + << ";"; } else { *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } return 0; @@ -337,17 +404,17 @@ int be_visitor_exception_ctor_assign::visit_union (be_union *) TAO_OutStream *os = this->ctx_->stream (); be_decl *bd = this->ctx_->node (); - os->indent (); + *os << be_nl; if (this->ctx_->exception ()) // Special constructor. { *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; + << ";"; } else { *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; + << bd->local_name () << ";"; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp index 71f9590bb4b..47d295c7a0f 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp @@ -18,16 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_exception, + exception, + "$Id$") -#include "be_visitor_exception.h" -ACE_RCSID(be_visitor_exception, exception, "$Id$") - - -// generic struct visitor +// Generic exception visitor. be_visitor_exception::be_visitor_exception (be_visitor_context *ctx) : be_visitor_scope (ctx) { @@ -37,74 +33,88 @@ be_visitor_exception::~be_visitor_exception (void) { } -// visit the Exception node and its scope +// Visit the Exception node and its scope. int be_visitor_exception::visit_exception (be_exception *) { - return -1; // must be overriden + // Must be overriden. + return -1; } int be_visitor_exception::visit_field (be_field *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 + // 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.node (node); + int status = 0; - // this switch is acceptable rather than having derived visitors overriding + // 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_EXCEPTION_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CH); + be_visitor_field_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CI); + be_visitor_field_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CS); + be_visitor_field_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); + be_visitor_field_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); + be_visitor_field_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); + be_visitor_field_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception::" "visit_field - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception::" "visit_field - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_field - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp index bd9a64347cb..5894e7b4d1a 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp @@ -18,14 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_exception.h" #include "be_visitor_typecode/typecode_decl.h" -ACE_RCSID(be_visitor_exception, exception_ch, "$Id$") - +ACE_RCSID (be_visitor_exception, + exception_ch, + "$Id$") // ****************************************************** // For client header. @@ -43,103 +40,107 @@ be_visitor_exception_ch::~be_visitor_exception_ch (void) // Visit the Exception node and its scope. int be_visitor_exception_ch::visit_exception (be_exception *node) { - TAO_OutStream *os = 0; - - if (!node->cli_hdr_gen () && !node->imported ()) + if (node->cli_hdr_gen () || node->imported ()) { - os = this->ctx_->stream (); - os->gen_ifdef_macro (node->flat_name ()); + return 0; + } - *os << "class " << be_global->stub_export_macro () - << " " << node->local_name () - << " : public CORBA::UserException" << be_nl; - *os << "{" << be_nl - << "public:" << be_idt_nl; + TAO_OutStream *os = this->ctx_->stream (); - // Generate code for field members. - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_ch::" - "visit_exception - " - "codegen for scope failed\n"), -1); - } + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; - *os << be_nl; + os->gen_ifdef_macro (node->flat_name ()); - // Constructors and destructor. - *os << node->local_name () << " (void);" << be_nl - << node->local_name () << " (const " << node->local_name () - << " &);" << be_nl - << "~" << node->local_name () << " (void);\n" << be_nl; + *os << "class " << be_global->stub_export_macro () + << " " << node->local_name () + << " : public CORBA::UserException" << be_nl; + *os << "{" << be_nl + << "public:" << be_idt_nl; - // Assignment operator. - *os << node->local_name () << " &operator= (const " - << node->local_name () << " &);\n" << be_nl; + // Generate code for field members. + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception_ch::" + "visit_exception - " + "codegen for scope failed\n"), + -1); + } - *os << "static void _tao_any_destructor (void*);\n" << be_nl; + *os << be_nl; - *os << "static " << node->local_name () - << " *_downcast (CORBA::Exception *);" << be_nl; + // Constructors and destructor. + *os << node->local_name () << " (void);" << be_nl + << node->local_name () << " (const " << node->local_name () + << " &);" << be_nl + << "~" << node->local_name () << " (void);\n" << be_nl; - *os << "static CORBA::Exception *_alloc (void);\n" << be_nl; + // Assignment operator. + *os << node->local_name () << " &operator= (const " + << node->local_name () << " &);\n" << be_nl; - *os << "virtual CORBA::Exception *" - << "_tao_duplicate (void) const;\n" << be_nl - << "virtual void _raise (void);\n" << be_nl - << "virtual void _tao_encode (" << be_idt << be_idt_nl - << "TAO_OutputCDR &" << be_nl - << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl - << ") const;" << be_uidt_nl << be_nl - << "virtual void _tao_decode (" << be_idt << be_idt_nl - << "TAO_InputCDR &" << be_nl - << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; + *os << "static void _tao_any_destructor (void*);\n" << be_nl; - // Generate constructor that takes each member as a parameter. We need a - // new state. Such a constructor exists if we have members. - if (node->member_count () > 0) - { - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_CH); - be_visitor_exception_ctor visitor (&ctx); - - if (visitor.visit_exception (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_exception - " - "codegen for ctor failed\n"), - -1); - } - } + *os << "static " << node->local_name () + << " *_downcast (CORBA::Exception *);" << be_nl; + + *os << "static CORBA::Exception *_alloc (void);\n" << be_nl; + + *os << "virtual CORBA::Exception *" + << "_tao_duplicate (void) const;\n" << be_nl + << "virtual void _raise (void);\n" << be_nl + << "virtual void _tao_encode (" << be_idt << be_idt_nl + << "TAO_OutputCDR &" << be_nl + << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ") const;" << be_uidt_nl << be_nl + << "virtual void _tao_decode (" << be_idt << be_idt_nl + << "TAO_InputCDR &" << be_nl + << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; - if (be_global->tc_support ()) + // Generate constructor that takes each member as a parameter. We need a + // new state. Such a constructor exists if we have members. + if (node->member_count () > 0) + { + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_CH); + be_visitor_exception_ctor visitor (&ctx); + + if (node->accept (&visitor) == -1) { - *os << be_nl <<"virtual CORBA::TypeCode_ptr _type (void) const;"; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception::" + "visit_exception - " + "codegen for ctor failed\n"), + -1); } + } + + if (be_global->tc_support ()) + { + *os << be_nl <<"virtual CORBA::TypeCode_ptr _type (void) const;"; + } + + *os << be_uidt_nl << "};" << be_nl << be_nl; - *os << be_uidt_nl << "};\n\n"; + if (be_global->tc_support ()) + { + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); + be_visitor_typecode_decl visitor (&ctx); - if (be_global->tc_support ()) + if (node->accept (&visitor) == -1) { - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - be_visitor_typecode_decl visitor (&ctx); - - if (visitor.visit_exception (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_ch::" - "visit_exception - " - "TypeCode declaration failed\n"), - -1); - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception_ch::" + "visit_exception - " + "TypeCode declaration failed\n"), + -1); } - - os->gen_endif (); - node->cli_hdr_gen (1); } + os->gen_endif (); + node->cli_hdr_gen (1); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ci.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ci.cpp index 7f7a34758b1..dd6ffb31917 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ci.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, exception_ci, "$Id$") +ACE_RCSID (be_visitor_exception, + exception_ci, + "$Id$") // ****************************************************** @@ -43,27 +39,30 @@ be_visitor_exception_ci::~be_visitor_exception_ci (void) // visit the Exception node and its scope int be_visitor_exception_ci::visit_exception (be_exception *node) { - TAO_OutStream *os = this->ctx_->stream (); // output stream + TAO_OutStream *os = this->ctx_->stream (); if (!node->cli_inline_gen () && !node->imported ()) { os = this->ctx_->stream (); os->indent (); + *os << "// *************************************************************" << be_nl; *os << "// Inline operations for exception " << node->name () << be_nl; *os << "// *************************************************************\n\n"; - // generate inline code required of any anonymous types of members + // Generate inline code required of any anonymous types of members. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception::" "visit_exception -" - "code for inline failed\n"), -1); + "code for inline failed\n"), + -1); } node->cli_inline_gen (I_TRUE); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp index bb5d9ac87b9..50498fa9201 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp @@ -18,18 +18,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_exception.h" #include "be_visitor_typecode/typecode_defn.h" -ACE_RCSID(be_visitor_exception, exception_cs, "$Id$") - +ACE_RCSID (be_visitor_exception, + exception_cs, + "$Id$") // *************************************************************************** // For client stubs. // *************************************************************************** + be_visitor_exception_cs::be_visitor_exception_cs (be_visitor_context *ctx) : be_visitor_exception (ctx) { @@ -42,325 +40,319 @@ be_visitor_exception_cs::~be_visitor_exception_cs (void) // Visit the Exception_Cs node and its scope. int be_visitor_exception_cs::visit_exception (be_exception *node) { - TAO_OutStream *os = 0; + if (node->cli_stub_gen () || node->imported ()) + { + return 0; + } + + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); - if (!node->cli_stub_gen () && !node->imported ()) + // Generate stub code required of any anonymous types of members. + if (this->visit_scope (node) == -1) { - os = this->ctx_->stream (); - os->indent (); + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception::" + "visit_exception -" + "code for stub failed\n"), + -1); + } + + *os << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Default constructor. + *os << "// Default constructor." << be_nl; + *os << node->name () << "::" << node->local_name () + << " (void)" << be_idt_nl; + *os << ": CORBA_UserException (" << be_idt << be_idt << be_idt_nl + << "\"" << node->repoID () << "\"," << be_nl + << "\"" << node->local_name () << "\"" << be_uidt_nl + << ")" << be_uidt << be_uidt << be_uidt_nl; + *os << "{" << be_nl; + *os << "}" << be_nl << be_nl; + + // Destructor. + *os << "// Destructor - all members are of self managing types." + << be_nl; + *os << node->name () << "::~" << node->local_name () + << " (void)" << be_nl; + *os << "{" << be_nl; + *os << "}" << be_nl << be_nl; + + // Copy constructor. + *os << "// Copy constructor." << be_nl; + *os << node->name () << "::" << node->local_name () << " (const ::" + << node->name () << " &_tao_excp)" << be_idt_nl; + *os << ": CORBA_UserException (" << be_idt << be_idt << be_idt_nl + << "_tao_excp._rep_id ()," << be_nl + << "_tao_excp._name ()" << be_uidt_nl + << ")" << be_uidt << be_uidt << be_uidt_nl; + *os << "{"; + + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); + + if (node->nmembers () > 0) + { + *os << be_idt; - // Generate stub code required of any anonymous types of members. - if (this->visit_scope (node) == -1) + // Assign each individual member. + be_visitor_exception_ctor_assign visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" + "(%N:%l) be_visitor_exception_cs::" "visit_exception -" - "code for stub failed\n"), + "codegen for scope failed\n"), -1); } + } - *os << "// TAO_IDL - Generated from " << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << be_uidt_nl + << "}" << be_nl << be_nl; - // Default constructor. - *os << "// Default constructor." << be_nl; - *os << node->name () << "::" << node->local_name () - << " (void)" << be_idt_nl; - *os << ": CORBA_UserException (" << be_idt << be_idt << be_idt_nl - << "\"" << node->repoID () << "\"," << be_nl - << "\"" << node->local_name () << "\"" << be_uidt_nl - << ")" << be_uidt << be_uidt << be_uidt_nl; - *os << "{" << be_nl; - *os << "}" << be_nl << be_nl; + // Assignment operator. + *os << "// Assignment operator." << be_nl; + *os << node->name () << "&" << be_nl; + *os << node->name () << "::operator= (const ::" + << node->name () << " &_tao_excp)" << be_nl + << "{" << be_idt_nl + << "this->CORBA_UserException::operator= " + << "(_tao_excp);"; - // Destructor. - *os << "// Destructor - all members are of self managing types." - << be_nl; - *os << node->name () << "::~" << node->local_name () - << " (void)" << be_nl; - *os << "{" << be_nl; - *os << "}" << be_nl << be_nl; + // Assign each individual member. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); + be_visitor_exception_ctor_assign visitor (&ctx); - // Copy constructor. - *os << "// Copy constructor." << be_nl; - *os << node->name () << "::" << node->local_name () << " (const ::" - << node->name () << " &_tao_excp)" << be_idt_nl; - *os << ": CORBA_UserException (" << be_idt << be_idt << be_idt_nl - << "_tao_excp._rep_id ()," << be_nl - << "_tao_excp._name ()" << be_uidt_nl - << ")" << be_uidt << be_uidt << be_uidt_nl; - *os << "{\n"; - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception_cs::" + "visit_exception -" + "codegen for scope failed\n"), + -1); + } - if (node->nmembers () > 0) + *os << be_nl + << "return *this;" << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "void " + << node->name () + << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl + << "{" << be_idt_nl + << node->local_name () << " *tmp = ACE_static_cast (" + << node->local_name () << "*, _tao_void_pointer);" << be_nl + << "delete tmp;" << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << node->name () << " *" << be_nl; + *os << node->name () << "::_downcast (CORBA::Exception *exc)" << be_nl; + *os << "{" << be_idt_nl; + *os << "if (!ACE_OS::strcmp (\"" << node->repoID () + << "\", exc->_rep_id ()))" << be_idt_nl; + *os << "{" << be_idt_nl; + *os << "return ACE_dynamic_cast (" << node->local_name () + << " *, exc);" << be_uidt_nl; + *os << "}" << be_uidt_nl; + *os << "else" << be_idt_nl; + *os << "{" << be_idt_nl; + *os << "return 0;" << be_uidt_nl; + *os << "}" << be_uidt << be_uidt_nl; + *os << "}" << be_nl << be_nl; + + // Generate the _alloc method. + *os << "CORBA::Exception *" << node->name () + << "::_alloc (void)" << be_nl; + *os << "{" << be_idt_nl; + *os << "CORBA::Exception *retval = 0;" << be_nl + << "ACE_NEW_RETURN (retval, ::" << node->name () + << ", 0);" << be_nl + << "return retval;" << be_uidt_nl; + *os << "}" << be_nl << be_nl; + + *os << "CORBA::Exception *" << be_nl + << node->name () << "::_tao_duplicate (void) const" << be_nl + << "{" << be_idt_nl + << "CORBA::Exception *result;" << be_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "result," << be_nl + << "::" << node->name () << " (*this)," << be_nl + << "0" << be_uidt_nl + << ");" << be_uidt_nl + << "return result;" << be_uidt_nl + << "}\n" << be_nl; + + *os << "void " << node->name () << "::_raise ()" << be_nl + << "{" << be_idt_nl + << "TAO_RAISE (*this);" << be_uidt_nl + << "}\n" << be_nl; + + *os << "void " << node->name () + << "::_tao_encode (" << be_idt << be_idt_nl; + + if (!node->is_local ()) + { + *os << "TAO_OutputCDR &cdr" << be_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ") const" << be_uidt_nl + << "{" << be_idt_nl + << "if (cdr << *this)" << be_idt_nl + << "{" << be_idt_nl + << "return;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + if (be_global->use_raw_throw ()) + { + *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; + } + else { - *os << be_idt; - - be_visitor_exception_ctor_assign cc_visitor (&ctx); - - // Visits scope and generates assignment line in copy constructor. - if (cc_visitor.visit_exception (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception -" - "codegen for scope failed\n"), - -1); - } - - *os << be_uidt; - os->decr_indent (); + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; } *os << "}" << be_nl << be_nl; + } + else + { + *os << "TAO_OutputCDR &" << be_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ") const" << be_uidt_nl + << "{" << be_idt_nl; - // Assignment operator. - *os << "// Assignment operator." << be_nl; - *os << node->name () << "&" << be_nl; - *os << node->name () << "::operator= (const ::" - << node->name () << " &_tao_excp)" << be_nl - << "{" << be_idt_nl - << "this->CORBA_UserException::operator= " - << "(_tao_excp);\n"; - - // Assign each individual member. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); - be_visitor_exception_ctor_assign ao_visitor (&ctx); - - // Visits scope and generates line in assignment operator. - if (ao_visitor.visit_exception (node) == -1) + if (be_global->use_raw_throw ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception -" - "codegen for scope failed\n"), - -1); + *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; + } + else + { + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; } - os->indent (); - *os << "return *this;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "void " - << node->name () - << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl - << "{" << be_idt_nl - << node->local_name () << " *tmp = ACE_static_cast (" - << node->local_name () << "*, _tao_void_pointer);" << be_nl - << "delete tmp;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << node->name () << " *" << be_nl; - *os << node->name () << "::_downcast (CORBA::Exception *exc)" << be_nl; - *os << "{" << be_idt_nl; - *os << "if (!ACE_OS::strcmp (\"" << node->repoID () - << "\", exc->_rep_id ()))" << be_idt_nl; - *os << "{" << be_idt_nl; - *os << "return ACE_dynamic_cast (" << node->local_name () - << " *, exc);" << be_uidt_nl; - *os << "}" << be_uidt_nl; - *os << "else" << be_idt_nl; - *os << "{" << be_idt_nl; - *os << "return 0;" << be_uidt_nl; - *os << "}" << be_uidt << be_uidt_nl; *os << "}" << be_nl << be_nl; + } - // Generate the _alloc method. - *os << "CORBA::Exception *" << node->name () - << "::_alloc (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "CORBA::Exception *retval = 0;" << be_nl - << "ACE_NEW_RETURN (retval, ::" << node->name () - << ", 0);" << be_nl - << "return retval;" << be_uidt_nl; - *os << "}" << be_nl << be_nl; + *os << "void " << node->name () + << "::_tao_decode (" << be_idt << be_idt_nl; - *os << "CORBA::Exception *" << be_nl - << node->name () << "::_tao_duplicate (void) const" << be_nl + if (!node->is_local ()) + { + *os << "TAO_InputCDR &cdr" << be_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl - << "CORBA::Exception *result;" << be_nl - << "ACE_NEW_RETURN (" << be_idt << be_idt_nl - << "result," << be_nl - << "::" << node->name () << " (*this)," << be_nl - << "0" << be_uidt_nl - << ");" << be_uidt_nl - << "return result;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "void " << node->name () << "::_raise ()" << be_nl + << "if (cdr >> *this)" << be_idt_nl << "{" << be_idt_nl - << "TAO_RAISE (*this);" << be_uidt_nl - << "}\n" << be_nl; - - *os << "void " << node->name () - << "::_tao_encode (" << be_idt << be_idt_nl; + << "return;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; - if (!node->is_local ()) + if (be_global->use_raw_throw ()) { - *os << "TAO_OutputCDR &cdr" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ") const" << be_uidt_nl - << "{" << be_idt_nl - << "if (cdr << *this)" << be_idt_nl - << "{" << be_idt_nl - << "return;" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; - } - else - { - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; - } - - *os << "}" << be_nl << be_nl; + *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; } else { - *os << "TAO_OutputCDR &" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ") const" << be_uidt_nl - << "{" << be_idt_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; - } - else - { - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; - } - - *os << "}" << be_nl << be_nl; + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; } - *os << "void " << node->name () - << "::_tao_decode (" << be_idt << be_idt_nl; + *os << "}" << be_nl << be_nl; + } + else + { + *os << "TAO_InputCDR &" << be_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl; - if (!node->is_local ()) + if (be_global->use_raw_throw ()) { - *os << "TAO_InputCDR &cdr" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "if (cdr >> *this)" << be_idt_nl - << "{" << be_idt_nl - << "return;" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; - } - else - { - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; - } - - *os << "}" << be_nl << be_nl; + *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; } else { - *os << "TAO_InputCDR &" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw CORBA::MARSHAL ();" << be_uidt_nl; - } - else - { - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; - } - - *os << "}" << be_nl << be_nl; + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl; } - // Constructor taking all members. It exists only if there are any - // members. - if (node->member_count () > 0) + *os << "}" << be_nl << be_nl; + } + + // Constructor taking all members. It exists only if there are any + // members. + if (node->member_count () > 0) + { + // Generate the signature. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_CS); + be_visitor_exception_ctor ec_visitor (&ctx); + + if (node->accept (&ec_visitor) == -1) { - // Generate the signature. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_CS); - be_visitor_exception_ctor con_visitor (&ctx); - - if (con_visitor.visit_exception (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_exception - " - "codegen for ctor failed\n"), - -1); - } - - *os << " : CORBA_UserException (" - << be_idt << be_idt << be_idt << be_idt_nl - << "\"" << node->repoID () << "\"," << be_nl - << "\"" << node->local_name () << "\"" << be_uidt_nl - << ")" << be_uidt << be_uidt << be_uidt << be_uidt_nl; - *os << "{\n"; - - // Assign each individual member. We need yet another state. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); - - // Indicate that the special ctor is being generated. - ctx.exception (1); - - be_visitor_exception_ctor_assign ca_visitor (&ctx); - - *os << be_idt; - - if (ca_visitor.visit_exception (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception -" - "codegen for scope failed\n"), - -1); - } - - os->decr_indent (); - *os << "}\n\n"; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception::" + "visit_exception - " + "codegen for ctor failed\n"), + -1); } - if (be_global->tc_support ()) + *os << " : CORBA_UserException (" + << be_idt << be_idt << be_idt << be_idt_nl + << "\"" << node->repoID () << "\"," << be_nl + << "\"" << node->local_name () << "\"" << be_uidt_nl + << ")" << be_uidt << be_uidt << be_uidt << be_uidt_nl; + *os << "{" << be_idt; + + // Assign each individual member. We need yet another state. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); + + // Indicate that the special ctor is being generated. + ctx.exception (1); + + be_visitor_exception_ctor_assign eca_visitor (&ctx); + + if (node->accept (&eca_visitor) == -1) { - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - be_visitor_typecode_defn tc_visitor (&ctx); - - if (tc_visitor.visit_exception (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception - " - "TypeCode definition failed\n"), - -1); - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception_cs::" + "visit_exception -" + "codegen for scope failed\n"), + -1); } - if (be_global->tc_support ()) + *os << be_uidt_nl << "}" << be_nl << be_nl; + } + + if (be_global->tc_support ()) + { + *os << "// TAO extension - the virtual _type method." << be_nl; + *os << "CORBA::TypeCode_ptr " << node->name () + << "::_type (void) const" << be_nl; + *os << "{" << be_idt_nl; + *os << "return ::" << node->tc_name () << ";" << be_uidt_nl; + *os << "}" << be_nl; + } + + if (be_global->tc_support ()) + { + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); + ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); + be_visitor_typecode_defn visitor (&ctx); + + if (node->accept (&visitor) == -1) { - *os << "\n// TAO extension - the virtual _type method." << be_nl; - *os << "CORBA::TypeCode_ptr " << node->name () - << "::_type (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return ::" << node->tc_name () << ";" << be_uidt_nl; - *os << "}" << be_nl << be_nl; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_exception_cs::" + "visit_exception - " + "TypeCode definition failed\n"), + -1); } - - node->cli_stub_gen (I_TRUE); } + node->cli_stub_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp index db7cb836e3a..cf497604458 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp @@ -18,21 +18,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, exception_ctor, "$Id$") +ACE_RCSID (be_visitor_exception, + exception_ctor, + "$Id$") // ************************************************************************ // code to generate the special ctor // ************************************************************************ -be_visitor_exception_ctor::be_visitor_exception_ctor -(be_visitor_context *ctx) +be_visitor_exception_ctor::be_visitor_exception_ctor (be_visitor_context *ctx) : be_visitor_scope (ctx) { } @@ -59,8 +54,6 @@ int be_visitor_exception_ctor::visit_exception (be_exception *node) TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); - os->indent (); - if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) { *os << node->local_name (); @@ -119,19 +112,23 @@ int be_visitor_exception_ctor::visit_field (be_field *node) } *os << " _tao_" << node->local_name (); + return 0; } int be_visitor_exception_ctor::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << "const "; @@ -139,10 +136,14 @@ int be_visitor_exception_ctor::visit_array (be_array *node) if (this->ctx_->state () != TAO_CodeGen::TAO_EXCEPTION_CTOR_CH && !tdef) - *os << this->ctx_->scope ()->full_name () << "::"; + { + *os << this->ctx_->scope ()->full_name () << "::"; + } if (!tdef) - *os << "_"; + { + *os << "_"; + } *os << bt->nested_type_name (this->ctx_->scope ()); @@ -151,113 +152,218 @@ int be_visitor_exception_ctor::visit_array (be_array *node) int be_visitor_exception_ctor::visit_enum (be_enum *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } + return 0; } int be_visitor_exception_ctor::visit_interface (be_interface *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr "); + { + *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr"); + } else - *os << "const " << bt->name () << "_ptr "; + { + *os << "const " << bt->name () << "_ptr"; + } + return 0; } int be_visitor_exception_ctor::visit_interface_fwd (be_interface_fwd *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + 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_EXCEPTION_CTOR_CH) + { + *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr"); + } + else + { + *os << "const " << bt->name () << "_ptr"; + } - // set the right type; + return 0; +} + +int be_visitor_exception_ctor::visit_valuetype (be_valuetype *node) +{ + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr "); + { + *os << "const " << bt->nested_type_name (this->ctx_->scope (), " *"); + } else - *os << "const " << bt->name () << "_ptr "; + { + *os << "const " << bt->name () << " *"; + } + return 0; } -int be_visitor_exception_ctor::visit_predefined_type (be_predefined_type *node) +int be_visitor_exception_ctor::visit_valuetype_fwd (be_valuetype_fwd *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; + + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } + else + { + bt = node; + } - // set the right type; + if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) + { + *os << "const " << bt->nested_type_name (this->ctx_->scope (), " *"); + } + else + { + *os << "const " << bt->name () << " *"; + } + + return 0; +} + +int be_visitor_exception_ctor::visit_predefined_type (be_predefined_type *node) +{ + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } + + AST_PredefinedType::PredefinedType pt = node->pt (); - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) + if (pt == AST_PredefinedType::PT_any) { if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + { + *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << "const " << bt->name (); + { + *os << "const " << bt->name (); + } + *os << " &"; + return 0; - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + } + else if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr "); + { + *os << "const " << bt->nested_type_name (this->ctx_->scope (), + "_ptr "); + } else - *os << "const " << bt->name () << "_ptr "; - } // end else if - else // simple predefined types + { + *os << "const " << bt->name () << "_ptr "; + } + } + else { if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); - } // end of else + { + *os << bt->name (); + } + } return 0; } int be_visitor_exception_ctor::visit_sequence (be_sequence *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + { + *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << "const " << bt->name (); + { + *os << "const " << bt->name (); + } + *os << " &"; + return 0; } @@ -279,45 +385,64 @@ int be_visitor_exception_ctor::visit_string (be_string *node) int be_visitor_exception_ctor::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + { + *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << "const " << bt->name (); + { + *os << "const " << bt->name (); + } + *os << " &"; + return 0; } int be_visitor_exception_ctor::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; + if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + { + *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << "const " << bt->name (); + { + *os << "const " << bt->name (); + } + *os << " &"; + return 0; } int be_visitor_exception_ctor::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -326,6 +451,7 @@ int be_visitor_exception_ctor::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_factory.cpp b/TAO/TAO_IDL/be/be_visitor_factory.cpp index 52b6c1fa471..2a228ffe01d 100644 --- a/TAO/TAO_IDL/be/be_visitor_factory.cpp +++ b/TAO/TAO_IDL/be/be_visitor_factory.cpp @@ -10,761 +10,135 @@ // // = DESCRIPTION // Defines a factory that returns a specialized visitor object based on the -// code generation state. This factory creates all the commonly used -// visitors that are not affected by decisions such as whether we use -// compiled marshaling or interpretive marshaling. +// code generation state. This factory creates visitors associated with +// Asynchronous Messaging Invocations (AMI) since, because of implied IDL, +// state is not locally known at visitor creation time. // // = AUTHOR // Aniruddha Gokhale // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "ast_argument.h" -// individual visitors included only here #include "be_visitor_factory.h" - -#include "be_visitor_argument.h" -#include "be_visitor_array.h" -#include "be_visitor_attribute.h" -#include "be_visitor_constant.h" -#include "be_visitor_enum.h" -#include "be_visitor_exception.h" -#include "be_visitor_field.h" -#include "be_visitor_interface.h" -#include "be_visitor_interface_fwd.h" -#include "be_visitor_valuetype.h" -#include "be_visitor_valuetype_fwd.h" -#include "be_visitor_module.h" -#include "be_visitor_operation.h" -#include "be_visitor_root.h" -#include "be_visitor_sequence.h" -#include "be_visitor_structure.h" -#include "be_visitor_typecode.h" -#include "be_visitor_typedef.h" -#include "be_visitor_union.h" -#include "be_visitor_union_branch.h" - -ACE_RCSID(be, be_visitor_factory, "$Id$") - - - // The BASE abstract visitor factory - TAO_Visitor_Factory::TAO_Visitor_Factory (void) +#include "be_visitor_context.h" + +#include "be_visitor_decl.h" +#include "be_visitor_scope.h" +#include "be_visitor_interface/interface.h" +#include "be_visitor_interface/interface_ch.h" +#include "be_visitor_interface/ami_interface_ch.h" +#include "be_visitor_valuetype/valuetype.h" +#include "be_visitor_valuetype/valuetype_ch.h" +#include "be_visitor_valuetype/valuetype_obv_ch.h" +#include "be_visitor_valuetype/valuetype_obv_cs.h" +#include "be_visitor_valuetype/ami_exception_holder_ch.h" +#include "be_visitor_valuetype/ami_exception_holder_cs.h" +#include "be_visitor_operation/operation.h" +#include "be_visitor_operation/operation_ch.h" +#include "be_visitor_operation/operation_cs.h" +#include "be_visitor_operation/ami_ch.h" +#include "be_visitor_operation/ami_cs.h" +#include "be_visitor_operation/ami_handler_reply_stub_operation_ch.h" +#include "be_visitor_operation/ami_handler_reply_stub_operation_cs.h" +#include "be_visitor_operation/ami_exception_holder_operation_cs.h" + +ACE_RCSID (be, + be_visitor_factory, + "$Id$") + +TAO_Visitor_Factory::TAO_Visitor_Factory (void) { } -// destructor TAO_Visitor_Factory::~TAO_Visitor_Factory (void) { } -// The concrete visitor factory for visitors irrespective of the the marshaling -// approaches used. -// -// This common visitor factory also deals with a 2nd level of code-generation -// choices that the user has requested. This involves enabling/disabling -// support for specific type of kind, e.g., generation of TypeCodes or Any -// operators or Real C++ exception suport. -TAO_Common_Visitor_Factory::TAO_Common_Visitor_Factory (void) -{ -} - -// destructor -TAO_Common_Visitor_Factory::~TAO_Common_Visitor_Factory (void) -{ -} - be_visitor * -TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) +TAO_Visitor_Factory::make_visitor (be_visitor_context *ctx) { - TAO_CodeGen::CG_STATE st = ctx->state (); - // create a new context so that ownership issues are not confused. This newly - // created context is a copy of what was sent by the caller. The newly - // created visitor will own this new copy. - be_visitor_context *new_ctx = new be_visitor_context (*ctx); - switch (st) - { - case TAO_CodeGen::TAO_ROOT_CH: - return new be_visitor_root_ch (new_ctx); - case TAO_CodeGen::TAO_ROOT_CI: - return new be_visitor_root_ci (new_ctx); - case TAO_CodeGen::TAO_ROOT_CS: - return new be_visitor_root_cs (new_ctx); - case TAO_CodeGen::TAO_ROOT_SH: - return new be_visitor_root_sh (new_ctx); - case TAO_CodeGen::TAO_ROOT_SI: - return new be_visitor_root_si (new_ctx); - case TAO_CodeGen::TAO_ROOT_SS: - return new be_visitor_root_ss (new_ctx); - case TAO_CodeGen::TAO_ROOT_IH: - return new be_visitor_root_ih (new_ctx); - case TAO_CodeGen::TAO_ROOT_IS: - return new be_visitor_root_is (new_ctx); - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - // this is the starting point for generation of all Any operators. If we - // have the any support enabled, then go ahead - if (be_global->any_support ()) - return new be_visitor_root_any_op (new_ctx); - else - // return a NO_OP visitor - return new be_visitor_decl (new_ctx); - - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - return new be_visitor_root_cdr_op (new_ctx); - - case TAO_CodeGen::TAO_MODULE_CH: - return new be_visitor_module_ch (new_ctx); - - case TAO_CodeGen::TAO_MODULE_SH: - return new be_visitor_module_sh (new_ctx); - - case TAO_CodeGen::TAO_MODULE_IH: - return new be_visitor_module_ih (new_ctx); - - case TAO_CodeGen::TAO_MODULE_CI: - case TAO_CodeGen::TAO_MODULE_CS: - case TAO_CodeGen::TAO_MODULE_SI: - case TAO_CodeGen::TAO_MODULE_SS: - case TAO_CodeGen::TAO_MODULE_IS: - return new be_visitor_module (new_ctx); - - case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - return new be_visitor_module_any_op (new_ctx); - - case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - return new be_visitor_module_cdr_op (new_ctx); + be_visitor *retval = 0; + switch (ctx->state ()) + { case TAO_CodeGen::TAO_INTERFACE_CH: - return new be_visitor_interface_ch (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_CI: - return new be_visitor_interface_ci (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_CS: - return new be_visitor_interface_cs (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_SH: - return new be_visitor_interface_sh (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_IH: - return new be_visitor_interface_ih (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_SI: - return new be_visitor_interface_si (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_SS: - return new be_visitor_interface_ss (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_IS: - return new be_visitor_interface_is (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH: - return new be_visitor_interface_proxy_brokers_ch (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_BROKER_CH: - return new be_visitor_interface_base_proxy_broker_ch (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CH: - return new be_visitor_interface_remote_proxy_broker_ch (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS: - return new be_visitor_interface_remote_proxy_broker_cs (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SH: - return new be_visitor_interface_strategized_proxy_broker_sh (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SS: - return new be_visitor_interface_strategized_proxy_broker_ss (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CH: - return new be_visitor_interface_proxy_impls_ch (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: - return new be_visitor_interface_base_proxy_impl_ch (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: - return new be_visitor_interface_remote_proxy_impl_ch (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: - return new be_visitor_interface_remote_proxy_impl_cs (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: - return new be_visitor_interface_thru_poa_proxy_impl_sh (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS: - return new be_visitor_interface_thru_poa_proxy_impl_ss (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: - return new be_visitor_interface_direct_proxy_impl_sh (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: - return new be_visitor_interface_direct_proxy_impl_ss (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - return new be_visitor_interface_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - return new be_visitor_interface_any_op_cs (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - return new be_visitor_interface_tie_sh (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - return new be_visitor_interface_tie_si (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - return new be_visitor_interface_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - return new be_visitor_interface_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - return new be_visitor_interface_cdr_op_cs (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: - return new be_visitor_interface_smart_proxy_ch (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - return new be_visitor_interface_smart_proxy_cs (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: - return new be_visitor_interface_interceptors_ch (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: - return new be_visitor_interface_interceptors_cs (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: - return new be_visitor_interface_interceptors_sh (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: - return new be_visitor_interface_interceptors_ss (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_FWD_CH: - return new be_visitor_interface_fwd_ch (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_FWD_CI: - return new be_visitor_interface_fwd_ci (new_ctx); - - case TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH: - return new be_visitor_interface_fwd_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI: - return new be_visitor_interface_fwd_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CS: - return new be_visitor_decl (new_ctx); // noop - case TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH: - return new be_visitor_interface_fwd_any_op_ch (new_ctx); - - // Valuetype-related visitors - - case TAO_CodeGen::TAO_VALUETYPE_CH: - return new be_visitor_valuetype_ch (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_CS: - return new be_visitor_valuetype_cs (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_CI: - return new be_visitor_valuetype_ci (new_ctx); - - case TAO_CodeGen::TAO_VALUETYPE_FWD_CH: - return new be_visitor_valuetype_fwd_ch (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_FWD_CI: - return new be_visitor_valuetype_fwd_ci (new_ctx); - - case TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH: - return new be_visitor_valuetype_fwd_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI: - return new be_visitor_valuetype_fwd_cdr_op_ci (new_ctx); - + ACE_NEW_RETURN (retval, + be_visitor_interface_ch (ctx), + 0); + break; case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: - return new be_visitor_valuetype_obv_ch (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: - return new be_visitor_valuetype_obv_ci (new_ctx); + ACE_NEW_RETURN (retval, + be_visitor_valuetype_obv_ch (ctx), + 0); + break; case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: - return new be_visitor_valuetype_obv_cs (new_ctx); - - case TAO_CodeGen::TAO_FIELD_OBV_CH: - return new be_visitor_valuetype_field_ch (new_ctx); - - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CS: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_OBV_CH: - return new be_visitor_obv_operation_arglist (new_ctx); - - case TAO_CodeGen::TAO_MODULE_OBV_CH: - case TAO_CodeGen::TAO_MODULE_OBV_CI: - case TAO_CodeGen::TAO_MODULE_OBV_CS: - return new be_visitor_obv_module (new_ctx); - - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - return new be_visitor_valuetype_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - return new be_visitor_valuetype_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - return new be_visitor_valuetype_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - return new be_visitor_valuetype_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - return new be_visitor_valuetype_any_op_cs (new_ctx); - - case TAO_CodeGen::TAO_VALUETYPE_INIT_CH: - return new be_visitor_valuetype_init_ch (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_INIT_CI: - return new be_visitor_valuetype_init_ci (new_ctx); - case TAO_CodeGen::TAO_VALUETYPE_INIT_CS: - return new be_visitor_valuetype_init_cs (new_ctx); - - case TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH: - return new be_visitor_valuetype_init_arglist_ch (new_ctx); - - case TAO_CodeGen::TAO_STRUCT_CH: - return new be_visitor_structure_ch (new_ctx); - case TAO_CodeGen::TAO_STRUCT_CS: - return new be_visitor_structure_cs (new_ctx); - case TAO_CodeGen::TAO_STRUCT_CI: - return new be_visitor_structure_ci (new_ctx); - case TAO_CodeGen::TAO_STRUCT_ANY_OP_CH: - return new be_visitor_structure_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_STRUCT_ANY_OP_CS: - return new be_visitor_structure_any_op_cs (new_ctx); - case TAO_CodeGen::TAO_STRUCT_CDR_OP_CH: - return new be_visitor_structure_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_STRUCT_CDR_OP_CI: - return new be_visitor_structure_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_STRUCT_CDR_OP_CS: - return new be_visitor_structure_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_CONSTANT_CH: - return new be_visitor_constant_ch (new_ctx); - case TAO_CodeGen::TAO_CONSTANT_CS: - return new be_visitor_constant_cs (new_ctx); - - case TAO_CodeGen::TAO_ENUM_CH: - return new be_visitor_enum_ch (new_ctx); - case TAO_CodeGen::TAO_ENUM_CS: - return new be_visitor_enum_cs (new_ctx); - case TAO_CodeGen::TAO_ENUM_ANY_OP_CH: - return new be_visitor_enum_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_ENUM_ANY_OP_CS: - return new be_visitor_enum_any_op_cs (new_ctx); - case TAO_CodeGen::TAO_ENUM_CDR_OP_CH: - return new be_visitor_enum_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_ENUM_CDR_OP_CI: - return new be_visitor_enum_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_ENUM_CDR_OP_CS: - return new be_visitor_decl (new_ctx); - - case TAO_CodeGen::TAO_FIELD_CH: - return new be_visitor_field_ch (new_ctx); - case TAO_CodeGen::TAO_FIELD_CS: - return new be_visitor_field_cs (new_ctx); - case TAO_CodeGen::TAO_FIELD_CI: - return new be_visitor_field_ci (new_ctx); - case TAO_CodeGen::TAO_FIELD_CDR_OP_CH: - return new be_visitor_field_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_FIELD_CDR_OP_CI: - return new be_visitor_field_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_FIELD_CDR_OP_CS: - return new be_visitor_field_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_UNION_CH: - return new be_visitor_union_ch (new_ctx); - case TAO_CodeGen::TAO_UNION_CI: - return new be_visitor_union_ci (new_ctx); - case TAO_CodeGen::TAO_UNION_CS: - return new be_visitor_union_cs (new_ctx); - case TAO_CodeGen::TAO_UNION_PUBLIC_CH: - return new be_visitor_union_branch_public_ch (new_ctx); - case TAO_CodeGen::TAO_UNION_PUBLIC_CI: - return new be_visitor_union_branch_public_ci (new_ctx); - case TAO_CodeGen::TAO_UNION_PUBLIC_CS: - return new be_visitor_union_branch_public_cs (new_ctx); - case TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS: - return new be_visitor_union_branch_public_assign_cs (new_ctx); - case TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS: - return new be_visitor_union_branch_public_reset_cs (new_ctx); - case TAO_CodeGen::TAO_UNION_PUBLIC_ACCESS_CS: - return new be_visitor_union_branch_public_access_cs (new_ctx); - case TAO_CodeGen::TAO_UNION_PRIVATE_CH: - return new be_visitor_union_branch_private_ch (new_ctx); - case TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CH: - return new be_visitor_union_discriminant_ch (new_ctx); - case TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CI: - return new be_visitor_union_discriminant_ci (new_ctx); - case TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CS: - return new be_visitor_union_discriminant_cs (new_ctx); - case TAO_CodeGen::TAO_UNION_ANY_OP_CH: - return new be_visitor_union_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_UNION_ANY_OP_CS: + ACE_NEW_RETURN (retval, + be_visitor_valuetype_obv_cs (ctx), + 0); break; - case TAO_CodeGen::TAO_UNION_CDR_OP_CH: - return new be_visitor_union_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_UNION_CDR_OP_CI: - return new be_visitor_union_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_UNION_CDR_OP_CS: - return new be_visitor_union_cdr_op_cs (new_ctx); - case TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CH: - return new be_visitor_union_branch_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CI: - return new be_visitor_union_branch_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CS: - return new be_visitor_union_branch_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_SEQUENCE_CH: - return new be_visitor_sequence_ch (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_CI: - return new be_visitor_sequence_ci (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_CS: - return new be_visitor_sequence_cs (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_BASE_CH: - case TAO_CodeGen::TAO_SEQUENCE_BASE_CI: - case TAO_CodeGen::TAO_SEQUENCE_BASE_CS: - return new be_visitor_sequence_base (new_ctx); - case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH: - case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI: - return new be_visitor_sequence_elemtype (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH: - case TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CI: - case TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CS: - return new be_visitor_sequence_buffer_type (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CH: - return new be_visitor_sequence_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CS: - return new be_visitor_sequence_any_op_cs (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH: - return new be_visitor_sequence_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI: - return new be_visitor_sequence_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS: - return new be_visitor_sequence_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_TYPEDEF_CH: - return new be_visitor_typedef_ch (new_ctx); - case TAO_CodeGen::TAO_TYPEDEF_CS: - return new be_visitor_typedef_cs (new_ctx); - case TAO_CodeGen::TAO_TYPEDEF_CI: - return new be_visitor_typedef_ci (new_ctx); - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - return new be_visitor_typedef_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - return new be_visitor_typedef_any_op_cs (new_ctx); - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - return new be_visitor_typedef_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - return new be_visitor_typedef_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - return new be_visitor_typedef_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_TYPECODE_DECL: - // Do we need TypeCode Support? - if (be_global->tc_support ()) - return new be_visitor_typecode_decl (new_ctx); - else - // return a NO_OP visitor - return new be_visitor_decl (new_ctx); - - case TAO_CodeGen::TAO_TYPECODE_DEFN: - // Do we need TypeCode Support? - if (be_global->tc_support ()) - return new be_visitor_typecode_defn (new_ctx); - else - // return a NO_OP visitor - return new be_visitor_decl (new_ctx); - - case TAO_CodeGen::TAO_ATTRIBUTE_CH: - case TAO_CodeGen::TAO_ATTRIBUTE_CS: - case TAO_CodeGen::TAO_ATTRIBUTE_SH: - case TAO_CodeGen::TAO_ATTRIBUTE_IH: - case TAO_CodeGen::TAO_ATTRIBUTE_SS: - case TAO_CodeGen::TAO_ATTRIBUTE_IS: - case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SH: - case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI: - case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CH: - case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CS: - case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CH: - case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CS: - case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_SH: - case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_SS: - - case TAO_CodeGen::TAO_ATTRIBUTE_BASE_PROXY_IMPL_CH: - case TAO_CodeGen::TAO_ATTRIBUTE_PROXY_IMPL_XH: - case TAO_CodeGen::TAO_ATTRIBUTE_REMOTE_PROXY_IMPL_CS: - case TAO_CodeGen::TAO_ATTRIBUTE_THRU_POA_PROXY_IMPL_SS: - case TAO_CodeGen::TAO_ATTRIBUTE_DIRECT_PROXY_IMPL_SS: - return new be_visitor_attribute (new_ctx); - - case TAO_CodeGen::TAO_EXCEPTION_CH: - return new be_visitor_exception_ch (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_CI: - return new be_visitor_exception_ci (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_CS: - return new be_visitor_exception_cs (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_CTOR_CH: - case TAO_CodeGen::TAO_EXCEPTION_CTOR_CS: - return new be_visitor_exception_ctor (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS: - return new be_visitor_exception_ctor_assign (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH: - return new be_visitor_exception_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS: - return new be_visitor_exception_any_op_cs (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH: - return new be_visitor_exception_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI: - return new be_visitor_exception_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS: - return new be_visitor_exception_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_ARRAY_CH: - return new be_visitor_array_ch (new_ctx); - case TAO_CodeGen::TAO_ARRAY_CI: - return new be_visitor_array_ci (new_ctx); - case TAO_CodeGen::TAO_ARRAY_CS: - return new be_visitor_array_cs (new_ctx); - case TAO_CodeGen::TAO_ARRAY_ANY_OP_CH: - return new be_visitor_array_any_op_ch (new_ctx); - case TAO_CodeGen::TAO_ARRAY_ANY_OP_CS: - return new be_visitor_array_any_op_cs (new_ctx); - case TAO_CodeGen::TAO_ARRAY_CDR_OP_CH: - return new be_visitor_array_cdr_op_ch (new_ctx); - case TAO_CodeGen::TAO_ARRAY_CDR_OP_CI: - return new be_visitor_array_cdr_op_ci (new_ctx); - case TAO_CodeGen::TAO_ARRAY_CDR_OP_CS: - return new be_visitor_array_cdr_op_cs (new_ctx); - default: - // an error - delete new_ctx; - return 0; - } - return 0; -} - -// The concrete visitor factory for operation visitors generating compiled -// stubs and skeletons - -TAO_Compiled_Visitor_Factory::TAO_Compiled_Visitor_Factory (void) -{ -} - -// destructor -TAO_Compiled_Visitor_Factory::~TAO_Compiled_Visitor_Factory (void) -{ -} - -be_visitor * -TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) -{ - TAO_CodeGen::CG_STATE st = ctx->state (); - // create a new context so that ownership issues are not confused. This newly - // created context is a copy of what was sent by the caller. The newly - // created visitor will own this new copy. - be_visitor_context *new_ctx = new be_visitor_context (*ctx); - - switch (st) - { - case TAO_CodeGen::TAO_UNION_ANY_OP_CS: - return new be_visitor_union_any_op_cs (new_ctx); case TAO_CodeGen::TAO_OPERATION_CH: - return new be_visitor_operation_ch (new_ctx); + ACE_NEW_RETURN (retval, + be_visitor_operation_ch (ctx), + 0); + break; case TAO_CodeGen::TAO_OPERATION_CS: - return new be_visitor_operation_cs (new_ctx); - case TAO_CodeGen::TAO_OPERATION_SH: - return new be_visitor_operation_sh (new_ctx); - case TAO_CodeGen::TAO_OPERATION_SS: - return new be_visitor_operation_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_IS: - return new be_visitor_operation_is (new_ctx); - case TAO_CodeGen::TAO_OPERATION_IH: - return new be_visitor_operation_ih (new_ctx); - case TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CH: - return new be_visitor_operation_smart_proxy_ch (new_ctx); - case TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS: - return new be_visitor_operation_smart_proxy_cs (new_ctx); - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CH: - return new be_visitor_operation_interceptors_ch (new_ctx); - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS: - return new be_visitor_operation_interceptors_cs (new_ctx); - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SH: - return new be_visitor_operation_interceptors_sh (new_ctx); - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS: - return new be_visitor_operation_interceptors_ss (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH: - return new be_visitor_operation_base_proxy_impl_ch (new_ctx); - case TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH: - return new be_visitor_operation_proxy_impl_xh (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS: - return new be_visitor_operation_remote_proxy_impl_cs (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS: - return new be_visitor_operation_thru_poa_proxy_impl_ss (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS: - return new be_visitor_operation_direct_proxy_impl_ss (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETTYPE_CH: - case TAO_CodeGen::TAO_OPERATION_RETTYPE_SH: - case TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS: - return new be_visitor_operation_rettype (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_RETTYPE_CH: - return new be_visitor_operation_interceptors_info_rettype (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS: - return new be_visitor_operation_rettype_vardecl_cs (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETVAL_PRE_INVOKE_CS: - return new be_visitor_operation_rettype_pre_invoke_cs (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS: - return new be_visitor_operation_rettype_marshal_ss (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS: - return new be_visitor_operation_rettype_return_cs (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS: - return new be_visitor_operation_exceptlist_cs (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST: - return new be_visitor_operation_interceptors_exceptlist (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_SS: - return new be_visitor_operation_rettype_vardecl_ss (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETVAL_MARSHAL_SS: - return new be_visitor_operation_rettype_marshal_ss (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_RETVAL_ASSIGN_SS: - return new be_visitor_operation_rettype_assign_ss (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_INVOKE_ARG_LIST: - return new be_visitor_operation_inv_arglist (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_IS: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS: - - case TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_BASE_PROXY_IMPL_CH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS: - return new be_visitor_operation_arglist (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CH: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CH: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CS: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SH: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SH: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS: - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_SS: - return new be_visitor_operation_interceptors_arglist (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_RESULT: - return new be_visitor_operation_interceptors_result (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS: - case TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS: - case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: - case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: - case TAO_CodeGen::TAO_OPERATION_ARG_POST_UPCALL_SS: - case TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS: - return new be_visitor_operation_argument (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: - case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - return new be_compiled_visitor_operation_argument_marshal (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_TIE_SH: - return new be_visitor_operation_tie_sh (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_TIE_SI: - return new be_visitor_operation_tie_si (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: - return new be_compiled_visitor_operation_argument_invoke (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH: - case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_SH: - case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS: - return new be_visitor_args_arglist (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CH: - return new be_visitor_args_request_info_ch (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH: - return new be_visitor_args_request_info_arglist (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CS: - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CS: - return new be_visitor_args_request_info_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_PARAMLIST: - return new be_visitor_args_paramlist (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_RESULT: - return new be_visitor_args_request_info_result (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SH: - return new be_visitor_args_request_info_sh (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SS: - case TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_SS: - return new be_visitor_args_request_info_ss (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_PRE_INVOKE_CS: - return new be_visitor_args_pre_invoke_cs (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS: - return new be_visitor_args_invoke_cs (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS: - return new be_visitor_args_post_invoke_cs (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS: - return new be_visitor_args_vardecl_ss (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS: - case TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS: - return new be_visitor_args_upcall_ss (new_ctx); - - case TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS: - case TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS: - return new be_visitor_args_marshal_ss (new_ctx); - - // AMI next generation visitors. + ACE_NEW_RETURN (retval, + be_visitor_operation_cs (ctx), + 0); + break; case TAO_CodeGen::TAO_AMI_INTERFACE_CH: - return new be_visitor_ami_interface_ch (new_ctx); - + ACE_NEW_RETURN (retval, + be_visitor_ami_interface_ch (ctx), + 0); + break; case TAO_CodeGen::TAO_AMI_HANDLER_REPLY_STUB_OPERATION_CH: - return new be_visitor_operation_ami_handler_reply_stub_operation_ch (new_ctx); - + ACE_NEW_RETURN ( + retval, + be_visitor_operation_ami_handler_reply_stub_operation_ch (ctx), + 0 + ); + break; case TAO_CodeGen::TAO_AMI_HANDLER_REPLY_STUB_OPERATION_CS: - return new be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (new_ctx); - + ACE_NEW_RETURN ( + retval, + be_visitor_operation_ami_handler_reply_stub_operation_cs (ctx), + 0 + ); + break; case TAO_CodeGen::TAO_AMI_SENDC_OPERATION_CH: - return new be_visitor_operation_ami_ch (new_ctx); - + ACE_NEW_RETURN (retval, + be_visitor_operation_ami_ch (ctx), + 0); + break; case TAO_CodeGen::TAO_AMI_SENDC_OPERATION_CS: - return new be_compiled_visitor_operation_ami_cs (new_ctx); - + ACE_NEW_RETURN (retval, + be_visitor_operation_ami_cs (ctx), + 0); + break; case TAO_CodeGen::TAO_AMI_EXCEPTION_HOLDER_RAISE_OPERATION_CS: - return new be_visitor_operation_ami_exception_holder_operation_cs (new_ctx); - + ACE_NEW_RETURN ( + retval, + be_visitor_operation_ami_exception_holder_operation_cs (ctx), + 0 + ); + break; case TAO_CodeGen::TAO_AMI_EXCEPTION_HOLDER_VALUETYPE_CH: - return new be_visitor_valuetype_ami_exception_holder_ch (new_ctx); - + ACE_NEW_RETURN (retval, + be_visitor_valuetype_ami_exception_holder_ch (ctx), + 0); + break; case TAO_CodeGen::TAO_AMI_EXCEPTION_HOLDER_VALUETYPE_CS: - return new be_visitor_valuetype_ami_exception_holder_cs (new_ctx); - - // AMH ResponseHandler class visitors - case TAO_CodeGen::TAO_INTERFACE_AMH_RH_CH: - return new be_visitor_amh_rh_interface_sh (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: - return new be_visitor_amh_rh_interface_sh (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return new be_visitor_amh_rh_interface_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_AMH_RH_SH: - return new be_visitor_amh_rh_operation_sh (new_ctx); - case TAO_CodeGen::TAO_OPERATION_AMH_RH_SS: - return new be_visitor_amh_rh_operation_ss (new_ctx); - + ACE_NEW_RETURN (retval, + be_visitor_valuetype_ami_exception_holder_cs (ctx), + 0); + break; default: - // cannot handle it; delegate it to the common visitor factory - delete new_ctx; - return TAO_COMMON_VISITOR_FACTORY::instance ()->make_visitor (ctx); + // An error. + return 0; } + + return retval; } + diff --git a/TAO/TAO_IDL/be/be_visitor_field.cpp b/TAO/TAO_IDL/be/be_visitor_field.cpp index b219838d510..4e7c67ef3c0 100644 --- a/TAO/TAO_IDL/be/be_visitor_field.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field.cpp @@ -17,13 +17,29 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_type.h" +#include "be_field.h" +#include "be_array.h" +#include "be_typedef.h" +#include "be_enum.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_predefined_type.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_union.h" +#include "be_helper.h" +#include "utl_identifier.h" #include "be_visitor_field.h" +#include "be_visitor_array.h" +#include "be_visitor_structure.h" +#include "be_visitor_union.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_field/field_ch.cpp" #include "be_visitor_field/field_ci.cpp" #include "be_visitor_field/field_cs.cpp" @@ -31,4 +47,6 @@ #include "be_visitor_field/cdr_op_ci.cpp" #include "be_visitor_field/cdr_op_cs.cpp" -ACE_RCSID(be, be_visitor_field, "$Id$") +ACE_RCSID (be, + be_visitor_field, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp index 35f083cec82..39808029877 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp @@ -18,127 +18,114 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_visitor_array/cdr_op_ch.h" +#include "be_visitor_enum/cdr_op_ch.h" +#include "be_visitor_sequence/cdr_op_ch.h" +#include "be_visitor_structure/structure.h" +#include "be_visitor_structure/cdr_op_ch.h" +#include "be_visitor_union/union.h" +#include "be_visitor_union/cdr_op_ch.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_field, + cdr_op_ch, + "$Id$") // ********************************************** -// visitor for field in the client header file +// Visitor for field in the client header file. // ********************************************** -// constructor +// Constructor. be_visitor_field_cdr_op_ch::be_visitor_field_cdr_op_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor +// Destructor. be_visitor_field_cdr_op_ch::~be_visitor_field_cdr_op_ch (void) { } -// visit the field node +// Visit the field node. int be_visitor_field_cdr_op_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_field_cdr_op_ch::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be. -// visit array type int be_visitor_field_cdr_op_ch::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. + // This is the case for anonymous arrays. - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // 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.node (node); - // first generate the struct declaration + // First generate the array declaration. ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_field_cdr_op_ch::visit_enum (be_enum *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // 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 ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // 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.node (node); - // first generate the enum declaration + // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -146,38 +133,28 @@ be_visitor_field_cdr_op_ch::visit_enum (be_enum *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; } -// visit sequence type int be_visitor_field_cdr_op_ch::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // 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 ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // 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.node (node); - // first generate the sequence declaration + // First generate the sequence declaration. ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -185,13 +162,11 @@ be_visitor_field_cdr_op_ch::visit_sequence (be_sequence *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; } -// visit structure type int be_visitor_field_cdr_op_ch::visit_structure (be_structure *node) { @@ -208,16 +183,9 @@ be_visitor_field_cdr_op_ch::visit_structure (be_structure *node) // first generate the struct declaration ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -225,23 +193,22 @@ be_visitor_field_cdr_op_ch::visit_structure (be_structure *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; } -// visit typedefed type int be_visitor_field_cdr_op_ch::visit_typedef (be_typedef *node) { - // save the node for use in code generation and + // Save the node for use in code generation and // indicate that the field of the field node - // is a typedefed quantity + // is a typedefed quantity. this->ctx_->alias (node); - // make a decision based on the primitive base type + // 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, @@ -250,6 +217,7 @@ be_visitor_field_cdr_op_ch::visit_typedef (be_typedef *node) "Bad primitive type\n" ), -1); } + this->ctx_->alias (0); return 0; } @@ -258,28 +226,20 @@ be_visitor_field_cdr_op_ch::visit_typedef (be_typedef *node) int be_visitor_field_cdr_op_ch::visit_union (be_union *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // 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 ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // 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.node (node); - // first generate the enum declaration + // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -287,7 +247,6 @@ be_visitor_field_cdr_op_ch::visit_union (be_union *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp index 6bba94f290c..f98fbe7918e 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp @@ -18,13 +18,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, cdr_op_ci, "$Id$") +#include "be_visitor_array/cdr_op_ci.h" +#include "be_visitor_enum/cdr_op_ci.h" +#include "be_visitor_sequence/cdr_op_ci.h" +#include "be_visitor_structure/cdr_op_ci.h" +#include "be_visitor_union/cdr_op_ci.h" +ACE_RCSID (be_visitor_field, + cdr_op_ci, + "$Id$") // ********************************************** // Visitor for field in the client stubs file. @@ -78,8 +80,6 @@ int be_visitor_field_cdr_op_ci::visit_array (be_array *node) { TAO_OutStream *os = this->ctx_->stream (); - - // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); if (f == 0) @@ -97,7 +97,9 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) // 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 (fname, + '\0', + NAMEBUFSIZE); if (this->ctx_->alias () == 0 // Not a typedef. && node->is_child (this->ctx_->scope ())) @@ -137,10 +139,12 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> " << "_tao_aggregate_" << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << " << "_tao_aggregate_" << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_SCOPE: // This is done in cdr_op_cs and hacked into *.i. @@ -171,18 +175,9 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) // First generate the declaration. ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_array_cdr_op_ci visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_array - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -190,8 +185,6 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -221,9 +214,11 @@ be_visitor_field_cdr_op_ci::visit_enum (be_enum *node) { case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_SCOPE: // Proceed further. @@ -251,18 +246,9 @@ be_visitor_field_cdr_op_ci::visit_enum (be_enum *node) // Generate the typcode for enums. ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_enum - " - "Bad visitor\n"), - -1); - } + be_visitor_enum_cdr_op_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -270,8 +256,6 @@ be_visitor_field_cdr_op_ci::visit_enum (be_enum *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -282,16 +266,15 @@ int be_visitor_field_cdr_op_ci::visit_interface (be_interface *) { TAO_OutStream *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_field_cdr_op_ci::" "visit_interface - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } // Check what is the code generations substate. Are we generating code for @@ -300,12 +283,14 @@ be_visitor_field_cdr_op_ci::visit_interface (be_interface *) { case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> _tao_aggregate." << f->local_name () << ".out ())"; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << _tao_aggregate." << f->local_name () << ".in ())"; + break; case TAO_CodeGen::TAO_CDR_SCOPE: - // Nothing to be done because an interface cannit be declared inside a + // Nothing to be done because an interface cannot be declared inside a // structure. break; default: @@ -344,12 +329,14 @@ be_visitor_field_cdr_op_ci::visit_interface_fwd (be_interface_fwd *) { case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> _tao_aggregate." << f->local_name () << ".out ())"; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << _tao_aggregate." << f->local_name () << ".in ())"; + break; case TAO_CodeGen::TAO_CDR_SCOPE: - // Nothing to be done because an interface cannit be declared inside a + // Nothing to be done because an interface cannot be declared inside a // structure. break; default: @@ -364,6 +351,96 @@ be_visitor_field_cdr_op_ci::visit_interface_fwd (be_interface_fwd *) return 0; } +// Visit value type. +int +be_visitor_field_cdr_op_ci::visit_valuetype (be_valuetype *) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_field *f = this->ctx_->be_node_as_field (); + + if (!f) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_field_cdr_op_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 >> _tao_aggregate." << f->local_name () << ".out ())"; + + break; + case TAO_CodeGen::TAO_CDR_OUTPUT: + *os << "(strm << _tao_aggregate." << f->local_name () << ".in ())"; + + break; + case TAO_CodeGen::TAO_CDR_SCOPE: + // Nothing to be done because a valuetype cannot be declared inside a + // structure. + break; + default: + // Error. + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_field_cdr_op_ci::" + "visit_valuetype - " + "bad sub state\n"), + -1); + } + + return 0; +} + +// Visit value forward type. +int +be_visitor_field_cdr_op_ci::visit_valuetype_fwd (be_valuetype_fwd *) +{ + TAO_OutStream *os = this->ctx_->stream (); + + // Retrieve the field node. + be_field *f = this->ctx_->be_node_as_field (); + + if (f == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_field_cdr_op_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 >> _tao_aggregate." << f->local_name () << ".out ())"; + + break; + case TAO_CodeGen::TAO_CDR_OUTPUT: + *os << "(strm << _tao_aggregate." << f->local_name () << ".in ())"; + + break; + case TAO_CodeGen::TAO_CDR_SCOPE: + // Nothing to be done because a valuetype cannot be declared inside a + // structure. + break; + default: + // Error. + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_field_cdr_op_ci::" + "visit_valuetype_fwd - " + "bad sub state\n"), + -1); + } + + return 0; +} + // Visit predefined type. int be_visitor_field_cdr_op_ci::visit_predefined_type (be_predefined_type *node) @@ -488,9 +565,11 @@ be_visitor_field_cdr_op_ci::visit_sequence (be_sequence *node) { case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_SCOPE: // Proceed further. @@ -520,17 +599,9 @@ be_visitor_field_cdr_op_ci::visit_sequence (be_sequence *node) // 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_field_cdr_op_ci::" - "visit_sequence - " - "Bad visitor\n"), - -1); - } + be_visitor_sequence_cdr_op_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -538,8 +609,6 @@ be_visitor_field_cdr_op_ci::visit_sequence (be_sequence *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -569,9 +638,11 @@ be_visitor_field_cdr_op_ci::visit_string (be_string *) { case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> _tao_aggregate." << f->local_name () << ".out ())"; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << _tao_aggregate." << f->local_name () << ".in ())"; + break; case TAO_CodeGen::TAO_CDR_SCOPE: // Nothing to be done. @@ -612,9 +683,11 @@ be_visitor_field_cdr_op_ci::visit_structure (be_structure *node) { case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_SCOPE: // Proceed further. @@ -643,18 +716,9 @@ be_visitor_field_cdr_op_ci::visit_structure (be_structure *node) // 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 == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_struct - " - "Bad visitor\n"), - -1); - } + be_visitor_structure_cdr_op_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -662,8 +726,6 @@ be_visitor_field_cdr_op_ci::visit_structure (be_structure *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -717,9 +779,11 @@ be_visitor_field_cdr_op_ci::visit_union (be_union *node) { case TAO_CodeGen::TAO_CDR_INPUT: *os << "(strm >> _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "(strm << _tao_aggregate." << f->local_name () << ")"; + return 0; case TAO_CodeGen::TAO_CDR_SCOPE: // Proceed further. @@ -748,18 +812,9 @@ be_visitor_field_cdr_op_ci::visit_union (be_union *node) // Generate the inline code for union. ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_cdr_op_ci visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_union - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -767,62 +822,6 @@ be_visitor_field_cdr_op_ci::visit_union (be_union *node) "codegen failed\n"), -1); } - - delete visitor; - } - - return 0; -} - -// Visit structure type. -int -be_visitor_field_cdr_op_ci::visit_valuetype (be_valuetype *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - // retrieve the field node. - be_field *f = this->ctx_->be_node_as_field (); - - if (f == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_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 >> _tao_aggregate." << f->local_name () << ".out ())"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_aggregate." << f->local_name () << ".in ())"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // Proceed further. - break; - default: - // Error. - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_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. - { - // Valuetype cannot be declared inside any structured type - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_valuetype - logic error. Please report.\n"), - -1); } return 0; @@ -896,7 +895,9 @@ be_visitor_cdr_op_field_decl::visit_array (be_array *node) // the full_name with or without the underscore and use it later on. char fname [NAMEBUFSIZE]; - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); if (this->ctx_->alias () == 0 // Not a typedef. && node->is_child (this->ctx_->scope ())) @@ -942,6 +943,7 @@ be_visitor_cdr_op_field_decl::visit_array (be_array *node) << "_tao_aggregate." << f->local_name () << be_uidt_nl << ")" << be_uidt << be_uidt_nl << ");" << be_uidt_nl; + break; case TAO_CodeGen::TAO_CDR_SCOPE: default: diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp index 93f25b43b70..d62b67833e5 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp @@ -18,133 +18,86 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_visitor_array/cdr_op_cs.h" +#include "be_visitor_sequence/cdr_op_cs.h" +#include "be_visitor_structure/cdr_op_cs.h" +#include "be_visitor_union/cdr_op_cs.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, cdr_op_cs, "$Id$") +ACE_RCSID (be_visitor_field, + cdr_op_cs, + "$Id$") // ********************************************** // visitor for field in the client stubs file // ********************************************** -// constructor -be_visitor_field_cdr_op_cs::be_visitor_field_cdr_op_cs (be_visitor_context *ctx) +be_visitor_field_cdr_op_cs::be_visitor_field_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_field_cdr_op_cs::~be_visitor_field_cdr_op_cs (void) { } -// visit the field node int be_visitor_field_cdr_op_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_cdr_op_cs::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_field_cdr_op_cs::visit_array (be_array *node) { - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && 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_); - - // set the node to be the node being visited. The scope - // is still the same ctx.node (node); - - // first generate the declaration ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_field_cdr_op_cs::visit_enum (be_enum *node) { - 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_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } return 0; } @@ -154,135 +107,87 @@ be_visitor_field_cdr_op_cs::visit_sequence (be_sequence *node) if (node->node_type () != AST_Decl::NT_typedef && node->is_child (this->ctx_->scope ())) { - // 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 - - // set the node to be the node being visited. The scope is - // still the same be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // generate the code for sequences ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_field_cdr_op_cs::visit_structure (be_structure *node) { if (node->node_type () != AST_Decl::NT_typedef && node->is_child (this->ctx_->scope ())) { - // 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_); - // set the node to be the node being visited. The scope is - // still the same ctx.node (node); - - // generate the inline code for structs ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_field_cdr_op_cs::visit_typedef (be_typedef *node) { - // save the typedef node for use in code generation as we visit the - // base type this->ctx_->alias (node); - - // 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_field_cdr_op_cs::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_field_cdr_op_cs::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp index d1aabf2214f..31c468d4e9f 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp @@ -18,39 +18,32 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, field_ch, "$Id$") +#include "be_visitor_enum/enum_ch.h" +#include "be_visitor_sequence/sequence_ch.h" +#include "nr_extern.h" +ACE_RCSID (be_visitor_field, + field_ch, + "$Id$") // ********************************************** -// visitor for field in the client header file +// Visitor for field in the client header file. // ********************************************** -// Constructor. be_visitor_field_ch::be_visitor_field_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// Destructor. be_visitor_field_ch::~be_visitor_field_ch (void) { } -// Visit the field node. int be_visitor_field_ch::visit_field (be_field *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // First generate the type information. - bt = be_type::narrow_from_decl (node->field_type ()); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { @@ -78,9 +71,8 @@ be_visitor_field_ch::visit_field (be_field *node) return 0; } -// =Visit operations on all possible data types that a field can be. +// Visit operations on all possible data types that a field can be. -// Visit array type. int be_visitor_field_ch::visit_array (be_array *node) { @@ -110,18 +102,9 @@ be_visitor_field_ch::visit_array (be_array *node) // First generate the array declaration ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_array_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_array - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -130,8 +113,6 @@ be_visitor_field_ch::visit_array (be_array *node) -1); } - delete visitor; - // Having defined all array type and its supporting operations, now // generate the actual variable that is a field of the structure. *os << "_" << bt->local_name (); @@ -159,7 +140,6 @@ be_visitor_field_ch::visit_array (be_array *node) return 0; } -// Visit enum type. int be_visitor_field_ch::visit_enum (be_enum *node) { @@ -186,18 +166,9 @@ be_visitor_field_ch::visit_enum (be_enum *node) // 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_field_ch::" - "visit_enum - " - "Bad visitor\n"), - -1); - } + be_visitor_enum_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -205,8 +176,6 @@ be_visitor_field_ch::visit_enum (be_enum *node) "codegen failed\n"), -1); } - - delete visitor; } // This was a typedefed array. @@ -229,7 +198,6 @@ be_visitor_field_ch::visit_enum (be_enum *node) return 0; } -// Visit interface type. int be_visitor_field_ch::visit_interface (be_interface *node) { @@ -265,7 +233,6 @@ be_visitor_field_ch::visit_interface (be_interface *node) return 0; } -// Visit interface forward type. int be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) { @@ -301,7 +268,6 @@ be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) return 0; } -// Visit valuetype type. int be_visitor_field_ch::visit_valuetype (be_valuetype *node) { @@ -337,7 +303,6 @@ be_visitor_field_ch::visit_valuetype (be_valuetype *node) return 0; } -// Visit valuetype forward type. int be_visitor_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { @@ -373,7 +338,6 @@ be_visitor_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) return 0; } -// Visit predefined type. int be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) { @@ -389,26 +353,27 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. - if (node->pt () == AST_PredefinedType::PT_pseudo) + if (node->pt () == AST_PredefinedType::PT_object) + { + *os << bt->name () << "_var"; + } + else if (node->pt () == AST_PredefinedType::PT_pseudo) { - // Check if we are dealing with a CORBA::Object, - if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) + // This was a typedefed array. + // ACE_NESTED_CLASS macro generated by nested_type_name + // is necessary if the struct, union, or valuetype containing this + // field was not defined inside a module. In such a case, VC++ + // complains that the non-module scope is not yet fully defined. + UTL_Scope *holds_container = this->ctx_->scope ()->defined_in (); + AST_Decl *hc_decl = ScopeAsDecl (holds_container); + + if (hc_decl->node_type () != AST_Decl::NT_module) { - *os << bt->name () << "_var"; + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); } else { - // ACE_NESTED_CLASS macro generated by nested_type_name - // is not necessary in all cases. - if (bt->defined_in ()->scope_node_type () == AST_Decl::NT_interface) - { - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); - } - else - { - *os << bt->name () << "_var"; - } + *os << bt->name () << "_var"; } } else @@ -434,7 +399,6 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) return 0; } -// Visit sequence type. int be_visitor_field_ch::visit_sequence (be_sequence *node) { @@ -450,29 +414,17 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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); // 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_field_ch::" - "visit_sequence - " - "Bad visitor\n"), - -1); - } + be_visitor_sequence_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -481,24 +433,17 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) -1); } - delete visitor; - // If we are being reused by valutype, this would get generated // in the private section of the OBV_xx class, so we must // generate the typedef for that case elsewhere. if (this->ctx_->scope ()->node_type () != AST_Decl::NT_interface) { - // Generate the anonymous sequence member typedef - // but we must protect against certain versions of g++. - // This provides a consistent name to use instead of the - // implementation-specific name. + // Generate the anonymous sequence member typedef. be_decl *bs = this->ctx_->scope (); - *os << "\n#if !defined (__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_nl - << "typedef " << bt->nested_type_name (bs) + + *os << "typedef " << bt->nested_type_name (bs) << " _" << this->ctx_->node ()->local_name () - << "_seq;\n"; - *os << "#endif /* ! __GNUC__ || ACE_HAS_GNUG_PRE_2_8 */\n" << be_nl; + << "_seq;" << be_nl; } } @@ -527,15 +472,11 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) return 0; } -// Visit string type. int be_visitor_field_ch::visit_string (be_string *node) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // Set the right type. if (node->width () == (long) sizeof (char)) { *os << "TAO_String_Manager"; @@ -548,7 +489,6 @@ be_visitor_field_ch::visit_string (be_string *node) return 0; } -// Visit structure type. int be_visitor_field_ch::visit_structure (be_structure *node) { @@ -564,29 +504,16 @@ be_visitor_field_ch::visit_structure (be_structure *node) bt = node; } - // 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 ())) { - // 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); - // First generate the struct declaration. ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_structure_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_struct - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -594,8 +521,6 @@ be_visitor_field_ch::visit_structure (be_structure *node) "codegen failed\n"), -1); } - - delete visitor; } // This was a typedefed array. @@ -657,29 +582,16 @@ be_visitor_field_ch::visit_union (be_union *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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); - // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_union - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -687,8 +599,6 @@ be_visitor_field_ch::visit_union (be_union *node) "codegen failed\n"), -1); } - - delete visitor; } // This was a typedefed array. diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp index 57d2daa7690..027f32549d7 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp @@ -18,238 +18,167 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_visitor_array/array_ci.h" +#include "be_visitor_sequence/sequence_ci.h" +#include "be_visitor_structure/structure_ci.h" +#include "be_visitor_union/union_ci.h" -#include "be_visitor_field.h" +ACE_RCSID (be_visitor_field, + field_ci, + "$Id$") -ACE_RCSID(be_visitor_field, field_ci, "$Id$") - -// ********************************************** -// visitor for field in the client inline file. -// -// Generate inline code for types that are defined -// inside the structure -// ********************************************** - -// constructor be_visitor_field_ci::be_visitor_field_ci (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor be_visitor_field_ci::~be_visitor_field_ci (void) { } -// visit the field node int be_visitor_field_ci::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); - // first generate the type information + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be -// visit array int be_visitor_field_ci::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. - - // 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 struct declaration + ctx.node (node); 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_field_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit sequence int be_visitor_field_ci::visit_sequence (be_sequence *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); 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_field_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_field_ci::visit_structure (be_structure *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); 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_field_ci::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_field_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 + this->ctx_->alias (node); 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); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_field_ci::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); 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_field_ci::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp index 756c8aa123b..9664770cbf9 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp @@ -18,268 +18,193 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_visitor_array/array_cs.h" +#include "be_visitor_enum/enum_cs.h" +#include "be_visitor_sequence/sequence_cs.h" +#include "be_visitor_structure/structure_cs.h" +#include "be_visitor_union/union_cs.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, field_cs, "$Id$") +ACE_RCSID (be_visitor_field, + field_cs, + "$Id$") // ********************************************** -// visitor for field in the client stubs file +// Visitor for field in the client stubs file. // ********************************************** -// constructor be_visitor_field_cs::be_visitor_field_cs (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor be_visitor_field_cs::~be_visitor_field_cs (void) { } -// visit the field node int be_visitor_field_cs::visit_field (be_field *node) { - // first generate the type information 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); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (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); + "codegen for field type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_field_cs::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be - // defined - - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. - - // 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 struct declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_field_cs::visit_enum (be_enum *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_ENUM_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } int be_visitor_field_cs::visit_sequence (be_sequence *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_field_cs::visit_structure (be_structure *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_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 + this->ctx_->alias (node); 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); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_field_cs::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_home.cpp b/TAO/TAO_IDL/be/be_visitor_home.cpp new file mode 100644 index 00000000000..4d887c5377f --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_home.cpp @@ -0,0 +1,27 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_visitor_home.cpp +// +// = DESCRIPTION +// Visitors for generation of code for a component home. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_visitor_home.h" +#include "be_visitor_context.h" + +ACE_RCSID (be, + be_visitor_home, + "$Id$") + diff --git a/TAO/TAO_IDL/be/be_visitor_interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface.cpp index 3334d14f4fa..b517d8d5492 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface.cpp @@ -1,5 +1,6 @@ // $Id$ // +/* -*- c++ -*- */ // ============================================================================ // // = LIBRARY @@ -16,13 +17,38 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_argument.h" +#include "be_interface.h" +#include "be_attribute.h" +#include "be_constant.h" +#include "be_enum.h" +#include "be_exception.h" +#include "be_operation.h" +#include "be_structure.h" +#include "be_structure_fwd.h" +#include "be_union.h" +#include "be_union_fwd.h" +#include "be_typedef.h" +#include "be_predefined_type.h" +#include "be_helper.h" +#include "be_extern.h" +#include "be_argument.h" +#include "utl_identifier.h" #include "be_visitor_interface.h" +#include "be_visitor_interface.h" +#include "be_visitor_attribute.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_structure.h" +#include "be_visitor_structure_fwd.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" +#include "be_visitor_union_fwd.h" +#include "be_visitor_operation.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_interface/interface.cpp" #include "be_visitor_interface/interface_ch.cpp" #include "be_visitor_interface/interface_ci.cpp" @@ -32,10 +58,6 @@ #include "be_visitor_interface/interface_si.cpp" #include "be_visitor_interface/interface_ss.cpp" #include "be_visitor_interface/interface_is.cpp" -// #include "be_visitor_interface/thru_poa_collocated_sh.cpp" -// #include "be_visitor_interface/thru_poa_collocated_ss.cpp" -// #include "be_visitor_interface/direct_collocated_sh.cpp" -// #include "be_visitor_interface/direct_collocated_ss.cpp" #include "be_visitor_interface/tie_sh.cpp" #include "be_visitor_interface/tie_si.cpp" #include "be_visitor_interface/any_op_ch.cpp" @@ -46,7 +68,6 @@ #include "be_visitor_interface/smart_proxy_ch.cpp" #include "be_visitor_interface/smart_proxy_cs.cpp" #include "be_visitor_interface/ami_interface_ch.cpp" -#include "be_visitor_interface/interceptors_ch.cpp" #include "be_visitor_interface/interceptors_cs.cpp" #include "be_visitor_interface/interceptors_sh.cpp" #include "be_visitor_interface/interceptors_ss.cpp" @@ -76,4 +97,6 @@ #include "be_visitor_interface/amh_rh_ss.cpp" #include "be_visitor_interface/amh_rh_sh.cpp" -ACE_RCSID(be, be_visitor_interface, "$Id$") +ACE_RCSID (be, + be_visitor_interface, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_ch.cpp index cc633dc5b03..24c03a490fe 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_ch.cpp @@ -11,14 +11,13 @@ */ //============================================================================= -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + amh_ch, + "$Id$") -ACE_RCSID(be_visitor_amh_interface, interface, "$Id$") - -be_visitor_amh_interface_ch::be_visitor_amh_interface_ch (be_visitor_context *ctx) +be_visitor_amh_interface_ch::be_visitor_amh_interface_ch ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -114,17 +113,13 @@ be_visitor_amh_interface_ch::visit_interface (be_interface *node) // Generate the body. *os << "{" << be_nl - << "public:" << be_nl + << "public:" << be_idt_nl - // Generate the _ptr_type and _var_type typedefs - // but we must protect against certain versions of g++. - << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_idt_nl + // Generate the _ptr_type and _var_type typedefs. << "typedef " << node->local_name () << "_ptr _ptr_type;" << be_nl << "typedef " << node->local_name () << "_var _var_type;" - << be_uidt_nl - << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n" << be_idt_nl; + << be_nl; // Generate code for the interface definition by traversing thru the // elements of its scope. We depend on the front-end to have made sure @@ -139,6 +134,5 @@ be_visitor_amh_interface_ch::visit_interface (be_interface *node) } node->cli_hdr_gen (I_TRUE); - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp index f7c3359823c..943f5c9f8a1 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp @@ -11,15 +11,14 @@ */ //============================================================================= -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_interface.h" - -#include "be_visitor_operation/amh_rh_sh.h" - -be_visitor_amh_rh_interface_sh::be_visitor_amh_rh_interface_sh -(be_visitor_context *ctx): be_visitor_interface_sh (ctx) +ACE_RCSID (be_visitor_interface, + amh_rh_ss, + "$Id$") + +be_visitor_amh_rh_interface_sh::be_visitor_amh_rh_interface_sh ( + be_visitor_context *ctx + ) + : be_visitor_interface_sh (ctx) { } @@ -38,7 +37,6 @@ int be_visitor_amh_rh_interface_sh::visit_interface (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // Generate the skeleton class name, use the AMH-node name as a @@ -46,12 +44,14 @@ be_visitor_amh_rh_interface_sh::visit_interface (be_interface *node) ACE_CString rh_base_class_name = node->local_name (); // ...and prepend either the "TAO_" prefix... ACE_CString rh_skel_class_name = "TAO_"; + if (!node->is_nested ()) { // ...or the "POA_TAO_" prefix if we are in the global // namespace.... rh_skel_class_name = "POA_TAO_"; } + rh_skel_class_name += rh_base_class_name.c_str (); *os << "class " << rh_skel_class_name.c_str () << ";" << be_nl; @@ -92,5 +92,6 @@ be_visitor_amh_rh_interface_sh::visit_interface (be_interface *node) } *os << be_uidt_nl << "};\n\n"; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp index b5840ed3f26..7ca7785afff 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp @@ -11,14 +11,13 @@ */ //============================================================================= -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_interface, + amh_rh_ss, + "$Id$") -#include "be_visitor_interface.h" -#include "be_visitor_operation/amh_rh_ss.h" - -be_visitor_amh_rh_interface_ss::be_visitor_amh_rh_interface_ss (be_visitor_context *ctx) +be_visitor_amh_rh_interface_ss::be_visitor_amh_rh_interface_ss ( + be_visitor_context *ctx + ) : be_visitor_interface_ss (ctx) { } @@ -38,7 +37,9 @@ int be_visitor_amh_rh_interface_ss::visit_interface (be_interface *node) { if (node->srv_skel_gen () || node->imported ()) - return 0; + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); @@ -52,20 +53,20 @@ be_visitor_amh_rh_interface_ss::visit_interface (be_interface *node) node->compute_full_name (rh_skel_prefix.c_str(), "", buf); ACE_CString rh_skel_full_scope_name ("POA_"); rh_skel_full_scope_name += buf; - delete[] buf; + delete [] buf; ACE_CString rh_skel_class_name_prefix (rh_skel_prefix.c_str ()); + if (!node->is_nested ()) { // ...or the "POA_TAO_" prefix if we are in the global // namespace.... rh_skel_class_name_prefix = "POA_TAO_"; } - //node->compute_full_name (rh_skel_class_name_prefix.c_str(), "", buf); + ACE_CString rh_skel_class_name (rh_skel_class_name_prefix); rh_skel_class_name += node->local_name (); - // constructor *os << be_nl << "// TAO_IDL - Generated from " << __FILE__ << ":" << __LINE__ << be_nl; @@ -89,7 +90,7 @@ be_visitor_amh_rh_interface_ss::visit_interface (be_interface *node) *os << "}\n\n"; - // generate code for elements in the scope (e.g., operations) + // Generate code for elements in the scope (e.g., operations) // We'll rely on the base class (be_visitor_scope) to do the // right thing for us. if (this->visit_scope (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp index 2d01cd2ee3b..4d690cdb2b6 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp @@ -11,12 +11,9 @@ */ //============================================================================= -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" -#include "be_visitor_operation.h" +ACE_RCSID (be_visitor_interface, + amh_sh, + "$Id$") be_visitor_amh_interface_sh::be_visitor_amh_interface_sh ( be_visitor_context *ctx @@ -29,10 +26,10 @@ be_visitor_amh_interface_sh::~be_visitor_amh_interface_sh (void) { } -/** The node is the original interface node but we 'tweak' with the - local_name and the the operation signatures to generate the AMH - skeleton on the 'fly'. -*/ +// The node is the original interface node but we 'tweak' with the +// local_name and the the operation signatures to generate the AMH +// skeleton on the 'fly'. + int be_visitor_amh_interface_sh::visit_interface (be_interface *node) { @@ -47,10 +44,8 @@ be_visitor_amh_interface_sh::visit_interface (be_interface *node) return 0; } - TAO_OutStream *os = this->ctx_->stream (); // output stream - - ACE_CString class_name; // holds the class name - + TAO_OutStream *os = this->ctx_->stream (); + ACE_CString class_name; os->indent (); // We shall have a POA_ prefix only if we are at the topmost level. @@ -366,7 +361,7 @@ be_visitor_amh_interface_sh::add_amh_operation (be_operation *node, original_arg->name ()), -1); - operation->add_argument_to_scope (arg); + operation->be_add_argument (arg); } } } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp index a8a079ffe3e..8f33e20956a 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp @@ -10,14 +10,13 @@ */ //============================================================================= -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_interface, + amh_ss, + "$Id$") -#include "be_visitor_interface.h" -#include "be_visitor_operation.h" - -be_visitor_amh_interface_ss::be_visitor_amh_interface_ss (be_visitor_context *ctx) +be_visitor_amh_interface_ss::be_visitor_amh_interface_ss ( + be_visitor_context *ctx + ) : be_visitor_interface_ss (ctx) { } @@ -45,7 +44,9 @@ be_visitor_amh_interface_ss::visit_interface (be_interface *node) { // Do not generate AMH classes for any sort of implied IDL. if (node->original_interface () != 0) - return 0; + { + return 0; + } return be_visitor_interface_ss::visit_interface (node); } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp index ba0bc444b7e..11c5e47e19c 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, ami_interface_ch, "$Id$") - +ACE_RCSID (be_visitor_interface, + ami_interface_ch, + "$Id$") // ****************************************************** // Interface visitor for client header // ****************************************************** -be_visitor_ami_interface_ch::be_visitor_ami_interface_ch (be_visitor_context *ctx) +be_visitor_ami_interface_ch::be_visitor_ami_interface_ch ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -54,8 +51,6 @@ be_visitor_ami_interface_ch::visit_interface (be_interface *node) // Grab the stream. TAO_OutStream *os = this->ctx_->stream (); - - os->gen_ifdef_macro (node->replacement ()->flat_name (), "_ptr"); // Forward declaration. @@ -67,6 +62,5 @@ be_visitor_ami_interface_ch::visit_interface (be_interface *node) << "_ptr;" << be_nl << be_nl; os->gen_endif (); - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp index 21f9a83a58e..c0ddcab6ee3 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp @@ -19,13 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_interface, + any_op_ch, + "$Id$") // *************************************************************************** // Interface visitor for generating Any operator declarations in the client header @@ -52,6 +48,9 @@ be_visitor_interface_any_op_ch::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the Any <<= and >>= operator declarations. os->indent (); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp index 66b6abd68e3..2f4284fd450 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp @@ -17,13 +17,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_interface, + any_op_cs, + "$Id$") // *************************************************************************** // Interface visitor for generating Any operator declarations in the client @@ -51,124 +47,54 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - // Generate the Any <<= and >>= operator declarations. - - *os << be_nl - << "// TAO_IDL - Generated from " << be_nl + *os << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // Copying insertion. - *os << "void operator<<= (" << be_idt << be_idt_nl - << "CORBA::Any &_tao_any," << be_nl - << node->full_name () << "_ptr _tao_elem" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - if (!node->is_local ()) { - *os << "TAO_OutputCDR stream;" << be_nl << be_nl + // Generate the Any <<= and >>= operator declarations + // Any <<= and >>= operators. + *os << "void" << be_nl + << "operator<<= (" << be_idt << be_idt_nl + << "CORBA::Any &_tao_any," << be_nl + << node->full_name () << "_ptr _tao_elem" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "TAO_OutputCDR stream;" << be_nl << "if (stream << _tao_elem)" << be_idt_nl - << "{" << be_idt_nl; - } - - *os << "_tao_any._tao_replace (" << be_idt << be_idt_nl - << node->tc_name () << ", " << be_nl; - - if (!node->is_local ()) - { - *os << "TAO_ENCAP_BYTE_ORDER," << be_nl - << "stream.begin ()," << be_nl; - } - - *os << "1," << be_nl - << node->full_name () << "::_duplicate (_tao_elem)," << be_nl - << node->name () << "::_tao_any_destructor" << be_uidt_nl - << ");" << be_uidt; - - if (node->is_local ()) - { - *os << be_nl << be_nl - << "_tao_any.contains_local (1);"; - } - - *os << be_uidt_nl; - - if (!node->is_local ()) - { - *os << "}" << be_uidt << be_uidt_nl; - } - - *os << "}\n" << be_nl; - - // Non-copying insertion. - *os << "void operator<<= (" << be_idt << be_idt_nl - << "CORBA::Any &_tao_any," << be_nl - << node->full_name () << "_ptr *_tao_elem" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - - if (!node->is_local ()) - { - *os << "TAO_OutputCDR stream;" << be_nl << be_nl - << "if (stream << *_tao_elem)" << be_idt_nl - << "{" << be_idt_nl; - } - - *os << "_tao_any._tao_replace (" << be_idt << be_idt_nl - << node->tc_name () << ", " << be_nl; - - if (!node->is_local ()) - { - *os << "TAO_ENCAP_BYTE_ORDER," << be_nl - << "stream.begin ()," << be_nl; - } - - *os << "1," << be_nl - << "*_tao_elem," << be_nl - << node->name () << "::_tao_any_destructor" << be_uidt_nl - << ");" << be_uidt; - - if (node->is_local ()) - { - *os << be_nl << be_nl - << "_tao_any.contains_local (1);"; - } - - *os << be_uidt_nl; - - if (!node->is_local ()) - { - *os << "}" << be_uidt << be_uidt_nl; - } - - *os << "}\n" << be_nl; - - // Exraction. - *os << "CORBA::Boolean operator>>= (" << be_idt << be_idt_nl - << "const CORBA::Any &_tao_any," << be_nl - << node->full_name () << "_ptr &_tao_elem" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "ACE_TRY_NEW_ENV" << be_nl - << "{" << be_idt_nl - << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl << be_nl - << "CORBA::Boolean result =" << be_idt_nl - << "type->equivalent (" << be_idt << be_idt_nl - << node->tc_name () << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl - << "ACE_TRY_CHECK;" << be_nl << be_nl - << "if (!result)" << be_idt_nl - << "{" << be_idt_nl - << "return 0; // not equivalent" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - - if (!node->is_local ()) - { - *os << "TAO_InputCDR stream (" << be_idt << be_idt_nl + << "{" << be_idt_nl + << "_tao_any._tao_replace (" << be_idt << be_idt_nl + << node->tc_name () << ", " << be_nl + << "TAO_ENCAP_BYTE_ORDER," << be_nl + << "stream.begin ()," << be_nl + << "1," << be_nl + << node->full_name () << "::_duplicate (_tao_elem)," << be_nl + << node->name () << "::_tao_any_destructor" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "CORBA::Boolean" << be_nl + << "operator>>= (" << be_idt << be_idt_nl + << "const CORBA::Any &_tao_any," << be_nl + << node->full_name () << "_ptr &_tao_elem" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "ACE_TRY_NEW_ENV" << be_nl + << "{" << be_idt_nl + << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl + << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl << be_nl + << "CORBA::Boolean result =" << be_idt_nl + << "type->equivalent (" << be_idt << be_idt_nl + << node->tc_name () << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "ACE_TRY_CHECK;" << be_nl << be_nl + << "if (!result)" << be_idt_nl + << "{" << be_idt_nl + << "return 0; // not equivalent" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "TAO_InputCDR stream (" << be_idt << be_idt_nl << "_tao_any._tao_get_cdr ()," << be_nl << "_tao_any._tao_byte_order ()" << be_uidt_nl << ");" << be_uidt_nl << be_nl @@ -181,50 +107,58 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) << node->name () << "::_tao_any_destructor" << be_uidt_nl << ");" << be_uidt_nl << be_nl << "return 1;" << be_uidt_nl - << "}" << be_uidt << be_uidt_nl; + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl + << "ACE_CATCHANY" << be_nl + << "{" << be_idt_nl + << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl + << "return 0;" << be_uidt_nl + << "}" << be_nl + << "ACE_ENDTRY;" << be_nl + << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl + << "return 0;" << be_uidt_nl + << "}" << be_nl << be_nl; + } + + *os << "#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) || \\" + << be_idt_nl + << " defined (ACE_HAS_GNU_REPO)" << be_nl; + + if (node->is_abstract ()) + { + *os << "template class TAO_Abstract_Manager<"; } else { - *os << "_tao_elem =" << be_idt_nl - << "ACE_reinterpret_cast (" << be_idt << be_idt_nl - << node->name () << "_ptr," << be_nl - << "ACE_const_cast (void *, _tao_any.value ())" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl << be_nl - << "return 1;" << be_uidt_nl; + *os << "template class TAO_Object_Manager<"; } - *os << "}" << be_nl - << "ACE_CATCHANY" << be_nl - << "{" << be_nl - << "}" << be_nl - << "ACE_ENDTRY;"; - - *os << be_nl << be_nl - << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl - << "return 0;"; + *os << node->full_name () << "," + << node->full_name () << "_var>;" << be_uidt_nl + << "#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)" << be_nl; - *os << be_uidt_nl - << "}\n\n"; + if (node->is_abstract ()) + { + *os << "# pragma instantiate TAO_Abstract_Manager<"; + } + else + { + *os << "# pragma instantiate TAO_Object_Manager<"; + } - *os << "#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) || \\" - << be_idt << be_idt_nl - << "defined (ACE_HAS_GNU_REPO)" << be_uidt_nl - << "template class TAO_Object_Manager<" - << node->full_name () << "," - << node->full_name () << "_var>;" << be_uidt_nl - << "#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)" << be_nl - << "# pragma instantiate TAO_Object_Manager<" - << node->full_name () << "," - << node->full_name () << "_var>" << be_nl + *os << node->full_name () << "," + << node->full_name () << "_var>" << be_uidt_nl << "#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */\n\n"; // All we have to do is to visit the scope and generate code. - if (this->visit_scope (node) == -1) + if (!node->is_local ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::visit_interface - " - "codegen for scope failed\n"), - -1); + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface::visit_interface - " + "codegen for scope failed\n"), -1); + } } node->cli_stub_any_op_gen (1); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp index 67068688a0d..2de0f8bf792 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp @@ -1,37 +1,40 @@ //$Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_interface, + base_proxy_broker_ch, + "$Id$") -#include "be_visitor_interface.h" - -ACE_RCSID (be_visitor_interface, base_proxy_broker_ch, "$Id$") - -be_visitor_interface_base_proxy_broker_ch::be_visitor_interface_base_proxy_broker_ch (be_visitor_context *ctx) +be_visitor_interface_base_proxy_broker_ch:: +be_visitor_interface_base_proxy_broker_ch (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_base_proxy_broker_ch::~be_visitor_interface_base_proxy_broker_ch (void) +be_visitor_interface_base_proxy_broker_ch:: +~be_visitor_interface_base_proxy_broker_ch (void) { // No-Op. } int -be_visitor_interface_base_proxy_broker_ch::visit_interface (be_interface *node) +be_visitor_interface_base_proxy_broker_ch::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Base Proxy Broker Declaration " << be_nl << "//" << be_nl << be_nl; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the class declaration. - os->indent (); *os << "class " << be_global->stub_export_macro () << " " << node->base_proxy_broker_name () << be_nl << "{" << be_nl << "public:" diff --git a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp index 3fab08b2919..9717c686dda 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp @@ -1,21 +1,21 @@ -//$Id$ +// +// $Id$ +// -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_interface, + base_proxy_impl_ch, + "$Id$") -#include "be_visitor_interface.h" - -ACE_RCSID (be_visitor_interface, base_proxy_impl_ch, "$Id$") - -be_visitor_interface_base_proxy_impl_ch::be_visitor_interface_base_proxy_impl_ch (be_visitor_context *ctx) +be_visitor_interface_base_proxy_impl_ch:: +be_visitor_interface_base_proxy_impl_ch (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_base_proxy_impl_ch::~be_visitor_interface_base_proxy_impl_ch (void) +be_visitor_interface_base_proxy_impl_ch:: +~be_visitor_interface_base_proxy_impl_ch (void) { // No-Op. } @@ -25,43 +25,59 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // os->indent (); - *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Base Proxy Impl. Declaration" << be_nl << "//" << be_nl << be_nl; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate Class Declaration. *os << "class " << be_global->stub_export_macro () << " " << node->base_proxy_impl_name () << be_idt_nl << ": "; - if (node->n_inherits () > 0) + int n_parents = node->n_inherits (); + int has_concrete_parent = 0; + + if (n_parents > 0) { *os << be_idt; - for (int i = 0; i < node->n_inherits (); i++) + for (int i = 0; i < n_parents; ++i) { be_interface *inherited = be_interface::narrow_from_decl (node->inherits ()[i]); - *os << "public virtual "; - *os << inherited->full_base_proxy_impl_name (); + if (inherited->is_abstract ()) + { + continue; + } - if (i < node->n_inherits () - 1) + if (has_concrete_parent == 1) { // Node is the case of multiple // inheritance, so put a comma. *os << ", " << be_nl; } + + *os << "public virtual "; + *os << inherited->full_base_proxy_impl_name (); + + has_concrete_parent = 1; } - *os << be_uidt << be_uidt_nl; // idt = 0 + if (has_concrete_parent == 1) + { + *os << be_uidt << be_uidt_nl; + } } - else + + if (has_concrete_parent == 0) { - *os << "public virtual TAO_Object_Proxy_Impl" << be_uidt_nl; + *os << "public virtual TAO_Object_Proxy_Impl" << be_uidt << be_uidt_nl; } *os << "{" << be_nl << "public:" @@ -76,7 +92,8 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_base_proxy_impl_ch::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } *os << be_uidt_nl; @@ -91,5 +108,61 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) << "// End Base Proxy Impl. Declaration" << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; + return 0; } + +int +be_visitor_interface_base_proxy_impl_ch::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_base_proxy_impl_ch" + "::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); + be_visitor_operation_base_proxy_impl_ch op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ch.cpp index 5c1b9c100c6..22b6bd53d8a 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ch.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_interface, + cdr_op_ch, + "$Id$") // *************************************************************************** // Interface visitor for generating CDR operator declarations in the client header // *************************************************************************** -be_visitor_interface_cdr_op_ch::be_visitor_interface_cdr_op_ch -(be_visitor_context *ctx) +be_visitor_interface_cdr_op_ch::be_visitor_interface_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -45,15 +42,19 @@ int be_visitor_interface_cdr_op_ch::visit_interface (be_interface *node) { // No CDR operations for locality constraint interfaces. - if (node->cli_hdr_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_hdr_cdr_op_gen () || node->imported () || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); - // generate the CDR << and >> operator declarations + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Generate the CDR << and >> operator declarations. os->indent (); + *os << be_global->stub_export_macro () << " CORBA::Boolean " << "operator<< (TAO_OutputCDR &, const " << node->full_name () << "_ptr );" << be_nl; @@ -61,20 +62,18 @@ be_visitor_interface_cdr_op_ch::visit_interface (be_interface *node) << "operator>> (TAO_InputCDR &, " << node->full_name () << "_ptr &);\n"; - - // set the substate as generating code for the types defined in our scope + // 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_interface_cdr_op_ch::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - node->cli_hdr_cdr_op_gen (1); - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ci.cpp index ac2d4b52d17..a46d835851e 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ci.cpp @@ -18,21 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_interface, + cdr_op_ci, + "$Id$") // *************************************************************************** // Interface visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_interface_cdr_op_ci::be_visitor_interface_cdr_op_ci -(be_visitor_context *ctx) +be_visitor_interface_cdr_op_ci::be_visitor_interface_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -59,7 +56,7 @@ be_visitor_interface_cdr_op_ci::visit_interface (be_interface *node) // First generate code for our children. The reason we do this first is // because the inlined code for our children must be available before - // it in our parent, but we must forward declare the parent + // it is seen in our parent, but we must forward declare the parent // we use operators, so code like this: // // // IDL @@ -71,8 +68,10 @@ be_visitor_interface_cdr_op_ci::visit_interface (be_interface *node) // defined). // + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the CDR << and >> operator declarations. - os->indent (); *os << be_global->stub_export_macro () << " CORBA::Boolean operator<< (" << be_idt << be_idt_nl @@ -100,7 +99,8 @@ be_visitor_interface_cdr_op_ci::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_cdr_op_ci" "::visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } node->cli_inline_cdr_op_gen (1); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp index f3c743a6dfa..b25161cd35a 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp @@ -18,16 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_interface, + cdr_op_cs, + "$Id$") -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, cdr_op_cs, "$Id$") - -be_visitor_interface_cdr_op_cs::be_visitor_interface_cdr_op_cs -(be_visitor_context *ctx) +be_visitor_interface_cdr_op_cs::be_visitor_interface_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -50,6 +47,7 @@ be_visitor_interface_cdr_op_cs::visit_interface (be_interface *node) // Set the substate as generating code for the types defined in our scope. this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); + // Visit the scope and generate code. if (this->visit_scope (node) == -1) { @@ -61,6 +59,9 @@ be_visitor_interface_cdr_op_cs::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set the sub state as generating code for the output operator. this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_OUTPUT); @@ -69,7 +70,17 @@ be_visitor_interface_cdr_op_cs::visit_interface (be_interface *node) << "const " << node->full_name () << "_ptr _tao_objref" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl; - *os << "CORBA::Object_ptr _tao_corba_obj = _tao_objref;" << be_nl; + + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr"; + } + else + { + *os << "CORBA::Object_ptr"; + } + + *os << " _tao_corba_obj = _tao_objref;" << be_nl; *os << "return (strm << _tao_corba_obj);" << be_uidt_nl << "}\n\n"; @@ -83,16 +94,53 @@ be_visitor_interface_cdr_op_cs::visit_interface (be_interface *node) << "{" << be_idt_nl; *os << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl; - *os << "CORBA::Object_var obj;" << be_nl; + + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase_var obj;" << be_nl << be_nl; + } + else + { + *os << "CORBA::Object_var obj;" << be_nl << be_nl; + } + *os << "if ((strm >> obj.inout ()) == 0)" << be_idt_nl + << "{" << be_idt_nl << "return 0;" << be_uidt_nl - << "// narrow to the right type" << be_nl; - *os << "_tao_objref =" << be_idt_nl - << node->full_name () << "::_unchecked_narrow (" - << be_idt << be_idt_nl - << "obj.in ()" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; + << "}" << be_uidt_nl << be_nl + << "// Narrow to the right type." << be_nl; + + if (node->is_abstract ()) + { + *os << "if (obj->_is_objref ())" << be_idt_nl + << "{" << be_idt_nl + << "_tao_objref =" << be_idt_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "obj.in ()" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_uidt_nl + << "else" << be_idt_nl + << "{" << be_idt_nl + << "_tao_objref =" << be_idt_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "obj._retn ()" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + } + else + { + *os << "_tao_objref =" << be_idt_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "obj.in ()" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + } + *os << "ACE_TRY_CHECK;" << be_nl; *os << "return 1;" << be_uidt_nl; *os << "}" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp index 877a0abbf10..a00dbf149c2 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp @@ -1,44 +1,49 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + direct_proxy_impl_sh, + "$Id$") -ACE_RCSID (be_visitor_interface, direct_proxy_broker_impl_sh, "$Id$") - -be_visitor_interface_direct_proxy_impl_sh::be_visitor_interface_direct_proxy_impl_sh (be_visitor_context *ctx) +be_visitor_interface_direct_proxy_impl_sh:: +be_visitor_interface_direct_proxy_impl_sh (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } - -be_visitor_interface_direct_proxy_impl_sh::~be_visitor_interface_direct_proxy_impl_sh (void) +be_visitor_interface_direct_proxy_impl_sh:: +~be_visitor_interface_direct_proxy_impl_sh (void) { // No-Op. } int -be_visitor_interface_direct_proxy_impl_sh::visit_interface (be_interface *node) +be_visitor_interface_direct_proxy_impl_sh::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); - // os->gen_ifdef_macro (node->flat_name (), "DIRECT_PROXY_IMPL_"); os->decr_indent (0); *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Direct Impl. Declaration" << be_nl << "//" << be_nl << be_nl; // Generate Class Declaration. *os << "class " << be_global->skel_export_macro () << " " << node->direct_proxy_impl_name (); - *os << " : " << be_idt_nl << "public virtual " << node->full_base_proxy_impl_name () + *os << " : " << be_idt_nl << "public virtual " + << node->full_base_proxy_impl_name () << "," << be_nl << "public virtual " << "TAO_Direct_Object_Proxy_Impl"; if (node->n_inherits () > 0) { *os << "," << be_nl; + for (int i = 0; i < node->n_inherits (); i++) { be_interface *inherited = @@ -46,13 +51,14 @@ be_visitor_interface_direct_proxy_impl_sh::visit_interface (be_interface *node) *os << "public virtual "; *os << inherited->full_direct_proxy_impl_name (); - if (i < node->n_inherits () - 1) // node is the case of multiple - // inheritance, so put a comma + + if (i < node->n_inherits () - 1) { *os << ", "; } + *os << be_nl; - } // end of for loop + } } *os << be_uidt_nl; @@ -69,7 +75,8 @@ be_visitor_interface_direct_proxy_impl_sh::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) direct_proxy_impl_sh::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } *os << "};" << be_uidt << be_nl << be_nl; @@ -78,7 +85,61 @@ be_visitor_interface_direct_proxy_impl_sh::visit_interface (be_interface *node) << "// Direct Proxy Impl. Declaration" << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; - // os->gen_endif (); + return 0; +} + +int +be_visitor_interface_direct_proxy_impl_sh::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_thru_poa_proxy_" + "impl_sh::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); + be_visitor_operation_proxy_impl_xh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + return 0; } + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp index 1572fc0390b..1ba64f475f6 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp @@ -1,47 +1,45 @@ +// //$Id$ +// -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_interface, + direct_proxy_impl_ss, + "$Id$") -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, direct_proxy_impl_ss, "$Id$") - -be_visitor_interface_direct_proxy_impl_ss::be_visitor_interface_direct_proxy_impl_ss (be_visitor_context *ctx) +be_visitor_interface_direct_proxy_impl_ss:: +be_visitor_interface_direct_proxy_impl_ss (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_direct_proxy_impl_ss::~be_visitor_interface_direct_proxy_impl_ss (void) +be_visitor_interface_direct_proxy_impl_ss:: +~be_visitor_interface_direct_proxy_impl_ss (void) { // No-Op. } int -be_visitor_interface_direct_proxy_impl_ss::visit_interface (be_interface *node) +be_visitor_interface_direct_proxy_impl_ss::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); os->indent (); + *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Direct Proxy Implementation" << be_nl << "//" << be_nl << be_nl; - // Ctor Implementation *os << node->full_direct_proxy_impl_name () << "::" << node->direct_proxy_impl_name () << " (void)" << be_nl << "{}" << be_nl << be_nl; - /* - // Dtor Implementation - *os << node->full_direct_proxy_impl_name () << "::" - << "~" << node->direct_proxy_impl_name () << " (void)" - << be_nl << "{}" << be_nl << be_nl; - */ + if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -56,5 +54,72 @@ be_visitor_interface_direct_proxy_impl_ss::visit_interface (be_interface *node) << "// End Direct Proxy Implementation" << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl; + return 0; } + +int +be_visitor_interface_direct_proxy_impl_ss::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_direct_proxy" + "_impl_ss::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS); + be_visitor_operation_direct_proxy_impl_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ch.cpp deleted file mode 100644 index 1976a1499ab..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ch.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -// $Id$ -// -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interceptors_ch.cpp -// -// = DESCRIPTION -// This provides code generation for interceptor classes for an -// interface in the client header. -// -// = AUTHOR -// Kirthika Parameswaran <kirthika@cs.wustl.edu> -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interceptors_ch, "$Id$") - - -// ************************************************************ -// interceptor class in header -// ************************************************************ - - -be_visitor_interface_interceptors_ch::be_visitor_interface_interceptors_ch -(be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_interceptors_ch::~be_visitor_interface_interceptors_ch (void) -{ -} - -int be_visitor_interface_interceptors_ch::visit_interface (be_interface *) -{ - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp index b5cc2b9adc7..d22df743fd8 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp @@ -18,34 +18,33 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interceptors_cs, "$Id$") - +ACE_RCSID (be_visitor_interface, + interceptors_cs, + "$Id$") // ************************************************************ // interceptor class in header // ************************************************************ - -be_visitor_interface_interceptors_cs::be_visitor_interface_interceptors_cs -(be_visitor_context *ctx) +be_visitor_interface_interceptors_cs::be_visitor_interface_interceptors_cs ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } -be_visitor_interface_interceptors_cs::~be_visitor_interface_interceptors_cs (void) +be_visitor_interface_interceptors_cs::~be_visitor_interface_interceptors_cs ( + void + ) { } int be_visitor_interface_interceptors_cs::visit_interface (be_interface *node) { if (node->is_local ()) - return 0; + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); @@ -53,7 +52,11 @@ int be_visitor_interface_interceptors_cs::visit_interface (be_interface *node) // elements of its scope. We depend on the front-end to have made sure // that only legal syntactic elements appear in our scope. + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + os->indent (); + *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl; // Generate code for the interface definition by traversing thru the @@ -67,11 +70,79 @@ int be_visitor_interface_interceptors_cs::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ch::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } *os << "#endif /* TAO_HAS_INTERCEPTORS */\n"; return 0; +} + +int +be_visitor_interface_interceptors_cs::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_interceptors_cs::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + AST_Decl::NodeType nt = d->node_type (); + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); + be_visitor_operation_interceptors_cs op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + return 0; } + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_sh.cpp index 4177f137a55..9171ffc89b7 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_sh.cpp @@ -18,27 +18,25 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interceptors_sh, "$Id$") - +ACE_RCSID (be_visitor_interface, + interceptors_sh, + "$Id$") // ************************************************************ // interceptor class in header // ************************************************************ -be_visitor_interface_interceptors_sh::be_visitor_interface_interceptors_sh -(be_visitor_context *ctx) +be_visitor_interface_interceptors_sh::be_visitor_interface_interceptors_sh ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } -be_visitor_interface_interceptors_sh::~be_visitor_interface_interceptors_sh (void) +be_visitor_interface_interceptors_sh::~be_visitor_interface_interceptors_sh ( + void + ) { } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp index 2ff6cc66b4d..6860fc7faf7 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp @@ -18,27 +18,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interceptors_ss, "$Id$") - +ACE_RCSID (be_visitor_interface, + interceptors_ss, + "$Id$") // ************************************************************ // interceptor class in header // ************************************************************ - -be_visitor_interface_interceptors_ss::be_visitor_interface_interceptors_ss -(be_visitor_context *ctx) +be_visitor_interface_interceptors_ss::be_visitor_interface_interceptors_ss ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } -be_visitor_interface_interceptors_ss::~be_visitor_interface_interceptors_ss (void) +be_visitor_interface_interceptors_ss::~be_visitor_interface_interceptors_ss ( + void + ) { } @@ -51,6 +48,9 @@ int be_visitor_interface_interceptors_ss::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate code for the interface definition by traversing thru the // elements of its scope. We depend on the front-end to have made sure // that only legal syntactic elements appear in our scope. @@ -66,10 +66,77 @@ int be_visitor_interface_interceptors_ss::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ch::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } *os << "#endif /* TAO_HAS_INTERCEPTORS */\n"; return 0; } + +int +be_visitor_interface_interceptors_ss::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_interceptors_ss::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); + be_visitor_operation_interceptors_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp index 1ccc1b815d2..9947f290e92 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp @@ -18,20 +18,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface, "$Id$") +ACE_RCSID (be_visitor_interface, + interface, + "$Id$") // ****************************************************** // Generic Interface visitor // ****************************************************** be_visitor_interface::be_visitor_interface (be_visitor_context *ctx) - : be_visitor_scope (ctx) + : be_visitor_scope (ctx) { } @@ -39,7 +35,7 @@ be_visitor_interface::~be_visitor_interface (void) { } -// this method must be overridden by the derived interface visitors +// This method must be overridden by the derived interface visitors. int be_visitor_interface::visit_interface (be_interface *) { @@ -47,35 +43,156 @@ be_visitor_interface::visit_interface (be_interface *) } int +be_visitor_interface::visit_scope (be_scope *node) +{ + if (this->be_visitor_scope::visit_scope (node) == -1) + { + return -1; + } + + be_interface *intf = be_interface::narrow_from_scope (node); + + if (intf == 0) + { + return 0; + } + + if (intf->is_abstract ()) + { + return 0; + } + + if (! intf->has_mixed_parentage ()) + { + return 0; + } + + be_interface::tao_code_emitter helper = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_INTERFACE_CH: + helper = + be_visitor_interface_ch::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: + helper = + be_visitor_interface_base_proxy_impl_ch::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: + helper = + be_visitor_interface_remote_proxy_impl_ch::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_CS: + helper = + be_visitor_interface_cs::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: + helper = + be_visitor_interface_remote_proxy_impl_cs::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: + helper = + be_visitor_interface_interceptors_cs::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_SH: + helper = + be_visitor_interface_sh::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: + helper = + be_visitor_interface_thru_poa_proxy_impl_sh::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: + helper = + be_visitor_interface_direct_proxy_impl_sh::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_SS: + helper = + be_visitor_interface_ss::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: + helper = + be_visitor_interface_interceptors_ss::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: + helper = + be_visitor_interface_direct_proxy_impl_ss::gen_abstract_ops_helper; + break; + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS: + helper = + be_visitor_interface_thru_poa_proxy_impl_ss::gen_abstract_ops_helper; + break; + default: + break; + } + + if (helper == 0) + { + return 0; + } + + int status = + intf->traverse_inheritance_graph (helper, + this->ctx_->stream (), + I_TRUE); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_*::" + "visit_scope - " + "traversal of inheritance graph failed\n"), + -1); + } + + return 0; +} + +int be_visitor_interface::is_amh_rh_node (be_interface *node) { //If, is implied-IDL - if (node->original_interface () != 0) - { - // and the name starts with AMH - if (ACE_OS::strncmp (node->local_name (), "AMH", 3) == 0) - { - // then it is an AMH node - return 1; - } - } + if (node->original_interface () != 0) + { + // and the name starts with AMH + if (ACE_OS::strncmp (node->local_name (), "AMH", 3) == 0) + { + // then it is an AMH node. + return 1; + } + } + return 0; } -// =all common visit methods for interface visitor +void +be_visitor_interface::add_abstract_op_args (AST_Operation *old_op, + be_operation &new_op) +{ + AST_Decl *d = 0; + + for (UTL_ScopeActiveIterator si (old_op, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + new_op.add_to_scope (d); + } + + new_op.be_add_exceptions (old_op->exceptions ()); +} + +// All common visit methods for interface visitor. -// visit an attribute int be_visitor_interface::visit_attribute (be_attribute *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 + // 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.node (node); - // 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_INTERFACE_CH: @@ -102,9 +219,6 @@ be_visitor_interface::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CS); break; - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CH); - break; case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CS); break; @@ -120,19 +234,14 @@ be_visitor_interface::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_INTERFACE_TIE_SI: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI); break; - - case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_BASE_PROXY_IMPL_CH); break; - - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_PROXY_IMPL_XH); break; - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_REMOTE_PROXY_IMPL_CS); break; @@ -156,7 +265,6 @@ be_visitor_interface::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SH: case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SS: case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CS: - case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CS: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SH: @@ -167,8 +275,6 @@ be_visitor_interface::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS: case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SH: case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SS: - - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: @@ -182,55 +288,51 @@ be_visitor_interface::visit_attribute (be_attribute *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_attribute - " - "Bad context state\n: " ), + "Bad context state\n: "), -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_attribute - " - "NUL visitor\n" - ), -1); - } + // Same visitor for all the above cases where an action is taken. + be_visitor_attribute visitor (&ctx); - // let the node accept this visitor - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_attribute - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit a constant int be_visitor_interface::visit_constant (be_constant *node) { - // instantiate a visitor context with a copy of our context. This info + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: @@ -238,7 +340,6 @@ be_visitor_interface::visit_constant (be_constant *node) case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: @@ -250,7 +351,6 @@ be_visitor_interface::visit_constant (be_constant *node) case TAO_CodeGen::TAO_INTERFACE_SS: case TAO_CodeGen::TAO_INTERFACE_TIE_SH: case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CS: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SH: @@ -273,81 +373,86 @@ be_visitor_interface::visit_constant (be_constant *node) case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS: case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: - case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done - - default: + return 0; // nothing to be done + default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_constant - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_constant - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_interface::visit_enum (be_enum *node) { - // instantiate a visitor context with a copy of our context. This info + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CI: case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: @@ -356,7 +461,6 @@ be_visitor_interface::visit_enum (be_enum *node) case TAO_CodeGen::TAO_INTERFACE_SS: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: @@ -388,8 +492,7 @@ be_visitor_interface::visit_enum (be_enum *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done - + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -400,26 +503,15 @@ be_visitor_interface::visit_enum (be_enum *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } @@ -427,41 +519,70 @@ be_visitor_interface::visit_enum (be_enum *node) int be_visitor_interface::visit_exception (be_exception *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -469,7 +590,6 @@ be_visitor_interface::visit_exception (be_exception *node) case TAO_CodeGen::TAO_INTERFACE_SS: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: @@ -501,8 +621,7 @@ be_visitor_interface::visit_exception (be_exception *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done - + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -513,26 +632,15 @@ be_visitor_interface::visit_exception (be_exception *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_exception - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_exception - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } @@ -541,17 +649,16 @@ int be_visitor_interface::visit_operation (be_operation *node) { - // instantiate a visitor context with a copy of our context. This info + // Instantiate a visitor context with a copy of our context. This info // will be modified ased 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 + ctx.node (node); + int status = 1; switch (this->ctx_->state ()) { + // These first two cases may have the context state changed + // by a strategy, so we use the visitor factory below. case TAO_CodeGen::TAO_INTERFACE_CH: ctx.state (TAO_CodeGen::TAO_OPERATION_CH); break; @@ -559,70 +666,133 @@ be_visitor_interface::visit_operation (be_operation *node) ctx.state (TAO_CodeGen::TAO_OPERATION_CS); break; case TAO_CodeGen::TAO_INTERFACE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SH); + be_visitor_operation_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_IH: - ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_IH); + be_visitor_operation_ih visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SS); + be_visitor_operation_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_IS: - ctx.state (TAO_CodeGen::TAO_OPERATION_IS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_IS); + be_visitor_operation_is visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SH); + be_visitor_operation_tie_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SI); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SI); + be_visitor_operation_tie_si visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CH); + be_visitor_operation_smart_proxy_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS); + be_visitor_operation_smart_proxy_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CS); + be_visitor_operation_interceptors_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SH); + be_visitor_operation_interceptors_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_SS); + be_visitor_operation_interceptors_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); + be_visitor_operation_base_proxy_impl_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); - break; - - // AMH stuff + { + ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); + be_visitor_operation_proxy_impl_xh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_AMH_RH_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_OPERATION_AMH_RH_SH); + be_visitor_amh_rh_operation_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_AMH_RH_SS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_AMH_RH_SS); + be_visitor_amh_rh_operation_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); + be_visitor_operation_remote_proxy_impl_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS); + be_visitor_operation_thru_poa_proxy_impl_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS); - break; - + { + ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_PROXY_IMPL_SS); + be_visitor_operation_direct_proxy_impl_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: @@ -641,30 +811,44 @@ be_visitor_interface::visit_operation (be_operation *node) } } - // Change the state depending on the kind of node strategy + if (status == 0) + { + return 0; + } + else if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface::" + "visit_operation - " + "failed to accept visitor\n"), + -1); + } + + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state ())); - // grab the appropriate visitor + // Grab the appropriate visitor. be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // visit the node using this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; @@ -673,29 +857,30 @@ be_visitor_interface::visit_operation (be_operation *node) // the node. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); - // grab the appropriate visitor + // Grab the appropriate visitor. visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // visit the node using this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } @@ -703,45 +888,73 @@ be_visitor_interface::visit_operation (be_operation *node) return 0; } -// Visit an structure. int be_visitor_interface::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -749,7 +962,6 @@ be_visitor_interface::visit_structure (be_structure *node) case TAO_CodeGen::TAO_INTERFACE_SS: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: @@ -787,73 +999,176 @@ be_visitor_interface::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_interface::visit_structure_fwd (be_structure_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_INTERFACE_CH: + { + ctx.state (TAO_CodeGen::TAO_STRUCT_FWD_CH); + be_visitor_structure_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_INTERFACE_CI: + case TAO_CodeGen::TAO_INTERFACE_CS: + case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: + case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: + case TAO_CodeGen::TAO_INTERFACE_SH: + case TAO_CodeGen::TAO_INTERFACE_IH: + case TAO_CodeGen::TAO_INTERFACE_IS: + case TAO_CodeGen::TAO_INTERFACE_SI: + case TAO_CodeGen::TAO_INTERFACE_SS: + case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: + case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: + case TAO_CodeGen::TAO_INTERFACE_TIE_SH: + case TAO_CodeGen::TAO_INTERFACE_TIE_SI: + + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CS: + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SS: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_BROKER_CH: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_BROKER_CS: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CH: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS: + case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SH: + case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SS: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CS: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SS: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CS: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS: + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: + + case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: + case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface::" + "visit_structure_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); + "visit_structure_fwd - " + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit a union int be_visitor_interface::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -861,7 +1176,6 @@ be_visitor_interface::visit_union (be_union *node) case TAO_CodeGen::TAO_INTERFACE_SS: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: @@ -893,79 +1207,182 @@ be_visitor_interface::visit_union (be_union *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_interface::visit_union_fwd (be_union_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_INTERFACE_CH: + { + ctx.state (TAO_CodeGen::TAO_UNION_FWD_CH); + be_visitor_union_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_INTERFACE_CI: + case TAO_CodeGen::TAO_INTERFACE_CS: + case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: + case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: + case TAO_CodeGen::TAO_INTERFACE_SH: + case TAO_CodeGen::TAO_INTERFACE_IH: + case TAO_CodeGen::TAO_INTERFACE_IS: + case TAO_CodeGen::TAO_INTERFACE_SI: + case TAO_CodeGen::TAO_INTERFACE_SS: + case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: + case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: + case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: + case TAO_CodeGen::TAO_INTERFACE_TIE_SH: + case TAO_CodeGen::TAO_INTERFACE_TIE_SI: + + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CS: + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SS: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_BROKER_CH: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_BROKER_CS: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CH: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS: + case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SH: + case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SS: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CS: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SH: + case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SS: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: + case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CS: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: + case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS: + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: + case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS: + + case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: + case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface::" + "visit_union_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" - "visit_union - " - "failed to accept visitor\n" - ), -1); + "visit_union_fwd - " + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit a typedef int be_visitor_interface::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -973,7 +1390,6 @@ be_visitor_interface::visit_typedef (be_typedef *node) case TAO_CodeGen::TAO_INTERFACE_SS: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH: case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS: - case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH: case TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS: @@ -1005,36 +1421,25 @@ be_visitor_interface::visit_typedef (be_typedef *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_typedef - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_typedef - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp index ff4e5e6e007..467b7c46f93 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp @@ -18,14 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_interface.h" #include "be_visitor_typecode/typecode_decl.h" -ACE_RCSID(be_visitor_interface, interface_ch, "$Id$") - +ACE_RCSID (be_visitor_interface, + interface_ch, + "$Id$") // ****************************************************** // Interface visitor for client header @@ -43,336 +40,466 @@ be_visitor_interface_ch::~be_visitor_interface_ch (void) int be_visitor_interface_ch::visit_interface (be_interface *node) { + if (node->cli_hdr_gen () || node->imported ()) + { + return 0; + } + TAO_OutStream *os = this->ctx_->stream (); long i; - // If not already generated and not imported. - if (!node->cli_hdr_gen () && !node->imported ()) - { - // == STEP 1: generate the class name and class names we inherit == + // == STEP 1: generate the class name and class names we inherit == - // Generate the ifdefined macro for the _ptr type. - os->gen_ifdef_macro (node->flat_name (), - "_ptr"); + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + // Generate the ifdefined macro for the _ptr type. + os->gen_ifdef_macro (node->flat_name (), + "_ptr"); - // The following two are required to be under the ifdef macro to avoid - // multiple declarations. - // Forward declaration. - *os << "class " << node->local_name () << ";" << be_nl; - // Generate the _ptr declaration. - *os << "typedef " << node->local_name () << " *" - << node->local_name () << "_ptr;" << be_nl; + // The following two are required to be under the ifdef macro to avoid + // multiple declarations. - os->gen_endif (); + // Forward declaration. + *os << "class " << node->local_name () << ";" << be_nl; + // Generate the _ptr declaration. + *os << "typedef " << node->local_name () << " *" + << node->local_name () << "_ptr;" << be_nl; - // Generate the ifdefined macro for the var type. - os->gen_ifdef_macro (node->flat_name (), "_var"); + os->gen_endif (); - // Generate the _var declaration. - if (node->gen_var_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ch::" - "visit_interface - " - "codegen for _var failed\n"), - -1); - } + // Generate the ifdefined macro for the var type. + os->gen_ifdef_macro (node->flat_name (), "_var"); - os->gen_endif (); + // Generate the _var declaration. + if (node->gen_var_defn () == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_ch::" + "visit_interface - " + "codegen for _var failed\n"), + -1); + } - // Generate the ifdef macro for the _out class. - os->gen_ifdef_macro (node->flat_name (), - "_out"); + os->gen_endif (); - // Generate the _out declaration. - if (node->gen_out_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ch::" - "visit_interface - " - "codegen for _out failed\n"), - -1); - } + // Generate the ifdef macro for the _out class. + os->gen_ifdef_macro (node->flat_name (), + "_out"); - // Generate the endif macro. - os->gen_endif (); + // Generate the _out declaration. + if (node->gen_out_defn () == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_ch::" + "visit_interface - " + "codegen for _out failed\n"), + -1); + } - *os << "// *************************************************************" - << be_nl - << "// " << node->name () << be_nl - << "// TAO_IDL - Generated from" << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl - << "// *************************************************************" + // Generate the endif macro. + os->gen_endif (); + + // The above code could have been executed by the forward declaration + // as long as it wasn't imported. The code below can only be + // executed by an interface definition, also non-imported. + if (node->imported ()) + { + return 0; + } + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Now the interface definition itself. + os->gen_ifdef_macro (node->flat_name ()); + + if (!node->is_local () && !node->is_abstract ()) + { + // Forward class declaration + *os << "// Forward Classes Declaration." << be_nl + << "class " << node->base_proxy_impl_name () << ";" << be_nl + << "class " << node->remote_proxy_impl_name () << ";" << be_nl + << "class " << node->base_proxy_broker_name () << ";" << be_nl + << "class " << node->remote_proxy_broker_name () << ";" << be_nl << be_nl; + } - // Now the interface definition itself. - os->gen_ifdef_macro (node->flat_name ()); + // Now generate the class definition. + *os << "class " << be_global->stub_export_macro () + << " " << node->local_name () << be_idt_nl + << ": " ; - if (!node->is_local ()) - { - // Forward class declaration - *os << "// Forward Classes Declaration." << be_nl - << "class " << node->base_proxy_impl_name () << ";" << be_nl - << "class " << node->remote_proxy_impl_name () << ";" << be_nl - << "class " << node->base_proxy_broker_name () << ";" << be_nl - << "class " << node->remote_proxy_broker_name () << ";" - << be_nl << be_nl; - } + long nparents = node->n_inherits (); + int has_concrete_parent = 0; - // Now generate the class definition. - *os << "class " << be_global->stub_export_macro () - << " " << node->local_name () << be_idt_nl - << ": " ; + // If node interface inherits from other interfaces. + if (nparents > 0) + { + *os << be_idt; - // If node interface inherits from other interfaces. - if (node->n_inherits () > 0) + for (i = 0; i < nparents; ++i) { - *os << be_idt; + if (! node->inherits ()[i]->is_abstract ()) + { + has_concrete_parent = 1; + } + + *os << "public virtual " + << node->inherits ()[i]->name (); - for (i = 0; i < node->n_inherits (); i++) + if (i < nparents - 1) { - *os << "public virtual " - << node->inherits ()[i]->name (); - - if (i < node->n_inherits () - 1) - { - // Node has multiple inheritance, so put a comma. - *os << "," << be_nl; - } + // Node has multiple inheritance, so put a comma. + *os << "," << be_nl; } + } + if (has_concrete_parent == 1 || node->is_abstract ()) + { *os << be_uidt << be_uidt_nl; } - else + else if (! node->is_abstract ()) { - // We do not inherit from anybody, hence we do so from the base - // CORBA::Object class. - *os << "public virtual CORBA_Object" << be_uidt_nl; + *os << "," << be_nl; } + } + else if (node->is_abstract ()) + { + *os << "public virtual CORBA::AbstractBase" << be_uidt_nl; + } - // Generate the body. + if (has_concrete_parent == 0 && ! node->is_abstract ()) + { + *os << "public virtual CORBA::Object"; + + if (nparents > 0) + { + *os << be_uidt; + } + + *os << be_uidt_nl; + } - *os << "{" << be_nl - << "public:" << be_nl + // Generate the body. - // Generate the _ptr_type and _var_type typedefs - // but we must protect against certain versions of g++. - << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_idt_nl - << "typedef " << node->local_name () << "_ptr _ptr_type;" - << be_nl - << "typedef " << node->local_name () << "_var _var_type;" - << be_uidt_nl - << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n" << be_idt_nl; - - // Generate the static variable that we use for narrowing. - *os << "static int _tao_class_id;" << be_nl << be_nl; - - // Generate the static _duplicate, _narrow, and _nil operations. - *os << "// The static operations." << be_nl - << "static " << node->local_name () << "_ptr " << "_duplicate (" - << node->local_name () << "_ptr obj);" << be_nl << be_nl - << "static " << node->local_name () << "_ptr " - << "_narrow (" << be_idt << be_idt_nl - << "CORBA::Object_ptr obj" << be_nl - << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; + *os << "{" << be_nl + << "public:" << be_idt_nl + + // Generate the _ptr_type and _var_type typedefs. + << "typedef " << node->local_name () << "_ptr _ptr_type;" + << be_nl + << "typedef " << node->local_name () << "_var _var_type;" + << be_nl; + + // Generate the static variable that we use for narrowing. + *os << "static int _tao_class_id;" << be_nl << be_nl; + + // Generate the static _duplicate, _narrow, and _nil operations. + *os << "// The static operations." << be_nl + << "static " << node->local_name () << "_ptr " << "_duplicate (" + << node->local_name () << "_ptr obj);" << be_nl << be_nl + << "static " << node->local_name () << "_ptr " + << "_narrow (" << be_idt << be_idt_nl; + + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr obj" << be_nl; + } + else + { + *os << "CORBA::Object_ptr obj" << be_nl; + } + + *os << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; + + // There's no need for an _unchecked_narrow for locality + // constrained object. + *os << "static " << node->local_name () << "_ptr " + << "_unchecked_narrow (" << be_idt << be_idt_nl; + + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr obj" << be_nl; + } + else + { + *os << "CORBA::Object_ptr obj" << be_nl; + } - // There's no need for an _unchecked_narrow for locality - // constrained object. - *os << "static " << node->local_name () << "_ptr " - << "_unchecked_narrow (" << be_idt << be_idt_nl - << "CORBA::Object_ptr obj" << be_nl + *os << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; + + // This method is defined in the header file to workaround old + // g++ problems. + *os << "static " << node->local_name () << "_ptr _nil (void)" + << be_idt_nl << "{" << be_idt_nl + << "return (" << node->local_name () + << "_ptr)0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + if (node->is_abstract ()) + { + *os << "static foo_ptr _downcast (CORBA::AbstractBase_ptr abs);" + << be_nl << be_nl; + } + + // No Any operator for local interfaces. + if (! node->is_local () && be_global->any_support ()) + { + *os << "static void _tao_any_destructor (void*);" << be_nl << be_nl; + } + + // Generate code for the interface definition by traversing thru the + // elements of its scope. We depend on the front-end to have made sure + // that only legal syntactic elements appear in our scope. + + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_ch::" + "visit_interface - " + "codegen for scope failed\n"), + -1); + } + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // If we inherit from both CORBA::Object and CORBA::AbstractBase, + // we have to override _add_ref() to avoid ambiguity, because it is + // called in _tao_Queryinterface(). + if (node->has_mixed_parentage ()) + { + *os << "virtual void _add_ref (void);" << be_nl << be_nl; + } + + // The _is_a method + if (! node->is_local ()) + { + *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl + << "const char *type_id" << be_nl << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl << ");" << be_uidt_nl << be_nl; + } - // This method is defined in the header file to workaround old - // g++ problems. - *os << "static " << node->local_name () << "_ptr _nil (void)" - << be_idt_nl << "{" << be_idt_nl - << "return (" << node->local_name () - << "_ptr)0;" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; + // The _tao_QueryInterface method. + *os << "virtual void *_tao_QueryInterface (ptr_arith_t type);" + << be_nl << be_nl; - *os << "static void _tao_any_destructor (void*);" << be_nl << be_nl; + // The _interface_repository_id method. + *os << "virtual const char* _interface_repository_id (void) const;"; - // Generate code for the interface definition by traversing thru the - // elements of its scope. We depend on the front-end to have made sure - // that only legal syntactic elements appear in our scope. + if (node->is_abstract ()) + { + *os << be_nl << be_nl + << "virtual void *_tao_obv_narrow (ptr_arith_t type_id);"; + } - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ch::" - "visit_interface - " - "codegen for scope failed\n"), -1); - } + if (! node->is_local () && ! node->is_abstract ()) + { + // Add the Proxy Broker member variable. + *os << be_uidt_nl + << "private:" << be_idt_nl + << node->base_proxy_broker_name () << " *" + << "the" << node->base_proxy_broker_name () + << "_;"; + } - // The _is_a method - if (! node->is_local ()) - { - *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl - << "const CORBA::Char *type_id" << be_nl - << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; - } + *os << be_uidt_nl << be_nl + << "protected:" << be_idt_nl; - // The _tao_QueryInterface method. - *os << "virtual void *_tao_QueryInterface (ptr_arith_t type);" + if (! node->is_local () && ! node->is_abstract ()) + { + // Generate the "protected" constructor so that users cannot + // instantiate us. + + *os << node->local_name () << " (int collocated = 0);" << be_nl << be_nl; - // The _interface_repository_id method. - *os << "virtual const char* _interface_repository_id (void) const;\n" - << be_uidt_nl; + *os << "// These methods travese the inheritance tree and set the" + << be_nl + << "// parents piece of the given class in the right mode" + << be_nl + << "virtual void " << node->flat_name () + << "_setup_collocation (int collocated);" << be_nl << be_nl; + } + else + { + // Protected default constructor for abstract interfaces. + *os << node->local_name () << " (void);" << be_nl; - if (!node->is_local ()) - { - // Add the Proxy Broker member variable. - *os << "private:" << be_idt_nl - << node->base_proxy_broker_name () << " *" - << "the" << node->base_proxy_broker_name () - << "_;" << be_nl << be_uidt_nl; - } + // Protected copy constructor for abstract interfaces. + *os << node->local_name () << " (const " + << node->local_name () << " &);" << be_nl; + } - *os << "protected:" << be_idt_nl; + // Local interfaces don't support stub objects. + if (! node->is_local ()) + { + *os << node->local_name () + << " (" << be_idt << be_idt_nl << "TAO_Stub *objref, " << be_nl + << "CORBA::Boolean _tao_collocated = 0," << be_nl + << "TAO_Abstract_ServantBase *servant = 0" << be_uidt_nl + << ");" << be_uidt_nl; + } - if (!node->is_local ()) - { - // Generate the "protected" constructor so that users cannot - // instantiate us. - - *os << node->local_name () << " (int collocated = 0);" - << be_nl << be_nl; - - *os << "// These methods travese the inheritance tree and set the" - << be_nl - << "// parents piece of the given class in the right mode" - << be_nl - << "virtual void " << node->flat_name () - << "_setup_collocation (int collocated);" << be_nl << be_nl; - } - else - { - *os << node->local_name () << " (void);" << be_nl << be_nl; - } + // Protected destructor. + *os << "virtual ~" << node->local_name () << " (void);"; - // Local interfaces don't support stub objects. - if (! node->is_local ()) - { - *os << node->local_name () - << " (" << be_idt << be_idt_nl << "TAO_Stub *objref, " << be_nl - << "CORBA::Boolean _tao_collocated = 0," << be_nl - << "TAO_Abstract_ServantBase *servant = 0" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; - - // Friends declarations. - *os << "friend class " << node->remote_proxy_impl_name () << ";" - << be_nl - << "friend class " << node->thru_poa_proxy_impl_name () << ";" - << be_nl - << "friend class " << node->direct_proxy_impl_name () << ";" - << be_nl << be_nl; - } - // Protected destructor. - *os << "virtual ~" << node->local_name () << " (void);" - << be_uidt_nl << be_nl; + if (! node->is_abstract ()) + { + // Friends declarations. + *os << be_nl << be_nl + << "friend class " << node->remote_proxy_impl_name () << ";" + << be_nl + << "friend class " << node->thru_poa_proxy_impl_name () << ";" + << be_nl + << "friend class " << node->direct_proxy_impl_name () << ";"; + } + + // Private copy constructor and assignment operator. These are not + // allowed, hence they are private. + *os << be_uidt_nl << be_nl + << "private:" << be_idt_nl; - // private copy constructor and assignment operator. These are not - // allowed, hence they are private. - *os << "private:" << be_idt_nl; + // Abstract interfaces have a *protected* copy constructor. + if (! node->is_abstract ()) + { *os << node->local_name () << " (const " - << node->local_name () << " &);" - << be_nl - << "void operator= (const " << node->local_name () << " &);"; + << node->local_name () << " &);" << be_nl; + } + + *os << "void operator= (const " << node->local_name () << " &);"; + + // Generate the embedded RequestInfo classes per operation. + // This is to be used by interceptors. + be_visitor *visitor = 0; + be_visitor_context ctx (*this->ctx_); - // Generate the embedded RequestInfo classes per operation. - // This is to be used by interceptors. - be_visitor_context ctx (*this->ctx_); + ctx = *this->ctx_; - // Interceptor related classes. - ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH); - be_visitor_interface_interceptors_ch interceptor_visitor (&ctx); + *os << be_uidt_nl; + *os << "};" << be_nl << be_nl; - if (node->accept (&interceptor_visitor) == -1) + // Don't support smart proxies for local interfaces. + // @@@ (JP) This is TODO for abstract interfaces. + if (! node->is_local () && ! node->is_abstract ()) + { + // Smart Proxy related classes. + ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH); + be_visitor_interface_smart_proxy_ch sp_visitor (&ctx); + + if (node->accept (&sp_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " - "codegen for interceptor classes failed\n"), + "codegen for smart proxy classes failed\n"), -1); } + // Proxy Implementation Declaration. ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CH); + be_visitor_interface_proxy_impls_ch spi_visitor (&ctx); - *os << be_uidt_nl; - *os << "};" << be_nl << be_nl; - - // Don't support smart proxies for local interfaces. - if (! node->is_local ()) + if (node->accept (&spi_visitor) == -1) { - // Smart Proxy related classes. - ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH); - be_visitor_interface_smart_proxy_ch sp_visitor (&ctx); + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ch::" + "visit_interface - " + "codegen for Proxy Broker classes failed\n"), + -1); + } - if (node->accept (&sp_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" - "visit_interface - " - "codegen for smart proxy classes failed\n"), - -1); - } + // Proxy Broker Declaration. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH); + be_visitor_interface_proxy_brokers_ch pb_visitor (&ctx); - // Proxy Implementation Declaration. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CH); - be_visitor_interface_proxy_impls_ch spi_visitor (&ctx); + if (node->accept (&pb_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ch::" + "visit_interface - " + "codegen for Proxy Broker classes failed\n"), + -1); + } + } - if (node->accept (&spi_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" - "visit_interface - " - "codegen for Proxy Broker classes failed\n"), - -1); - } + os->gen_endif (); - // Proxy Broker Declaration. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH); - be_visitor_interface_proxy_brokers_ch pb_visitor (&ctx); + if (be_global->tc_support ()) + { + ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); + be_visitor_typecode_decl td_visitor (&ctx); - if (node->accept (&pb_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" - "visit_interface - " - "codegen for Proxy Broker classes failed\n"), - -1); - } + if (node->accept (&td_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_ch::" + "visit_interface - " + "TypeCode declaration failed\n"), + -1); } + } - os->gen_endif (); + node->cli_hdr_gen (I_TRUE); + return 0; +} - if (be_global->tc_support ()) - { - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - be_visitor_typecode_decl td_visitor (&ctx); +int +be_visitor_interface_ch::gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } - if (node->accept (&td_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ch::" - "visit_interface - " - "TypeCode declaration failed\n"), - -1); - } + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interface::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); } - node->cli_hdr_gen (I_TRUE); + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + ctx.state (TAO_CodeGen::TAO_OPERATION_CH); + be_visitor_operation_ch op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } } return 0; } + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp index 2c44fb86a4e..af50193a815 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp @@ -18,18 +18,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_ci, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_ci, + "$Id$") // ************************************************** // Interface visitor for client inline // ************************************************** + be_visitor_interface_ci::be_visitor_interface_ci (be_visitor_context *ctx) : be_visitor_interface (ctx) { @@ -67,10 +64,41 @@ be_visitor_interface_ci::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + os->gen_ifdef_macro (node->flat_name (), ""); - // Generate the constructor from stub and servant. - node->gen_stub_ctor (os); + if (node->is_abstract ()) + { + *os << "ACE_INLINE" << be_nl + << node->name () << "::" << node->local_name () + << " (void)" << be_idt_nl + << ": CORBA_AbstractBase ()" << be_uidt_nl + << "{}" << be_nl << be_nl; + + *os << "ACE_INLINE" << be_nl + << node->name () << "::" << node->local_name () + << " (const " << node->local_name () << " &rhs)" << be_idt_nl + << ": CORBA_AbstractBase (rhs)" << be_uidt_nl + << "{}" << be_nl << be_nl; + + *os << "ACE_INLINE" << be_nl + << node->name () << "::" << node->local_name () + << " (" << be_idt << be_idt_nl + << "TAO_Stub *objref," << be_nl + << "CORBA::Boolean _tao_collocated," << be_nl + << "TAO_Abstract_ServantBase *servant" << be_uidt_nl + << ")" << be_nl + << ": CORBA_AbstractBase (objref, _tao_collocated, servant)" + << be_uidt_nl + << "{}" << be_nl; + } + else + { + // Generate the constructor from stub and servant. + node->gen_stub_ctor (os); + } os->gen_endif (); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp index 98120e67045..3d712b05e18 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp @@ -18,14 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_interface.h" #include "be_visitor_typecode/typecode_defn.h" -ACE_RCSID(be_visitor_interface, interface_cs, "$Id$") - +ACE_RCSID (be_visitor_interface, + interface_cs, + "$Id$") // ************************************************************ // Interface visitor for client stubs @@ -62,8 +59,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); - *os << be_nl; - *os << "// TAO_IDL - Generated from " << be_nl + *os << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Initialize the static narrrowing helper variable. @@ -103,9 +99,18 @@ be_visitor_interface_cs::visit_interface (be_interface *node) *os << node->full_name () << "_ptr" << be_nl << "tao_" << node->flat_name () - << "_narrow (" << be_idt << be_idt_nl - << "CORBA::Object *p" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl + << "_narrow (" << be_idt << be_idt_nl; + + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase *p" << be_nl; + } + else + { + *os << "CORBA::Object *p" << be_nl; + } + + *os << "ACE_ENV_ARG_DECL" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl << "return " << node->full_name () @@ -113,8 +118,16 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << be_uidt_nl << "}" << be_nl << be_nl; - *os << "CORBA::Object *" << be_nl - << "tao_" << node->flat_name () + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase *" << be_nl; + } + else + { + *os << "CORBA::Object *" << be_nl; + } + + *os << "tao_" << node->flat_name () << "_upcast (" << be_idt << be_idt_nl << "void *src" << be_uidt_nl << ")" << be_uidt_nl @@ -125,6 +138,23 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << "return *tmp;" << be_uidt_nl << "}" << be_nl << be_nl; + if (node->has_mixed_parentage ()) + { + *os << "void" << be_nl + << "CORBA::release (" << node->name () << "_ptr p)" << be_nl + << "{" << be_idt_nl + << "CORBA::AbstractBase_ptr abs = p;" << be_nl + << "CORBA::release (abs);" << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "CORBA::Boolean" << be_nl + << "CORBA::is_nil (" << node->name () << "_ptr p)" << be_nl + << "{" << be_idt_nl + << "CORBA::Object_ptr obj = p;" << be_nl + << "return CORBA::is_nil (obj);" << be_uidt_nl + << "}" << be_nl << be_nl; + } + // Generate the _var class. if (node->gen_var_impl () == -1) { @@ -152,9 +182,9 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // the implementation of said operations. ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS); - be_visitor_interface_interceptors_cs interceptor_visitor (&ctx); + be_visitor_interface_interceptors_cs ii_visitor (&ctx); - if (node->accept (&interceptor_visitor) == -1) + if (node->accept (&ii_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" @@ -163,13 +193,13 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - if (!node->is_local ()) + if (!node->is_local () && ! node->is_abstract ()) { ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS); - be_visitor_interface_remote_proxy_impl_cs rpi_visitor (&ctx); + be_visitor_interface_remote_proxy_impl_cs irpi_visitor (&ctx); - if (node->accept (&rpi_visitor) == -1) + if (node->accept (&irpi_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" @@ -180,9 +210,9 @@ be_visitor_interface_cs::visit_interface (be_interface *node) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS); - be_visitor_interface_remote_proxy_broker_cs rpb_visitor (&ctx); + be_visitor_interface_remote_proxy_broker_cs irpb_visitor (&ctx); - if (node->accept (&rpb_visitor) == -1) + if (node->accept (&irpb_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" @@ -192,233 +222,212 @@ be_visitor_interface_cs::visit_interface (be_interface *node) } } - // Generation location info. - *os << be_nl; - *os << "// TAO_IDL - Generated from " << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - - *os << node->name () << "::" << node->local_name (); - - if (!node->is_local ()) - { - *os << " (int collocated)" << be_nl - << "{" << be_idt_nl - << "this->" << node->flat_name () - << "_setup_collocation (collocated);" << be_uidt_nl - << be_uidt << "}" << be_nl << be_nl; - } - else - { - *os << " (void)" << be_nl - << "{}" << be_nl << be_nl; - } - - *os << node->name () << "::~" << node->local_name () - << " (void)" << be_nl; - *os << "{}" << be_nl << be_nl; - - if (!node->is_local ()) + if (! node->is_abstract ()) { - // Collocation setup method. - *os << "void" << be_nl - << node->name () << "::" << node->flat_name () - << "_setup_collocation (int collocated)" << be_nl - << "{" << be_idt_nl - << "if (collocated)" << be_idt_nl - << "this->the" << node->base_proxy_broker_name () - << "_ =" << be_idt_nl - << "::" << node->flat_client_enclosing_scope () - << node->base_proxy_broker_name () - << "_Factory_function_pointer (this);" - << be_uidt << be_uidt_nl - << "else" << be_idt_nl - << "this->the" << node->base_proxy_broker_name () - << "_ =" << be_idt_nl - << "::" << node->full_remote_proxy_broker_name () - << "::the" << node->remote_proxy_broker_name () - << " ();" << be_uidt << be_uidt; - - // Now we setup the immediate parents. - int n_parents = node->n_inherits (); + // Generate the destructor and default constructor. + *os << be_nl; + *os << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << node->name () << "::" << node->local_name (); - if (n_parents > 0) + if (!node->is_local ()) { - *os << be_nl; + *os << " (int collocated)" << be_nl + << "{" << be_idt_nl + << "this->" << node->flat_name () + << "_setup_collocation (collocated);" << be_uidt_nl + << be_uidt << "}" << be_nl << be_nl; + } + else + { + *os << " (void)" << be_nl + << "{}" << be_nl << be_nl; + } - for (int i = 0; i < n_parents; i++) + if (!node->is_local ()) + { + // Collocation setup method. + *os << "void" << be_nl + << node->name () << "::" << node->flat_name () + << "_setup_collocation (int collocated)" << be_nl + << "{" << be_idt_nl + << "if (collocated)" << be_idt_nl + << "this->the" << node->base_proxy_broker_name () + << "_ =" << be_idt_nl + << "::" << node->flat_client_enclosing_scope () + << node->base_proxy_broker_name () + << "_Factory_function_pointer (this);" + << be_uidt << be_uidt_nl + << "else" << be_idt_nl + << "this->the" << node->base_proxy_broker_name () + << "_ =" << be_idt_nl + << "::" << node->full_remote_proxy_broker_name () + << "::the" << node->remote_proxy_broker_name () + << " ();" << be_uidt << be_uidt; + + // Now we setup the immediate parents. + int n_parents = node->n_inherits (); + int has_concrete_parent = 0; + + if (n_parents > 0) { - be_interface *inherited = - be_interface::narrow_from_decl (node->inherits ()[i]); + for (int i = 0; i < n_parents; ++i) + { + be_interface *inherited = + be_interface::narrow_from_decl (node->inherits ()[i]); - *os << be_nl - << "this->" << inherited->flat_name () - << "_setup_collocation" << " (collocated);"; + if (inherited->is_abstract ()) + { + continue; + } - if (i == n_parents - 1) - { - *os << be_uidt_nl; - } - else - { - *os << be_nl; + if (has_concrete_parent == 0) + { + *os << be_nl; + } + + has_concrete_parent = 1; + + *os << be_nl + << "this->" << inherited->flat_name () + << "_setup_collocation" << " (collocated);"; } } - } - else - { - *os << be_uidt_nl; - } - *os << "}" << be_nl << be_nl; + *os << be_uidt_nl << "}"; + } } - // Then generate the code for the static methods. - *os << "void " - << node->name () - << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl - << "{" << be_idt_nl - << node->local_name () << " *tmp = ACE_static_cast (" - << node->local_name () << "*, _tao_void_pointer);" << be_nl - << "CORBA::release (tmp);" << be_uidt_nl - << "}\n" << be_nl; - - // The _narrow method. - *os << node->full_name () << "_ptr " << node->full_name () - << "::_narrow (" << be_idt << be_idt_nl - << "CORBA::Object_ptr obj" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; + *os << be_nl << be_nl + << node->name () << "::~" << node->local_name () + << " (void)" << be_nl; + *os << "{}" << be_nl << be_nl; - // Local interfaces have slightly different _narrow implementation. + // Then generate the code for the static methods + // Local interfaces don't have any operators. if (! node->is_local ()) { - // Remote _narrow implementation. - *os << "if (CORBA::is_nil (obj))" << be_idt_nl - << "return " << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ();" << be_uidt_nl; + *os << "void " << be_nl + << node->name () + << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl + << "{" << be_idt_nl + << node->local_name () << " *tmp = ACE_static_cast (" + << node->local_name () << "*, _tao_void_pointer);" << be_nl + << "CORBA::release (tmp);" << be_uidt_nl + << "}" << be_nl << be_nl; + } - *os << "if (! obj->_is_local ())" << be_idt_nl + if (node->has_mixed_parentage ()) + { + *os << "void" << be_nl + << node->name () << "::_add_ref (void)" << be_nl << "{" << be_idt_nl - << "CORBA::Boolean is_a = obj->_is_a (\"" - << node->repoID () << "\" ACE_ENV_ARG_PARAMETER);" << be_nl - << "ACE_CHECK_RETURN (" << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ());" << be_nl - << "if (is_a == 0)" << be_idt_nl - << "return " << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ();" << be_uidt << be_uidt_nl - << "}" << be_uidt_nl; + << "this->CORBA_Object::_add_ref ();" << be_uidt_nl + << "}" << be_nl << be_nl; } - *os << "return " << bt->nested_type_name (this->ctx_->scope ()) - << "::_unchecked_narrow (obj ACE_ENV_ARG_PARAMETER);" << be_uidt_nl - << "}" << be_nl << be_nl; + // The _narrow method - // The _unchecked_narrow method + *os << node->full_name () << "_ptr" << be_nl << node->full_name () + << "::_narrow (" << be_idt << be_idt_nl; - *os << node->full_name () << "_ptr " << be_nl - << node->full_name () << "::_unchecked_narrow (" - << be_idt << be_idt_nl - << "CORBA::Object_ptr obj" << be_nl - << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "if (CORBA::is_nil (obj))" << be_idt_nl - << "return " << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ();" << be_uidt_nl; + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr obj" << be_nl; + } + else + { + *os << "CORBA::Object_ptr obj" << be_nl; + } + *os << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl; + // Local interfaces have slightly different _narrow implementation. if (! node->is_local ()) { - // Remote _uncheck_narrow implementation. - *os << "if (! obj->_is_local ())" << be_idt_nl + // Remote _narrow implementation. + *os << "if (CORBA::is_nil (obj))" << be_idt_nl << "{" << be_idt_nl - << "TAO_Stub* stub = obj->_stubobj ();" << be_nl - << "if (stub)" << be_idt_nl - << "stub->_incr_refcnt ();" << be_uidt_nl - // Declare the default proxy. - << bt->nested_type_name (this->ctx_->scope ()) - << "_ptr default_proxy = " - << bt->nested_type_name (this->ctx_->scope ()) - <<"::_nil ();\n\n"; - - // If the policy didtates that the proxy be collocated, use the - // function to create one. - os->indent (); - *os << "if (" << be_idt << be_idt_nl // 2 idt - << "!CORBA::is_nil (stub->servant_orb_var ().ptr ()) &&" << be_nl - << "stub->servant_orb_var ()->orb_core ()->optimize_collocation_objects () &&" - << be_nl - << "obj->_is_collocated () &&" << be_nl - << node->flat_client_enclosing_scope () << node->base_proxy_broker_name () - << "_Factory_function_pointer != 0" << be_uidt_nl << ")" // 1 idt - << be_nl << "{" // 0 idt - << be_idt_nl // 1 idt - << "ACE_NEW_RETURN (" << be_idt << be_idt_nl // 2 idt - << "default_proxy," << be_nl - << "::" << bt->name () - << " (" << be_idt << be_idt_nl // 3 idt - << "stub," << be_nl - << "1," << be_nl - << "obj->_servant ()" << be_uidt_nl << ")," << be_uidt_nl - << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ()" << be_uidt_nl << ");" - << be_uidt << be_uidt_nl // 1 idt - << "}" << be_uidt_nl << be_nl; // 0 idt + << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + if (! node->is_abstract ()) + { + *os << "if (! obj->_is_local ())" << be_idt_nl + << "{" << be_idt_nl; + } - // The default proxy will either be returned else be transformed to - // a smart one! - *os << "if (CORBA::is_nil (default_proxy))" << be_idt_nl - << "{" << be_idt_nl - << "ACE_NEW_RETURN (" << be_idt << be_idt_nl - << "default_proxy," << be_nl - << "::" << bt->name () << " (" << be_idt << be_idt_nl - << "stub," << be_nl - << "0," << be_nl - << "obj->_servant ()" << be_uidt_nl - << ")," << be_uidt_nl - << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ()" << be_uidt_nl + *os << "CORBA::Boolean is_a =" << be_idt_nl + << "obj->_is_a (" << be_idt << be_idt_nl + << "\"" << node->repoID () << "\"" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl << ");" << be_uidt << be_uidt_nl - << "}" << be_uidt_nl << be_nl; + << "ACE_CHECK_RETURN (" << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ());" << be_nl << be_nl + << "if (is_a == 0)" << be_idt_nl + << "{" << be_idt_nl + << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ();" << be_uidt_nl; - if (be_global->gen_smart_proxies ()) + if (node->is_abstract ()) { - *os << "return TAO_" << node->flat_name () - << "_PROXY_FACTORY_ADAPTER::instance ()->create_proxy (default_proxy);" - << be_uidt_nl; + *os << "}" << be_uidt_nl; } else { - *os << "return default_proxy;" << be_uidt_nl; + *os << "}" << be_uidt << be_uidt_nl; + *os << "}" << be_uidt_nl; } - *os << "}" << be_uidt_nl - << "else " << be_idt_nl; + *os << be_nl; + } + + *os << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "::_unchecked_narrow (obj ACE_ENV_ARG_PARAMETER);" << be_uidt_nl + << "}" << be_nl << be_nl; + + if (node->is_abstract ()) + { + this->gen_abstract_unchecked_narrow (node, + bt, + os); } else { - *os << be_idt; + this->gen_concrete_unchecked_narrow (node, + bt, + os); } - *os << "return" << be_idt_nl - << "ACE_reinterpret_cast" << be_idt_nl - <<"(" << be_idt_nl - << node->local_name () << "_ptr," << be_idt_nl - << "obj->_tao_QueryInterface" << be_idt_nl - << "(" << be_idt_nl - << "ACE_reinterpret_cast" << be_idt_nl - << "(" << be_idt_nl - << "ptr_arith_t," << be_nl - << "&" << node->local_name () - << "::_tao_class_id" << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << ")" << be_uidt << be_uidt << be_uidt_nl - << ");" << be_uidt << be_uidt << be_uidt << be_uidt_nl; - - *os << "}\n" << be_nl; - + if (node->is_abstract ()) + { + *os << node->full_name () << "_ptr" << be_nl + << node->full_name () + << "::_downcast (CORBA::AbstractBase_ptr abs)" << be_nl + << "{" << be_idt_nl + << "if (CORBA::is_nil (abs))" << be_idt_nl + << "{" << be_idt_nl + << "return " << node->local_name () << "::_nil ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "return (" << node->local_name () + << "_ptr) abs->_tao_obv_narrow ((ptr_arith_t) &_downcast);" + << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "void *" << be_nl + << node->full_name () + << "::_tao_obv_narrow (ptr_arith_t type_id)" << be_nl + << "{" << be_idt_nl + << "if (type_id == (ptr_arith_t) &_downcast)" << be_idt_nl + << "{" << be_idt_nl + << "return this;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "return 0;" << be_uidt_nl + << "}" << be_nl << be_nl; + } // The _duplicate method *os << node->full_name () << "_ptr" << be_nl @@ -426,28 +435,34 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << bt->nested_type_name (this->ctx_->scope ()) << "_ptr obj)" << be_nl << "{" << be_idt_nl - << "if (!CORBA::is_nil (obj))" << be_idt_nl + << "if (! CORBA::is_nil (obj))" << be_idt_nl + << "{" << be_idt_nl << "obj->_add_ref ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl << "return obj;" << be_uidt_nl << "}" << be_nl << be_nl; - // generate the is_a method. _is_a is not supported on local objects. + // Generate the is_a method (not supported on local objects). if (! node->is_local ()) { os->indent (); - *os << "CORBA::Boolean " << node->full_name () - << "::_is_a (" - << "const CORBA::Char *value ACE_ENV_ARG_DECL)" - << be_nl + + *os << "CORBA::Boolean" << be_nl + << node->full_name () << "::_is_a (" << be_idt << be_idt_nl + << "const char *value" << be_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ")" << be_uidt_nl << "{\n"; os->incr_indent (); - *os << "if (\n"; + *os << "if (" << be_idt << be_idt_nl; - os->incr_indent (0); + int status = + node->traverse_inheritance_graph (be_interface::is_a_helper, + os); - if (node->traverse_inheritance_graph (be_interface::is_a_helper, os) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_cs::" @@ -455,25 +470,67 @@ be_visitor_interface_cs::visit_interface (be_interface *node) "_is_a method codegen failed\n"), -1); } - os->indent (); - *os << "(!ACE_OS::strcmp ((char *)value, \"IDL:omg.org/CORBA/Object:1.0\")))\n"; - *os << " return 1; // success using local knowledge\n"; - os->decr_indent (); - *os << "else" << be_nl; - *os << " return this->CORBA_Object::_is_a (value ACE_ENV_ARG_PARAMETER);\n"; - os->decr_indent (); - *os << "}\n\n"; + if (node->is_abstract () || node->has_mixed_parentage ()) + { + *os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl + << "(char *)value," << be_nl + << "\"IDL:omg.org/CORBA/AbstractBase:1.0\"" << be_uidt_nl + << ")"; + } + + if (node->has_mixed_parentage ()) + { + *os << " ||" << be_uidt_nl; + } + else if (node->is_abstract ()) + { + *os << be_uidt << be_uidt_nl; + } + + if (! node->is_abstract ()) + { + *os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl + << "(char *)value," << be_nl + << "\"IDL:omg.org/CORBA/Object:1.0\"" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl; + } + + *os << " )" << be_nl + << "{" << be_idt_nl + << "return 1; // success using local knowledge" << be_uidt_nl + << "}" << be_uidt_nl + << "else" << be_idt_nl + << "{" << be_idt_nl; + + if (node->is_abstract ()) + { + *os << "return 0;" << be_uidt_nl; + } + else + { + *os << "return this->CORBA_Object::_is_a (" << be_idt << be_idt_nl + << "value" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + } + + *os << "}" << be_uidt << be_uidt_nl + << "}\n\n"; } // Generating _tao_QueryInterface method. os->indent (); + *os << "void *" << node->full_name () << "::_tao_QueryInterface (ptr_arith_t type)" << be_nl << "{" << be_idt_nl - << "void *retv = 0;" << be_nl + << "void *retv = 0;" << be_nl << be_nl << "if "; - if (node->traverse_inheritance_graph (be_interface::queryinterface_helper, os) == -1) + if (node->traverse_inheritance_graph ( + be_interface::queryinterface_helper, + os + ) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_cs::" @@ -482,26 +539,56 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - *os << "(type == ACE_reinterpret_cast (ptr_arith_t, &CORBA::Object::_tao_class_id))" - << be_idt_nl << "retv = ACE_reinterpret_cast (void *," << be_idt_nl - << "ACE_static_cast (CORBA::Object_ptr, this));" << be_uidt_nl << be_uidt_nl - << "if (retv)" << be_idt_nl + *os << "(type == ACE_reinterpret_cast (" + << be_idt << be_idt << be_idt << be_idt << be_idt << be_idt_nl + << " ptr_arith_t," << be_nl; + + if (node->is_abstract ()) + { + *os << " &CORBA::AbstractBase"; + } + else + { + *os << " &CORBA::Object"; + } + + *os << "::_tao_class_id)" << be_uidt_nl + << " )" << be_uidt << be_uidt << be_uidt << be_uidt_nl + << "{" << be_idt_nl + << "retv =" << be_idt_nl + << "ACE_reinterpret_cast (" << be_idt << be_idt_nl + << "void *," << be_nl + << "ACE_static_cast ("; + + if (node->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr"; + } + else + { + *os << "CORBA::Object_ptr"; + } + + *os << ", this)" << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + *os << "if (retv != 0)" << be_idt_nl + << "{" << be_idt_nl << "this->_add_ref ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl << "return retv;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; - os->indent (); *os << "const char* " << node->full_name () << "::_interface_repository_id (void) const" << be_nl << "{" << be_idt_nl << "return \"" << node->repoID () << "\";" << be_uidt_nl - << "}\n\n"; - - os->decr_indent (0); + << "}" << be_uidt_nl << be_nl; - // generate code for the elements of the interface + // Generate code for the elements of the interface. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -511,22 +598,25 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - - // Smart Proxy classes. - if (! node->is_local ()) + if (! node->is_abstract ()) { - be_visitor_context ctx (*this->ctx_); + // Smart Proxy classes. + if (! node->is_local ()) + { + be_visitor_context ctx (*this->ctx_); + be_visitor *visitor = 0; - ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS); - be_visitor_interface_smart_proxy_cs visitor (&ctx); + ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS); + be_visitor_interface_smart_proxy_cs isp_visitor (&ctx); - if (node->accept (&visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_cs::" - "visit_interface - " - "codegen for smart proxy classes failed\n"), - -1); + if (node->accept (&isp_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_cs::" + "visit_interface - " + "codegen for smart proxy classes failed\n"), + -1); + } } } @@ -534,9 +624,9 @@ be_visitor_interface_cs::visit_interface (be_interface *node) { ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - be_visitor_typecode_defn td_visitor (&ctx); + be_visitor_typecode_defn tc_visitor (&ctx); - if (node->accept (&td_visitor) == -1) + if (node->accept (&tc_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_cs::" @@ -548,3 +638,227 @@ be_visitor_interface_cs::visit_interface (be_interface *node) return 0; } + +int +be_visitor_interface_cs::gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_cs::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_CS); + be_visitor_operation_cs op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + +void +be_visitor_interface_cs::gen_concrete_unchecked_narrow (be_interface *node, + be_type *bt, + TAO_OutStream *os) +{ + *os << node->full_name () << "_ptr " << be_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "CORBA::Object_ptr obj" << be_nl + << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "if (CORBA::is_nil (obj))" << be_idt_nl + << "{" << be_idt_nl + << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + + if (! node->is_local ()) + { + // Remote _unchecked_narrow implementation. + *os << "if (! obj->_is_local ())" << be_idt_nl + << "{" << be_idt_nl + << "TAO_Stub* stub = obj->_stubobj ();" << be_nl << be_nl + << "if (stub != 0)" << be_idt_nl + << "{" << be_idt_nl + << "stub->_incr_refcnt ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + // Declare the default proxy. + *os << bt->nested_type_name (this->ctx_->scope ()) + << "_ptr default_proxy = " + << bt->nested_type_name (this->ctx_->scope ()) + <<"::_nil ();" << be_nl << be_nl; + + // If the policy didtates that the proxy be collocated, use the + // function to create one. + *os << "if (" << be_idt << be_idt_nl + << "!CORBA::is_nil (stub->servant_orb_var ().ptr ()) &&" << be_nl + << "stub->servant_orb_var ()->orb_core ()->optimize_collocation_objects () &&" + << be_nl + << "obj->_is_collocated () &&" << be_nl + << node->flat_client_enclosing_scope () << node->base_proxy_broker_name () + << "_Factory_function_pointer != 0" << be_uidt_nl << ")" + << be_nl << "{" + << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "default_proxy," << be_nl + << "::" << bt->name () + << " (" << be_idt << be_idt_nl + << "stub," << be_nl + << "1," << be_nl + << "obj->_servant ()" << be_uidt_nl << ")," << be_uidt_nl + << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ()" << be_uidt_nl << ");" + << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + + // The default proxy will either be returned else be transformed to + // a smart one! + *os << "if (CORBA::is_nil (default_proxy))" << be_idt_nl + << "{" << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "default_proxy," << be_nl + << "::" << bt->name () << " (" << be_idt << be_idt_nl + << "stub," << be_nl + << "0," << be_nl + << "obj->_servant ()" << be_uidt_nl + << ")," << be_uidt_nl + << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + if (be_global->gen_smart_proxies ()) + { + *os << "return TAO_" << node->flat_name () + << "_PROXY_FACTORY_ADAPTER::instance ()->create_proxy (default_proxy);" + << be_uidt_nl; + } + else + { + *os << "return default_proxy;" << be_uidt_nl; + } + + *os << "}" << be_uidt_nl + << "else " << be_idt_nl; + } + else + { + *os << be_idt; + } + + // Local _unchecked_narrow. + *os << "return" << be_idt_nl + << "ACE_reinterpret_cast (" << be_idt << be_idt_nl + << node->local_name () << "_ptr," << be_nl + << "obj->_tao_QueryInterface (" << be_idt << be_idt_nl + << "ACE_reinterpret_cast (" << be_idt << be_idt_nl + << "ptr_arith_t," << be_nl + << "&" << node->local_name () << "::_tao_class_id" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt << be_uidt_nl; + + *os << "}" << be_nl << be_nl; +} + +void +be_visitor_interface_cs::gen_abstract_unchecked_narrow (be_interface *node, + be_type *bt, + TAO_OutStream *os) +{ + *os << node->full_name () << "_ptr " << be_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "CORBA::AbstractBase_ptr obj" << be_nl + << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "if (CORBA::is_nil (obj))" << be_idt_nl + << "{" << be_idt_nl + << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + // Declare the default proxy. + *os << bt->nested_type_name (this->ctx_->scope ()) + << "_ptr default_proxy = " + << bt->nested_type_name (this->ctx_->scope ()) + <<"::_nil ();" << be_nl << be_nl; + + *os << "if (obj->_is_objref ())" << be_idt_nl + << "{" << be_idt_nl; + + *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "default_proxy," << be_nl + << "::" << bt->name () << " (" << be_idt << be_idt_nl + << "obj->_stubobj ()," << be_nl + << "0," << be_nl + << "obj->_servant ()" << be_uidt_nl + << ")," << be_uidt_nl + << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl; + + *os << "else" << be_idt_nl + << "{" << be_idt_nl + << "default_proxy = " << bt->name () << "::_downcast (obj);" + << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + *os << "return default_proxy;" << be_uidt_nl; + + *os << "}" << be_nl << be_nl; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp index d1b29aa441b..f47b5821a39 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp @@ -16,16 +16,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_ih, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_ih, + "$Id$") // ************************************************************ -// Interface visitor for implementation header +// Interface visitor for implementation header. // ************************************************************ be_visitor_interface_ih::be_visitor_interface_ih (be_visitor_context *ctx) @@ -40,30 +36,34 @@ be_visitor_interface_ih::~be_visitor_interface_ih (void) int be_visitor_interface_ih::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream - static char namebuf [NAMEBUFSIZE]; // holds the class name + TAO_OutStream *os = this->ctx_->stream (); + static char namebuf [NAMEBUFSIZE]; if (node->impl_hdr_gen () || node->imported ()) - return 0; - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); + { + return 0; + } - os = this->ctx_->stream (); + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); - // generate the skeleton class name + // Generate the skeleton class name. - os->indent (); // start with whatever indentation level we are at + os->indent (); ACE_OS::sprintf (namebuf, "%s", node->flat_name ()); *os << "//Class " << be_global->impl_class_prefix () << namebuf << be_global->impl_class_suffix () << be_nl; - // now generate the class definition + + // Now generate the class definition. *os << "class " << be_global->stub_export_macro () << " " << be_global->impl_class_prefix () << namebuf << be_global->impl_class_suffix () << " : "; - //inherit from the base skeleton file + + // Inherit from the base skeleton file. *os <<"public virtual "<< node->full_skel_name (); *os << be_nl @@ -97,7 +97,7 @@ be_visitor_interface_ih::visit_interface (be_interface *node) << be_global->impl_class_suffix () << " (void);" << be_nl << be_uidt_nl; - // generate code for elements in the scope (e.g., operations) + // Generate code for elements in the scope (e.g., operations). if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -107,31 +107,15 @@ be_visitor_interface_ih::visit_interface (be_interface *node) -1); } - /* - if (node->n_inherits () > 0) - { - // this interface inherits from other interfaces - be_interface *intf; // inherited interface - - for (i = 0; i < node->n_inherits (); i++) - { - intf = be_interface::narrow_from_decl (node->inherits ()[i]); - // generate code for elements in the scope (e.g., operations) - if (this->visit_scope (intf) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ih::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - } - } - */ + // Generate the code for the members of the derived classes. + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_ih::method_helper, + os + ); - //Generate the code for the members of the derived classes - if (node->traverse_inheritance_graph (be_visitor_interface_ih::method_helper, os) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh_ss::" @@ -146,11 +130,11 @@ be_visitor_interface_ih::visit_interface (be_interface *node) } -//Helper method to generate members within the scope of the base classes +// Helper method to generate members within the scope of the base classes. int be_visitor_interface_ih::method_helper (be_interface *derived, - be_interface *node, - TAO_OutStream *os) + be_interface *node, + TAO_OutStream *os) { if (strcmp (derived->flat_name (), node->flat_name ()) != 0) @@ -159,16 +143,16 @@ be_visitor_interface_ih::method_helper (be_interface *derived, ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); ctx.interface (derived); ctx.stream (os); + be_visitor_interface_ih visitor (&ctx); - be_visitor* visitor = tao_cg->make_visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) + if (visitor.visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_is::" - "method_helper\n"), -1); + "method_helper\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp index 243e6bb1e61..1dbd41d5731 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp @@ -16,18 +16,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - - // ************************************************************ -// Interface visitor for implementation skeletons +// Interface visitor for implementation skeletons. // ************************************************************ -ACE_RCSID(be_visitor_interface, interface_is, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_is, + "$Id$") be_visitor_interface_is::be_visitor_interface_is (be_visitor_context *ctx) : be_visitor_interface (ctx) @@ -44,22 +39,20 @@ be_visitor_interface_is::visit_interface (be_interface *node) this->ctx_->interface (node); - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); if (node->impl_skel_gen () || node->imported ()) - return 0; - - os = this->ctx_->stream (); - - - // generate the skeleton class name + { + return 0; + } - os->indent (); // start with whatever indentation level we are at + // Generate the skeleton class name. + os->indent (); - // constructor *os << "// Implementation skeleton constructor" << be_nl; - // find if we are at the top scope or inside some module + + // Find if we are at the top scope or inside some module. *os << be_global->impl_class_prefix () << node->flat_name () << be_global->impl_class_suffix () <<"::" << be_global->impl_class_prefix () << node->flat_name () @@ -69,7 +62,6 @@ be_visitor_interface_is::visit_interface (be_interface *node) *os << "{" << be_nl << "}" << be_nl << be_uidt_nl; - // destructor os->indent (); *os << "// Implementation skeleton destructor" << be_nl; @@ -82,7 +74,7 @@ be_visitor_interface_is::visit_interface (be_interface *node) *os << "{" <<be_nl; *os << "}" << be_nl <<be_uidt_nl; - if (be_global->gen_copy_ctor () ) + if (be_global->gen_copy_ctor ()) { *os << "//Implementation Skeleton Copy Constructor" << be_nl; @@ -93,11 +85,12 @@ be_visitor_interface_is::visit_interface (be_interface *node) << be_global->impl_class_prefix () << node->flat_name () << be_global->impl_class_suffix () << "& t)"<< be_idt_nl; - if(node->n_inherits () >0) + if (node->n_inherits () > 0) { - node->gen_copy_ctors(os); + node->gen_copy_ctors (os); *os << ", TAO_ServantBase (t)" << be_nl; } + *os << "{" << be_nl << "}" << be_nl << be_uidt_nl; } @@ -117,7 +110,7 @@ be_visitor_interface_is::visit_interface (be_interface *node) << "}" << be_nl << be_uidt_nl; } - // generate code for elements in the scope (e.g., operations) + // Generate code for elements in the scope (e.g., operations). if (this->visit_scope (node) == -1) { @@ -127,63 +120,50 @@ be_visitor_interface_is::visit_interface (be_interface *node) "codegen for scope failed\n"), -1); } - /* - if (node->n_inherits () > 0) - { - // this interface inherits from other interfaces - be_interface *intf; // inherited interface - - for (int i = 0; i < node->n_inherits (); i++) - { - intf = be_interface::narrow_from_decl (node->inherits ()[i]); - // generate code for elements in the scope (e.g., operations) - if (this->visit_scope (intf) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ih::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - } - */ - if (node->traverse_inheritance_graph (be_visitor_interface_is::method_helper, os) == -1) + + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_is::method_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_tie_sh_ss::" + "be_visitor_interface_is::" "visit_interface - " "traversal of inhertance graph failed\n"), -1); } - return 0; } -//Helper method to generate the members in the scope of the base classes +// Helper method to generate the members in the scope of the base classes. int be_visitor_interface_is::method_helper (be_interface *derived, - be_interface *node, - TAO_OutStream *os) + be_interface *node, + TAO_OutStream *os) { - - if (strcmp (derived->flat_name (), node->flat_name ()) != 0) + if (ACE_OS::strcmp (derived->flat_name (), node->flat_name ()) != 0) { be_visitor_context ctx; ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); ctx.interface (derived); ctx.stream (os); + be_visitor_interface_is visitor (&ctx); + + if (visitor.visit_scope (node) == -1) - be_visitor* visitor = tao_cg->make_visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_is::" - "method_helper\n"), -1); + "method_helper\n"), + -1); } - delete visitor; + } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp index b8384ace7ba..cb14fe10d2b 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp @@ -18,17 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_sh, "$Id$") - +ACE_RCSID (be_visitor_interface, + interface_sh, + "$Id$") // ************************************************************ -// Interface visitor for server header +// Interface visitor for server header. // ************************************************************ be_visitor_interface_sh::be_visitor_interface_sh (be_visitor_context *ctx) @@ -43,29 +38,33 @@ be_visitor_interface_sh::~be_visitor_interface_sh (void) int be_visitor_interface_sh::visit_interface (be_interface *node) { - if (node->srv_hdr_gen () || node->imported ()) - return 0; + if (node->srv_hdr_gen () || node->imported () || node->is_abstract ()) + { + return 0; + } // If this node is a AMH-RH node, then generate code for it if (node->is_local ()) { if (this->is_amh_rh_node (node)) { - // Create amh_rh_visitors + // Create amh_rh_visitors. be_visitor_amh_rh_interface_sh amh_rh_intf (this->ctx_); amh_rh_intf.visit_interface (node); } - return 0; + + return 0; } if (this->generate_amh_classes (node) == -1) - return -1; - - TAO_OutStream *os = this->ctx_->stream (); // output stream + { + return -1; + } - ACE_CString class_name; // holds the class name + TAO_OutStream *os = this->ctx_->stream (); os->indent (); + ACE_CString class_name; // We shall have a POA_ prefix only if we are at the topmost level. if (!node->is_nested ()) @@ -79,6 +78,9 @@ be_visitor_interface_sh::visit_interface (be_interface *node) class_name += node->local_name (); } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate the skeleton class name. *os << "class " << class_name.c_str () << ";" << be_nl; @@ -113,21 +115,33 @@ be_visitor_interface_sh::visit_interface (be_interface *node) << " " << class_name.c_str () << be_idt_nl << ": " << be_idt; long n_parents = node->n_inherits (); + AST_Interface *parent = 0; + int has_concrete_parent = 0; if (n_parents > 0) { for (int i = 0; i < n_parents; ++i) { - *os << "public virtual " << "POA_" - << node->inherits ()[i]->name (); + parent = node->inherits ()[i]; + + if (parent->is_abstract ()) + { + continue; + } - if (i < n_parents - 1) + if (has_concrete_parent == 1) { *os << "," << be_nl; } + + *os << "public virtual " << "POA_" + << parent->name (); + + has_concrete_parent = 1; } } - else + + if (has_concrete_parent == 0) { // We don't inherit from another user defined object, hence our // base class is the ServantBase class. @@ -209,10 +223,18 @@ be_visitor_interface_sh::visit_interface (be_interface *node) -1); } + *os << "\n"; + // Generate skeletons for operations of our base classes. These // skeletons just cast the pointer to the appropriate type // before invoking the call. - if (node->traverse_inheritance_graph (be_interface::gen_skel_helper, os) == -1) + int status = + node->traverse_inheritance_graph ( + be_interface::gen_skel_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_sh::" @@ -224,14 +246,12 @@ be_visitor_interface_sh::visit_interface (be_interface *node) // Generate the embedded RequestInfo classes per operation. // This is to be used by interceptors. be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = 0; // Interceptor related classes. ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_interceptors_sh ii_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ii_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -239,29 +259,27 @@ be_visitor_interface_sh::visit_interface (be_interface *node) -1); } - delete visitor; - visitor = 0; - *os << be_uidt_nl << "};\n\n"; - if (be_global->gen_thru_poa_collocation () || - be_global->gen_direct_collocation ()) + if (be_global->gen_thru_poa_collocation () + || be_global->gen_direct_collocation ()) { ctx = *this->ctx_; // Generate strategized proxy broker. ctx.state (TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SH); - visitor = tao_cg->make_visitor (&ctx); - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for thru_poa_collocated class failed\n"), - -1); - } - - delete visitor; + be_visitor_interface_strategized_proxy_broker_sh ispb_visitor (&ctx); + + if (node->accept (&ispb_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "be_visitor_interface_sh::" + "visit_interface - " + "codegen for thru_poa_collocated class failed\n" + ), + -1 + ); + } } ctx = *this->ctx_; @@ -269,51 +287,99 @@ be_visitor_interface_sh::visit_interface (be_interface *node) // Generate the collocated class. if (be_global->gen_thru_poa_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_thru_poa_proxy_impl_sh itppi_visitor (&ctx); - if (visitor == 0 || node->accept (visitor) == -1) + if (node->accept (&itppi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_sh::" "visit_interface - " "codegen for thru_poa_collocated class failed\n"), -1); } - - delete visitor; } ctx = *this->ctx_; if (be_global->gen_direct_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_direct_proxy_impl_sh idpi_visitor (&ctx); - if (visitor == 0 || node->accept (visitor) == -1) + if (node->accept (&idpi_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "be_visitor_interface_sh::" + "visit_interface - " + "codegen for thru_poa_collocated class failed\n" + ), + -1 + ); + } + } + + *os << "\n"; + return 0; +} + +int +be_visitor_interface_sh::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for thru_poa_collocated class failed\n"), + "(%N:%l) be_visitor_interface_sh::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), -1); } - delete visitor; + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + ctx.state (TAO_CodeGen::TAO_OPERATION_SH); + be_visitor_operation_sh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } } - *os << "\n"; return 0; } - void be_visitor_interface_sh::this_method (be_interface *node) { @@ -333,5 +399,6 @@ be_visitor_interface_sh::generate_amh_classes (be_interface *node) be_visitor_amh_interface_sh amh_intf (this->ctx_); return amh_intf.visit_interface (node); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp index 7ac5571926c..ecc0f5e998e 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_si, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_si, + "$Id$") // ************************************************************************ @@ -43,16 +39,22 @@ be_visitor_interface_si::~be_visitor_interface_si (void) int be_visitor_interface_si::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream + if (node->srv_inline_gen () + || node->imported () + || node->is_local () + || node->is_abstract ()) + { + return 0; + } - if (node->srv_inline_gen () || node->imported () || node->is_local ()) - return 0; + TAO_OutStream *os = this->ctx_->stream (); - os = this->ctx_->stream (); + // Determine if we are in some form of a multiple inheritance. + int status = + node->traverse_inheritance_graph (be_interface::in_mult_inheritance_helper, + 0); - // determine if we are in some form of a multiple inheritance - if (node->traverse_inheritance_graph - (be_interface::in_mult_inheritance_helper, 0) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_si::visit_interface " @@ -62,27 +64,28 @@ be_visitor_interface_si::visit_interface (be_interface *node) // Generate skeletons for operations of our base classes. These skeletons // just cast the pointer to the appropriate type before invoking the - // call. Hence we generate these in the inline file - if (node->traverse_inheritance_graph (be_interface::gen_skel_helper, os) - == -1) + // call. Hence we generate these in the inline file. + status = node->traverse_inheritance_graph (be_interface::gen_skel_helper, + os); + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_si::" "visit_interface - " - "codegen for base class skeletons failed\n"), -1); + "codegen for base class skeletons failed\n"), + -1); } if (be_global->gen_tie_classes ()) { - // generate the TIE class + // Generate the TIE class. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SI); ctx.stream (tao_cg->server_template_inline ()); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_tie_si visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_sh::" "visit_interface - " diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp index f30ceb3ff6a..18261ecdc24 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp @@ -18,18 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" -#include "ace/SString.h" - -ACE_RCSID(be_visitor_interface, interface_ss, "$Id$") - +ACE_RCSID (be_visitor_interface, + interface_ss, + "$Id$") // ************************************************************ -// Interface visitor for server skeletons +// Interface visitor for server skeletons. // ************************************************************ be_visitor_interface_ss::be_visitor_interface_ss (be_visitor_context *ctx) @@ -44,7 +38,7 @@ be_visitor_interface_ss::~be_visitor_interface_ss (void) int be_visitor_interface_ss::visit_interface (be_interface *node) { - if (node->srv_skel_gen () || node->imported ()) + if (node->srv_skel_gen () || node->imported () || node->is_abstract ()) { return 0; } @@ -53,7 +47,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) { if (this->is_amh_rh_node (node)) { - // Create amh_rh_visitors + // Create amh_rh_visitors. be_visitor_amh_rh_interface_ss amh_rh_ss_intf (this->ctx_); amh_rh_ss_intf.visit_interface (node); } @@ -62,20 +56,24 @@ be_visitor_interface_ss::visit_interface (be_interface *node) } if (this->generate_amh_classes (node) == -1) - return -1; + { + return -1; + } - // Generate the normal skeleton as usual + // Generate the normal skeleton as usual. TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at + os->indent (); ACE_CString full_skel_name_holder = this->generate_full_skel_name (node); + const char *full_skel_name = full_skel_name_holder.c_str (); ACE_CString flat_name_holder = this->generate_flat_name (node); + const char *flat_name = flat_name_holder.c_str (); if (node->gen_operation_table (flat_name, full_skel_name) == -1) @@ -96,13 +94,14 @@ be_visitor_interface_ss::visit_interface (be_interface *node) -1); } - *os << "// TAO_IDL - Generated from " << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl; + *os << be_nl << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Find if we are at the top scope or inside some module, // pre-compute the prefix that must be added to the local name in // each case. const char *local_name_prefix = ""; + if (!node->is_nested ()) { local_name_prefix = "POA_"; @@ -110,6 +109,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) ACE_CString node_local_name_holder = this->generate_local_name (node); + const char *node_local_name = node_local_name_holder.c_str (); *os << full_skel_name << "::" @@ -149,7 +149,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) *os << "{" << be_nl; *os << "}\n\n"; - // generate code for elements in the scope (e.g., operations) + // Generate code for elements in the scope (e.g., operations). if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -159,6 +159,9 @@ be_visitor_interface_ss::visit_interface (be_interface *node) -1); } + *os << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate code for the _is_a skeleton. os->indent (); *os << "void " << full_skel_name @@ -228,9 +231,14 @@ be_visitor_interface_ss::visit_interface (be_interface *node) << be_idt_nl; if (be_global->use_raw_throw ()) - *os << "throw CORBA::MARSHAL ();" << be_uidt << be_uidt_nl; + { + *os << "throw CORBA::MARSHAL ();" << be_uidt << be_uidt_nl; + } else - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt << be_uidt_nl; + { + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt << be_uidt_nl; + } + *os << "}\n\n"; // Generate code for the _interface skeleton. @@ -310,14 +318,14 @@ be_visitor_interface_ss::visit_interface (be_interface *node) // Generate code for the _is_a override. os->indent (); + *os << "CORBA::Boolean " << full_skel_name << "::_is_a (" << be_idt << be_idt_nl << "const char* value" << be_nl << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl - << "const char *base_id = \"IDL:org.omg/CORBA/Object:1.0\";" << be_nl - << "if (\n" << be_idt; + << "if (" << be_idt << be_idt_nl; if (node->traverse_inheritance_graph (be_interface::is_a_helper, os) == -1) { @@ -328,11 +336,29 @@ be_visitor_interface_ss::visit_interface (be_interface *node) -1); } - os->indent (); - *os << "(!ACE_OS::strcmp ((char *)value, base_id)))" - << be_idt_nl << "return 1;" << be_uidt_nl + *os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl + << "(char *)value," << be_nl + << "\"IDL:org.omg/CORBA/Object:1.0\"" << be_uidt_nl + << ")"; + + if (node->has_mixed_parentage ()) + { + *os << " ||" << be_uidt_nl + << "!ACE_OS::strcmp (" << be_idt << be_idt_nl + << "(char *)value," << be_nl + << "\"IDL:org.omg/CORBA/AbstractBase:1.0\"" << be_uidt_nl + << ")"; + } + + *os << be_uidt << be_uidt_nl + << " )" << be_nl + << "{" << be_idt_nl + << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt << be_uidt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << be_nl; // the downcast method. @@ -351,10 +377,13 @@ be_visitor_interface_ss::visit_interface (be_interface *node) -1); } - *os << "if (ACE_OS::strcmp (logical_type_id, " - << "\"IDL:omg.org/CORBA/Object:1.0\") == 0)" << be_idt_nl + *os << "if (ACE_OS::strcmp (logical_type_id," << be_nl + << " \"IDL:omg.org/CORBA/Object:1.0\") == 0)" + << be_idt_nl + << "{" << be_idt_nl << "return ACE_static_cast(PortableServer::Servant, this);" - << be_uidt_nl; + << be_uidt_nl + << "}" << be_uidt_nl << be_nl; *os << "return 0;" << be_uidt_nl << "}" << be_nl << be_nl; @@ -366,7 +395,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) *os << "return \"" << node->repoID () << "\";" << be_uidt_nl; *os << "}" << be_nl << be_nl; - // Print out dispatch method + // Print out dispatch method. this->dispatch_method (node); *os << be_nl; @@ -378,40 +407,120 @@ be_visitor_interface_ss::visit_interface (be_interface *node) return 0; } +int +be_visitor_interface_ss::gen_abstract_ops_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_ss::" + "abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_SS); + be_visitor_operation_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} void be_visitor_interface_ss::this_method (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // the _this () operation - *os << node->full_name () << "*" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // the _this () operation. + *os << node->full_name () << " *" << be_nl << node->full_skel_name () << "::_this (ACE_ENV_SINGLE_ARG_DECL)" << be_nl - << "{" << be_idt_nl // idt = 1 + << "{" << be_idt_nl << "TAO_Stub *stub = this->_create_stub (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl - << "TAO_Stub_Auto_Ptr safe_stub (stub);" << be_nl << be_nl; + << "TAO_Stub_Auto_Ptr safe_stub (stub);" << be_nl; *os << "CORBA::Object_ptr tmp = CORBA::Object::_nil ();" << be_nl << be_nl << "if (stub->servant_orb_var ()->orb_core ()->" - << "optimize_collocation_objects ())" - << be_idt_nl // idt = 2 - << "ACE_NEW_RETURN (tmp, CORBA::Object (stub, 1, this), 0);" - << be_uidt_nl // idt = 1 - << "else" - << be_idt_nl // idt = 2 - << "ACE_NEW_RETURN (tmp, CORBA::Object (stub, 0, this), 0);" - << be_uidt_nl << be_nl // idt = 1 - << "CORBA::Object_var obj = tmp;" << be_nl << be_nl; - - *os << "(void) safe_stub.release ();" << be_nl << be_nl; - - *os << "return " << "::" << node->full_name () + << "optimize_collocation_objects ())" << be_idt_nl + << "{" << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "tmp," << be_nl + << "CORBA::Object (" << be_idt << be_idt_nl + << "stub," << be_nl + << "1," << be_nl + << "this" << be_uidt_nl + << ")," << be_uidt_nl + << "0" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl + << "else" << be_idt_nl + << "{" << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "tmp," << be_nl + << "CORBA::Object (" << be_idt << be_idt_nl + << "stub," << be_nl + << "0," << be_nl + << "this" << be_uidt_nl + << ")," << be_uidt_nl + << "0" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + *os << "CORBA::Object_var obj = tmp;" << be_nl + << "(void) safe_stub.release ();" << be_nl + << "return " << "::" << node->full_name () << "::_unchecked_narrow (obj.in ());" - << be_uidt_nl // idt = 0 + << be_uidt_nl << "}" << be_nl; } @@ -420,7 +529,9 @@ be_visitor_interface_ss::dispatch_method (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // now the dispatch method + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "void " << node->full_skel_name () << "::_dispatch (" << be_idt << be_idt_nl << "TAO_ServerRequest &req," << be_nl @@ -433,7 +544,7 @@ be_visitor_interface_ss::dispatch_method (be_interface *node) << " this" << be_nl << " ACE_ENV_ARG_PARAMETER);" << be_uidt_nl; - *os << "}" << be_nl << be_nl; + *os << "}" << be_nl; } int @@ -444,6 +555,7 @@ be_visitor_interface_ss::generate_amh_classes (be_interface *node) be_visitor_amh_interface_ss amh_intf (this->ctx_); return amh_intf.visit_interface (node); } + return 0; } @@ -452,15 +564,14 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // Strategized Proxy Broker Implementation + // Strategized Proxy Broker Implementation. be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_interceptors_ss ii_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ii_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " @@ -468,19 +579,15 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) -1); } - delete visitor; - visitor = 0; - if (be_global->gen_thru_poa_collocation () || be_global->gen_direct_collocation ()) { ctx = (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_strategized_proxy_broker_ss ispb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ispb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " @@ -488,7 +595,8 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) -1); } - delete visitor; + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; // Proxy Broker Factory Function. *os << be_nl @@ -540,42 +648,34 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) // Proxy Impl Implementations. if (be_global->gen_thru_poa_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_thru_poa_proxy_impl_ss itppi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&itppi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " "codegen for Base Proxy Broker class failed\n"), -1); } - - delete visitor; } if (be_global->gen_direct_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_direct_proxy_impl_ss idpi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&idpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " "codegen for Base Proxy Broker class failed\n"), -1); } - - delete visitor; } os->decr_indent (0); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp index 357e932f3af..538a39cf926 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp @@ -1,19 +1,23 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + proxy_brokers_ch, + "$Id$") -ACE_RCSID (be_visitor_interface, proxy_brokers_ch, "$Id$") - - be_visitor_interface_proxy_brokers_ch::be_visitor_interface_proxy_brokers_ch (be_visitor_context *ctx) - : be_visitor_interface (ctx) +be_visitor_interface_proxy_brokers_ch::be_visitor_interface_proxy_brokers_ch ( + be_visitor_context *ctx + ) + : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_proxy_brokers_ch::~be_visitor_interface_proxy_brokers_ch (void) +be_visitor_interface_proxy_brokers_ch::~be_visitor_interface_proxy_brokers_ch ( + void + ) { // No-Op. } @@ -35,11 +39,10 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) be_visitor *visitor = 0; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_BROKER_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_base_proxy_broker_ch bpb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&bpb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -47,15 +50,12 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) -1); } - delete visitor; - ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_remote_proxy_broker_ch rpb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&rpb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -63,7 +63,5 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp index cca6a5e8a65..d5bc901855b 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp @@ -1,19 +1,23 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + base_proxy_broker_impl_ch, + "$Id$") -ACE_RCSID (be_visitor_interface, base_proxy_broker_impl_ch, "$Id$") - -be_visitor_interface_proxy_impls_ch::be_visitor_interface_proxy_impls_ch (be_visitor_context *ctx) +be_visitor_interface_proxy_impls_ch::be_visitor_interface_proxy_impls_ch ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_proxy_impls_ch::~be_visitor_interface_proxy_impls_ch (void) +be_visitor_interface_proxy_impls_ch::~be_visitor_interface_proxy_impls_ch ( + void + ) { // No-Op. } @@ -26,43 +30,37 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) // Generate Guards. *os << "// The Proxy Implementations are used by each interface to" << be_nl - << "// perform a call. Each different implementation encapsulate" + << "// perform a call. Each different implementation encapsulates" << be_nl - << "// an invocation logics." << be_nl << be_nl; + << "// an invocation logic." << be_nl << be_nl; // Code Generation for the proxy imlpementations base class. be_visitor *visitor = 0; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_base_proxy_impl_ch bpi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&bpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" + "be_visitor_interface_proxy_impls_ch::" "visit_interface - " "codegen for Base Proxy Impl. class failed\n"), -1); } - delete visitor; - ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_remote_proxy_impl_ch rpi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&rpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" + "be_visitor_interface_proxy_impls_ch::" "visit_interface - " "codegen for Remote Proxy Broker class failed\n"), -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp index 273530debd1..e197ce1bc46 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp @@ -1,27 +1,29 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" +// +// $Id$ +// ACE_RCSID (be_visitor_interface, be_visitor_interface_remote_proxy_broker_ch, "$Id$") -be_visitor_interface_remote_proxy_broker_ch::be_visitor_interface_remote_proxy_broker_ch (be_visitor_context *ctx) +be_visitor_interface_remote_proxy_broker_ch:: +be_visitor_interface_remote_proxy_broker_ch (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_remote_proxy_broker_ch::~be_visitor_interface_remote_proxy_broker_ch (void) +be_visitor_interface_remote_proxy_broker_ch:: +~be_visitor_interface_remote_proxy_broker_ch (void) { // No-Op. } int -be_visitor_interface_remote_proxy_broker_ch::visit_interface (be_interface *node) +be_visitor_interface_remote_proxy_broker_ch::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -29,10 +31,14 @@ be_visitor_interface_remote_proxy_broker_ch::visit_interface (be_interface *node os->indent (); *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Remote Proxy Broker Declaration " << be_nl << "//" << be_nl << be_nl; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "class " << be_global->stub_export_macro () << " " << node->remote_proxy_broker_name () << be_idt_nl << ": public virtual " @@ -48,7 +54,8 @@ be_visitor_interface_remote_proxy_broker_ch::visit_interface (be_interface *node << be_nl << be_nl; // Accessor Method - *os << "virtual " << node->base_proxy_impl_name () << " &" << "select_proxy (" + *os << "virtual " << node->base_proxy_impl_name () << " &" + << "select_proxy (" << be_idt << be_idt_nl; *os << node->local_name () << " *object" << be_nl @@ -62,8 +69,10 @@ be_visitor_interface_remote_proxy_broker_ch::visit_interface (be_interface *node *os << "public:" << be_idt_nl; // Factory Member Function declaration. - *os << "// This member function is used to get an handle to the unique instance" << be_nl - << "// of the Remote Proxy Broker that is available for a given" << be_nl + *os << "// This member function is used to get an handle to the " + << "unique instance" << be_nl + << "// of the Remote Proxy Broker that is available for a given" + << be_nl << "// interface." << be_nl << "static " << node->remote_proxy_broker_name () << " *the" << node->remote_proxy_broker_name () diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_cs.cpp index 93fa5e34089..d2b53e17245 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_cs.cpp @@ -1,33 +1,41 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + remote_proxy_broker_cs, + "$Id$") -ACE_RCSID (be_visitor_interface, base_proxy_broker_cs, "$Id$") - -be_visitor_interface_remote_proxy_broker_cs::be_visitor_interface_remote_proxy_broker_cs (be_visitor_context *ctx) +be_visitor_interface_remote_proxy_broker_cs:: +be_visitor_interface_remote_proxy_broker_cs (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_remote_proxy_broker_cs::~be_visitor_interface_remote_proxy_broker_cs (void) +be_visitor_interface_remote_proxy_broker_cs:: +~be_visitor_interface_remote_proxy_broker_cs (void) { // No-Op. } int -be_visitor_interface_remote_proxy_broker_cs::visit_interface (be_interface *node) +be_visitor_interface_remote_proxy_broker_cs::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + // Generate the class declaration. os->indent (); *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Remote & Base Proxy Broker Implementation" << be_nl << "//" << be_nl << be_nl; @@ -82,11 +90,11 @@ be_visitor_interface_remote_proxy_broker_cs::visit_interface (be_interface *node << "return this->remote_proxy_impl_;" << be_uidt_nl << "}" << be_nl << be_nl; - *os << be_nl << "//" << be_nl << "// End Remote & Base Proxy Broker Implementation" << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp index ebdd838fd64..c43cf1a98a2 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp @@ -1,25 +1,29 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + remote_proxy_impl_ch, + "$Id$") -ACE_RCSID (be_visitor_interface, remote_proxy_broker_impl_ch, "$Id$") - -be_visitor_interface_remote_proxy_impl_ch::be_visitor_interface_remote_proxy_impl_ch (be_visitor_context *ctx) +be_visitor_interface_remote_proxy_impl_ch:: +be_visitor_interface_remote_proxy_impl_ch (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_remote_proxy_impl_ch::~be_visitor_interface_remote_proxy_impl_ch (void) +be_visitor_interface_remote_proxy_impl_ch:: +~be_visitor_interface_remote_proxy_impl_ch (void) { // No-Op. } int -be_visitor_interface_remote_proxy_impl_ch::visit_interface (be_interface *node) +be_visitor_interface_remote_proxy_impl_ch::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -29,31 +33,33 @@ be_visitor_interface_remote_proxy_impl_ch::visit_interface (be_interface *node) << "// Remote Proxy Impl. Declaration" << be_nl << "//" << be_nl << be_nl; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate Class Declaration. *os << "class " << be_global->stub_export_macro () << " " << node->remote_proxy_impl_name () << be_idt_nl; *os << ": " << "public virtual " << node->base_proxy_impl_name () - << "," << be_idt_nl << "public virtual " << "TAO_Remote_Object_Proxy_Impl"; + << "," << be_idt_nl << "public virtual " + << "TAO_Remote_Object_Proxy_Impl"; - if (node->n_inherits () > 0) - { - *os << "," << be_nl; + int nparents = node->n_inherits (); - for (int i = 0; i < node->n_inherits (); i++) + if (nparents > 0) + { + for (int i = 0; i < nparents; ++i) { be_interface *inherited = be_interface::narrow_from_decl (node->inherits ()[i]); - *os << "public virtual "; - *os << inherited->full_remote_proxy_impl_name (); - - if (i < node->n_inherits () - 1) + if (inherited->is_abstract ()) { - // Node is the case of multiple - // inheritance, so put a comma. - *os << ", "; - *os << be_nl; + continue; } + + *os << "," << be_nl; + *os << "public virtual "; + *os << inherited->full_remote_proxy_impl_name (); } } @@ -86,3 +92,58 @@ be_visitor_interface_remote_proxy_impl_ch::visit_interface (be_interface *node) return 0; } + +int +be_visitor_interface_remote_proxy_impl_ch::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_remote_proxy_" + "impl_ch::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); + be_visitor_operation_proxy_impl_xh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp index 3bca271e829..8d9f84ac942 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp @@ -1,31 +1,38 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + remote_proxy_impl_cs, + "$Id$") -ACE_RCSID (be_visitor_interface, remote_proxy_broker_impl_cs, "$Id$") - -be_visitor_interface_remote_proxy_impl_cs::be_visitor_interface_remote_proxy_impl_cs (be_visitor_context *ctx) +be_visitor_interface_remote_proxy_impl_cs:: +be_visitor_interface_remote_proxy_impl_cs (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } - -be_visitor_interface_remote_proxy_impl_cs::~be_visitor_interface_remote_proxy_impl_cs (void) +be_visitor_interface_remote_proxy_impl_cs:: +~be_visitor_interface_remote_proxy_impl_cs (void) { // No-Op. } int -be_visitor_interface_remote_proxy_impl_cs::visit_interface (be_interface *node) +be_visitor_interface_remote_proxy_impl_cs::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); os->decr_indent (0); + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Base & Remote Proxy Implementation. " << be_nl << "//" << be_nl << be_nl; // Create the destructor implementation for the base @@ -35,12 +42,7 @@ be_visitor_interface_remote_proxy_impl_cs::visit_interface (be_interface *node) *os << node->full_base_proxy_impl_name () << "::" << node->base_proxy_impl_name () << " (void)" << be_nl << "{}" << be_nl << be_nl; - /* - // Dtor Impl. - *os << node->full_base_proxy_impl_name () << "::~" - << node->base_proxy_impl_name () << " (void)" << be_nl - << "{}" << be_nl << be_nl; - */ + // Create the destructor implementation for the remote // proxy implementation. @@ -49,13 +51,6 @@ be_visitor_interface_remote_proxy_impl_cs::visit_interface (be_interface *node) << node->remote_proxy_impl_name () << " (void)" << be_nl << "{}" << be_nl << be_nl; - /* - // Dtor Impl - *os << node->full_remote_proxy_impl_name () << "::~" - << node->remote_proxy_impl_name () << " (void)" << be_nl - << "{}" << be_nl << be_nl; - */ - // Generate the code for the Remote Proxy Impl. // operations *os << "// Remote Implementation of the IDL interface methods" @@ -75,6 +70,72 @@ be_visitor_interface_remote_proxy_impl_cs::visit_interface (be_interface *node) << "// End Base & Remote Proxy Implemeentation. " << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; + return 0; +} + +int +be_visitor_interface_remote_proxy_impl_cs::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_remote_proxy_" + "impl_cs::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_REMOTE_PROXY_IMPL_CS); + be_visitor_operation_remote_proxy_impl_cs op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; } + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_ch.cpp index fd4fd4987e8..7452a474649 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_ch.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, smart_proxy_ch, "$Id$") +ACE_RCSID (be_visitor_interface, + smart_proxy_ch, + "$Id$") // ************************************************************ // smart proxy class in header // ************************************************************ - -be_visitor_interface_smart_proxy_ch::be_visitor_interface_smart_proxy_ch -(be_visitor_context *ctx) +be_visitor_interface_smart_proxy_ch::be_visitor_interface_smart_proxy_ch ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -52,12 +48,17 @@ int be_visitor_interface_smart_proxy_ch::visit_interface (be_interface *node) be_type *bt; - // set the right type; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; - // output the class defn + { + bt = node; + } + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *os << "class " << be_global->stub_export_macro ()<< " " << "TAO_" << node->flat_name () @@ -122,6 +123,7 @@ int be_visitor_interface_smart_proxy_ch::visit_interface (be_interface *node) << "};\n\n"; os->indent (); + *os << "typedef TAO_Singleton<TAO_"<<node->flat_name () << "_Proxy_Factory_Adapter, TAO_SYNCH_RECURSIVE_MUTEX> TAO_" << node->flat_name ()<< "_PROXY_FACTORY_ADAPTER;"<<be_nl << be_nl; @@ -133,55 +135,61 @@ int be_visitor_interface_smart_proxy_ch::visit_interface (be_interface *node) << bt->nested_type_name (this->ctx_->scope ()); - if (node->n_inherits () > 0) // node interface inherits from other - // interfaces + if (node->n_inherits () > 0) { long i; + for (i = 0; i < node->n_inherits (); i++) { be_interface *inherited = be_interface::narrow_from_decl (node->inherits ()[i]); be_decl *scope = 0; + if (inherited->is_nested ()) { - // inherited node is used in the scope of "node" node + // Inherited node is used in the scope of "node" node. scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); } *os << "," << be_nl << " public virtual "; - *os << inherited->nested_sp_type_name (scope,"_Smart_Proxy_Base"); // dump the scoped name - } // end of for loop + *os << inherited->nested_sp_type_name (scope, + "_Smart_Proxy_Base"); + } } else { *os << "," << be_nl << " public virtual TAO_Smart_Proxy_Base"; } + *os << be_uidt_nl; *os << "{" << be_nl << "public:" << be_idt_nl - << "TAO_"<< node->flat_name () << "_Smart_Proxy_Base (void);" << be_nl - // Just to keep Old g++ complier (version: 2.7.2.3) happy its necessary - // to declare and define the destructor explicitly. - << "~TAO_"<< node->flat_name () << "_Smart_Proxy_Base (void);"<<be_nl - // This method will delegate this method to the <base_proxy_> - // member of the smart proxy and so the smart proxy's (nil) - // stubobj will not be returned. + << "TAO_"<< node->flat_name () << "_Smart_Proxy_Base (void);" + << be_nl + // Just to keep Old g++ complier (version: 2.7.2.3) happy it's + // necesssary to declare and define the destructor explicitly. + << "~TAO_"<< node->flat_name () << "_Smart_Proxy_Base (void);" + << be_nl + // This method will delegate this method to the <base_proxy_> + // member of the smart proxy and so the smart proxy's (nil) + // stubobj will not be returned. << "virtual TAO_Stub *_stubobj (void) const;" << be_uidt_nl; - // generate code for the interface definition by traversing thru the + // Generate code for the interface definition by traversing thru the // elements of its scope. We depend on the front-end to have made sure // that only legal syntactic elements appear in our scope. - os->indent (); + if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ch::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } *os << "protected:" << be_idt_nl @@ -197,5 +205,4 @@ int be_visitor_interface_smart_proxy_ch::visit_interface (be_interface *node) } return 0; - } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_cs.cpp index 48f57d01a47..7aae252e8a2 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/smart_proxy_cs.cpp @@ -17,26 +17,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, smart_proxy_cs, "$Id$") - +ACE_RCSID (be_visitor_interface, + smart_proxy_cs, + "$Id$") // ************************************************************ // be_visitor_interface_smart_proxy_cs // ************************************************************ -be_visitor_interface_smart_proxy_cs::be_visitor_interface_smart_proxy_cs -(be_visitor_context *ctx) +be_visitor_interface_smart_proxy_cs::be_visitor_interface_smart_proxy_cs ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } -be_visitor_interface_smart_proxy_cs::~be_visitor_interface_smart_proxy_cs (void) +be_visitor_interface_smart_proxy_cs::~be_visitor_interface_smart_proxy_cs ( + void + ) { } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_sh.cpp index 2b78387f443..152974f5126 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_sh.cpp @@ -1,51 +1,59 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + base_proxy_broker_sh, + "$Id$") -ACE_RCSID (be_visitor_interface, base_proxy_broker_sh, "$Id$") - -be_visitor_interface_strategized_proxy_broker_sh::be_visitor_interface_strategized_proxy_broker_sh (be_visitor_context *ctx) +be_visitor_interface_strategized_proxy_broker_sh:: +be_visitor_interface_strategized_proxy_broker_sh (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } - -be_visitor_interface_strategized_proxy_broker_sh::~be_visitor_interface_strategized_proxy_broker_sh (void) +be_visitor_interface_strategized_proxy_broker_sh:: +~be_visitor_interface_strategized_proxy_broker_sh (void) { // No-Op. } int -be_visitor_interface_strategized_proxy_broker_sh::visit_interface (be_interface *node) +be_visitor_interface_strategized_proxy_broker_sh::visit_interface ( + be_interface *node + ) { - TAO_OutStream *os = this->ctx_->stream (); - - // os->gen_ifdef_macro (node->local_name (), "STRATEGIZED_PROXY_BROKER_"); + TAO_OutStream *os = this->ctx_->stream (); // Generate the class declaration. os->indent (); *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Strategized Proxy Broker Declaration " << be_nl << "//" << be_nl << be_nl; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "class " << be_global->skel_export_macro () << " " << node->strategized_proxy_broker_name () << " : public virtual " - << "::" << node->full_base_proxy_broker_name () << be_nl << "{" << be_nl + << "::" << node->full_base_proxy_broker_name () << be_nl << "{" + << be_nl << "public: " << be_idt_nl; // Constructor *os << node->strategized_proxy_broker_name () << " (void);" << be_nl << be_nl; // Destructor - *os << "virtual ~" << node->strategized_proxy_broker_name () << " (void);" << be_nl << be_nl; + *os << "virtual ~" << node->strategized_proxy_broker_name () << " (void);" + << be_nl << be_nl; // Accessor Method - *os << "virtual " << "::" << node->full_base_proxy_impl_name () << " &" << "select_proxy (" << be_idt_nl; + *os << "virtual " << "::" << node->full_base_proxy_impl_name () << " &" + << "select_proxy (" << be_idt_nl; *os << "::" << node->full_name () << " *object" << be_nl << "ACE_ENV_ARG_DECL" << be_uidt_nl @@ -59,8 +67,10 @@ be_visitor_interface_strategized_proxy_broker_sh::visit_interface (be_interface << be_nl << "ACE_ENV_ARG_DECL" << be_uidt_nl << ");" << be_nl << be_nl - << "// Caches the proxy implementations. The proxy implementation" << be_nl - << "// are totally stateless, and those can be shared by all the" << be_nl + << "// Caches the proxy implementations. The proxy implementation" + << be_nl + << "// are totally stateless, and those can be shared by all the" + << be_nl << "// instances of a given IDL interface type." << be_nl << "::" << node->full_base_proxy_impl_name () << be_nl << "*proxy_cache_[TAO_Collocation_Strategies::CS_LAST];" @@ -68,8 +78,10 @@ be_visitor_interface_strategized_proxy_broker_sh::visit_interface (be_interface << "TAO_SYNCH_MUTEX mutex_;" << be_nl; // Factory Function declaration. - *os << "// This funxtion is used to get an handle to the unique instance" << be_nl - << "// of the Strategized Proxy Broker that is available for a given" << be_nl + *os << "// This funxtion is used to get an handle to the unique instance" + << be_nl + << "// of the Strategized Proxy Broker that is available for a given" + << be_nl << "// interface." << be_uidt_nl << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp index 644cff1056b..53669d2c205 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/strategized_proxy_broker_ss.cpp @@ -1,25 +1,29 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + strategized_proxy_broker_ss, + "$Id$") -ACE_RCSID (be_visitor_interface, base_proxy_broker_ss, "$Id$") - -be_visitor_interface_strategized_proxy_broker_ss::be_visitor_interface_strategized_proxy_broker_ss (be_visitor_context *ctx) +be_visitor_interface_strategized_proxy_broker_ss:: +be_visitor_interface_strategized_proxy_broker_ss (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_strategized_proxy_broker_ss::~be_visitor_interface_strategized_proxy_broker_ss (void) +be_visitor_interface_strategized_proxy_broker_ss:: +~be_visitor_interface_strategized_proxy_broker_ss (void) { // No-Op. } int -be_visitor_interface_strategized_proxy_broker_ss::visit_interface (be_interface *node) +be_visitor_interface_strategized_proxy_broker_ss::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -27,10 +31,14 @@ be_visitor_interface_strategized_proxy_broker_ss::visit_interface (be_interface os->indent (); *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// Strategized Proxy Broker Implementation" << be_nl << "//" << be_nl << be_nl; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// Factory function Implementation." << be_nl << node->full_strategized_proxy_broker_name () << " *" << node->full_strategized_proxy_broker_name () << "::the" @@ -126,59 +134,58 @@ be_visitor_interface_strategized_proxy_broker_ss::visit_interface (be_interface << "switch (strategy)" << be_idt_nl // idt = 4 << "{" << be_nl; - if (be_global->gen_thru_poa_collocation ()) - { - *os << "case TAO_Collocation_Strategies::CS_THRU_POA_STRATEGY:" - << be_idt_nl // idt = 5 - << "ACE_NEW_THROW_EX (" - << be_idt << be_idt_nl //idt = 7 - << "this->proxy_cache_[strategy]," << be_nl - << node->full_thru_poa_proxy_impl_name () << "," << be_nl - << "CORBA::NO_MEMORY ()" - << be_uidt << be_uidt_nl // idt = 5 - << ");" << be_nl - << "ACE_CHECK;" << be_nl - << "break;" - << be_nl << be_uidt_nl; // idt = 4 - } - - if (be_global->gen_direct_collocation ()) - { - *os << "case TAO_Collocation_Strategies::CS_DIRECT_STRATEGY:" - << be_idt_nl // idt = 5 - << "ACE_NEW_THROW_EX (" - << be_idt << be_idt_nl //idt = 7 - << "this->proxy_cache_[strategy]," << be_nl - << node->full_direct_proxy_impl_name () << "," << be_nl - << "CORBA::NO_MEMORY ()" - << be_uidt << be_uidt_nl // idt = 5 - << ");" << be_nl - << "ACE_CHECK;" << be_nl - << "break;" - << be_nl << be_uidt_nl; // idt = 4 - } - - *os << "case TAO_Collocation_Strategies::CS_REMOTE_STRATEGY:" << be_nl - << "default:" + + if (be_global->gen_thru_poa_collocation ()) + { + *os << "case TAO_Collocation_Strategies::CS_THRU_POA_STRATEGY:" + << be_idt_nl // idt = 5 + << "ACE_NEW_THROW_EX (" + << be_idt << be_idt_nl //idt = 7 + << "this->proxy_cache_[strategy]," << be_nl + << node->full_thru_poa_proxy_impl_name () << "," << be_nl + << "CORBA::NO_MEMORY ()" + << be_uidt << be_uidt_nl // idt = 5 + << ");" << be_nl + << "ACE_CHECK;" << be_nl + << "break;" + << be_nl << be_uidt_nl; // idt = 4 + } + + if (be_global->gen_direct_collocation ()) + { + *os << "case TAO_Collocation_Strategies::CS_DIRECT_STRATEGY:" << be_idt_nl // idt = 5 << "ACE_NEW_THROW_EX (" << be_idt << be_idt_nl //idt = 7 << "this->proxy_cache_[strategy]," << be_nl - << "::" << node->full_remote_proxy_impl_name () << "," << be_nl + << node->full_direct_proxy_impl_name () << "," << be_nl << "CORBA::NO_MEMORY ()" << be_uidt << be_uidt_nl // idt = 5 << ");" << be_nl << "ACE_CHECK;" << be_nl << "break;" - << be_uidt_nl // idt = 4 - << be_uidt_nl // idt = 3 - + << be_nl << be_uidt_nl; // idt = 4 + } + + *os << "case TAO_Collocation_Strategies::CS_REMOTE_STRATEGY:" << be_nl + << "default:" + << be_idt_nl // idt = 5 + << "ACE_NEW_THROW_EX (" + << be_idt << be_idt_nl //idt = 7 + << "this->proxy_cache_[strategy]," << be_nl + << "::" << node->full_remote_proxy_impl_name () << "," << be_nl + << "CORBA::NO_MEMORY ()" + << be_uidt << be_uidt_nl // idt = 5 + << ");" << be_nl + << "ACE_CHECK;" << be_nl + << "break;" + << be_uidt_nl // idt = 4 + << be_uidt_nl // idt = 3 << "}" << be_uidt_nl // idt = 2 << be_uidt_nl // idt = 1 << "}" << be_uidt_nl // idt = 0 - << "}" << be_nl << be_nl; *os << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp index b638b69469a..3516857ae54 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp @@ -1,73 +1,88 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + thru_poa_proxy_impl_sh, + "$Id$") -ACE_RCSID (be_visitor_interface, thru_poa_proxy_broker_impl_sh, "$Id$") - -be_visitor_interface_thru_poa_proxy_impl_sh::be_visitor_interface_thru_poa_proxy_impl_sh (be_visitor_context *ctx) +be_visitor_interface_thru_poa_proxy_impl_sh:: +be_visitor_interface_thru_poa_proxy_impl_sh (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_thru_poa_proxy_impl_sh::~be_visitor_interface_thru_poa_proxy_impl_sh (void) +be_visitor_interface_thru_poa_proxy_impl_sh:: +~be_visitor_interface_thru_poa_proxy_impl_sh (void) { // No-Op. } int -be_visitor_interface_thru_poa_proxy_impl_sh::visit_interface (be_interface *node) +be_visitor_interface_thru_poa_proxy_impl_sh::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// ThruPOA Impl. Declaration" << be_nl << "//" << be_nl << be_nl; + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate Class Declaration. *os << "class " << be_global->skel_export_macro () << " " << node->thru_poa_proxy_impl_name (); - *os << " : " << be_idt_nl << "public virtual " << "::" << node->full_base_proxy_impl_name () + *os << " : " << be_idt_nl << "public virtual " + << "::" << node->full_base_proxy_impl_name () << "," << be_nl << "public virtual " << "TAO_ThruPOA_Object_Proxy_Impl"; if (node->n_inherits () > 0) { - *os << "," << be_nl; + AST_Interface *parent = 0; + for (int i = 0; i < node->n_inherits (); i++) { + parent = node->inherits ()[i]; + + if (parent->is_abstract ()) + { + continue; + } + + *os << "," << be_nl; + be_interface *inherited = - be_interface::narrow_from_decl (node->inherits ()[i]); + be_interface::narrow_from_decl (parent); *os << "public virtual "; *os << "::" << inherited->full_thru_poa_proxy_impl_name (); - if (i < node->n_inherits () - 1) // node is the case of multiple - // inheritance, so put a comma - { - *os << ", "; - } - *os << be_nl; - } // end of for loop + } } *os << be_uidt_nl; - *os << "{" << be_nl << "public:" << be_idt_nl; + *os << "{" << be_nl << "public:" << be_idt_nl; - // Ctor - *os << node->thru_poa_proxy_impl_name () << " (void);" << be_nl << be_nl; + // Ctor + *os << node->thru_poa_proxy_impl_name () << " (void);" << be_nl << be_nl; - // Dtor - *os << "virtual ~" << node->thru_poa_proxy_impl_name () - << " (void) { }" << be_nl << be_nl; + // Dtor + *os << "virtual ~" << node->thru_poa_proxy_impl_name () + << " (void) { }" << be_nl << be_nl; if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) thru_poa_proxy_impl_sh::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } *os << be_uidt_nl << "};" << be_nl; @@ -76,7 +91,62 @@ be_visitor_interface_thru_poa_proxy_impl_sh::visit_interface (be_interface *node << "// ThruPOA Proxy Impl. Declaration" << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; - // os->gen_endif (); + return 0; } + +int +be_visitor_interface_thru_poa_proxy_impl_sh::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_thru_poa_proxy_" + "impl_sh::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName item_new_name (d->local_name (), + 0); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + &item_new_name, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); + be_visitor_operation_proxy_impl_xh op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp index 8e7105a8c03..1a6264ba044 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp @@ -1,43 +1,45 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// -#include "be_visitor_interface.h" +ACE_RCSID (be_visitor_interface, + thru_poa_proxy_impl_ss, + "$Id$") -ACE_RCSID (be_visitor_interface, thru_poa_proxy_broker_impl_ss, "$Id$") - -be_visitor_interface_thru_poa_proxy_impl_ss::be_visitor_interface_thru_poa_proxy_impl_ss (be_visitor_context *ctx) +be_visitor_interface_thru_poa_proxy_impl_ss:: +be_visitor_interface_thru_poa_proxy_impl_ss (be_visitor_context *ctx) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_thru_poa_proxy_impl_ss::~be_visitor_interface_thru_poa_proxy_impl_ss (void) +be_visitor_interface_thru_poa_proxy_impl_ss:: +~be_visitor_interface_thru_poa_proxy_impl_ss (void) { // No-Op. } int -be_visitor_interface_thru_poa_proxy_impl_ss::visit_interface (be_interface *node) +be_visitor_interface_thru_poa_proxy_impl_ss::visit_interface ( + be_interface *node + ) { TAO_OutStream *os = this->ctx_->stream (); *os << be_nl - << "///////////////////////////////////////////////////////////////////////\n" + << "///////////////////////////////////////////////////////////////////////" + << be_nl << "// ThruPOA Proxy Implementation\n" << "//\n\n"; + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Ctor Implementation *os << node->full_thru_poa_proxy_impl_name () << "::" << node->thru_poa_proxy_impl_name () << " (void)" << be_nl << "{}" << be_nl << be_nl; - /* - // Dtor Implementation - *os << node->full_thru_poa_proxy_impl_name () << "::~" - << node->thru_poa_proxy_impl_name () << " (void)" << be_nl - << "{}" << be_nl << be_nl; - */ // Generate the code for the ThruPOA Proxy Impl. // operations @@ -61,3 +63,69 @@ be_visitor_interface_thru_poa_proxy_impl_ss::visit_interface (be_interface *node return 0; } + +int +be_visitor_interface_thru_poa_proxy_impl_ss::gen_abstract_ops_helper ( + be_interface *node, + be_interface *base, + TAO_OutStream *os + ) +{ + if (node == base) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interface_thru_poa_proxy" + "_impl_ss::abstract_base_ops_helper - " + "bad node in this scope\n"), + -1); + } + + if (d->node_type () == AST_Decl::NT_op) + { + UTL_ScopedName *item_new_name = 0; + ACE_NEW_RETURN (item_new_name, + UTL_ScopedName (d->local_name ()->copy (), + 0), + -1); + + UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy (); + base->nconc (item_new_name); + + AST_Operation *op = AST_Operation::narrow_from_decl (d); + be_operation new_op (op->return_type (), + op->flags (), + 0, + op->is_local (), + op->is_abstract ()); + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); + new_op.set_name (base); + ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_PROXY_IMPL_SS); + be_visitor_operation_thru_poa_proxy_impl_ss op_visitor (&ctx); + op_visitor.visit_operation (&new_op); + + base->destroy (); + delete base; + base = 0; + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp index 5cf10eaa315..8421f97c59d 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, tie_sh, "$Id$") - +ACE_RCSID (be_visitor_interface, + tie_sh, + "$Id$") // ************************************************************ -// Interface visitor for server header +// Interface visitor for server header. // ************************************************************ -be_visitor_interface_tie_sh::be_visitor_interface_tie_sh (be_visitor_context *ctx) +be_visitor_interface_tie_sh::be_visitor_interface_tie_sh ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -47,7 +44,7 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) static char namebuf [NAMEBUFSIZE]; static char tiename [NAMEBUFSIZE]; - if (node->imported ()) + if (node->imported () || node->is_abstract ()) { return 0; } @@ -88,6 +85,9 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) // Now generate the class definition. os->indent (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// TIE class: Refer to CORBA v2.2, Section 20.34.4" << be_nl; *os << "template <class T>" << be_nl; *os << "class " << " " << tiename << " : public " << namebuf << be_nl; @@ -120,10 +120,13 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl << ");" << be_uidt << "\n"; - if (node->traverse_inheritance_graph ( - be_visitor_interface_tie_sh::method_helper, - os - ) == -1) + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_tie_sh::method_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh_ss::" @@ -133,6 +136,7 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) } os->decr_indent (1); + *os << "private:" << be_idt_nl << "T *ptr_;" << be_nl << "PortableServer::POA_var poa_;" << be_nl @@ -147,23 +151,30 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) int be_visitor_interface_tie_sh::method_helper (be_interface *, - be_interface *node, - TAO_OutStream *os) + be_interface *node, + TAO_OutStream *os) { + // Any methods from abstract parents have already been + // "added" to the derived interface scope by the overridden + // visit_scope() method in be_visitor_interface, so we can skip + // this base interface, if it is abstract. + if (node->is_abstract ()) + { + return 0; + } + be_visitor_context ctx; ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SH); - ctx.stream (os); - be_visitor* visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_tie_sh visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) + if (visitor.visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh::" - "method_helper\n"), -1); + "method_helper\n"), + -1); } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp b/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp index 7a42da46f21..560b8213187 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp @@ -19,20 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, tie_si, "$Id$") +ACE_RCSID (be_visitor_interface, + tie_si, + "$Id$") // ************************************************************************ // Interface visitor for server inline // ************************************************************************ -be_visitor_interface_tie_si::be_visitor_interface_tie_si (be_visitor_context *ctx) +be_visitor_interface_tie_si::be_visitor_interface_tie_si ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -44,46 +42,67 @@ be_visitor_interface_tie_si::~be_visitor_interface_tie_si (void) int be_visitor_interface_tie_si::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream - static char fulltiename [NAMEBUFSIZE]; // holds the class name - static char localtiename [NAMEBUFSIZE]; // holds the tie name - static char localskelname [NAMEBUFSIZE]; // holds the local skeleton name - - if (node->srv_inline_gen () || node->imported ()) - return 0; + if (node->srv_inline_gen () || node->imported () || node->is_abstract ()) + { + return 0; + } - ACE_OS::memset (fulltiename, '\0', NAMEBUFSIZE); - ACE_OS::memset (localtiename, '\0', NAMEBUFSIZE); - ACE_OS::memset (localskelname, '\0', NAMEBUFSIZE); + TAO_OutStream *os; + static char fulltiename [NAMEBUFSIZE]; + static char localtiename [NAMEBUFSIZE]; + static char localskelname [NAMEBUFSIZE]; + + ACE_OS::memset (fulltiename, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (localtiename, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (localskelname, + '\0', + NAMEBUFSIZE); os = this->ctx_->stream (); - // generate the skeleton class name which will be used to determine the TIE - // class name + // Generate the skeleton class name which will be used to determine the TIE + // class name. + + // We are outermost. + ACE_OS::sprintf (fulltiename, + "%s_tie", + node->full_skel_name ()); - // we are outermost - ACE_OS::sprintf (fulltiename, "%s_tie", node->full_skel_name ()); if (!node->is_nested ()) { - ACE_OS::sprintf (localskelname, "POA_%s", + ACE_OS::sprintf (localskelname, + "POA_%s", node->local_name ()); - ACE_OS::sprintf (localtiename, "POA_%s_tie", + ACE_OS::sprintf (localtiename, + "POA_%s_tie", node->local_name ()); } else { - ACE_OS::sprintf (localskelname, "%s", + ACE_OS::sprintf (localskelname, + "%s", node->local_name ()); - ACE_OS::sprintf (localtiename, "%s_tie", + ACE_OS::sprintf (localtiename, + "%s_tie", node->local_name ()); } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if (node->is_nested ()) { *os << "#if defined (ACE_HAS_USING_KEYWORD)\n\n"; } - os->indent (); // start with whatever indentation level we are at + os->indent (); + + *os << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl << be_nl; *os << "template <class T> ACE_INLINE" << be_nl << fulltiename << "<T>::" << localtiename << " (T &t)" << be_nl @@ -170,7 +189,13 @@ be_visitor_interface_tie_si::visit_interface (be_interface *node) << "::_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "}\n\n"; - if (node->traverse_inheritance_graph (be_visitor_interface_tie_si::method_helper, os) == -1) + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_tie_si::method_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh_ss::" @@ -192,19 +217,29 @@ be_visitor_interface_tie_si::method_helper (be_interface *derived, be_interface *node, TAO_OutStream *os) { + // Any methods from abstract parents have already been + // "added" to the derived interface scope by the overridden + // visit_scope() method in be_visitor_interface, so we can skip + // this base interface, if it is abstract. + if (node->is_abstract ()) + { + return 0; + } + be_visitor_context ctx; ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SI); ctx.interface (derived); ctx.stream (os); + be_visitor_interface_tie_si visitor (&ctx); + + if (visitor.visit_scope (node) == -1) - be_visitor* visitor = tao_cg->make_visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh::" - "method_helper\n"), -1); + "method_helper\n"), + -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface_fwd.cpp b/TAO/TAO_IDL/be/be_visitor_interface_fwd.cpp index 0796b99e556..a042bdc1498 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd.cpp @@ -18,17 +18,20 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_interface_fwd.h" +#include "be_interface.h" #include "be_visitor_interface_fwd.h" +#include "be_visitor_context.h" +#include "be_helper.h" +#include "be_extern.h" -// include all the individual files #include "be_visitor_interface_fwd/interface_fwd_ch.cpp" #include "be_visitor_interface_fwd/interface_fwd_ci.cpp" #include "be_visitor_interface_fwd/cdr_op_ch.cpp" #include "be_visitor_interface_fwd/cdr_op_ci.cpp" #include "be_visitor_interface_fwd/any_op_ch.cpp" -ACE_RCSID(be, be_visitor_interface_fwd, "$Id$") +ACE_RCSID (be, + be_visitor_interface_fwd, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_interface_fwd/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface_fwd/any_op_ch.cpp index 85a5f916b17..eafc335ad18 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd/any_op_ch.cpp @@ -19,13 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_interface_fwd.h" - -ACE_RCSID(be_visitor_interface_fwd, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_interface_fwd, + any_op_ch, + "$Id$") // *************************************************************************** // Generates Any operator declarations in the client header @@ -76,6 +72,5 @@ be_visitor_interface_fwd_any_op_ch::visit_interface_fwd ( << node->name () << " *&);\n"; node->cli_hdr_any_op_gen (1); - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ch.cpp index 51806a8387b..be788d61101 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ch.cpp @@ -19,21 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface_fwd.h" - -ACE_RCSID(be_visitor_interface_fwd, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_interface_fwd, + cdr_op_ch, + "$Id$") // *************************************************************************** // Forward declared interface visitor for generating CDR operator declarations // in the client header. Called if this node is not later defined in the file. // *************************************************************************** -be_visitor_interface_fwd_cdr_op_ch::be_visitor_interface_fwd_cdr_op_ch -(be_visitor_context *ctx) +be_visitor_interface_fwd_cdr_op_ch::be_visitor_interface_fwd_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -68,6 +65,7 @@ be_visitor_interface_fwd_cdr_op_ch::visit_interface_fwd (be_interface_fwd *node) // Generate the CDR << and >> operator declarations. os->indent (); + *os << be_global->stub_export_macro () << " CORBA::Boolean " << "operator<< (TAO_OutputCDR &, const " << node->full_name () << "_ptr );" << be_nl; @@ -76,6 +74,5 @@ be_visitor_interface_fwd_cdr_op_ch::visit_interface_fwd (be_interface_fwd *node) << node->full_name () << "_ptr &);\n"; node->cli_hdr_cdr_op_gen (1); - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ci.cpp index d6018d72cd6..34b287aa202 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ci.cpp @@ -19,13 +19,9 @@ // // ================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface_fwd.h" - -ACE_RCSID(be_visitor_interface_fwd, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_interface_fwd, + cdr_op_ci, + "$Id$") // **************************************************************** // Interface visitor for generating CDR operator declarations in the @@ -61,6 +57,7 @@ be_visitor_interface_fwd_cdr_op_ci::visit_interface_fwd ( // generate the CDR << and >> operator declarations os->indent (); + *os << be_global->stub_export_macro () << " CORBA::Boolean operator<< (" << be_idt << be_idt_nl << "TAO_OutputCDR &," << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ch.cpp index feb767c831c..7984871f1ee 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ch.cpp @@ -18,21 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface_fwd.h" - -ACE_RCSID(be_visitor_interface_fwd, interface_fwd_ch, "$Id$") - +ACE_RCSID (be_visitor_interface_fwd, + interface_fwd_ch, + "$Id$") // ******************************************************************** // Visitor implementation for the Interface_Fwd type // This one for the client header file // ******************************************************************** -be_visitor_interface_fwd_ch::be_visitor_interface_fwd_ch (be_visitor_context *ctx) +be_visitor_interface_fwd_ch::be_visitor_interface_fwd_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -45,13 +42,13 @@ be_visitor_interface_fwd_ch::~be_visitor_interface_fwd_ch (void) int be_visitor_interface_fwd_ch::visit_interface_fwd (be_interface_fwd *node) { - TAO_OutStream *os = this->ctx_->stream (); - if (node->cli_hdr_gen () || node->imported ()) { return 0; } + TAO_OutStream *os = this->ctx_->stream (); + // All we do in this is generate a forward declaration of the class. *os << "class " << node->local_name () << ";" << be_nl; @@ -106,6 +103,5 @@ be_visitor_interface_fwd_ch::visit_interface_fwd (be_interface_fwd *node) os->gen_endif (); node->cli_hdr_gen (I_TRUE); - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp index 70c08b598d5..8fa023edc4b 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp @@ -18,21 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface_fwd.h" - -ACE_RCSID(be_visitor_interface_fwd, interface_fwd_ci, "$Id$") - +ACE_RCSID (be_visitor_interface_fwd, + interface_fwd_ci, + "$Id$") // ******************************************************************** // Visitor implementation for the Interface_Fwd type // This one for the client inline file // ******************************************************************** -be_visitor_interface_fwd_ci::be_visitor_interface_fwd_ci (be_visitor_context *ctx) +be_visitor_interface_fwd_ci::be_visitor_interface_fwd_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } diff --git a/TAO/TAO_IDL/be/be_visitor_module.cpp b/TAO/TAO_IDL/be/be_visitor_module.cpp index 1bd1b4ffe36..6028e016bb0 100644 --- a/TAO/TAO_IDL/be/be_visitor_module.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module.cpp @@ -18,13 +18,38 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_module.h" +#include "be_constant.h" +#include "be_enum.h" +#include "be_exception.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_structure.h" +#include "be_structure_fwd.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_union_fwd.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_extern.h" +#include "be_helper.h" +#include "utl_err.h" #include "be_visitor_module.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_interface.h" +#include "be_visitor_interface_fwd.h" +#include "be_visitor_structure.h" +#include "be_visitor_structure_fwd.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" +#include "be_visitor_union_fwd.h" +#include "be_visitor_valuetype.h" +#include "be_visitor_valuetype_fwd.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_module/module.cpp" #include "be_visitor_module/module_ch.cpp" #include "be_visitor_module/module_sh.cpp" @@ -32,5 +57,7 @@ #include "be_visitor_module/any_op.cpp" #include "be_visitor_module/cdr_op.cpp" -ACE_RCSID(be, be_visitor_module, "$Id$") +ACE_RCSID (be, + be_visitor_module, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_module/any_op.cpp b/TAO/TAO_IDL/be/be_visitor_module/any_op.cpp index 2d50f3b54d0..5819d998f17 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/any_op.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/any_op.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, any_op, "$Id$") - +ACE_RCSID (be_visitor_module, + any_op, + "$Id$") // *************************************************************************** // Module visitor for generating Any operator declarations in the client header @@ -45,12 +40,13 @@ be_visitor_module_any_op::~be_visitor_module_any_op (void) int be_visitor_module_any_op::visit_module (be_module *node) { - // 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_module::visit_module - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_module/cdr_op.cpp b/TAO/TAO_IDL/be/be_visitor_module/cdr_op.cpp index 9f3fd486ddf..540057da455 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/cdr_op.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/cdr_op.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, cdr_op, "$Id") - +ACE_RCSID (be_visitor_module, + cdr_op, + "$Id: cdr_op.cpp,v 1.2 1999/05/28 02:16:43 coryan Exp ") // *************************************************************************** // Module visitor for generating CDR operator declarations in the client header @@ -45,12 +40,13 @@ be_visitor_module_cdr_op::~be_visitor_module_cdr_op (void) int be_visitor_module_cdr_op::visit_module (be_module *node) { - // 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_module_cdr_op::visit_module - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_module/module.cpp b/TAO/TAO_IDL/be/be_visitor_module/module.cpp index d57c95b1ace..db31834b964 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/module.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/module.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module, "$Id$") +ACE_RCSID (be_visitor_module, + module, + "$Id$") // ****************************************************** @@ -40,7 +36,6 @@ be_visitor_module::~be_visitor_module (void) { } -// visit the Module node and its scope int be_visitor_module::visit_module (be_module *node) { if (node->nmembers () == 0) @@ -49,41 +44,44 @@ int be_visitor_module::visit_module (be_module *node) node); } - // all we have to do is to visit the scope if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::visit_module - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } return 0; } -// =all common visit methods for module visitor +// All common visit methods for module visitor. -// visit a constant int be_visitor_module::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: @@ -101,70 +99,77 @@ be_visitor_module::visit_constant (be_constant *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_constant - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_constant - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_module::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; case TAO_CodeGen::TAO_MODULE_CI: case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: @@ -177,73 +182,90 @@ be_visitor_module::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_enum - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an exception int be_visitor_module::visit_exception (be_exception *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_SI: @@ -260,115 +282,161 @@ be_visitor_module::visit_exception (be_exception *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_exception - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_exception - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an interface int be_visitor_module::visit_interface (be_interface *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 + ctx.node (node); + int status = 1; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: + // This is the only context state involved in strategies. ctx.state (TAO_CodeGen::TAO_INTERFACE_CH); break; case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CI); + be_visitor_interface_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CS); + be_visitor_interface_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_SH); + be_visitor_interface_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_IH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); + be_visitor_interface_ih visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_SI); + be_visitor_interface_si visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_SS); + be_visitor_interface_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_IS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); + be_visitor_interface_is visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH); + be_visitor_interface_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS); + be_visitor_interface_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH); + be_visitor_interface_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI); + be_visitor_interface_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS); + be_visitor_interface_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } + if (status == 0) + { + return 0; + } + else if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_module::" + "visit_interface - " + "failed to accept visitor\n"), + -1); + } + // Change the state depending on the kind of node strategy ctx.state (node->next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; @@ -377,28 +445,29 @@ be_visitor_module::visit_interface (be_interface *node) // the node. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } @@ -406,39 +475,53 @@ be_visitor_module::visit_interface (be_interface *node) return 0; } -// visit an interface_fwd int be_visitor_module::visit_interface_fwd (be_interface_fwd *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); + be_visitor_interface_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); + be_visitor_interface_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); + be_visitor_interface_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); + be_visitor_interface_fwd_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); + be_visitor_interface_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: case TAO_CodeGen::TAO_MODULE_CS: case TAO_CodeGen::TAO_MODULE_SH: @@ -452,173 +535,175 @@ be_visitor_module::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface_fwd - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface_fwd - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_interface_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an valuetype int be_visitor_module::visit_valuetype (be_valuetype *node) { - // instantiate a visitor context with a copy of our context. This info + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CH); + be_visitor_valuetype_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CI); + be_visitor_valuetype_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CS); + be_visitor_valuetype_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH); + be_visitor_valuetype_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI); + be_visitor_valuetype_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS); + be_visitor_valuetype_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH); + be_visitor_valuetype_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS); + be_visitor_valuetype_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: - case TAO_CodeGen::TAO_MODULE_IH: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SH); + be_visitor_valuetype_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SI: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SI); + be_visitor_valuetype_si visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SS: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SS); + be_visitor_valuetype_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_IS: - return 0; // nothing to do, resp. not yet impl. + return 0; // nothing to do. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - // Change the state depending on the kind of node strategy - ctx.state (node->next_state (ctx.state ())); - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_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_module::" - "visit_valuetype - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - visitor = 0; - - // Do addtional "extra" code generation if necessary - if (node->has_extra_code_generation (ctx.state ())) - { - // Change the state depending on the kind of node strategy - ctx.state (node->next_state (ctx.state (), 1)); - - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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_module::" - "visit_valuetype - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - visitor = 0; + "failed to accept visitor\n"), + -1); } return 0; } -// visit a valuetype_fwd int be_visitor_module::visit_valuetype_fwd (be_valuetype_fwd *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); + be_visitor_valuetype_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); + be_visitor_valuetype_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); + be_visitor_valuetype_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); + be_visitor_valuetype_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: @@ -634,73 +719,90 @@ be_visitor_module::visit_valuetype_fwd (be_valuetype_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype_fwd - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype_fwd - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_valuetype_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an structure int be_visitor_module::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_SI: @@ -712,73 +814,143 @@ be_visitor_module::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_module::visit_structure_fwd (be_structure_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_MODULE_CH: + { + ctx.state (TAO_CodeGen::TAO_STRUCT_FWD_CH); + be_visitor_structure_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_MODULE_CI: + case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: + case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: + case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: + case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: + case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: + case TAO_CodeGen::TAO_MODULE_CS: + case TAO_CodeGen::TAO_MODULE_SH: + case TAO_CodeGen::TAO_MODULE_SI: + case TAO_CodeGen::TAO_MODULE_SS: + case TAO_CodeGen::TAO_MODULE_IH: + case TAO_CodeGen::TAO_MODULE_IS: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_module::" + "visit_structure_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); + "visit_structure_fwd - " + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit an union int be_visitor_module::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_SI: @@ -790,73 +962,143 @@ be_visitor_module::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_module::visit_union_fwd (be_union_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_MODULE_CH: + { + ctx.state (TAO_CodeGen::TAO_UNION_FWD_CH); + be_visitor_union_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_MODULE_CI: + case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: + case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: + case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: + case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: + case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: + case TAO_CodeGen::TAO_MODULE_CS: + case TAO_CodeGen::TAO_MODULE_SH: + case TAO_CodeGen::TAO_MODULE_SI: + case TAO_CodeGen::TAO_MODULE_SS: + case TAO_CodeGen::TAO_MODULE_IH: + case TAO_CodeGen::TAO_MODULE_IS: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_module::" + "visit_union_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" - "visit_union - " - "failed to accept visitor\n" - ), -1); + "visit_union_fwd - " + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit a typedef int be_visitor_module::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_SI: case TAO_CodeGen::TAO_MODULE_SS: @@ -868,30 +1110,19 @@ be_visitor_module::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_typedef - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_typedef - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp b/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp index 8f6ec45705d..85e5719acc8 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp @@ -17,14 +17,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module_ch, "$Id$") - +ACE_RCSID (be_visitor_module, + module_ch, + "$Id$") // ****************************************************** // Module visitor for client header @@ -42,13 +37,15 @@ be_visitor_module_ch::~be_visitor_module_ch (void) int be_visitor_module_ch::visit_module (be_module *node) { - TAO_OutStream *os; // output stream - if (!node->cli_hdr_gen () && !node->imported ()) { - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; os->indent (); + *os << "TAO_NAMESPACE " << " " << node->local_name () << be_nl << "{" << be_idt_nl; @@ -61,10 +58,14 @@ be_visitor_module_ch::visit_module (be_module *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module_ch::" "visit_module - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - *os << be_uidt_nl + *os << be_uidt_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + + *os << be_nl << "}\nTAO_NAMESPACE_CLOSE // module " << node->name () << "\n\n"; } diff --git a/TAO/TAO_IDL/be/be_visitor_module/module_ih.cpp b/TAO/TAO_IDL/be/be_visitor_module/module_ih.cpp index 4c715342240..92eacef28aa 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/module_ih.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/module_ih.cpp @@ -16,13 +16,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module_ih, "$Id$") +ACE_RCSID (be_visitor_module, + module_ih, + "$Id$") // ************************************************************ // Module visitor for server header @@ -40,17 +36,17 @@ be_visitor_module_ih::~be_visitor_module_ih (void) int be_visitor_module_ih::visit_module (be_module *node) { - if (!node->impl_hdr_gen () && !node->imported ()) // not generated and not imported + if (!node->impl_hdr_gen () && !node->imported ()) { - if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module_sh::" + "(%N:%l) be_visitor_module_ih::" "visit_module - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_module/module_sh.cpp b/TAO/TAO_IDL/be/be_visitor_module/module_sh.cpp index f6173c11bf2..69277ece870 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/module_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/module_sh.cpp @@ -17,14 +17,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module_sh, "$Id$") - +ACE_RCSID (be_visitor_module, + module_sh, + "$Id$") // ************************************************************ // Module visitor for server header @@ -42,12 +37,13 @@ be_visitor_module_sh::~be_visitor_module_sh (void) int be_visitor_module_sh::visit_module (be_module *node) { - TAO_OutStream *os; - // Not generated and not imported. if (!node->srv_hdr_gen () && !node->imported ()) { - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Generate the skeleton class name. @@ -75,10 +71,15 @@ be_visitor_module_sh::visit_module (be_module *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module_sh::" "visit_module - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } os->decr_indent (); + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "}" << be_nl << "TAO_NAMESPACE_CLOSE // module " << node->name () << "\n\n"; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation.cpp index a8351b2acdb..d8096fb0927 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation.cpp @@ -18,13 +18,33 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_argument.h" +#include "be_array.h" +#include "be_attribute.h" +#include "be_enum.h" +#include "be_exception.h" +#include "be_interface_fwd.h" +#include "be_native.h" +#include "be_operation.h" +#include "be_predefined_type.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_type.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_extern.h" +#include "be_helper.h" +#include "utl_identifier.h" +#include "utl_exceptlist.h" +#include "nr_extern.h" #include "be_visitor_operation.h" +#include "be_visitor_argument.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_operation/operation.cpp" #include "be_visitor_operation/arglist.cpp" #include "be_visitor_operation/argument.cpp" @@ -50,13 +70,18 @@ #include "be_visitor_operation/tie_si.cpp" #include "be_visitor_operation/rettype_pre_invoke_cs.cpp" +// AMI #include "be_visitor_operation/ami_ch.cpp" #include "be_visitor_operation/ami_cs.cpp" #include "be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp" #include "be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp" #include "be_visitor_operation/ami_exception_holder_operation_cs.cpp" + +// Smart proxy #include "be_visitor_operation/smart_proxy_ch.cpp" #include "be_visitor_operation/smart_proxy_cs.cpp" + +// Interceptors #include "be_visitor_operation/interceptors_ch.cpp" #include "be_visitor_operation/interceptors_cs.cpp" #include "be_visitor_operation/interceptors_arglist.cpp" @@ -65,9 +90,10 @@ #include "be_visitor_operation/interceptors_exceptlist.cpp" #include "be_visitor_operation/interceptors_info_rettype.cpp" #include "be_visitor_operation/interceptors_result.cpp" + +// Collocation #include "be_visitor_operation/base_proxy_impl_ch.cpp" #include "be_visitor_operation/proxy_impl_xh.cpp" -#include "be_visitor_operation/inv_arglist.cpp" #include "be_visitor_operation/remote_proxy_impl_cs.cpp" #include "be_visitor_operation/thru_poa_proxy_impl_ss.cpp" #include "be_visitor_operation/direct_proxy_impl_ss.cpp" @@ -78,4 +104,6 @@ #include "be_visitor_operation/amh_rh_ss.cpp" #include "be_visitor_operation/amh_rh_sh.cpp" -ACE_RCSID(be, be_visitor_operation, "$Id$") +ACE_RCSID (be, + be_visitor_operation, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp index 12cfa035143..2296a5d4c65 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp @@ -19,21 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "ast_decl.h" -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_amh_rh_sh, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation_amh_rh_sh, + "$Id$") // ****************************************************** // Visitor for generating AMH-RH skeleton for "operation" // in skeleton header. // ****************************************************** -be_visitor_amh_rh_operation_sh::be_visitor_amh_rh_operation_sh (be_visitor_context *ctx) +be_visitor_amh_rh_operation_sh::be_visitor_amh_rh_operation_sh ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -92,20 +89,10 @@ be_visitor_amh_rh_operation_sh::visit_operation (be_operation *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_amh_rh_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_amh_rh_sh::" "visit_operation - " @@ -113,8 +100,6 @@ be_visitor_amh_rh_operation_sh::visit_operation (be_operation *node) -1); } - delete visitor; - *os << ";" << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp index 76669ed1dc8..43982f6d1d7 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp @@ -10,11 +10,9 @@ */ //============================================================================= -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" +ACE_RCSID (be_visitor_operation, + amh_rh_ss, + "$Id$") be_visitor_amh_rh_operation_ss::be_visitor_amh_rh_operation_ss ( be_visitor_context *ctx @@ -212,7 +210,7 @@ be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - be_compiled_visitor_operation_argument_invoke visitor (&ctx); + be_visitor_operation_argument_invoke visitor (&ctx); if (node->accept (&visitor) == -1) { diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp index 4d5d252ab47..086e4a10e77 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp @@ -19,16 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "ast_decl.h" -#include "be_visitor_operation.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_operation, amh_sh, "$Id$") - +ACE_RCSID (be_visitor_operation, + amh_sh, + "$Id$") // ****************************************************** // Visitor for generating AMH skeleton for "operation" in skeleton header. @@ -117,7 +110,7 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) *os << be_uidt_nl << "))" << be_uidt; } - *os << " = 0;\n" << be_nl; + *os << " = 0;" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp index f0e40e41975..10e8da9bfac 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp @@ -10,11 +10,9 @@ */ //============================================================================= -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" +ACE_RCSID (be_visitor_operation, + amh_ss, + "$Id$") be_visitor_amh_operation_ss::be_visitor_amh_operation_ss ( be_visitor_context *ctx @@ -111,7 +109,7 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) if (marshal_visitor.visit_argument (argument) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for demarshal failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp index aef71be2e41..a5966a04455 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_ami_ch, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation_ami_ch, + "$Id$") // ****************************************************** // Visitor for generating AMI stub for "operation" in client header. // ****************************************************** -be_visitor_operation_ami_ch::be_visitor_operation_ami_ch (be_visitor_context *ctx) +be_visitor_operation_ami_ch::be_visitor_operation_ami_ch ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -86,30 +83,16 @@ be_visitor_operation_ami_ch::visit_operation (be_operation *node) // parameter listing. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_arglist visitor (&ctx); - if (!visitor) + if (node->arguments ()->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ami_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->arguments ()->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ami_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - -// *os << be_nl; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp index a8577a4ac25..37e52f8374d 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp @@ -20,20 +20,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_ami_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation_ami_cs, + "$Id$") // ************************************************************ // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_ami_cs::be_visitor_operation_ami_cs (be_visitor_context *ctx) +be_visitor_operation_ami_cs::be_visitor_operation_ami_cs ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -49,8 +46,12 @@ be_visitor_operation_ami_cs::post_process (be_decl *bd) { // all we do here is to insert a comma and a newline TAO_OutStream *os = this->ctx_->stream (); + if (!this->last_node (bd)) - *os << ",\n"; + { + *os << ",\n"; + } + return 0; } @@ -59,16 +60,15 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) { // No sendc method for oneway operations. if (node->flags () == AST_Operation::OP_oneway) - return 0; - - TAO_OutStream *os; // output stream - be_visitor_context ctx; // visitor context - be_visitor *visitor; // visitor + { + return 0; + } - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + be_visitor_context ctx; + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os->indent (); // start with the current indentation level + os->indent (); // Generate the return type mapping. Return type is simply void. *os << "void" << be_nl; @@ -78,25 +78,32 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) // Grab the scope name. be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); + if (parent == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_cs::" - "visit_operation - " - "scope name is nil\n"), - -1); + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "scope name is nil\n"), + -1); + } // Generate the scope::operation name. *os << parent->full_name () << "::sendc_"; - // check if we are an attribute node in disguise + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "set_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name ()->get_string (); @@ -105,18 +112,16 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if ((!visitor) || (node->arguments ()->accept (visitor) == -1)) + be_visitor_operation_arglist oa_visitor (&ctx); + + if (node->arguments ()->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ami_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - visitor = 0; // Generate the actual code for the stub. However, if any of the argument // types is "native", we flag a MARSHAL exception. @@ -127,11 +132,11 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) be_type *bt = be_type::narrow_from_decl (node->arguments ()->return_type ()); - // generate any pre stub info if and only if none of our parameters is of the - // native type + // Generate any pre stub info if and only if none of our parameters is of the + // native type. if (!node->has_native ()) { - // native type does not exist. + // Native type does not exist. // Generate any "pre" stub information such as tables or declarations // This is a template method and the actual work will be done by the @@ -148,9 +153,11 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) if (node->has_native ()) // native exists => no stub { - if (this->gen_raise_exception (bt, - "CORBA::MARSHAL", - "") == -1) + int status = this->gen_raise_exception (bt, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ami_cs::" @@ -167,7 +174,7 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) << "TAO_Stub *istub = this->_stubobj ();" << be_nl << "if (istub == 0)" << be_idt_nl; - // if the stub object was bad, then we raise a system exception + // If the stub object was bad, then we raise a system exception. if (this->gen_raise_exception (bt, "CORBA::INV_OBJREF", "") == -1) { @@ -201,16 +208,16 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) return 0; } +// This method is used to generate the ParamData table entry. int be_visitor_operation_ami_cs::visit_argument (be_argument *node) { - // this method is used to generate the ParamData table entry - TAO_OutStream *os = this->ctx_->stream (); be_type *bt; // argument type - // retrieve the type for this argument + // Retrieve the type for this argument. bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -222,6 +229,7 @@ be_visitor_operation_ami_cs::visit_argument (be_argument *node) os->indent (); *os << "{" << bt->tc_name () << ", "; + switch (node->direction ()) { case AST_Argument::dir_IN: @@ -234,64 +242,15 @@ be_visitor_operation_ami_cs::visit_argument (be_argument *node) *os << "PARAM_OUT, "; break; } - *os << "0}"; - - return 0; -} - -// ************************************************************ -// Operation visitor for interpretive client stubs -// ************************************************************ - -be_interpretive_visitor_operation_ami_cs:: -be_interpretive_visitor_operation_ami_cs (be_visitor_context *ctx) - : be_visitor_operation_ami_cs (ctx) -{ -} - -be_interpretive_visitor_operation_ami_cs::~be_interpretive_visitor_operation_ami_cs (void) -{ -} -// concrete implementation of the template methods - -int -be_interpretive_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, - be_type *bt) -{ - ACE_UNUSED_ARG (node); - ACE_UNUSED_ARG (bt); - return 0; -} + *os << "0}"; -int -be_interpretive_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node, - be_type *bt) -{ - ACE_UNUSED_ARG (node); - ACE_UNUSED_ARG (bt); return 0; } -// ************************************************************ -// Operation visitor for compiled client stubs -// ************************************************************ - -be_compiled_visitor_operation_ami_cs:: -be_compiled_visitor_operation_ami_cs (be_visitor_context *ctx) - : be_visitor_operation_ami_cs (ctx) -{ -} - -be_compiled_visitor_operation_ami_cs::~be_compiled_visitor_operation_ami_cs (void) -{ -} - -// concrete implementation of the template methods - int -be_compiled_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, - be_type *bt) +be_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, + be_type *bt) { // Nothing to be done here, we do not through any exceptions, // besides system exceptions, so we do not need an user exception table. @@ -302,11 +261,10 @@ be_compiled_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, } int -be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node, - be_type *bt) +be_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node, + be_type *bt) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; os->indent (); @@ -321,20 +279,24 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node default: *os << "TAO_GIOP_Twoway_Asynch_Invocation _tao_call "; } + *os << "(" << be_idt << be_idt_nl << "istub," << be_nl; - *os << "\""; size_t ext = 0; if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } ext += 5; } @@ -369,11 +331,15 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "set_"; + // Now check if we are a "get" or "set" operation + if (node->nmembers () == 1) + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name () << "_reply_stub," << be_nl; @@ -429,34 +395,43 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->marshaling ()->accept (visitor) == -1)) + be_visitor_operation_argument_invoke visitor (&ctx); + + if (node->marshaling ()->accept (&visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" - "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for return var in do_static_call failed\n" + ), + -1 + ); } + *os << be_uidt << be_uidt_nl << "))" << be_nl; // If marshaling fails, raise exception. - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "") == -1) + int status = this->gen_raise_exception (bt, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "(%N:%l) be_visitor_operation_ami_cs::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); } + *os << be_uidt; } *os << be_nl - << "int _invoke_status = _tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);"; + << "int _invoke_status =" << be_idt_nl + << "_tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt; *os << be_uidt_nl; @@ -464,7 +439,7 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node if (this->gen_check_exception (bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "(%N:%l) be_visitor_operation_ami_cs::" "gen_marshal_and_invoke - " "codegen for checking exception failed\n"), -1); @@ -479,12 +454,15 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node << "if (_invoke_status != TAO_INVOKE_OK)" << be_nl << "{" << be_idt_nl; - if (this->gen_raise_exception (bt, - "CORBA::UNKNOWN", - "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES") == -1) + int status = + this->gen_raise_exception (bt, + "CORBA::UNKNOWN", + "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES"); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "(%N:%l) be_visitor_operation_ami_cs::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp index ed5ef268658..daba6c407e4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, ami_exception_holder_operation_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + ami_exception_holder_operation_cs, + "$Id$") // ************************************************************ // Operation visitor for client stubs @@ -127,7 +122,7 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation ( *os << "ACE_ENV_SINGLE_ARG_DECL"; } - *os << ")" << be_uidt; + *os << ")"; // now generate the throw specs if (this->gen_throw_spec (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp index 64ed89f8ce9..9b0eb3d35b6 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp @@ -20,42 +20,37 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, ami_handler_reply_stub_operation_ch, "$Id$") - +ACE_RCSID (be_visitor_operation, + ami_handler_reply_stub_operation_ch, + "$Id$") // ************************************************************ // Operation visitor for server header // ************************************************************ -be_visitor_operation_ami_handler_reply_stub_operation_ch::be_visitor_operation_ami_handler_reply_stub_operation_ch (be_visitor_context *ctx) +be_visitor_operation_ami_handler_reply_stub_operation_ch:: +be_visitor_operation_ami_handler_reply_stub_operation_ch (be_visitor_context *ctx) : be_visitor_operation (ctx) { } -be_visitor_operation_ami_handler_reply_stub_operation_ch::~be_visitor_operation_ami_handler_reply_stub_operation_ch (void) +be_visitor_operation_ami_handler_reply_stub_operation_ch:: +~be_visitor_operation_ami_handler_reply_stub_operation_ch (void) { } int -be_visitor_operation_ami_handler_reply_stub_operation_ch::visit_operation (be_operation *node) +be_visitor_operation_ami_handler_reply_stub_operation_ch::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node - + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // Generate the corresponding static skeleton method for this // operation only if there was no "native" type. if (!node->has_native ()) { - // Next line. *os << "static void "; @@ -72,6 +67,7 @@ be_visitor_operation_ami_handler_reply_stub_operation_ch::visit_operation (be_op *os << "_get_"; } } + *os << node->local_name () << "_reply_stub (" << be_idt << be_idt_nl; @@ -83,5 +79,6 @@ be_visitor_operation_ami_handler_reply_stub_operation_ch::visit_operation (be_op << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl << ");" << be_uidt_nl << be_nl; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp index 1220c388552..f3f61b23101 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp @@ -18,77 +18,90 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, ami_handler_reply_stub_operation_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + ami_handler_reply_stub_operation_cs, + "$Id$") // ************************************************************ -// Operation visitor for client stubs +// Operation visitor for client stubs. // ************************************************************ -be_visitor_operation_ami_handler_reply_stub_operation_cs::be_visitor_operation_ami_handler_reply_stub_operation_cs (be_visitor_context *ctx) +be_visitor_operation_ami_handler_reply_stub_operation_cs:: +be_visitor_operation_ami_handler_reply_stub_operation_cs ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } -be_visitor_operation_ami_handler_reply_stub_operation_cs::~be_visitor_operation_ami_handler_reply_stub_operation_cs (void) +be_visitor_operation_ami_handler_reply_stub_operation_cs:: +~be_visitor_operation_ami_handler_reply_stub_operation_cs (void) { } -// processing to be done after every element in the scope is processed +// Processing to be done after every element in the scope is processed int -be_visitor_operation_ami_handler_reply_stub_operation_cs::post_process (be_decl *bd) +be_visitor_operation_ami_handler_reply_stub_operation_cs::post_process ( + be_decl *bd + ) { - // all we do here is to insert a comma and a newline + // All we do here is to insert a comma and a newline. TAO_OutStream *os = this->ctx_->stream (); + if (!this->last_node (bd)) - *os << ",\n"; + { + *os << ",\n"; + } + return 0; } int -be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_operation *node) +be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node - be_visitor_context ctx; // visitor context - be_visitor *visitor = 0; // visitor + be_type *bt; + be_visitor_context ctx; - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - // Init the return type variable. + // Initialize the return type variable. bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_handler_reply_stub_operation_cs::" - "visit_operation - " - "Bad return type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_ami_handler_reply_stub_operation_cs::" + "visit_operation - " + "Bad return type\n" + ), + -1 + ); } // Start with the current indentation level. os->indent (); - // Generate the return type. Return type is simply void. *os << be_nl << "void" << be_nl; // Get the scope name. - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + if (!parent) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" - "visit_operation - " - "node information not sufficient :-<\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" + "visit_operation - " + "node information not sufficient :-<\n" + ), + -1 + ); } // Genereate scope name. @@ -96,15 +109,21 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_op // Generate the operation name. *os << "::"; + // Check if we are an attribute node in disguise if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; + // Now check if we are a "get" or "set" operation + if (node->nmembers () == 1) + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } } + *os << node->local_name () << "_reply_stub (" << be_idt_nl; // Generate the argument list. @@ -160,18 +179,16 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_op // declare variables for arguments ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument oad_visitor (&ctx); + + if (node->accept (&oad_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) ami_handler_reply_stub_operation_cs::" "visit_operation - " "codegen for return var decl failed\n"), -1); } - delete visitor; - visitor = 0; // Demarshal parameters if (this->gen_marshal_and_invoke (node, bt) == -1) @@ -272,23 +289,28 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_op return 0; } +// This method is used to generate the ParamData table entry. int -be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_argument (be_argument *node) +be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_argument ( + be_argument *node + ) { - // this method is used to generate the ParamData table entry - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; // argument type + be_type *bt; - // retrieve the type for this argument + // Retrieve the type for this argument. bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" + "visit_argument - " + "Bad argument type\n" + ), + -1 + ); } os->indent (); @@ -310,27 +332,12 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_argument (be_arg return 0; } -// ************************************************************ -// Operation visitor for compiled client skeletons of the AMI reply handler -// ************************************************************ - -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (be_visitor_context *ctx) - : be_visitor_operation_ami_handler_reply_stub_operation_cs (ctx) -{ -} - -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::~be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (void) -{ -} - -// concrete implementation of the template methods - int -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::gen_pre_stub_info (be_operation *node, - be_type *bt) +be_visitor_operation_ami_handler_reply_stub_operation_cs::gen_pre_stub_info ( + be_operation *node, + be_type * + ) { - ACE_UNUSED_ARG (bt); // Check if this operation raises any exceptions. In that case, we must // generate a list of exception typecodes. This is not valid for // attributes @@ -338,37 +345,38 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::gen_pre_stub_ { be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_exceptlist_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::" - "gen_pre_stub_info - " - "Exceptionlist generation error\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) " + "be_visitor_operation_ami_handler_reply_stub_operation_cs::" + "gen_pre_stub_info - " + "Exceptionlist generation error\n" + ), + -1 + ); } - delete visitor; } return 0; } int -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: - gen_marshal_and_invoke (be_operation *node, - be_type *bt) +be_visitor_operation_ami_handler_reply_stub_operation_cs::gen_marshal_and_invoke ( + be_operation *node, + be_type * + ) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor = 0; be_visitor_context ctx; - ACE_UNUSED_ARG (bt); - os->indent (); *os << "// Demarshall all the arguments." << be_nl; + if (this->has_param_type (node, AST_Argument::dir_IN)) { *os << "if (!(\n" << be_idt << be_idt << be_idt; @@ -377,24 +385,28 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument_marshal visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::" + "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" "gen_marshal_params - " "codegen for args failed\n"), -1); } - delete visitor; *os << be_uidt << be_uidt_nl << " ))" << be_nl; + if (be_global->use_raw_throw ()) - *os << "throw CORBA::MARSHAL ();" << be_uidt_nl << be_nl; + { + *os << "throw CORBA::MARSHAL ();" << be_uidt_nl << be_nl; + } else - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl << be_nl; + { + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl << be_nl; + } } @@ -402,14 +414,18 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: *os << "// Invoke the call back method." << be_nl << "_tao_reply_handler_object->"; - // check if we are an attribute node in disguise + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "set_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name () << " (" << be_idt << be_idt_nl; @@ -417,24 +433,18 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); - // generate the argument list containing the inout and inout arguments - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument oau_visitor (&ctx); + + if (node->accept (&oau_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) ami_handler_reply_stub_operation_cs::" "visit_operation - " "codegen for making upcall failed\n"), -1); } - delete visitor; - visitor = 0; - -// os->indent (); *os << be_uidt_nl << ");" << be_uidt_nl; - *os << "ACE_CHECK;" << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp index f112884f12e..6e6bee2d9b2 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_operation.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_operation, arglist, "$Id$") - +ACE_RCSID (be_visitor_operation, + arglist, + "$Id$") // ************************************************************ // operation visitor to generate the argument list. @@ -91,8 +86,8 @@ be_visitor_operation_arglist::visit_operation (be_operation *node) -1); } - *os << be_uidt_nl // idt = 1 - << ")" << be_uidt; // idt = 0 + *os << be_uidt_nl + << ")"; // idt = 0 // Now generate the throw specs. if (this->gen_throw_spec (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp index 79fe13e262c..3a8ff384e61 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp @@ -18,23 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, argument, "$Id$") - +ACE_RCSID (be_visitor_operation, + argument, + "$Id$") // ************************************************************ -// generic operation visitor to handle the pre/post -// do_static_call/upcall stuff with arguments +// Generic operation visitor to handle the pre/post +// do_static_call/upcall stuff with arguments. // ************************************************************ -be_visitor_operation_argument:: -be_visitor_operation_argument (be_visitor_context - *ctx) +be_visitor_operation_argument::be_visitor_operation_argument ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -48,8 +43,7 @@ be_visitor_operation_argument::post_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); - - // if we are not the last parameter, we insert a comma. This is only + // If we are not the last parameter, we insert a comma. This is only // applicable for the upcalls or the call to (de)marshal that we use in the // interpreted marshaling. switch (this->ctx_->state ()) @@ -62,10 +56,12 @@ be_visitor_operation_argument::post_process (be_decl *bd) { *os << "," << be_nl; } + break; default: break; } + return 0; } @@ -74,7 +70,7 @@ be_visitor_operation_argument::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - // all we do is hand over code generation to our scope + // All we do is hand over code generation to our scope. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -84,22 +80,27 @@ be_visitor_operation_argument::visit_operation (be_operation *node) -1); } - // if we are supporting the alternate mapping, we must pass the - // ACE_ENV_ARG_PARAMETER as the last parameter + // If we are supporting the alternate mapping, we must pass the + // ACE_ENV_ARG_PARAMETER as the last parameter. if (!be_global->exception_support ()) { switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: - // applicable only to these cases where the actual upcall is made + // Applicable only to these cases where the actual upcall is made. // Use ACE_ENV_SINGLE_ARG_DECL or ACE_ENV_ARG_DECL depending on // whether the operation node has parameters. if (node->argument_count () > 0) - *os << " ACE_ENV_ARG_PARAMETER"; + { + *os << " ACE_ENV_ARG_PARAMETER"; + } else - *os << "ACE_ENV_SINGLE_ARG_PARAMETER"; + { + *os << "ACE_ENV_SINGLE_ARG_PARAMETER"; + } + break; default: break; @@ -112,7 +113,7 @@ be_visitor_operation_argument::visit_operation (be_operation *node) int be_visitor_operation_argument::visit_argument (be_argument *node) { - // get the visitor that will dump the argument's mapping in the operation + // Get the visitor that will dump the argument's mapping in the operation // signature. be_visitor_context ctx (*this->ctx_); @@ -121,6 +122,7 @@ be_visitor_operation_argument::visit_argument (be_argument *node) // 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, @@ -132,7 +134,7 @@ be_visitor_operation_argument::visit_argument (be_argument *node) // 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 + // information from the context. be_interface *intf; intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) @@ -146,34 +148,68 @@ be_visitor_operation_argument::visit_argument (be_argument *node) "Bad interface\n"), -1); } - ctx.scope (intf); // set new scope + + ctx.scope (intf); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_PRE_INVOKE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_PRE_INVOKE_CS); + be_visitor_args_pre_invoke_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS); + be_visitor_args_invoke_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS); + be_visitor_args_post_invoke_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS); + be_visitor_args_vardecl_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS); + be_visitor_args_marshal_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS); + be_visitor_args_marshal_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS); + be_visitor_args_upcall_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); + be_visitor_args_upcall_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -184,19 +220,8 @@ be_visitor_operation_argument::visit_argument (be_argument *node) } } - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_argument::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (node->accept (visitor) == -1) + if (status == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_argument::" @@ -204,6 +229,6 @@ be_visitor_operation_argument::visit_argument (be_argument *node) "codegen for argument failed\n"), -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp index cb4d38bb115..d222235b04d 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp @@ -20,34 +20,31 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, argument_invoke, "$Id$") - +ACE_RCSID (be_visitor_operation, + argument_invoke, + "$Id$") // ************************************************************ // operation visitor to handle the passing of arguments to the CDR operators // ************************************************************ -be_compiled_visitor_operation_argument_invoke:: -be_compiled_visitor_operation_argument_invoke (be_visitor_context - *ctx) +be_visitor_operation_argument_invoke::be_visitor_operation_argument_invoke ( + be_visitor_context + *ctx + ) : be_visitor_operation_argument (ctx), - last_arg_printed_ (be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) + last_arg_printed_ (be_visitor_operation_argument_invoke::TAO_ARG_NONE) { } -be_compiled_visitor_operation_argument_invoke:: -~be_compiled_visitor_operation_argument_invoke (void) +be_visitor_operation_argument_invoke::~be_visitor_operation_argument_invoke ( + void + ) { } int -be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) +be_visitor_operation_argument_invoke::pre_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); @@ -57,7 +54,7 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); @@ -69,8 +66,8 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) - *os << " &&\n"; + be_visitor_operation_argument_invoke::TAO_ARG_NONE) + *os << " &&" << be_nl; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { @@ -81,14 +78,14 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) - *os << " &&\n"; + be_visitor_operation_argument_invoke::TAO_ARG_NONE) + *os << " &&" << be_nl; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) - *os << " &&\n"; + be_visitor_operation_argument_invoke::TAO_ARG_NONE) + *os << " &&" << be_nl; } break; case AST_Argument::dir_OUT: @@ -99,8 +96,8 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) - *os << " &&\n"; + be_visitor_operation_argument_invoke::TAO_ARG_NONE) + *os << " &&" << be_nl; } break; } @@ -109,7 +106,7 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) } int -be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) +be_visitor_operation_argument_invoke::post_process (be_decl *bd) { be_argument *arg = be_argument::narrow_from_decl (bd); @@ -117,7 +114,7 @@ be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); @@ -130,12 +127,12 @@ be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) case AST_Argument::dir_IN: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_IN; + be_visitor_operation_argument_invoke::TAO_ARG_IN; break; case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_INOUT; + be_visitor_operation_argument_invoke::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // these arguments don't get printed for the << operator on the stub @@ -151,19 +148,19 @@ be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_INOUT; + be_visitor_operation_argument_invoke::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_OUT; + be_visitor_operation_argument_invoke::TAO_ARG_OUT; break; } break; default: ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad sub state\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp index 756964eacbd..ec59c0045c8 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp @@ -20,34 +20,31 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, argument_marshal, "$Id$") - +ACE_RCSID (be_visitor_operation, + argument_marshal, + "$Id$") // ************************************************************ // operation visitor to handle the passing of arguments to the CDR operators // ************************************************************ -be_compiled_visitor_operation_argument_marshal:: -be_compiled_visitor_operation_argument_marshal (be_visitor_context - *ctx) +be_visitor_operation_argument_marshal::be_visitor_operation_argument_marshal ( + be_visitor_context + *ctx + ) : be_visitor_operation_argument (ctx), - last_arg_printed_ (be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + last_arg_printed_ (be_visitor_operation_argument_marshal::TAO_ARG_NONE) { } -be_compiled_visitor_operation_argument_marshal:: -~be_compiled_visitor_operation_argument_marshal (void) +be_visitor_operation_argument_marshal::~be_visitor_operation_argument_marshal ( + void + ) { } int -be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) +be_visitor_operation_argument_marshal::pre_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); @@ -57,7 +54,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" + "be_visitor_operation_argument_marshal" "::post_process - " "Bad argument node\n"), -1); @@ -68,7 +65,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) @@ -80,13 +77,13 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -98,7 +95,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -108,7 +105,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) } int -be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) +be_visitor_operation_argument_marshal::post_process (be_decl *bd) { be_argument *arg = be_argument::narrow_from_decl (bd); @@ -116,7 +113,7 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" + "be_visitor_operation_argument_marshal" "::post_process - " "Bad argument node\n"), -1); @@ -129,12 +126,12 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) case AST_Argument::dir_IN: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_IN; + be_visitor_operation_argument_marshal::TAO_ARG_IN; break; case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; + be_visitor_operation_argument_marshal::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // these arguments don't get printed for the << operator on the stub @@ -150,19 +147,19 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; + be_visitor_operation_argument_marshal::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_OUT; + be_visitor_operation_argument_marshal::TAO_ARG_OUT; break; } break; default: ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" + "be_visitor_operation_argument_marshal" "::post_process - " "Bad sub state\n"), -1); @@ -172,19 +169,19 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) // **************************************************************** -be_visitor_compiled_args_decl::be_visitor_compiled_args_decl (be_visitor_context *ctx) +be_visitor_args_decl::be_visitor_args_decl (be_visitor_context *ctx) : be_visitor_scope (ctx) { } int -be_visitor_compiled_args_decl::visit_operation (be_operation *node) +be_visitor_args_decl::visit_operation (be_operation *node) { return this->visit_scope (node); } int -be_visitor_compiled_args_decl::visit_argument (be_argument *node) +be_visitor_args_decl::visit_argument (be_argument *node) { this->ctx_->node (node); // save the argument node @@ -196,7 +193,7 @@ be_visitor_compiled_args_decl::visit_argument (be_argument *node) // visit array int -be_visitor_compiled_args_decl::visit_array (be_array *node) +be_visitor_args_decl::visit_array (be_array *node) { TAO_OutStream *os = this->ctx_->stream (); @@ -205,41 +202,52 @@ be_visitor_compiled_args_decl::visit_array (be_array *node) if (f == 0) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_compiled_args_decl::" + "(%N:%l) be_visitor_args_decl::" "visit_array - " "cannot retrieve argument node\n" - ), -1); + ), + -1); } // for anonymous arrays, the type name has a _ prepended. We compute // the full_name with or without the underscore and use it later on. char fname [NAMEBUFSIZE]; // to hold the full and - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); + 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 + // 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 + // 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->full_name (), + + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + node->full_name ()); } } else { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->full_name ()); + // Typedefed node. + ACE_OS::sprintf (fname, + "%s", + node->full_name ()); } if (f->direction () != AST_Argument::dir_IN) @@ -250,24 +258,27 @@ be_visitor_compiled_args_decl::visit_array (be_array *node) << f->local_name () << be_uidt_nl << ");" << be_uidt_nl; } + return 0; } // visit typedef type int -be_visitor_compiled_args_decl::visit_typedef (be_typedef *node) +be_visitor_args_decl::visit_typedef (be_typedef *node) { this->ctx_->alias (node); // 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_compiled_args_decl::" + "(%N:%l) be_visitor_args_decl::" "visit_typedef - " "Bad primitive type\n" - ), -1); + ), + -1); } this->ctx_->alias (0); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp index 5cf6a728d1b..5d02b51fea8 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp @@ -1,38 +1,29 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_operation, + x_proxy_impl_xh, + "$Id$") -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, x_proxy_impl_xh, "$Id$") - - -be_visitor_operation_base_proxy_impl_ch::be_visitor_operation_base_proxy_impl_ch (be_visitor_context *ctx) +be_visitor_operation_base_proxy_impl_ch:: +be_visitor_operation_base_proxy_impl_ch (be_visitor_context *ctx) : be_visitor_scope (ctx) { } -be_visitor_operation_base_proxy_impl_ch::~be_visitor_operation_base_proxy_impl_ch (void) +be_visitor_operation_base_proxy_impl_ch:: +~be_visitor_operation_base_proxy_impl_ch (void) { } int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node - -// os->indent (); // start with the current indentation level + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - // 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 ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -43,32 +34,19 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "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_operation_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; - // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -76,28 +54,16 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_BASE_PROXY_IMPL_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_arglist oabpi_visitor (&ctx); - if (!visitor) + if (node->accept (&oabpi_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp index 9b24f4fa611..3906b4e89eb 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp @@ -1,34 +1,31 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_operation, + direct_proxy_impl_ss, + "$Id$") -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, direct_proxy_impl_ss, "$Id$") - -be_visitor_operation_direct_proxy_impl_ss::be_visitor_operation_direct_proxy_impl_ss -(be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_operation_direct_proxy_impl_ss:: +be_visitor_operation_direct_proxy_impl_ss (be_visitor_context *ctx) + : be_visitor_operation (ctx) { } -be_visitor_operation_direct_proxy_impl_ss::~be_visitor_operation_direct_proxy_impl_ss (void) +be_visitor_operation_direct_proxy_impl_ss:: +~be_visitor_operation_direct_proxy_impl_ss (void) { } - int -be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) +be_visitor_operation_direct_proxy_impl_ss::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); // 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 - be_interface *intf; - intf = this->ctx_->attribute () + // information from the context. + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); @@ -41,8 +38,8 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) -1); } - // retrieve the operation return type be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -51,31 +48,21 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) "Bad return type\n"), -1); } + os->indent (); // STEP 2: generate the return type mapping (same as in the header file) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_direct_collocated_ss::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_direct_collocated_ss::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; *os << " " << intf->full_direct_proxy_impl_name () << "::" << node->local_name () << " "; @@ -84,26 +71,16 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_cs::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oapi_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oapi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt << "\n"; @@ -122,8 +99,11 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) << "\"" << intf->repoID () << "\"" << ")" << be_uidt_nl // idt = 2 << ")"; + if (this->gen_invoke (ctx, node) == -1) - return -1; + { + return -1; + } *os << be_uidt_nl << "}" << be_nl << be_nl; @@ -134,8 +114,10 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) int -be_visitor_operation_direct_proxy_impl_ss::gen_invoke (be_visitor_context &ctx, - be_operation *node) +be_visitor_operation_direct_proxy_impl_ss::gen_invoke ( + be_visitor_context &ctx, + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -144,10 +126,10 @@ be_visitor_operation_direct_proxy_impl_ss::gen_invoke (be_visitor_context &ctx, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_direct_collocated_ss::" "gen_invoke - " @@ -155,21 +137,9 @@ be_visitor_operation_direct_proxy_impl_ss::gen_invoke (be_visitor_context &ctx, -1); } - // end the upcall *os << be_uidt_nl << ");" << be_uidt << be_uidt << be_uidt_nl; + return 0; } -int -be_visitor_operation_direct_proxy_impl_ss::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp index f957bcb3397..0a8a34ad455 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, exceptlist_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + exceptlist_cs, + "$Id$") // **************************************************************************** // visitor to generate the exception list for operations @@ -52,6 +47,7 @@ be_visitor_operation_exceptlist_cs::visit_operation (be_operation *node) if (node->exceptions ()) { os->indent (); + *os << "static TAO_Exception_Data " << "_tao_" << node->flat_name () << "_exceptiondata [] = " << be_nl; *os << "{" << be_idt_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp index 27499952058..b5eeb05802b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp @@ -18,19 +18,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, interceptors_arglist, "$Id$") - +ACE_RCSID (be_visitor_operation, + interceptors_arglist, + "$Id$") // ************************************************************ -// operation visitor to generate the argument list. +// 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 +// visitors to avoid code duplication and tight coupling. // ************************************************************ be_visitor_operation_interceptors_arglist:: @@ -39,16 +34,18 @@ be_visitor_operation_interceptors_arglist (be_visitor_context *ctx) { } -be_visitor_operation_interceptors_arglist::~be_visitor_operation_interceptors_arglist (void) +be_visitor_operation_interceptors_arglist:: +~be_visitor_operation_interceptors_arglist (void) { } int -be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) +be_visitor_operation_interceptors_arglist::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); - // all we do is hand over code generation to our scope if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -58,7 +55,6 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) -1); } - // generate the ACE_ENV_ARG_PARAMETER for the alternative mapping if (!be_global->exception_support ()) { switch (this->ctx_->state ()) @@ -68,7 +64,6 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_SS: - // case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_RESULT: break; case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS: @@ -79,7 +74,7 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CS: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS: { - // last argument - is always CORBA::Environment + // Last argument - is always CORBA::Environment. *os << " ACE_ENV_ARG_DECL_NOT_USED"; break; } @@ -88,7 +83,7 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) { // @@ Do it for all cases i.e arg count > = 0 - // last argument - is always CORBA::Environment + // Last argument - is always CORBA::Environment. *os << " ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl; break; } @@ -116,14 +111,16 @@ be_visitor_operation_interceptors_arglist::pre_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); } if (arg->direction () == AST_Argument::dir_OUT) - return 0; + { + return 0; + } switch (this->ctx_->state ()) { @@ -191,8 +188,7 @@ be_visitor_operation_interceptors_arglist::visit_argument (be_argument *node) // 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. - be_interface *intf; - intf = this->ctx_->attribute () + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (op->defined_in ()); @@ -205,43 +201,70 @@ be_visitor_operation_interceptors_arglist::visit_argument (be_argument *node) -1); } - ctx.scope (intf); // set new scope + ctx.scope (intf); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CH); - break; case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; + case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SH: + case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS: + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); + be_visitor_args_request_info_arglist visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CH: + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CH); + be_visitor_args_request_info_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CS); + be_visitor_args_request_info_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CS); + be_visitor_args_request_info_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_PARAMLIST); - break; - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_PARAMLIST); + be_visitor_args_paramlist visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SH); - break; - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SH); + be_visitor_args_request_info_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SS); + be_visitor_args_request_info_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); + be_visitor_args_upcall_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -252,29 +275,15 @@ be_visitor_operation_interceptors_arglist::visit_argument (be_argument *node) } } - // Grab a visitor. - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interceptors_arglist::" "visit_argument - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_arglist::" - "visit_argument - " "codegen for interceptors_arglist failed\n"), -1); } - delete visitor; return 0; } @@ -288,14 +297,16 @@ be_visitor_operation_interceptors_arglist::post_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); } if (arg->direction () != AST_Argument::dir_OUT) - return 0; + { + return 0; + } switch (this->ctx_->state ()) { @@ -328,5 +339,6 @@ be_visitor_operation_interceptors_arglist::post_process (be_decl *bd) } } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ch.cpp index aedee6e66f5..d0632d128ac 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ch.cpp @@ -18,18 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_operation, + operation_interceptors_ch, + "$Id$") -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_interceptors_ch, "$Id$") - - - // ****************************************************** - // primary visitor for "operation" in client header - // ****************************************************** +// ****************************************************** +// primary visitor for "operation" in client header +// ****************************************************** be_visitor_operation_interceptors_ch::be_visitor_operation_interceptors_ch ( be_visitor_context *ctx diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp index 122e9f3784c..2c84d1e4fec 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp @@ -18,18 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_operation.h" - ACE_RCSID (be_visitor_operation, operation_interceptors_cs, "$Id$") - // ****************************************************** -// primary visitor for "operation" in client header +// Primary visitor for "operation" in client header // ****************************************************** be_visitor_operation_interceptors_cs::be_visitor_operation_interceptors_cs ( @@ -51,24 +45,28 @@ be_visitor_operation_interceptors_cs::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); if (this->generate_class_declaration (os, node) == -1) - return -1; + { + return -1; + } if (this->generate_class_definition (os, node) == -1) - return -1; + { + return -1; + } return 0; } int -be_visitor_operation_interceptors_cs:: - generate_class_declaration (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_cs::generate_class_declaration ( + TAO_OutStream *os, + be_operation *node + ) { be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - // Save the node + // Save the node. this->ctx_->node (node); // Generate the ClientRequestInfo object per operation to @@ -146,36 +144,32 @@ be_visitor_operation_interceptors_cs:: } *os << " (" << be_idt << be_idt_nl - << "TAO_GIOP_Invocation *_tao_invocation," << be_nl - << "CORBA::Object_ptr _tao_target"; + << "TAO_GIOP_Invocation *_tao_invocation," << be_nl; + + if (node->defined_in ()->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr _tao_target"; + } + else + { + *os << "CORBA::Object_ptr _tao_target"; + } // 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_OPERATION_INTERCEPTORS_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oia_visitor (&ctx); - if (!visitor) + if (node->accept (&oia_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_cs::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - if (be_global->exception_support ()) { *os << be_uidt; @@ -219,11 +213,10 @@ be_visitor_operation_interceptors_cs:: *os << be_nl << "void result ("; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_info_rettype oiir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&oiir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -235,7 +228,6 @@ be_visitor_operation_interceptors_cs:: } *os << be_uidt_nl << "private:" << be_idt_nl; - *os << "TAO_ClientRequestInfo_" << node->flat_name (); // We need the interface node in which this operation was defined. However, @@ -341,29 +333,17 @@ be_visitor_operation_interceptors_cs:: // we grab a visitor that generates the parameter listing and // modify it to generate reference members. ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiia_visitor (&ctx); - if (!visitor) + if (node->accept (&oiia_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - // Generate the result data member. // Generate the return type. bt = be_type::narrow_from_decl (node->return_type ()); @@ -383,11 +363,10 @@ be_visitor_operation_interceptors_cs:: { ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_info_rettype toiir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&toiir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -408,16 +387,16 @@ be_visitor_operation_interceptors_cs:: } int -be_visitor_operation_interceptors_cs:: - generate_class_definition (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_cs::generate_class_definition ( + TAO_OutStream *os, + be_operation *node + ) { // Start with the current indentation level. os->indent (); be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); // Save the node. this->ctx_->node (node); @@ -488,19 +467,26 @@ be_visitor_operation_interceptors_cs:: } *os << " (" << be_idt << be_idt_nl - << "TAO_GIOP_Invocation *_tao_invocation," << be_nl - << "CORBA::Object_ptr _tao_target"; + << "TAO_GIOP_Invocation *_tao_invocation," << be_nl; + + if (node->defined_in ()->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr _tao_target"; + } + else + { + *os << "CORBA::Object_ptr _tao_target"; + } // 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_OPERATION_INTERCEPTORS_ARGLIST_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist toiia_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&toiia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -508,7 +494,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; os->indent (); *os << be_uidt_nl << ")" << be_uidt_nl; @@ -519,11 +504,10 @@ be_visitor_operation_interceptors_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiai_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oiai_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -531,8 +515,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - os->decr_indent (); *os << be_nl << "{}\n\n"; @@ -582,20 +564,21 @@ be_visitor_operation_interceptors_cs:: { *os << "// Generate the argument list on demand." << be_nl << "Dynamic::ParameterList *parameter_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_parameter_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_parameter_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; size_t parameter_count = this->count_non_out_parameters (node); - if (node->argument_count () == 0 || - parameter_count == 0 || + if (node->argument_count () == 0 + || parameter_count == 0 // Now make sure that we have some in and inout // parameters. Otherwise, there is nothing to be put into // the Dyanmic::Paramlist. - (!(this->has_param_type (node, AST_Argument::dir_IN)) && - !(this->has_param_type (node, AST_Argument::dir_INOUT)))) + || (!(this->has_param_type (node, AST_Argument::dir_IN)) + && !(this->has_param_type (node, AST_Argument::dir_INOUT)))) { *os << "return parameter_list;" << be_uidt_nl; } @@ -621,11 +604,10 @@ be_visitor_operation_interceptors_cs:: // decide this. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oip_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oip_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -633,8 +615,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - *os << be_nl << "return safe_parameter_list._retn ();"; } @@ -701,7 +681,8 @@ be_visitor_operation_interceptors_cs:: { *os << "// Generate the exception list on demand." << be_nl << "Dynamic::ExceptionList *exception_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_exception_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_exception_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; @@ -718,11 +699,10 @@ be_visitor_operation_interceptors_cs:: // We change our scope to be able to generate the exceptionlist. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_exceptlist oie_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oie_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -730,8 +710,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - *os << be_nl << "return safe_exception_list._retn ();"; } @@ -805,7 +783,8 @@ be_visitor_operation_interceptors_cs:: // Return an Any with tk_void TypeCode. *os << "CORBA::Boolean tk_void_any = 1;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -815,7 +794,8 @@ be_visitor_operation_interceptors_cs:: { *os << "CORBA::Boolean tk_void_any = 0;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -825,11 +805,10 @@ be_visitor_operation_interceptors_cs:: // Generate the insertion of result into Any. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_RESULT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_result oir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&oir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -837,8 +816,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - *os << "return safe_result_any._retn ();"; } } @@ -867,7 +844,7 @@ be_visitor_operation_interceptors_cs:: if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_ch::" + "(%N:%l) be_visitor_interceptors_ch::" "visit_operation - " "Bad return type\n"), -1); @@ -882,11 +859,11 @@ be_visitor_operation_interceptors_cs:: *os << "TAO_ClientRequestInfo_"<< node->flat_name (); - // 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 and add a "_get"/"_set" to the flat - // name to get around the problem of overloaded methods which are - // generated for attributes. + // 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 and add a "_get"/"_set" + // to the flat name to get around the problem of overloaded methods + // which are generated for attributes. if (this->ctx_->attribute ()) { bt = be_type::narrow_from_decl (node->return_type ()); @@ -917,11 +894,10 @@ be_visitor_operation_interceptors_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype or_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -930,6 +906,7 @@ be_visitor_operation_interceptors_cs:: } os->indent (); + *os << " result)" << be_uidt << be_uidt << be_uidt_nl << "{" << be_idt_nl << "// update the result " << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp index 483f72c2553..f60dd96d77d 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, interceptors_exceptlist, "$Id$") - +ACE_RCSID (be_visitor_operation, + interceptors_exceptlist, + "$Id$") // ************************************************************ // Operation visitor for exception list diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_info_rettype.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_info_rettype.cpp index a119d621f85..5a244b36f95 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_info_rettype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_info_rettype.cpp @@ -19,40 +19,40 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, interceptors_info_rettype, "$Id$") - +ACE_RCSID (be_visitor_operation, + interceptors_info_rettype, + "$Id$") // **************************************************************************** // Operation visitor for return types. This generates the mapping for a return // type in an operation signature // **************************************************************************** -be_visitor_operation_interceptors_info_rettype::be_visitor_operation_interceptors_info_rettype (be_visitor_context - *ctx) +be_visitor_operation_interceptors_info_rettype:: +be_visitor_operation_interceptors_info_rettype (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -be_visitor_operation_interceptors_info_rettype::~be_visitor_operation_interceptors_info_rettype (void) +be_visitor_operation_interceptors_info_rettype:: +~be_visitor_operation_interceptors_info_rettype (void) { } int be_visitor_operation_interceptors_info_rettype::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name () << "_slice *"; @@ -62,14 +62,17 @@ be_visitor_operation_interceptors_info_rettype::visit_array (be_array *node) int be_visitor_operation_interceptors_info_rettype::visit_enum (be_enum *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name (); @@ -79,14 +82,17 @@ be_visitor_operation_interceptors_info_rettype::visit_enum (be_enum *node) int be_visitor_operation_interceptors_info_rettype::visit_interface (be_interface *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name () << "_ptr"; @@ -96,14 +102,17 @@ be_visitor_operation_interceptors_info_rettype::visit_interface (be_interface *n int be_visitor_operation_interceptors_info_rettype::visit_interface_fwd (be_interface_fwd *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name () << "_ptr"; @@ -113,14 +122,17 @@ be_visitor_operation_interceptors_info_rettype::visit_interface_fwd (be_interfac int be_visitor_operation_interceptors_info_rettype::visit_native (be_native *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name (); @@ -130,18 +142,22 @@ be_visitor_operation_interceptors_info_rettype::visit_native (be_native *node) int be_visitor_operation_interceptors_info_rettype::visit_predefined_type (be_predefined_type *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << bt->name () << "_ptr"; break; case AST_PredefinedType::PT_any: @@ -164,16 +180,19 @@ be_visitor_operation_interceptors_info_rettype::visit_predefined_type (be_predef int be_visitor_operation_interceptors_info_rettype::visit_sequence (be_sequence *node) { - - // we should never directly be here because anonymous sequence return types + // We should never directly be here because anonymous sequence return types // are not allowed - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name () << " *"; @@ -183,8 +202,7 @@ be_visitor_operation_interceptors_info_rettype::visit_sequence (be_sequence *nod int be_visitor_operation_interceptors_info_rettype::visit_string (be_string *node) { - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); if (node->width () == (long) sizeof (char)) { @@ -201,20 +219,23 @@ be_visitor_operation_interceptors_info_rettype::visit_string (be_string *node) int be_visitor_operation_interceptors_info_rettype::visit_structure (be_structure *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name (); // Based on whether we are variable or not, we return a pointer or the // aggregate type. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << " *"; } @@ -244,20 +265,23 @@ be_visitor_operation_interceptors_info_rettype::visit_typedef (be_typedef *node) int be_visitor_operation_interceptors_info_rettype::visit_union (be_union *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name (); // Based on whether we are variable or not, we return a pointer or the // aggregate type. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << " *"; } @@ -268,14 +292,17 @@ be_visitor_operation_interceptors_info_rettype::visit_union (be_union *node) int be_visitor_operation_interceptors_info_rettype::visit_valuetype (be_valuetype *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name () << " *"; @@ -285,14 +312,17 @@ be_visitor_operation_interceptors_info_rettype::visit_valuetype (be_valuetype *n int be_visitor_operation_interceptors_info_rettype::visit_valuetype_fwd (be_valuetype_fwd *node) { + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } *os << bt->name () << " *"; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_result.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_result.cpp index f7f400d7de3..817be665329 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_result.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_result.cpp @@ -18,33 +18,30 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_argument, interceptors_result, "$Id$") - +ACE_RCSID (be_visitor_argument, + interceptors_result, + "$Id$") // ************************************************************ // be_visitor_operation_interceptors_result for generating the result as // stored in the request info for interceptors // ************************************************************ -be_visitor_operation_interceptors_result::be_visitor_operation_interceptors_result (be_visitor_context *ctx) +be_visitor_operation_interceptors_result:: +be_visitor_operation_interceptors_result (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -be_visitor_operation_interceptors_result::~be_visitor_operation_interceptors_result (void) +be_visitor_operation_interceptors_result:: +~be_visitor_operation_interceptors_result (void) { } int be_visitor_operation_interceptors_result::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // if the current type is an alias, use that + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; if (this->ctx_->alias ()) @@ -66,7 +63,7 @@ be_visitor_operation_interceptors_result::visit_array (be_array *node) int be_visitor_operation_interceptors_result::visit_enum (be_enum *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= this->_result;" << be_nl; @@ -76,7 +73,7 @@ be_visitor_operation_interceptors_result::visit_enum (be_enum *) int be_visitor_operation_interceptors_result::visit_interface (be_interface *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= this->_result;" << be_nl; @@ -86,7 +83,7 @@ be_visitor_operation_interceptors_result::visit_interface (be_interface *) int be_visitor_operation_interceptors_result::visit_interface_fwd (be_interface_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= this->_result;" << be_nl; @@ -121,7 +118,7 @@ be_visitor_operation_interceptors_result::visit_valuetype_fwd (be_valuetype_fwd int be_visitor_operation_interceptors_result::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= "; @@ -140,6 +137,7 @@ be_visitor_operation_interceptors_result::visit_predefined_type (be_predefined_t *os << "CORBA::Any::from_octet (this->_result);" << be_nl; break; case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: case AST_PredefinedType::PT_any: case AST_PredefinedType::PT_long: case AST_PredefinedType::PT_ulong: @@ -167,7 +165,7 @@ be_visitor_operation_interceptors_result::visit_predefined_type (be_predefined_t int be_visitor_operation_interceptors_result::visit_sequence (be_sequence *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= this->_result;" << be_nl; @@ -177,14 +175,14 @@ be_visitor_operation_interceptors_result::visit_sequence (be_sequence *) int be_visitor_operation_interceptors_result::visit_string (be_string *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= "; - // we need to make a distinction between bounded and unbounded strings + // We need to make a distinction between bounded and unbounded strings. if (node->max_size ()->ev ()->u.ulval != 0) { - // bounded strings + // Bounded strings. if (node->width () == (long) sizeof (char)) { *os << "CORBA::Any::from_string ((char *)"; @@ -209,7 +207,7 @@ return 0; int be_visitor_operation_interceptors_result::visit_structure (be_structure *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= this->_result;" << be_nl; @@ -220,7 +218,7 @@ be_visitor_operation_interceptors_result::visit_structure (be_structure *) int be_visitor_operation_interceptors_result::visit_union (be_union *) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); *os << "(*result_any) <<= this->_result;" << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_sh.cpp index 0df38e65f67..d82171570fc 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_sh.cpp @@ -18,25 +18,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_interceptors_sh, "$Id$") - - - // ****************************************************** - // primary visitor for "operation" in server header - // ****************************************************** - - be_visitor_operation_interceptors_sh::be_visitor_operation_interceptors_sh (be_visitor_context *ctx) - : be_visitor_operation (ctx) +ACE_RCSID (be_visitor_operation, + operation_interceptors_sh, + "$Id$") + +// ****************************************************** +// primary visitor for "operation" in server header +// ****************************************************** + +be_visitor_operation_interceptors_sh::be_visitor_operation_interceptors_sh ( + be_visitor_context *ctx + ) + : be_visitor_operation (ctx) { } -be_visitor_operation_interceptors_sh::~be_visitor_operation_interceptors_sh (void) +be_visitor_operation_interceptors_sh::~be_visitor_operation_interceptors_sh ( + void + ) { } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp index d651e62e77f..ce6431704a0 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp @@ -19,18 +19,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_operation, + operation_interceptors_ss, + "$Id$") -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_interceptors_ss, "$Id$") - - - // ****************************************************** - // primary visitor for "operation" in server header - // ****************************************************** +// ****************************************************** +// primary visitor for "operation" in server header +// ****************************************************** be_visitor_operation_interceptors_ss::be_visitor_operation_interceptors_ss ( be_visitor_context *ctx @@ -51,22 +46,26 @@ be_visitor_operation_interceptors_ss::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); if (this->generate_class_declaration (os, node) == -1) - return -1; + { + return -1; + } if (this->generate_class_definition (os, node) == -1) - return -1; + { + return -1; + } return 0; } int -be_visitor_operation_interceptors_ss:: - generate_class_declaration (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_ss::generate_class_declaration ( + TAO_OutStream *os, + be_operation *node + ) { be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); // save the node. this->ctx_->node (node); @@ -129,7 +128,7 @@ be_visitor_operation_interceptors_ss:: -1); } - // grab the right visitor to generate the return type if its not + // Grab the right visitor to generate the return type if its not // void it means it is not the accessor. if (!this->void_return_type (bt)) { @@ -141,8 +140,7 @@ be_visitor_operation_interceptors_ss:: } } - - *os << " (" << be_idt_nl + *os << " (" << be_idt << be_idt_nl << "TAO_ServerRequest &_tao_server_request," << be_nl; be_interface *intf; @@ -160,43 +158,30 @@ be_visitor_operation_interceptors_ss:: } // Pass in the pointer to the Servant_Upcall. - *os << "TAO_Object_Adapter::Servant_Upcall *tao_servant_upcall,"; + *os << "TAO_Object_Adapter::Servant_Upcall *tao_servant_upcall," << be_nl; // Get the right object implementation. - *os << intf->full_skel_name () << " *tao_impl" << be_nl; + *os << intf->full_skel_name () << " *tao_impl"; // 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_OPERATION_INTERCEPTORS_ARGLIST_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oia_visitor (&ctx); - if (!visitor) + if (node->accept (&oia_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - - *os << ");\n\n"; + *os << be_uidt_nl << ");" << be_uidt_nl << be_nl; - os->indent (); - // Here I still need to generate the other methods + private args + // Here I still need to generate the other methods + private args. *os << "virtual Dynamic::ParameterList * arguments (" << be_idt << be_idt_nl << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl @@ -220,16 +205,16 @@ be_visitor_operation_interceptors_ss:: *os << "virtual char * target_most_derived_interface (" << be_idt << be_idt_nl - << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)" - << be_uidt_nl + << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ")" << be_nl << "ACE_THROW_SPEC ((CORBA::SystemException));" << be_uidt_nl << be_nl; *os << "virtual CORBA::Boolean target_is_a (" << be_idt << be_idt_nl << "const char * id" << be_nl - << "ACE_ENV_ARG_DECL_WITH_DEFAULTS)" - << be_uidt_nl - << "ACE_THROW_SPEC ((CORBA::SystemException));\n" + << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ")" << be_nl + << "ACE_THROW_SPEC ((CORBA::SystemException));" << be_uidt_nl; // Store the result for later use. @@ -249,14 +234,14 @@ be_visitor_operation_interceptors_ss:: // void since we cant have a private member to be of void type. if (!this->void_return_type (bt)) { - *os << "void result ("; + *os << be_nl << "void result ("; + ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype or_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -268,7 +253,6 @@ be_visitor_operation_interceptors_ss:: } *os << be_uidt_nl << "private:" << be_idt_nl; - *os << "TAO_ServerRequestInfo_" << node->flat_name (); // We need the interface node in which this operation was defined. However, @@ -301,7 +285,8 @@ be_visitor_operation_interceptors_ss:: } } - *os << " (const "<< "TAO_ServerRequestInfo_"<< node->flat_name (); + *os << " (" << be_idt << be_idt_nl + << "const "<< "TAO_ServerRequestInfo_"<< node->flat_name (); // 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 @@ -334,8 +319,10 @@ be_visitor_operation_interceptors_ss:: } - *os << " &);" << be_nl - << "void operator= (const " + *os << " &" << be_uidt_nl + << ");" << be_uidt_nl << be_nl + << "void operator= (" << be_idt << be_idt_nl + << "const " << "TAO_ServerRequestInfo_"<< node->flat_name (); // We need the interface node in which this operation was defined. However, @@ -369,33 +356,23 @@ be_visitor_operation_interceptors_ss:: } - *os << " &);" << be_nl; + *os << " &" << be_uidt_nl + << ");" << be_uidt_nl; *os << be_uidt_nl << "private:" << be_idt_nl; // Get the right object implementation. *os << intf->full_skel_name () << " *_tao_impl;" << be_nl; - // Need to generate the args as reference memebers... + // Need to generate the args as reference memebers. // generate the member list with the appropriate mapping. For these // we grab a visitor that generates the parameter listing and // modify it to generate reference members. - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SH); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_interceptors_arglist oiia_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oiia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_sh::" "visit_operation - " @@ -403,11 +380,8 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - // Generate the result data member. // Generate the return type. - bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) @@ -425,11 +399,10 @@ be_visitor_operation_interceptors_ss:: { ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype tor_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&tor_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -446,13 +419,13 @@ be_visitor_operation_interceptors_ss:: } int -be_visitor_operation_interceptors_ss:: - generate_class_definition (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_ss::generate_class_definition ( + TAO_OutStream *os, + be_operation *node + ) { be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); // Save the node. this->ctx_->node (node); @@ -557,11 +530,10 @@ be_visitor_operation_interceptors_ss:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oia_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -569,8 +541,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_uidt_nl << ")" << be_nl; // Generate the member list and set each member but before that, @@ -581,11 +551,10 @@ be_visitor_operation_interceptors_ss:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiai_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oiai_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_args_info_ss::" "visit_argument- " @@ -593,8 +562,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - os->decr_indent (); *os << be_nl << "{}\n\n"; @@ -635,24 +602,28 @@ be_visitor_operation_interceptors_ss:: } } - *os << "::arguments (ACE_ENV_SINGLE_ARG_DECL)" << be_idt_nl + *os << "::arguments (" << be_idt << be_idt_nl + << "ACE_ENV_SINGLE_ARG_DECL" << be_uidt_nl + << ")" << be_nl << "ACE_THROW_SPEC ((CORBA::SystemException))" << be_uidt_nl << "{" << be_idt_nl << "// Generate the argument list on demand." << be_nl << "Dynamic::ParameterList *parameter_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_parameter_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_parameter_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; size_t parameter_count = this->count_non_out_parameters (node); - if (node->argument_count () == 0 || - parameter_count == 0 || + + if (node->argument_count () == 0 + || parameter_count == 0 // Now make sure that we have some in and inout // parameters. Otherwise, there is nothing to be put into // the Dynamic::Parameterlist. - (!(this->has_param_type (node, AST_Argument::dir_IN)) && - !(this->has_param_type (node, AST_Argument::dir_INOUT)))) + || (!(this->has_param_type (node, AST_Argument::dir_IN)) + &&!(this->has_param_type (node, AST_Argument::dir_INOUT)))) { *os << "return parameter_list;" << be_uidt_nl; } @@ -678,11 +649,10 @@ be_visitor_operation_interceptors_ss:: // decide this. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oip_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oip_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -690,8 +660,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_nl << "return safe_parameter_list._retn ();" << be_uidt_nl; } @@ -737,7 +705,9 @@ be_visitor_operation_interceptors_ss:: } } - *os << "::exceptions (ACE_ENV_SINGLE_ARG_DECL)"<< be_idt_nl + *os << "::exceptions (" << be_idt << be_idt_nl + << "ACE_ENV_SINGLE_ARG_DECL" << be_uidt_nl + << ")"<< be_nl << "ACE_THROW_SPEC ((CORBA::SystemException))" << be_uidt_nl << "{" << be_idt_nl; @@ -745,7 +715,8 @@ be_visitor_operation_interceptors_ss:: { *os << "// Generate the exception list on demand." << be_nl << "Dynamic::ExceptionList *exception_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_exception_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_exception_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; @@ -762,11 +733,10 @@ be_visitor_operation_interceptors_ss:: // We change our scope to be able to generate the exceptionlist. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_exceptlist oie_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oie_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -774,8 +744,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_nl << "return safe_exception_list._retn ();"; } @@ -834,7 +802,9 @@ be_visitor_operation_interceptors_ss:: } } - *os << "::result (ACE_ENV_SINGLE_ARG_DECL)"<< be_idt_nl + *os << "::result (" << be_idt << be_idt_nl + << "ACE_ENV_SINGLE_ARG_DECL" << be_uidt_nl + << ")"<< be_nl << "ACE_THROW_SPEC ((CORBA::SystemException))" << be_uidt_nl << "{" << be_idt_nl; @@ -849,7 +819,8 @@ be_visitor_operation_interceptors_ss:: // Return an Any with tk_void TypeCode. *os << "CORBA::Boolean tk_void_any = 1;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -859,7 +830,8 @@ be_visitor_operation_interceptors_ss:: { *os << "CORBA::Boolean tk_void_any = 0;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -869,11 +841,10 @@ be_visitor_operation_interceptors_ss:: // Generate the insertion of result into Any. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_RESULT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_result oir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&oir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -881,8 +852,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_nl << "return safe_result_any._retn ();"; } @@ -941,7 +910,8 @@ be_visitor_operation_interceptors_ss:: *os << "::target_most_derived_interface (" << be_idt << be_idt_nl - << "ACE_ENV_SINGLE_ARG_DECL_NOT_USED)" << be_uidt_nl + << "ACE_ENV_SINGLE_ARG_DECL_NOT_USED" << be_uidt_nl + << ")" << be_nl << "ACE_THROW_SPEC ((CORBA::SystemException))" << be_uidt_nl << "{" << be_idt_nl << "return" << be_idt_nl @@ -987,7 +957,8 @@ be_visitor_operation_interceptors_ss:: *os << "::target_is_a (" << be_idt << be_idt_nl << "const char * id" << be_nl - << "ACE_ENV_ARG_DECL)" << be_uidt_nl + << "ACE_ENV_ARG_DECL" << be_uidt_nl + << ")" << be_nl << "ACE_THROW_SPEC ((CORBA::SystemException))" << be_uidt_nl << "{" << be_idt_nl << "return this->_tao_impl->_is_a (id ACE_ENV_ARG_PARAMETER);" @@ -1029,7 +1000,7 @@ be_visitor_operation_interceptors_ss:: if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_ch::" + "(%N:%l) be_visitor_interceptors_ch::" "visit_operation - " "Bad return type\n"), -1); @@ -1052,11 +1023,10 @@ be_visitor_operation_interceptors_ss:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype or_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " diff --git a/TAO/TAO_IDL/be/be_visitor_operation/inv_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/inv_arglist.cpp deleted file mode 100644 index 0e7b149472d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/inv_arglist.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// $Id$ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, inv_arglist, "$Id$") - - -be_visitor_operation_inv_arglist:: -be_visitor_operation_inv_arglist (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -be_visitor_operation_inv_arglist::~be_visitor_operation_inv_arglist (void) -{ -} - -int -be_visitor_operation_inv_arglist::visit_operation (be_operation *node) -{ - // 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_operation_inv_arglist::" - "visit_operation - " - "codegen for scope failed\n"), - -1); - } - - return 0; -} - -int -be_visitor_operation_inv_arglist::visit_argument (be_argument *node) -{ - // 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_inv_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 - be_interface *intf; - intf = this->ctx_->attribute () - ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) - : be_interface::narrow_from_scope (op->defined_in ()); - - if (!intf) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_inv_arglist::" - "visit_argument - " - "Bad interface\n"), - -1); - } - ctx.scope (intf); // set new scope - - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INVOKE_ARG_LIST); - - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_inv_arglist::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_inv_arglist::" - "visit_argument - " - "codegen for inv_arglist failed\n"), - -1); - } - delete visitor; - return 0; -} - - diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 5e65540aa00..a560547a29e 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -18,28 +18,25 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation, + "$Id$") // ************************************************************ // Generic Operation visitor // ************************************************************ be_visitor_operation::be_visitor_operation (be_visitor_context *ctx) - : be_visitor_scope (ctx) + : be_visitor_scope (ctx), + operation_name_ (0) { } be_visitor_operation::~be_visitor_operation (void) { + delete [] operation_name_; } - // Is the operation return type void? int be_visitor_operation::void_return_type (be_type *bt) @@ -141,7 +138,7 @@ be_visitor_operation::gen_throw_spec (be_operation *node) } UTL_Scope *scope = node->defined_in (); - be_interface *iface = be_interface::narrow_from_scope ( scope ); + be_interface *iface = be_interface::narrow_from_scope (scope); /***************************************************************************/ // 2.6 @@ -151,9 +148,11 @@ be_visitor_operation::gen_throw_spec (be_operation *node) if (iface != 0) { int is_amh_exception_holder = this->is_amh_exception_holder (iface); - if(!iface->is_valuetype () || is_amh_exception_holder) + AST_Decl::NodeType nt = iface->node_type (); + + if (nt != AST_Decl::NT_valuetype || is_amh_exception_holder) { - *os << be_idt_nl << throw_spec_open; + *os << be_nl << throw_spec_open; *os << be_idt_nl << "CORBA::SystemException"; if (node->exceptions ()) @@ -180,6 +179,7 @@ be_visitor_operation::gen_throw_spec (be_operation *node) *os << excp->name (); } } + *os << be_uidt_nl << throw_spec_close << be_uidt; } } @@ -244,7 +244,7 @@ be_visitor_operation::gen_environment_decl (int argument_emitted, // Method that returns the appropriate CORBA::Environment variable. const char * -be_visitor_operation::gen_environment_var () +be_visitor_operation::gen_environment_var (void) { static const char *ace_try_env_decl = "ACE_DECLARE_NEW_CORBA_ENV;"; static const char *null_env_decl = ""; @@ -320,11 +320,10 @@ int be_visitor_operation::gen_check_exception (be_type *return_type) { TAO_OutStream *os = this->ctx_->stream (); - os->indent (); if (return_type == 0 || this->void_return_type (return_type)) { - *os << "ACE_CHECK;\n"; + *os << "ACE_CHECK;" << be_nl; return 0; } @@ -344,7 +343,7 @@ be_visitor_operation::gen_check_exception (be_type *return_type) -1); } - *os << ");\n"; + *os << ");" << be_nl; return 0; } @@ -352,7 +351,6 @@ int be_visitor_operation::gen_check_interceptor_exception (be_type *return_type) { TAO_OutStream *os = this->ctx_->stream (); - os->indent (); if (return_type == 0 || this->void_return_type (return_type)) { @@ -379,3 +377,935 @@ be_visitor_operation::gen_check_interceptor_exception (be_type *return_type) *os << ");\n"; return 0; } + +int +be_visitor_operation::gen_stub_operation_body ( + be_operation *node, + be_type *return_type + ) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor_context ctx; + const char *target = "_collocated_tao_target_"; + + if (node->defined_in ()->is_abstract ()) + { + target = "this"; + } + + // Generate the actual code for the stub. However, if any of the argument + // types is "native", we flag a MARSHAL exception. + // last argument - is always ACE_ENV_ARG_PARAMETER + *os << "{" << be_idt_nl; + *os << this->gen_environment_var () << "\n"; + + // Generate any pre stub info if and only if none of our parameters is of + // the native type. + if (!node->has_native ()) + { + // native type does not exist. + + // Generate any "pre" stub information such as tables or declarations + // This is a template method and the actual work will be done by the + // derived class + if (this->gen_pre_stub_info (node) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "gen_pre_stub_info failed\n" + ), + -1 + ); + } + } + + // Declare return type. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS); + be_visitor_operation_rettype_vardecl_cs rd_visitor (&ctx); + + if (return_type->accept (&rd_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return var decl failed\n"), + -1); + } + + if (node->has_native ()) // native exists => no stub + { + if (this->gen_raise_exception (return_type, + "CORBA::MARSHAL", + "") == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return var failed\n" + ), + -1 + ); + } + } + else + { + // Generate code that retrieves the underlying stub object and then + // invokes do_static_call on it. + *os << "TAO_Stub *istub = " << target << "->_stubobj ();" + << be_nl << be_nl + << "if (istub == 0)" << be_idt_nl + << "{" << be_idt_nl; + + // If the stub object was bad, then we raise a system exception. + if (this->gen_raise_exception (return_type, "CORBA::INTERNAL", "") == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for checking exception failed\n" + ), + -1 + ); + } + + *os << be_uidt; + + os->indent (); + + *os << "}" << be_uidt_nl << be_nl; + + // Do any pre marshal and invoke processing with return type. This + // includes allocating memory, initialization. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_PRE_INVOKE_CS); + be_visitor_operation_rettype_pre_invoke_cs rpi_visitor (&ctx); + + if (return_type->accept (&rpi_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for retval pre invoke failed\n" + ), + -1 + ); + } + + // Do any pre marshal and invoke stuff with arguments. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS); + be_visitor_operation_argument api_visitor (&ctx); + + if (node->accept (&api_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for argument pre invoke failed\n" + ), + -1 + ); + } + + // Generate the code for marshaling in the parameters and transmitting + // them. + if (this->gen_marshal_and_invoke (node, return_type) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for marshal and invoke failed\n" + ), + -1 + ); + + } + + if (!this->void_return_type (return_type)) + { + // Now generate the normal successful return statement. + if (return_type->size_type () == AST_Type::VARIABLE + || return_type->base_node_type () == AST_Decl::NT_array) + { + *os << "return _tao_retval._retn ();"; + } + else + { + *os << "return _tao_retval;"; + } + } + } // end of if (!native) + + *os << be_uidt_nl << "}\n\n"; + + return 0; +} + +int +be_visitor_operation::gen_pre_stub_info ( + be_operation *node + ) +{ + // Check if this operation raises any exceptions. In that case, we must + // generate a list of exception typecodes. This is not valid for + // attributes. + if (!this->ctx_->attribute ()) + { + be_visitor_context ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); + be_visitor_operation_exceptlist_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) " + "be_visitor_operation_cs::" + "gen_pre_stub_info - " + "Exceptionlist generation error\n"), + -1); + } + } + + return 0; +} + +int +be_visitor_operation::gen_marshal_and_invoke ( + be_operation *node, + be_type *bt + ) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor_context ctx; + const char *target = "_collocated_tao_target_"; + + if (node->defined_in ()->is_abstract ()) + { + target = "this"; + } + + + os->indent (); + + *os << be_nl; + + // Create the GIOP_Invocation and grab the outgoing CDR stream. + switch (node->flags ()) + { + case AST_Operation::OP_oneway: + *os << "TAO_GIOP_Oneway_Invocation _tao_call "; + break; + default: + *os << "TAO_GIOP_Twoway_Invocation _tao_call "; + } + + // Do we have "_set_" or "_get_" prepended? + size_t ext = this->ctx_->attribute () ? 5 : 0; + + // Do we have any arguments in the operation that needs marshalling + int flag = + node->count_arguments_with_direction (AST_Argument::dir_IN + | AST_Argument::dir_INOUT); + + *os << "(" << be_idt << be_idt_nl + << "istub," << be_nl + << this->compute_operation_name (node) + << "," << be_nl + << ACE_OS::strlen (node->original_local_name ()->get_string ()) + ext + << "," << be_nl + << flag + << "," <<be_nl + << "istub->orb_core ()" << be_uidt_nl + << ");" << be_uidt_nl; + + *os << be_nl + << "int _invoke_status;" << be_nl; + + // Generate code to obtain the client request interceptors from the + // ORB. + *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl; + *os << "TAO_ClientRequestInterceptor_Adapter _tao_vfr (" + << be_idt << be_idt_nl + << "istub->orb_core ()->client_request_interceptors ()," << be_nl + << "&_tao_call," << be_nl + << "_invoke_status" + << be_uidt_nl + << ");" << be_uidt_nl; + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + // The connection retry loop. + *os << be_nl + << "for (;;)" << be_idt_nl + << "{" << be_idt_nl + << "_invoke_status = TAO_INVOKE_EXCEPTION;" << be_nl; + + + *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; + + *os << "TAO_ClientRequestInfo_" << node->flat_name (); + + // 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 and add a "_get"/"_set" to the flat + // name to get around the problem of overloaded methods which are + // generated for attributes. + if (this->ctx_->attribute ()) + { + bt = be_type::narrow_from_decl (node->return_type ()); + + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interceptors_ch::" + "visit_operation - " + "Bad return type\n"), + -1); + } + + // Grab the right visitor to generate the return type if its not + // void it means it is not the accessor. + if (!this->void_return_type (bt)) + { + *os << "_get"; + } + else + { + *os << "_set"; + } + } + + *os << " _tao_ri (" << be_idt << be_idt_nl + << "&_tao_call," << be_nl + << target; + + // Generate the formal argument fields which are passed + // to the RequestInfo object. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS); + be_visitor_operation_interceptors_arglist iia_visitor (&ctx); + + if (node->accept (&iia_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for arglist failed\n"), + -1); + } + + *os << be_uidt_nl << ");" << be_uidt_nl; + + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + // Prepare the request header. + *os << be_nl << "CORBA::Short _tao_response_flag = "; + + switch (node->flags ()) + { + case AST_Operation::OP_oneway: + *os << "_tao_call.sync_scope ();" << be_nl + << "TAO_INTERCEPTOR (_tao_ri.response_expected (0));" << be_nl; + break; + default: + *os << "TAO_TWOWAY_RESPONSE_FLAG;" << be_nl + << "TAO_INTERCEPTOR (_tao_ri.response_expected (1));" << be_nl; + } + + *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; + + *os << be_nl << "ACE_TRY" << be_idt_nl + << "{" << be_idt_nl; + + // Invoke send_request() interception point. + // This is done before the Invocation::start() call so that a + // connection can be avoided if send_request() throws an exception, + // i.e. this is an optimization. + *os << "_tao_vfr.send_request (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_nl; + + // _invoke_status is potentially set (via a reference) in + // TAO_ClientRequestInterceptor_Adapter::send_request() so check its + // value. If a location forward or transport retry occured, then we + // need to restart the loop so that the ClientRequestInfo object is + // setup for the re-issued request. + // + // Note that since we're invoking the send_request() interception + // point before the Invocation::start() call, i.e. before a + // connection is ever made, we're actually able to forward requests + // for oneways via the PortableInterceptor::ForwardRequest exception + // too! + *os << be_nl + << "if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_call.restart_flag (1);" << be_nl + << "continue;" << be_uidt_nl + << "}" << be_uidt_nl; + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + + *os << be_nl + << "_tao_call.start (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl; + + // Check if there is an exception. + if (this->gen_check_interceptor_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << be_nl + << "_tao_call.prepare_header (" << be_idt << be_idt_nl + << "ACE_static_cast (CORBA::Octet, _tao_response_flag)" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl; + + // Check if there is an exception. + if (this->gen_check_interceptor_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + // Now make sure that we have some in and inout parameters. Otherwise, there + // is nothing to be marshaled in. + if (this->has_param_type (node, AST_Argument::dir_IN) || + this->has_param_type (node, AST_Argument::dir_INOUT)) + { + *os << be_nl + << "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();" + << be_nl << be_nl + << "if (!(" << be_idt << be_idt_nl; + + // Marshal each in and inout argument. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); + be_visitor_operation_argument_invoke oai_visitor (&ctx); + + if (node->accept (&oai_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for return var in " + "do_static_call failed\n"), + -1); + } + + *os << be_nl + << "))" << be_uidt_nl + << "{" << be_idt_nl; + + // If marshaling fails, raise exception. + if (this->gen_raise_interceptor_exception (bt, "CORBA::MARSHAL", "") + == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + + *os << be_uidt_nl << be_nl; + *os << "}" << be_uidt_nl << be_nl; + } + else + { + *os << be_nl << be_nl; + } + + *os << "_invoke_status =" << be_idt_nl; + + if (node->flags () == AST_Operation::OP_oneway) + { + // Oneway operation. + *os << "_tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);"; + } + else + { + if (node->exceptions ()) + { + *os << "_tao_call.invoke (_tao_" << node->flat_name () + << "_exceptiondata, " + << node->exceptions ()->length () + << " ACE_ENV_ARG_PARAMETER);"; + } + else + { + *os << "_tao_call.invoke (0, 0 ACE_ENV_ARG_PARAMETER);"; + } + } + + *os << be_uidt_nl; + + // Check if there is an exception. + if (this->gen_check_interceptor_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << be_nl + << "if (_invoke_status == TAO_INVOKE_EXCEPTION)" << be_idt_nl + << "{" << be_idt_nl; + + // Unlisted user exception received by client. + int status = this->gen_raise_interceptor_exception ( + bt, + "CORBA::UNKNOWN", + "TAO_OMG_VMCID | 1, CORBA::COMPLETED_YES" + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + + *os << be_uidt_nl << "}" << be_uidt_nl; + + // Note that we no longer turn this code generation off if it's a + // one way operation since the sync scope policy may actually allow + // things such as LOCATION_FORWARD replies to be propagated back to + // the client (e.g. SYNC_WITH_TARGET). + *os << "else if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl + << "{" << be_idt_nl + << "TAO_INTERCEPTOR (" << be_idt << be_idt_nl + << "_tao_ri.reply_status (_invoke_status);" << be_nl + << "_tao_vfr.receive_other (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_uidt_nl + << ")" << be_uidt_nl + << be_nl + << "continue;" << be_uidt_nl + << "}" << be_uidt_nl + << be_nl; + + // If we reach here, we are ready to proceed. + // the code below this is for twoway operations only. + + if (!this->void_return_type (bt) + || this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) + + { + // Do any post_invoke stuff that might be necessary. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + be_visitor_operation_argument oapi_visitor (&ctx); + + if (node->accept (&oapi_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for args in post do_static_call\n"), + -1); + } + + // Generate any temporary variables to demarshal the arguments. + be_visitor_args_decl vis1 (&ctx); + + if (node->accept (&vis1) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_pre_stub_info - " + "codegen for pre args failed\n"), + -1); + } + + if (!this->void_return_type (bt)) + { + // Generate any temporary variables to demarshal the return value. + be_visitor_operation_rettype_post_invoke_cs vis2 (&ctx); + + if (bt->accept (&vis2) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_pre_stub_info - " + "codegen rettype [post invoke] failed\n"), + -1); + } + } + + // Check if there was a user exception, else demarshal the + // return val (if any) and parameters (if any) that came with + // the response message. + *os << be_nl + << "TAO_InputCDR &_tao_in = _tao_call.inp_stream ();" + << be_nl << be_nl + << "if (!(" << be_idt << be_idt_nl; + + if (!this->void_return_type (bt)) + { + // Demarshal the return value. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + be_visitor_operation_rettype_marshal_ss ori_visitor (&ctx); + + if (node->accept (&ori_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for return var failed\n"), + -1); + } + } + + if (this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) + { + if (!this->void_return_type (bt)) + { + *os << " &&" << be_nl; + } + + // Demarshal each out and inout argument. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + be_visitor_operation_argument_invoke oai_visitor (&ctx); + + if (node->accept (&oai_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for return var failed\n"), + -1); + } + } + + *os << be_nl + << "))" << be_uidt_nl + << "{" << be_idt_nl; + + // If marshaling fails, raise exception. + int status = this->gen_raise_interceptor_exception ( + bt, + "CORBA::MARSHAL", + "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES" + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + + *os << be_uidt_nl << "}" << be_uidt_nl; + } + + *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; + + // Populate the ClientRequestInfo object with result, if any, of the + // invocation. + if (!this->void_return_type (bt)) + { + // Here's what we are going to do to have a uniform way of getting the + // return value updated for the Request Info: + // declare a operation_retval type object and assign the + // _tao_retval._retn () to it. + // We pass this to the result updation method (note: it hasnt + // got destroyed) + // We then put it back into the original _tao_retval + // object. + // And finally the _retn () is returned from the operation w.o + // causing any problems. + + // Generate the return type mapping (same as in the header file) + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); + be_visitor_operation_rettype oro_visitor (&ctx); + + if (bt->accept (&oro_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return type failed\n" + ), + -1 + ); + } + + if (bt->size_type () == AST_Type::VARIABLE + || bt->base_node_type () == AST_Decl::NT_array) + { + *os << " _tao_retval_info =" << be_idt_nl + << "_tao_retval._retn ();" << be_uidt_nl + << "_tao_ri.result (_tao_retval_info);" << be_nl + << "_tao_retval = _tao_retval_info;" << be_nl; + } + else + { + *os << " _tao_retval_info =" << be_idt_nl + << "_tao_retval;" << be_uidt_nl + << "_tao_ri.result (_tao_retval_info);" << be_nl; + } + } + + // Oneway operations don't have receive_reply() interception since + // once the request goes over the wire, its the end of the story! + // However, we still need to call an ending interception point + // (receive_other()) to satisfy the General Flow Rules. + if (node->flags () != AST_Operation::OP_oneway) + { + // If we get this far (in the generated code) then we + // successfully completed the request, i.e. no connection retry + // will occur, nor will a LOCATION_FORWARD. + // Invoke receive_reply() interception point. + *os << be_nl + << "_tao_ri.reply_status (_invoke_status);" << be_nl + << "_tao_vfr.receive_reply (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl; + } + else if (node->flags () == AST_Operation::OP_oneway) + { + // Invoke receive_other() interception point. + *os << be_nl + << "_tao_ri.reply_status (_invoke_status);" << be_nl + << "_tao_vfr.receive_other (" << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_nl; + } + + *os << "ACE_TRY_CHECK;" + << be_uidt_nl + << "}" << be_uidt_nl; + + // Note that we do NOT catch the PortableInterceptor::ForwardRequest + // exception here. It is caught in the + // TAO_ClientRequestInterceptor_Adapter class. This is necessary to + // prevent applications from being able to throw the exception in an + // effort to get an easy (but illegal) way to forward a request. + + *os << "ACE_CATCHANY" << be_idt_nl + << "{" << be_idt_nl; + + // Update the exception field of the ClientRequestInfo. + *os << "_tao_ri.exception (&ACE_ANY_EXCEPTION);"<< be_nl; + + *os << "_tao_vfr.receive_exception (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_nl; + + // The receive_exception() interception point may have thrown a + // PortableInterceptor::ForwardRequest exception. In that event, + // the connection retry loop must be restarted so do not rethrow the + // caught exception. + *os << be_nl + << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl + << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_nl; + + *os << be_nl + << "if (_tao_status == PortableInterceptor::SYSTEM_EXCEPTION" << be_nl + << " || _tao_status == PortableInterceptor::USER_EXCEPTION)" + << be_idt_nl + << "{" << be_idt_nl; + + if (be_global->use_raw_throw ()) + { + *os << "throw;"; + } + else + { + *os << "ACE_RE_THROW;"; + } + + *os << be_uidt_nl + << "}" << be_uidt << be_uidt_nl; + + *os << "}" << be_uidt_nl + << "ACE_ENDTRY;" << be_nl; + + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + // The receive_exception() or receive_other() interception point may + // have thrown a PortableInterceptor::ForwardRequest exception. In + // that event, the connection retry loop must be restarted. Note + // that the _invoke_status variable is not set by the interceptor + // support code, so we must explicitly check the status in the + // ClientRequestInfo object. + *os << be_nl + << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl + << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl; + + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << be_nl + << "if (_tao_status == PortableInterceptor::LOCATION_FORWARD" << be_nl + << " || _tao_status == PortableInterceptor::TRANSPORT_RETRY)" + << be_idt_nl + << "{" << be_idt_nl + << "continue;" << be_uidt_nl + << "}" << be_uidt_nl; + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + *os << be_nl << "break;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + return 0; +} + +int +be_visitor_operation::gen_raise_interceptor_exception ( + be_type *bt, + const char *excep, + const char *completion_status + ) +{ + TAO_OutStream *os = this->ctx_->stream (); + + if (this->void_return_type (bt)) + { + if (be_global->use_raw_throw ()) + { + *os << "throw " << excep << "(" << completion_status << ");"; + } + else + { + *os << "TAO_INTERCEPTOR_THROW (" << be_idt << be_idt_nl + << excep << " (" << be_idt << be_idt_nl + << completion_status << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt; + } + } + else + { + if (bt->size_type () == AST_Type::VARIABLE + || bt->base_node_type () == AST_Decl::NT_array) + { + *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt << be_idt_nl + << excep << " (" << be_idt << be_idt_nl + << completion_status << be_uidt_nl + << ")," << be_uidt_nl + << "0" << be_uidt_nl + << ");" << be_uidt; + } + else + { + *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt << be_idt_nl + << excep << " (" << be_idt << be_idt_nl + << completion_status << be_uidt_nl + << ")," << be_uidt_nl + << "_tao_retval" << be_uidt_nl + << ");" << be_uidt; + } + } + + return 0; +} + +const char* +be_visitor_operation::compute_operation_name ( + be_operation *node + ) +{ + if (this->operation_name_ == 0) + { + // Length for two double quotes and the null termination char. + size_t len = 3; + + if (this->ctx_->attribute ()) + { + // "Added length for "_set_" or "_get_". + len += 5; + } + + len += ACE_OS::strlen (node->original_local_name ()->get_string ()); + + ACE_NEW_RETURN (this->operation_name_, + char [len], + 0); + + ACE_OS::strcpy (this->operation_name_, "\""); + + if (this->ctx_->attribute ()) + { + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + ACE_OS::strcat (this->operation_name_, "_set_"); + } + else + { + ACE_OS::strcat (this->operation_name_, "_get_"); + } + } + + ACE_OS::strcat (this->operation_name_, + node->original_local_name ()->get_string ()); + ACE_OS::strcat (this->operation_name_, "\""); + } + + return this->operation_name_; +} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp index 08ef81d3e6a..af66778bbf7 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp @@ -18,17 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_ch, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation_ch, + "$Id$") // ****************************************************** -// primary visitor for "operation" in client header +// Primary visitor for "operation" in client header. // ****************************************************** be_visitor_operation_ch::be_visitor_operation_ch (be_visitor_context *ctx) @@ -44,15 +39,17 @@ int be_visitor_operation_ch::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; this->ctx_->node (node); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // 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 ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -66,20 +63,10 @@ be_visitor_operation_ch::visit_operation (be_operation *node) // Grab the right visitor to generate the return type. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype or_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ch::" "visit_operation - " @@ -87,8 +74,6 @@ be_visitor_operation_ch::visit_operation (be_operation *node) -1); } - delete visitor; - // STEP 2: generate the operation name. *os << " " << node->local_name (); @@ -96,28 +81,16 @@ be_visitor_operation_ch::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_arglist oa_visitor (&ctx); - if (!visitor) + if (node->accept (&oa_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ch::" - "visit_operation - " - "Bad visitor to return type\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; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp index a02cdaa5c9b..4cea8a38b26 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation_cs, + "$Id$") // ************************************************************ // Operation visitor for client stubs @@ -127,131 +122,140 @@ be_visitor_operation_cs::visit_operation (be_operation *node) -1); } - *os << "{" << be_idt_nl; - *os << this->gen_environment_var (); - - if (be_global->exception_support ()) + // @@@ (JP) No collocation for abstract interface operations yet. We + // are generating the code as if there were no proxies, and using + // the (concrete interface's) stub info that we got over the wire. + if (intf->is_abstract ()) { - *os << be_nl << be_nl; + return this->gen_stub_operation_body (node, + bt); } - - // For what follows, the return type node nust be unaliased. - if (bt->node_type () == AST_Decl::NT_typedef) - { - be_typedef *btd = be_typedef::narrow_from_decl (bt); - bt = btd->primitive_base_type (); - } - - AST_Decl::NodeType bnt = bt->base_node_type (); - be_predefined_type *bpt = 0; - AST_PredefinedType::PredefinedType pdt = AST_PredefinedType::PT_void; - - if (bnt == AST_Decl::NT_pre_defined) + else { - bpt = be_predefined_type::narrow_from_decl (bt); - pdt = bpt->pt (); + *os << "{" << be_idt_nl; + *os << this->gen_environment_var (); - if (pdt == AST_PredefinedType::PT_longlong) + if (be_global->exception_support ()) { - *os << "CORBA::LongLong _tao_check_retval = " - << "ACE_CDR_LONGLONG_INITIALIZER;" << be_nl << be_nl; + *os << be_nl << be_nl; } - else if (pdt == AST_PredefinedType::PT_longdouble) + + // For what follows, the return type node nust be unaliased. + if (bt->node_type () == AST_Decl::NT_typedef) { - *os << "CORBA::LongDouble _tao_check_retval = " - << "ACE_CDR_LONG_DOUBLE_INITIALIZER;" << be_nl << be_nl; + be_typedef *btd = be_typedef::narrow_from_decl (bt); + bt = btd->primitive_base_type (); } - } - - // Generate code that retrieves the proper proxy implementation - // using the proxy broker available, and perform the call - // using the proxy implementation provided by the broker. - - *os << intf->base_proxy_impl_name () << " &proxy = " << be_idt_nl - << "this->the" << intf->base_proxy_broker_name () - << "_->select_proxy (this ACE_ENV_ARG_PARAMETER);" << be_uidt_nl; - if (!this->void_return_type (bt)) - { - *os << "ACE_CHECK_RETURN ("; + AST_Decl::NodeType bnt = bt->base_node_type (); + be_predefined_type *bpt = 0; + AST_PredefinedType::PredefinedType pdt = AST_PredefinedType::PT_void; - if (bnt == AST_Decl::NT_enum) - { - // The enum is a unique type, so we must cast. - *os << "(" << bt->name () << ")0);"; - } - else if (bnt == AST_Decl::NT_struct || bnt == AST_Decl::NT_union) + if (bnt == AST_Decl::NT_pre_defined) { - be_decl *bd = be_decl::narrow_from_decl (bt); + bpt = be_predefined_type::narrow_from_decl (bt); + pdt = bpt->pt (); - if (bd->size_type () == be_decl::FIXED) + if (pdt == AST_PredefinedType::PT_longlong) { - // For a fixed size struct or union the return value - // is not a pointer, so we call the default constructor - // and return the result. - *os << bt->name () << " ());"; + *os << "CORBA::LongLong _tao_check_retval = " + << "ACE_CDR_LONGLONG_INITIALIZER;" << be_nl << be_nl; } - else + else if (pdt == AST_PredefinedType::PT_longdouble) { - *os << "0);"; + *os << "CORBA::LongDouble _tao_check_retval = " + << "ACE_CDR_LONG_DOUBLE_INITIALIZER;" << be_nl << be_nl; } } - else if (bnt == AST_Decl::NT_pre_defined) + + // Generate code that retrieves the proper proxy implementation + // using the proxy broker available, and perform the call + // using the proxy implementation provided by the broker. + + *os << intf->base_proxy_impl_name () << " &proxy = " << be_idt_nl + << "this->the" << intf->base_proxy_broker_name () + << "_->select_proxy (this ACE_ENV_ARG_PARAMETER);" << be_uidt_nl; + + if (!this->void_return_type (bt)) { - if (pdt == AST_PredefinedType::PT_longlong - || pdt == AST_PredefinedType::PT_longdouble) + *os << "ACE_CHECK_RETURN ("; + + if (bnt == AST_Decl::NT_enum) + { + // The enum is a unique type, so we must cast. + *os << "(" << bt->name () << ")0);"; + } + else if (bnt == AST_Decl::NT_struct || bnt == AST_Decl::NT_union) { - *os << "_tao_check_retval);" << be_nl - << "ACE_UNUSED_ARG (_tao_check_retval);"; + if (bt->size_type () == AST_Type::FIXED) + { + // For a fixed size struct or union the return value + // is not a pointer, so we call the default constructor + // and return the result. + *os << bt->name () << " ());"; + } + else + { + *os << "0);"; + } + } + else if (bnt == AST_Decl::NT_pre_defined) + { + if (pdt == AST_PredefinedType::PT_longlong + || pdt == AST_PredefinedType::PT_longdouble) + { + *os << "_tao_check_retval);" << be_nl + << "ACE_UNUSED_ARG (_tao_check_retval);"; + } + else + { + *os << "0);"; + } } else { *os << "0);"; } + + *os << be_nl << be_nl + << "return "; } else { - *os << "0);"; + *os << "ACE_CHECK;" << be_nl << be_nl; } - *os << be_nl << be_nl - << "return "; - } - else - { - *os << "ACE_CHECK;" << be_nl << be_nl; - } + *os << "proxy." << node->local_name () + << " (" << be_idt << be_idt_nl << "this"; + + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + AST_Decl *d = si.item (); - *os << "proxy." << node->local_name () - << " (" << be_idt << be_idt_nl << "this"; + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "bad node in this scope\n"), + -1); + } - for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - AST_Decl *d = si.item (); + be_decl *decl = be_decl::narrow_from_decl (d); - if (d == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), - -1); + *os << "," << be_nl + << decl->local_name(); } - be_decl *decl = be_decl::narrow_from_decl (d); - - *os << "," << be_nl - << decl->local_name(); - } + if (!be_global->exception_support ()) + { + *os << " ACE_ENV_ARG_PARAMETER"; + } - if (!be_global->exception_support ()) - { - *os << " ACE_ENV_ARG_PARAMETER"; + *os << be_uidt_nl << ");" << be_uidt << be_uidt_nl << "}\n\n"; } - *os << be_uidt_nl << ");" << be_uidt << be_uidt_nl << "}\n\n"; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp index 716787d0da4..be08e30a904 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp @@ -16,16 +16,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_ih, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_ih, + "$Id$") // ************************************************************ -// Operation visitor for implementation header +// Operation visitor for implementation header. // ************************************************************ be_visitor_operation_ih::be_visitor_operation_ih (be_visitor_context *ctx) @@ -40,17 +36,14 @@ be_visitor_operation_ih::~be_visitor_operation_ih (void) int be_visitor_operation_ih::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); // save the node // 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 ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -64,20 +57,10 @@ be_visitor_operation_ih::visit_operation (be_operation *node) // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ih::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ih::" "visit_operation - " @@ -85,8 +68,6 @@ be_visitor_operation_ih::visit_operation (be_operation *node) -1); } - delete visitor; - // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -94,20 +75,10 @@ be_visitor_operation_ih::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_IH); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ih::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ih::" "visit_operation - " @@ -115,8 +86,6 @@ be_visitor_operation_ih::visit_operation (be_operation *node) -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp index fab89122083..928cddddcc5 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp @@ -16,14 +16,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "ace/SString.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_is, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_is, + "$Id$") // ************************************************************ // Operation visitor for implementation skeleton @@ -41,25 +36,16 @@ be_visitor_operation_is::~be_visitor_operation_is (void) int be_visitor_operation_is::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - //cout<<"Within visit_operation "<<endl; - os = this->ctx_->stream (); - be_interface *intf = - this->ctx_->interface (); - - + TAO_OutStream *os = this->ctx_->stream (); + be_interface *intf = this->ctx_->interface (); this->ctx_->node (node); // save the node os->indent (); // start with the current indentation level - - - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -69,50 +55,29 @@ be_visitor_operation_is::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_is::" - "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_operation_is::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; const char *classname = 0; if (intf) { - //If derived class + // If derived class/ classname = intf->flat_name (); - } - else { - ACE_CString str(node->flat_name ()); - - int lnmlength = ACE_OS::strlen (node->local_name ()->get_string ()); - - int fnmlength = ACE_OS::strlen (node->flat_name ()); - fnmlength--; - - classname = str.substr (0,(fnmlength-lnmlength) ).rep (); + classname = ScopeAsDecl (node->defined_in ())->flat_name (); } // STEP 2: generate the operation name @@ -123,69 +88,21 @@ be_visitor_operation_is::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_IS); - visitor = tao_cg->make_visitor (&ctx); - + be_visitor_operation_arglist oa_visitor (&ctx); - if (!visitor) + if (node->accept (&oa_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_is::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_is::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - - //generate the excetions thrown by the operation - // this->gen_throw_spec (node); - - *os <<be_idt_nl << "{"<<be_idt_nl; - *os << "//Add your implementation here"<<be_uidt_nl; - - //Code to generate teh return statement in the operations..... - //Can be uncommented when required - - /* - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_IS); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_is::" - "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_operation_is::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - */ + *os << be_idt_nl << "{" << be_idt_nl; + *os << "// Add your implementation here" << be_uidt_nl; *os << "}" << be_nl << be_uidt_nl; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp index 41ebae411c1..d6261d65ab4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_sh, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation_sh, + "$Id$") // ************************************************************ // Operation visitor for server header @@ -43,19 +38,19 @@ be_visitor_operation_sh::~be_visitor_operation_sh (void) int be_visitor_operation_sh::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + os->indent (); - os->indent (); // start with the current indentation level + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // 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 ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -65,30 +60,18 @@ be_visitor_operation_sh::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "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_operation_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -97,49 +80,44 @@ be_visitor_operation_sh::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_SH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - // generate the corresponding static skeleton method for this operation only + // Generate the corresponding static skeleton method for this operation only // if there was no "native" type. if (!node->has_native ()) { - os->indent (); *os << "static void "; - // check if we are an attribute node in disguise + + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; + // Now check if we are a "get" or "set" operation + if (node->nmembers () == 1) + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } } - *os << node->local_name () << - "_skel (" << be_idt << be_idt_nl + + *os << node->local_name () + << "_skel (" << be_idt << be_idt_nl << "TAO_ServerRequest &_tao_req," << be_nl << "void *_tao_servant," << be_nl << "void *_tao_servant_upcall" << be_nl << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ");" << be_uidt << "\n\n"; + << ");" << be_uidt << "\n"; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp index d5420b63ba6..e79e48011bb 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp @@ -18,18 +18,10 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" -#include "be_visitor_argument.h" - ACE_RCSID (be_visitor_operation, operation_ss, "$Id$") - // ************************************************************ // Operation visitor for server skeletons // ************************************************************ @@ -42,7 +34,7 @@ be_visitor_operation_ss::be_visitor_operation_ss (be_visitor_context *ctx) be_visitor_operation_ss::~be_visitor_operation_ss (void) { - delete[] this->operation_name_; + delete [] this->operation_name_; } // Processing to be done after every element in the scope is processed. @@ -91,8 +83,7 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // 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 - be_interface *intf; - intf = this->ctx_->attribute () + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); @@ -107,6 +98,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Generate the signature of the static skeleton. os->indent (); + + *os << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "void " << intf->full_skel_name () << "::"; // Check if we are an attribute node in disguise. @@ -130,8 +125,8 @@ be_visitor_operation_ss::visit_operation (be_operation *node) << "ACE_ENV_ARG_DECL" << be_uidt_nl << ")" << be_uidt_nl; - // Generate the actual code for the skeleton. However, if any of the argument - // types is "native", we do not generate any skeleton + // Generate the actual code for the skeleton. However, if any of the + // argument types is "native", we do not generate any skeleton // last argument - is always CORBA::Environment. *os << "{\n" << be_idt; @@ -157,9 +152,9 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Declare a return type variable. be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype_vardecl_ss ord_visitor (&ctx); - // Do we have any arguments in the operation that needs marshalling. + // Do we have any arguments in the operation that needs marshalling? int flag = node->count_arguments_with_direction (AST_Argument::dir_INOUT | AST_Argument::dir_OUT); @@ -172,9 +167,8 @@ be_visitor_operation_ss::visit_operation (be_operation *node) *os << "_tao_server_request.argument_flag (0);" << be_nl; } - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&ord_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -185,11 +179,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Declare variables for arguments. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument oad_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oad_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -263,11 +256,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // RequestInfo object. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiia_visitor (&ctx); - if ((!visitor) || (node->accept (visitor) == -1)) + if (node->accept (&oiia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -275,7 +267,6 @@ be_visitor_operation_ss::visit_operation (be_operation *node) -1); } - delete visitor; *os << be_uidt_nl << ");" << be_uidt_nl << be_nl; *os << "ACE_TRY" << be_idt_nl @@ -309,11 +300,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Make the upcall and assign to the return val. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_ASSIGN_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype_assign_ss ora_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&ora_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -326,11 +316,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) << "_tao_impl->" << node->local_name () << " (" << be_idt << be_idt_nl; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument oau_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oau_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -364,7 +353,7 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Close scope for "if (!_tao_vfr.location_forwarded ()" *os << be_uidt_nl - << "}" << be_uidt_nl; + << "}" << be_uidt; // Close the TAO_PICurrent_Guard scope *os << be_uidt_nl @@ -393,11 +382,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Generate the return type mapping (same as in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -405,9 +393,7 @@ be_visitor_operation_ss::visit_operation (be_operation *node) -1); } - delete visitor; - - if (bt->size_type () == be_decl::VARIABLE + if (bt->size_type () == AST_Type::VARIABLE || bt->base_node_type () == AST_Decl::NT_array) { *os << " _tao_retval_info = _tao_retval._retn ();" << be_nl @@ -451,14 +437,21 @@ be_visitor_operation_ss::visit_operation (be_operation *node) *os << be_nl << "if (_tao_status == PortableInterceptor::SYSTEM_EXCEPTION" << be_nl << " || _tao_status == PortableInterceptor::USER_EXCEPTION)" - << be_idt_nl; + << be_idt_nl + << "{" << be_idt_nl; if (be_global->use_raw_throw ()) - *os << "throw;" << be_uidt << be_uidt_nl; + { + *os << "throw;"; + } else - *os << "ACE_RE_THROW;" << be_uidt << be_uidt_nl; + { + *os << "ACE_RE_THROW;"; + } - *os << "}" << be_uidt_nl + *os << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << "ACE_ENDTRY;" << be_nl; *os << "ACE_CHECK;\n" << "#endif /* TAO_HAS_INTERCEPTORS */" << be_nl << be_nl; @@ -487,9 +480,9 @@ be_visitor_operation_ss::visit_operation (be_operation *node) *os << "// In case _tao_servant_upcall is not used in this function" << be_nl - << "ACE_UNUSED_ARG (_tao_servant_upcall);" << be_nl; + << "ACE_UNUSED_ARG (_tao_servant_upcall);" << be_uidt_nl + << "}" << be_nl << be_nl; - *os << be_uidt_nl << "}\n\n"; return 0; } @@ -499,10 +492,9 @@ be_visitor_operation_ss::visit_argument (be_argument *node) // This method is used to generate the ParamData table entry. TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; // argument type // Retrieve the type for this argument. - bt = be_type::narrow_from_decl (node->field_type ()); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { @@ -555,7 +547,6 @@ be_visitor_operation_ss::gen_demarshal_params (be_operation *node, be_type *) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; // Now make sure that we have some in and inout parameters. Otherwise, there @@ -572,13 +563,12 @@ be_visitor_operation_ss::gen_demarshal_params (be_operation *node, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument_marshal oad_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oad_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_demarshal_params - " "codegen for demarshal failed\n"), -1); @@ -587,12 +577,14 @@ be_visitor_operation_ss::gen_demarshal_params (be_operation *node, *os << be_uidt_nl << "))\n" << be_idt; // If marshaling fails, raise exception. - if (this->gen_raise_exception (0, - "CORBA::MARSHAL", - "") == -1) + int status = this->gen_raise_exception (0, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); @@ -610,7 +602,6 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, be_type *bt) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; // Setup parameters for marshaling and marshal them into the @@ -623,9 +614,9 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, // We still need the following check because we maybe 2way and yet have no // parameters and a void return type. - if (this->void_return_type (bt) && - !this->has_param_type (node, AST_Argument::dir_INOUT) && - !this->has_param_type (node, AST_Argument::dir_OUT)) + if (this->void_return_type (bt) + && !this->has_param_type (node, AST_Argument::dir_INOUT) + && !this->has_param_type (node, AST_Argument::dir_OUT)) { return 0; } @@ -635,17 +626,12 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, { ctx = *this->ctx_; - be_visitor_context *new_ctx = 0; - ACE_NEW_RETURN (new_ctx, - be_visitor_context (ctx), - 0); - - be_visitor_operation_rettype_post_upcall_ss visitor (new_ctx); + be_visitor_operation_rettype_post_upcall_ss visitor (&ctx); if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for return var [post upcall] failed\n"), -1); @@ -654,12 +640,12 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, // Generate any temporary variables to demarshal the arguments. ctx = *this->ctx_; - be_visitor_args_post_upcall_ss vis1 (new be_visitor_context (ctx)); + be_visitor_args_post_upcall_ss vis1 (&ctx); if (node->accept (&vis1) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_pre_stub_info - " "codegen for pre args failed\n"), -1); @@ -675,21 +661,20 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_MARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype_marshal_ss orm_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&orm_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for return var failed\n"), -1); } } - if (this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) + if (this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) { if (!this->void_return_type (bt)) @@ -702,13 +687,12 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument_marshal oam_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oam_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for args failed\n"), -1); @@ -716,13 +700,16 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, } *os << be_uidt_nl << "))\n"; - // if marshaling fails, raise exception - if (this->gen_raise_exception (0, - "CORBA::MARSHAL", - "") == -1) + + // If marshaling fails, raise exception. + int status = this->gen_raise_exception (0, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for raising exception failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp index d7e00029d36..6d2e814446b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp @@ -1,15 +1,12 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_operation, + proxy_impl_xh, + "$Id$") -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, proxy_impl_xh, "$Id$") - - -be_visitor_operation_proxy_impl_xh::be_visitor_operation_proxy_impl_xh (be_visitor_context *ctx) +be_visitor_operation_proxy_impl_xh::be_visitor_operation_proxy_impl_xh ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -20,17 +17,14 @@ be_visitor_operation_proxy_impl_xh::~be_visitor_operation_proxy_impl_xh (void) int be_visitor_operation_proxy_impl_xh::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - // 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 ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -40,30 +34,18 @@ int be_visitor_operation_proxy_impl_xh::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -72,26 +54,16 @@ int be_visitor_operation_proxy_impl_xh::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oapi_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oapi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp index 9e0cefca478..b7a7780c60e 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp @@ -1,60 +1,60 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - ACE_RCSID (be_visitor_operation, be_visitor_operation_remote_proxy_impl_cs, "$Id$") - // ************************************************************ // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_remote_proxy_impl_cs::be_visitor_operation_remote_proxy_impl_cs (be_visitor_context *ctx) - : be_visitor_operation (ctx), - operation_name_ (0) +be_visitor_operation_remote_proxy_impl_cs:: +be_visitor_operation_remote_proxy_impl_cs (be_visitor_context *ctx) + : be_visitor_operation (ctx) { } -be_visitor_operation_remote_proxy_impl_cs::~be_visitor_operation_remote_proxy_impl_cs (void) +be_visitor_operation_remote_proxy_impl_cs:: +~be_visitor_operation_remote_proxy_impl_cs (void) { - delete[] operation_name_; } -// processing to be done after every element in the scope is processed +// Processing to be done after every element in the scope is processed. int be_visitor_operation_remote_proxy_impl_cs::post_process (be_decl *bd) { - // all we do here is to insert a comma and a newline + // All we do here is to insert a comma and a newline. TAO_OutStream *os = this->ctx_->stream (); + if (!this->last_node (bd)) - *os << ",\n"; + { + *os << ",\n"; + } + return 0; } int -be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) +be_visitor_operation_remote_proxy_impl_cs::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node - be_visitor_context ctx; // visitor context - be_visitor *visitor; // visitor + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; + be_visitor_context ctx; - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + this->ctx_->node (node); if (node->is_local ()) - return 0; + { + return 0; + } - os->indent (); // start with the current indentation level + os->indent (); - // retrieve the operation return type + // Retrieve the operation return type. bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -67,197 +67,55 @@ be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) // Generate the return type mapping (same as in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype ort_visitor (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) + if (bt->accept (&ort_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // Generate the operation name be_decl* scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); be_interface *interface = be_interface::narrow_from_decl (scope); - *os <<" " << interface->full_remote_proxy_impl_name () << "::" << node->local_name (); + + *os <<" " << interface->full_remote_proxy_impl_name () + << "::" << node->local_name (); // Generate the argument list with the appropriate mapping (same as - // in the header file) + // in the header file). ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS); - visitor = tao_cg->make_visitor (&ctx); - if ((!visitor) || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for argument list failed\n"), - -1); - } - delete visitor; + be_visitor_operation_arglist arglist_visitor (&ctx); - // Generate the actual code for the stub. However, if any of the argument - // types is "native", we flag a MARSHAL exception. - // last argument - is always ACE_ENV_ARG_PARAMETER - *os << "{" << be_idt_nl; - -/* This shall go away as soon as we drop the include_env switch - (2001-10-29 oliver.kellogg@t-online.de) =======*/ - // Deal with differences between IDL mapping for true C++ exceptions and - // alternate mapping. Since our code uses the ACE_TRY_ENV variable in a - // number of places, for the true exception case, we will have to explicitly - // declare the ACE_TRY_ENV variable. - *os << this->gen_environment_var () << "\n"; -//============================================================================ - - // Generate any pre stub info if and only if none of our parameters is of the - // native type. - if (!node->has_native ()) - { - // native type does not exist. - - // Generate any "pre" stub information such as tables or declarations - // This is a template method and the actual work will be done by the - // derived class - if (this->gen_pre_stub_info (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "gen_pre_stub_info failed\n"), - -1); - } - } - - // Declare return type. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (node->accept (&arglist_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" "visit_operation - " - "codegen for return var decl failed\n"), + "codegen for argument list failed\n"), -1); } - if (node->has_native ()) // native exists => no stub - { - if (this->gen_raise_exception (bt, - "CORBA::MARSHAL", - "") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for return var failed\n"), - -1); - } - } - else - { - // Generate code that retrieves the underlying stub object and then - // invokes do_static_call on it. - *os << be_nl - << "TAO_Stub *istub = _collocated_tao_target_->_stubobj ();" << be_nl - << "if (istub == 0)" << be_idt_nl; - - // if the stub object was bad, then we raise a system exception - if (this->gen_raise_exception (bt, - "CORBA::INTERNAL", - "") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for checking exception failed\n"), - -1); - - } - *os << be_uidt_nl << "\n"; - - // do any pre marshal and invoke processing with return type. This - // includes allocating memory, initialization. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_PRE_INVOKE_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for retval pre invoke failed\n"), - -1); - } - - // do any pre marshal and invoke stuff with arguments - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for argument pre invoke failed\n"), - -1); - } - - // generate the code for marshaling in the parameters and transmitting - // them - if (this->gen_marshal_and_invoke (node, bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for marshal and invoke failed\n"), - -1); - - } - - if (!this->void_return_type (bt)) - { - // now generate the normal successful return statement - // os->indent (); - if (bt->size_type () == be_decl::VARIABLE - || bt->base_node_type () == AST_Decl::NT_array) - { - *os << "return _tao_retval._retn ();"; - } - else - { - *os << "return _tao_retval;"; - } - } - } // end of if (!native) - - *os << be_uidt_nl << "}\n\n"; - - return 0; + // Generate the code for the operation body. + return this->gen_stub_operation_body (node, + bt); } - - - int be_visitor_operation_remote_proxy_impl_cs::visit_argument (be_argument *node) { - // this method is used to generate the ParamData table entry + // This method is used to generate the ParamData table entry. TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; // argument type + be_type *bt; - // retrieve the type for this argument + // Retrieve the type for this argument. bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -269,6 +127,7 @@ be_visitor_operation_remote_proxy_impl_cs::visit_argument (be_argument *node) os->indent (); *os << "{" << bt->tc_name () << ", "; + switch (node->direction ()) { case AST_Argument::dir_IN: @@ -286,703 +145,3 @@ be_visitor_operation_remote_proxy_impl_cs::visit_argument (be_argument *node) return 0; } -int -be_visitor_operation_remote_proxy_impl_cs::gen_pre_stub_info (be_operation *node) -{ - - // Check if this operation raises any exceptions. In that case, we must - // generate a list of exception typecodes. This is not valid for - // attributes - if (!this->ctx_->attribute ()) - { - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_cs::" - "gen_pre_stub_info - " - "Exceptionlist generation error\n"), - -1); - } - } - - return 0; -} - -int -be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( - be_operation *node, - be_type *bt) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; - be_visitor_context ctx; - - os->indent (); - - // create the GIOP_Invocation and grab the outgoing CDR stream - switch (node->flags ()) - { - case AST_Operation::OP_oneway: - *os << "TAO_GIOP_Oneway_Invocation _tao_call "; - break; - default: - *os << "TAO_GIOP_Twoway_Invocation _tao_call "; - } - - // Do we have "_set_" or "_get_" prepended? - size_t ext = this->ctx_->attribute () ? 5 : 0; - - // Do we have any arguments in the operation that needs marshalling - int flag = - node->count_arguments_with_direction (AST_Argument::dir_IN - | AST_Argument::dir_INOUT); - - *os << "(" << be_idt << be_idt_nl - << "istub," << be_nl - << this->compute_operation_name (node) - << "," << be_nl - << ACE_OS::strlen (node->original_local_name ()->get_string ()) + ext - << "," << be_nl - << flag - << "," <<be_nl - << "istub->orb_core ()" << be_uidt_nl - << ");" << be_uidt_nl; - - *os << be_nl - << "int _invoke_status;" << be_nl; - - // Generate code to obtain the client request interceptors from the - // ORB. - *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl; - *os << "TAO_ClientRequestInterceptor_Adapter _tao_vfr (" - << be_idt << be_idt_nl - << "istub->orb_core ()->client_request_interceptors ()," << be_nl - << "&_tao_call," << be_nl - << "_invoke_status" - << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - // The connection retry loop. - *os << be_nl - << "for (;;)" << be_idt_nl - << "{" << be_idt_nl - << "_invoke_status = TAO_INVOKE_EXCEPTION;" << be_nl; - - - *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; - - *os << "TAO_ClientRequestInfo_" << node->flat_name (); - - // 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 and add a "_get"/"_set" to the flat - // name to get around the problem of overloaded methods which are - // generated for attributes. - if (this->ctx_->attribute ()) - { - bt = be_type::narrow_from_decl (node->return_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_ch::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // Grab the right visitor to generate the return type if its not - // void it means it is not the accessor. - if (!this->void_return_type (bt)) - *os << "_get"; - else - *os << "_set"; - } - - *os << " _tao_ri (" << be_idt_nl - << "&_tao_call," << be_nl - << "_collocated_tao_target_"; - - // Generate the formal argument fields which are passed - // to the RequestInfo object. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS); - visitor = tao_cg->make_visitor (&ctx); - - if ((!visitor) || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for arglist failed\n"), - -1); - } - - delete visitor; - - *os << be_uidt_nl << ");" << be_nl; - - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - *os << be_nl; - - // Prepare the request header. - *os << be_nl << "CORBA::Short _tao_response_flag = "; - - switch (node->flags ()) - { - case AST_Operation::OP_oneway: - *os << "_tao_call.sync_scope ();" << be_nl - << "TAO_INTERCEPTOR (_tao_ri.response_expected (0));" << be_nl; - break; - default: - *os << "TAO_TWOWAY_RESPONSE_FLAG;" << be_nl - << "TAO_INTERCEPTOR (_tao_ri.response_expected (1));" << be_nl; - } - - *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; - - *os << be_nl << "ACE_TRY" << be_idt_nl - << "{" << be_idt_nl; - - // Invoke send_request() interception point. - // This is done before the Invocation::start() call so that a - // connection can be avoided if send_request() throws an exception, - // i.e. this is an optimization. - *os << "_tao_vfr.send_request (" << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_nl - << "ACE_TRY_CHECK;" << be_nl; - - // _invoke_status is potentially set (via a reference) in - // TAO_ClientRequestInterceptor_Adapter::send_request() so check its - // value. If a location forward or transport retry occured, then we - // need to restart the loop so that the ClientRequestInfo object is - // setup for the re-issued request. - // - // Note that since we're invoking the send_request() interception - // point before the Invocation::start() call, i.e. before a - // connection is ever made, we're actually able to forward requests - // for oneways via the PortableInterceptor::ForwardRequest exception - // too! - *os << be_nl - << "if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl - << "{" << be_idt_nl - << "_tao_call.restart_flag (1);" << be_nl - << "continue;" << be_uidt_nl - << "}" << be_uidt_nl; - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - - *os << be_nl - << "_tao_call.start (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl; - // check if there is an exception - if (this->gen_check_interceptor_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << be_nl - << "_tao_call.prepare_header (" << be_idt << be_idt_nl - << "ACE_static_cast (CORBA::Octet, _tao_response_flag)" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt_nl; - // check if there is an exception - - if (this->gen_check_interceptor_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - // Now make sure that we have some in and inout parameters. Otherwise, there - // is nothing to be marshaled in. - if (this->has_param_type (node, AST_Argument::dir_IN) || - this->has_param_type (node, AST_Argument::dir_INOUT)) - { - *os << be_nl - << "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();" - << be_nl - << "if (!(" << be_idt << be_idt_nl; - - // Marshal each in and inout argument. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), - -1); - } - *os << be_uidt_nl - << "))" << be_nl; - - // If marshaling fails, raise exception. - if (this->gen_raise_interceptor_exception (bt, - "CORBA::MARSHAL", - "") - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - - *os << be_uidt_nl; - } - else - *os << be_nl; - - *os << "_invoke_status =" << be_idt_nl; - if (node->flags () == AST_Operation::OP_oneway) - { - // Oneway operation. - *os << "_tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);"; - } - else - { - if (node->exceptions ()) - { - *os << "_tao_call.invoke (_tao_" << node->flat_name () - << "_exceptiondata, " - << node->exceptions ()->length () - << " ACE_ENV_ARG_PARAMETER);"; - } - else - { - *os << "_tao_call.invoke (0, 0 ACE_ENV_ARG_PARAMETER);"; - } - } - - *os << be_uidt_nl; - // Check if there is an exception. - if (this->gen_check_interceptor_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << be_nl - << "if (_invoke_status == TAO_INVOKE_EXCEPTION)" << be_idt_nl - << "{" << be_idt_nl; - - // Unlisted user exception received by client. - if (this->gen_raise_interceptor_exception ( - bt, - "CORBA::UNKNOWN", - "TAO_OMG_VMCID | 1, CORBA::COMPLETED_YES") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - - *os << be_uidt_nl << "}" << be_uidt_nl; - - // Note that we no longer turn this code generation off if it's a - // one way operation since the sync scope policy may actually allow - // things such as LOCATION_FORWARD replies to be propagated back to - // the client (e.g. SYNC_WITH_TARGET). - *os << "else if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl - << "{" << be_idt_nl - << "TAO_INTERCEPTOR (" << be_idt_nl - << "_tao_ri.reply_status (_invoke_status);" << be_nl - << "_tao_vfr.receive_other (" << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_nl - << "ACE_TRY_CHECK;" << be_uidt_nl - << ")" << be_nl - << be_nl - << "continue;" << be_uidt_nl - << "}" << be_uidt_nl - << be_nl; - - // If we reach here, we are ready to proceed. - // the code below this is for twoway operations only. - - if (!this->void_return_type (bt) || - this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) - - { - // Do any post_invoke stuff that might be necessary. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for args in post do_static_call\n"), - -1); - } - - // Generate any temporary variables to demarshal the arguments - ctx = *this->ctx_; - be_visitor_compiled_args_decl vis1 (new be_visitor_context (ctx)); - if (node->accept (&vis1) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_pre_stub_info - " - "codegen for pre args failed\n"), - -1); - } - - if (!this->void_return_type (bt)) - { - // Generate any temporary variables to demarshal the return value - ctx = *this->ctx_; - be_visitor_context *new_ctx = - new be_visitor_context (ctx); - be_visitor_operation_rettype_post_invoke_cs vis2 (new_ctx); - if (bt->accept (&vis2) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_pre_stub_info - " - "codegen rettype [post invoke] failed\n"), - -1); - } - } - - // check if there was a user exception, else demarshal the - // return val (if any) and parameters (if any) that came with - // the response message - *os << "TAO_InputCDR &_tao_in = _tao_call.inp_stream ();" << be_nl - << "if (!(" << be_idt << be_idt_nl; - - if (!this->void_return_type (bt)) - { - // demarshal the return val - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var failed\n"), - -1); - } - } - - if (this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) - { - if (!this->void_return_type (bt)) - *os << " &&" << be_nl; - - // demarshal each out and inout argument - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var failed\n"), - -1); - } - } - - *os << be_nl - << "))" << be_uidt_nl - << "{" << be_idt_nl; - // if marshaling fails, raise exception - if (this->gen_raise_interceptor_exception - (bt, "CORBA::MARSHAL", - "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - - *os << be_uidt_nl << "}" << be_uidt_nl; - } - - *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; - - // Populate the ClientRequestInfo object with result, if any, of the - // invocation. - if (!this->void_return_type (bt)) - { - // Here's what we are going to do to have a uniform way of getting the - // return value updated for the Request Info: - // declare a operation_retval type object and assign the - // _tao_retval._retn () to it. - // We pass this to the result updation method (note: it hasnt - // got destroyed) - // We then put it back into the original _tao_retval - // object. - // And finally the _retn () is returned from the operation w.o - // causing any problems. - - // Generate the return type mapping (same as in the header file) - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - - if (bt->size_type () == be_decl::VARIABLE - || bt->base_node_type () == AST_Decl::NT_array) - { - *os << " _tao_retval_info = _tao_retval._retn ();" << be_nl - << "_tao_ri.result (_tao_retval_info);" << be_nl - << "_tao_retval = _tao_retval_info;" << be_nl; - } - else - { - *os << " _tao_retval_info = _tao_retval;" << be_nl - << "_tao_ri.result (_tao_retval_info);" << be_nl; - } - } - - // Oneway operations don't have receive_reply() interception since - // once the request goes over the wire, its the end of the story! - // However, we still need to call an ending interception point - // (receive_other()) to satisfy the General Flow Rules. - if (node->flags () != AST_Operation::OP_oneway) - { - // If we get this far (in the generated code) then we - // successfully completed the request, i.e. no connection retry - // will occur, nor will a LOCATION_FORWARD. - // Invoke receive_reply() interception point. - *os << be_nl - << "_tao_ri.reply_status (_invoke_status);" << be_nl - << "_tao_vfr.receive_reply (" << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_nl; - } - else if (node->flags () == AST_Operation::OP_oneway) - { - // Invoke receive_other() interception point. - *os << be_nl - << "_tao_ri.reply_status (_invoke_status);" << be_nl - << "_tao_vfr.receive_other (" << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_nl; - } - - *os << "ACE_TRY_CHECK;" << be_uidt_nl; - - *os << be_uidt_nl - << "}" << be_uidt_nl; - - // Note that we do NOT catch the PortableInterceptor::ForwardRequest - // exception here. It is caught in the - // TAO_ClientRequestInterceptor_Adapter class. This is necessary to - // prevent applications from being able to throw the exception in an - // effort to get an easy (but illegal) way to forward a request. - - *os << "ACE_CATCHANY" << be_idt_nl - << "{" << be_idt_nl; - - // Update the exception field of the ClientRequestInfo. - *os << "_tao_ri.exception (&ACE_ANY_EXCEPTION);"<< be_nl; - - *os << "_tao_vfr.receive_exception (" << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_nl - << "ACE_TRY_CHECK;" << be_nl; - - // The receive_exception() interception point may have thrown a - // PortableInterceptor::ForwardRequest exception. In that event, - // the connection retry loop must be restarted so do not rethrow the - // caught exception. - *os << be_nl - << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl - << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl - << "ACE_TRY_CHECK;" << be_nl; - - *os << be_nl - << "if (_tao_status == PortableInterceptor::SYSTEM_EXCEPTION" << be_nl - << " || _tao_status == PortableInterceptor::USER_EXCEPTION)" - << be_idt_nl; - - if (be_global->use_raw_throw ()) - *os << "throw;" << be_uidt << be_uidt_nl; - else - *os << "ACE_RE_THROW;" << be_uidt << be_uidt_nl; - - *os << "}" << be_uidt_nl - << "ACE_ENDTRY;" << be_nl; - - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - // The receive_exception() or receive_other() interception point may - // have thrown a PortableInterceptor::ForwardRequest exception. In - // that event, the connection retry loop must be restarted. Note - // that the _invoke_status variable is not set by the interceptor - // support code, so we must explicitly check the status in the - // ClientRequestInfo object. - *os << be_nl - << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl - << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl; - - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << be_nl - << "if (_tao_status == PortableInterceptor::LOCATION_FORWARD" << be_nl - << " || _tao_status == PortableInterceptor::TRANSPORT_RETRY)" - << be_idt_nl - << "continue;" << be_uidt_nl; - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - *os << be_nl << "break;" << be_uidt_nl - << "}" << be_uidt_nl; - - return 0; -} - -int -be_visitor_operation_remote_proxy_impl_cs::gen_raise_interceptor_exception (be_type *bt, - const char *excep, - const char *completion_status) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (this->void_return_type (bt)) - { - if (be_global->use_raw_throw ()) - { - *os << "throw " << excep << "(" << completion_status << ");"; - } - else - { - *os << "TAO_INTERCEPTOR_THROW (" << be_idt_nl - << excep << " (" << completion_status - << ")" << be_uidt_nl - << ");" << be_nl; - } - } - else - { - if (bt->size_type () == be_decl::VARIABLE - || bt->base_node_type () == AST_Decl::NT_array) - { - *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt_nl - << excep << " (" << completion_status << ")," << be_nl - << "0" << be_uidt_nl - << ");" << be_nl; - } - else - { - *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt_nl - << excep << " (" << completion_status << ")," << be_nl - << "_tao_retval" << be_uidt_nl - << ");" << be_nl; - } - } - - return 0; -} - -const char* -be_visitor_operation_remote_proxy_impl_cs::compute_operation_name (be_operation *node) -{ - if (this->operation_name_ == 0) - { - size_t len = 3; // length for two double quotes - // and the null termination char. - if (this->ctx_->attribute ()) - len += 5; // "Added length for "_set_" or "_get_". - - len += ACE_OS::strlen (node->original_local_name ()->get_string ()); - - ACE_NEW_RETURN (this->operation_name_, - char [len], - 0); - - ACE_OS::strcpy (this->operation_name_, "\""); - if (this->ctx_->attribute ()) - { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - ACE_OS::strcat (this->operation_name_, "_set_"); - else - ACE_OS::strcat (this->operation_name_, "_get_"); - } - ACE_OS::strcat (this->operation_name_, - node->original_local_name ()->get_string ()); - ACE_OS::strcat (this->operation_name_, "\""); - } - return this->operation_name_; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp index 973012c93b6..ff0c96d5d75 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype, "$Id$") +ACE_RCSID (be_visitor_operation, + rettype, + "$Id$") // **************************************************************************** @@ -166,9 +162,10 @@ be_visitor_operation_rettype::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << bt->name (); - // If it's not TCKind, it's either TypeCode or ValueBase. + // If it's not TCKind, it's either Object, TypeCode or ValueBase. if (ACE_OS::strcmp (bt->local_name ()->get_string (), "TCKind") != 0) { *os << "_ptr"; @@ -252,7 +249,7 @@ be_visitor_operation_rettype::visit_structure (be_structure *node) // Based on whether we are variable or not, we return a pointer or the // aggregate type. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << " *"; } @@ -299,7 +296,7 @@ be_visitor_operation_rettype::visit_union (be_union *node) // Based on whether we are variable or not, we return a pointer or the // aggregate type. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << " *"; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_assign_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_assign_ss.cpp index 65f263d1a45..073f6dd5d97 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_assign_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_assign_ss.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_assign_ss, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_assign_ss, + "$Id$") // **************************************************************************** // visitor for assignment to a return value variable from the upcall @@ -122,6 +117,7 @@ visit_predefined_type (be_predefined_type *node) case AST_PredefinedType::PT_void: break; case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: case AST_PredefinedType::PT_any: default: *os << "_tao_retval = "; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_is.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_is.cpp index 9578bd33269..8ce8cf18421 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_is.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_is.cpp @@ -16,22 +16,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_is, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_is, + "$Id$") // **************************************************************************** // Operation visitor for return types. This generates the mapping for a return // type in an operation signature // **************************************************************************** -be_visitor_operation_rettype_is::be_visitor_operation_rettype_is (be_visitor_context - *ctx) +be_visitor_operation_rettype_is::be_visitor_operation_rettype_is ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -43,64 +39,65 @@ be_visitor_operation_rettype_is::~be_visitor_operation_rettype_is (void) int be_visitor_operation_rettype_is::visit_array (be_array *) { - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - *os << "return 0;" <<be_nl; + *os << "return 0;" << be_nl; return 0; } int be_visitor_operation_rettype_is::visit_enum (be_enum *) { + TAO_OutStream *os = this->ctx_->stream (); + + *os << "return 0;" << be_nl; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - *os << "return 0;" <<be_nl; return 0; } int be_visitor_operation_rettype_is::visit_interface (be_interface *) { + TAO_OutStream *os = this->ctx_->stream (); + + *os << "return 0;" << be_nl; - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - *os << "return 0;" <<be_nl; return 0; } int be_visitor_operation_rettype_is::visit_interface_fwd (be_interface_fwd *) { + TAO_OutStream *os = this->ctx_->stream (); - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + *os << "return 0;" << be_nl; - *os << "return 0;" <<be_nl; return 0; } int be_visitor_operation_rettype_is::visit_native (be_native *) { + TAO_OutStream *os = this->ctx_->stream (); - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + *os << "return 0;" << be_nl; - *os << "return 0;" <<be_nl; return 0; } int be_visitor_operation_rettype_is::visit_predefined_type (be_predefined_type *node) { - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); switch (node->pt ()) { case AST_PredefinedType::PT_void: - *os << "return;" <<be_nl; - break; + *os << "return;" << be_nl; + + break; default: - *os << "return 0;" <<be_nl; + *os << "return 0;" << be_nl; + break; } @@ -110,42 +107,40 @@ be_visitor_operation_rettype_is::visit_predefined_type (be_predefined_type *node int be_visitor_operation_rettype_is::visit_sequence (be_sequence *) { + // We should never directly be here because anonymous sequence return types + // are not allowed. + TAO_OutStream *os = this->ctx_->stream (); + *os << "return 0;" << be_nl; - // we should never directly be here because anonymous sequence return types - // are not allowed - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - *os << "return 0;" <<be_nl; return 0; } int be_visitor_operation_rettype_is::visit_string (be_string *) { + TAO_OutStream *os = this->ctx_->stream (); - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - + *os << "return 0;" << be_nl; - *os << "return 0;" <<be_nl; return 0; } int be_visitor_operation_rettype_is::visit_structure (be_structure *) { - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "return 0;" <<be_nl; + return 0; } int be_visitor_operation_rettype_is::visit_typedef (be_typedef *node) { + this->ctx_->alias (node); - this->ctx_->alias (node); // set the alias node if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -154,6 +149,7 @@ be_visitor_operation_rettype_is::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } @@ -161,10 +157,9 @@ be_visitor_operation_rettype_is::visit_typedef (be_typedef *node) int be_visitor_operation_rettype_is::visit_union (be_union *) { + TAO_OutStream *os = this->ctx_->stream (); - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - *os << "return 0;" <<be_nl; + *os << "return 0;" << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_marshal_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_marshal_ss.cpp index 6abd8fdaf79..ee688d485cb 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_marshal_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_marshal_ss.cpp @@ -23,12 +23,9 @@ // // ============================================================================ -#include "idl.h" -#include "be.h" -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_marshal_ss, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_marshal_ss, + "$Id$") // **************************************************************************** // visitor for arguments passing to the CDR operators. @@ -45,13 +42,14 @@ be_visitor_operation_rettype_marshal_ss:: { } -int be_visitor_operation_rettype_marshal_ss:: -visit_operation (be_operation *node) +int be_visitor_operation_rettype_marshal_ss::visit_operation ( + be_operation *node + ) { - this->ctx_->node (node); // save the argument node + this->ctx_->node (node); - // retrieve the type of the argument be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -68,12 +66,10 @@ visit_operation (be_operation *node) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { - os->indent (); *os << "(_tao_out << "; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { - os->indent (); *os << "(_tao_in >> "; } else @@ -261,6 +257,7 @@ int be_visitor_operation_rettype_marshal_ss::visit_predefined_type (be_predefine switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << "_tao_retval.in ()"; break; case AST_PredefinedType::PT_any: @@ -302,6 +299,7 @@ int be_visitor_operation_rettype_marshal_ss::visit_predefined_type (be_predefine switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << "_tao_retval.inout ()"; break; case AST_PredefinedType::PT_any: @@ -436,14 +434,14 @@ int be_visitor_operation_rettype_marshal_ss::visit_structure (be_structure *node if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << "_tao_retval.in ()"; else *os << "_tao_retval"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << "_tao_retval.inout ()"; else *os << "_tao_retval"; @@ -465,14 +463,14 @@ int be_visitor_operation_rettype_marshal_ss::visit_union (be_union *node) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << "_tao_retval.in ()"; else *os << "_tao_retval"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) *os << "_tao_retval.inout ()"; else *os << "_tao_retval"; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_invoke_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_invoke_cs.cpp index 07274f66d0f..f6dfc8e7e3f 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_invoke_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_invoke_cs.cpp @@ -19,45 +19,44 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_post_invoke_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_post_invoke_cs, + "$Id$") // ******************************************************************************* // be_visitor_operation_rettype_post_invoke_cs // ******************************************************************************** be_visitor_operation_rettype_post_invoke_cs:: - be_visitor_operation_rettype_post_invoke_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx) +be_visitor_operation_rettype_post_invoke_cs (be_visitor_context *ctx) + : be_visitor_decl (ctx) { } int be_visitor_operation_rettype_post_invoke_cs::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt = node; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } *os << bt->name () << "_forany _tao_retval_forany (" << be_idt << be_idt_nl << "_tao_retval.inout ()" << be_uidt_nl - << ");\n" << be_uidt; + << ");" << be_uidt_nl; + return 0; } int be_visitor_operation_rettype_post_invoke_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // set the alias node + this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -66,6 +65,7 @@ be_visitor_operation_rettype_post_invoke_cs::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_upcall_ss.cpp index 8e547ffee36..90b7d6af6fb 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_upcall_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_upcall_ss.cpp @@ -19,38 +19,36 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_post_upcall_ss, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_post_upcall_ss, + "$Id$") // **************************************************************************** // visitor to do any post processing for return type after an upcall // **************************************************************************** be_visitor_operation_rettype_post_upcall_ss:: - be_visitor_operation_rettype_post_upcall_ss (be_visitor_context *ctx) - : be_visitor_decl (ctx) +be_visitor_operation_rettype_post_upcall_ss (be_visitor_context *ctx) + : be_visitor_decl (ctx) { } int be_visitor_operation_rettype_post_upcall_ss::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt = node; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } *os << bt->name () << "_forany _tao_retval_forany (" << be_idt << be_idt_nl << "_tao_retval.inout ()" << be_uidt_nl << ");\n" << be_uidt; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_invoke_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_invoke_cs.cpp index d3eb147723f..ca2f69c51e4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_invoke_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_invoke_cs.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_pre_invoke_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_pre_invoke_cs, + "$Id$") // ***************************************************************************** // be_visitor_operation_rettype_pre_invoke_cs @@ -46,28 +41,32 @@ be_visitor_operation_rettype_pre_invoke_cs:: int be_visitor_operation_rettype_pre_invoke_cs::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - os->indent (); *os << "{" << be_idt_nl << bt->name () << "_slice *tmp;" << be_nl << "ACE_ALLOCATOR_RETURN (tmp, " << bt->name () << "_alloc (), _tao_retval._retn ());" << be_nl << "_tao_retval = tmp;" << be_uidt_nl << "}\n"; + return 0; } int be_visitor_operation_rettype_pre_invoke_cs::visit_interface (be_interface *) { - // don't do anything. This is the overriding action + // Don't do anything. This is the overriding action. return 0; } @@ -81,57 +80,68 @@ int be_visitor_operation_rettype_pre_invoke_cs:: visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); switch (node->pt ()) { case AST_PredefinedType::PT_any: - os->indent (); + *os << "{" << be_idt_nl << "CORBA::Any *tmp;" << be_nl << "ACE_NEW_RETURN (tmp, CORBA::Any, _tao_retval._retn ());" << be_nl << "_tao_retval = tmp;" << be_uidt_nl << "}\n"; + break; default: break; } + return 0; } int be_visitor_operation_rettype_pre_invoke_cs::visit_sequence (be_sequence *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); + *os << "{" << be_idt_nl << bt->name () << " *tmp;" << be_nl << "ACE_NEW_RETURN (tmp, " << bt->name () << ", _tao_retval._retn ());" << be_nl << "_tao_retval = tmp;" << be_uidt_nl << "}\n"; + return 0; } int be_visitor_operation_rettype_pre_invoke_cs::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - // check if the union is variable if (node->size_type () == be_type::VARIABLE) { os->indent (); @@ -142,13 +152,15 @@ be_visitor_operation_rettype_pre_invoke_cs::visit_structure (be_structure *node) << "_tao_retval = tmp;" << be_uidt_nl << "}\n"; } + return 0; } int be_visitor_operation_rettype_pre_invoke_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // set the alias node + this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -157,6 +169,7 @@ be_visitor_operation_rettype_pre_invoke_cs::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } @@ -164,18 +177,22 @@ be_visitor_operation_rettype_pre_invoke_cs::visit_typedef (be_typedef *node) int be_visitor_operation_rettype_pre_invoke_cs::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - // check if the union is variable if (node->size_type () == be_type::VARIABLE) { os->indent (); + *os << "{" << be_idt_nl << bt->name () << " *tmp;" << be_nl << "ACE_NEW_RETURN (tmp, " @@ -183,6 +200,7 @@ be_visitor_operation_rettype_pre_invoke_cs::visit_union (be_union *node) << "_tao_retval = tmp;" << be_uidt_nl << "}\n"; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_return_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_return_cs.cpp index 300c34bb256..84e0d9b0de3 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_return_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_return_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_return_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_return_cs, + "$Id$") // ************************************************************ // be_visitor_operation_rettype_return_cs @@ -33,120 +28,132 @@ ACE_RCSID(be_visitor_operation, rettype_return_cs, "$Id$") // code to generate the return statement of the stub. // ************************************************************ -be_visitor_operation_rettype_return_cs::be_visitor_operation_rettype_return_cs -(be_visitor_context *ctx) +be_visitor_operation_rettype_return_cs:: +be_visitor_operation_rettype_return_cs (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -be_visitor_operation_rettype_return_cs::~be_visitor_operation_rettype_return_cs (void) +be_visitor_operation_rettype_return_cs:: +~be_visitor_operation_rettype_return_cs (void) { } int be_visitor_operation_rettype_return_cs::visit_array (be_array *) { - // Grab the out stream TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval._retn ()"; + return 0; } int be_visitor_operation_rettype_return_cs::visit_enum (be_enum *) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval"; + return 0; } int be_visitor_operation_rettype_return_cs::visit_interface (be_interface *) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval._retn ()"; + return 0; } int be_visitor_operation_rettype_return_cs::visit_interface_fwd (be_interface_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval"; + return 0; } int be_visitor_operation_rettype_return_cs::visit_valuetype (be_valuetype *) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval._retn ()"; + return 0; } int be_visitor_operation_rettype_return_cs::visit_valuetype_fwd (be_valuetype_fwd *) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval._retn ()"; + return 0; } int -be_visitor_operation_rettype_return_cs::visit_predefined_type (be_predefined_type *node) +be_visitor_operation_rettype_return_cs::visit_predefined_type ( + be_predefined_type *node + ) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << "_tao_retval._retn ()"; - break; + break; case AST_PredefinedType::PT_any: *os << "_tao_retval._retn ()"; - break; + break; case AST_PredefinedType::PT_void: break; - default: *os << "_tao_retval"; + break; } + return 0; } int be_visitor_operation_rettype_return_cs::visit_sequence (be_sequence *) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval._retn ()"; + return 0; } int be_visitor_operation_rettype_return_cs::visit_string (be_string *) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); *os << "_tao_retval._retn ()"; + return 0; } int be_visitor_operation_rettype_return_cs::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << "_tao_retval._retn ()"; } @@ -154,13 +161,15 @@ be_visitor_operation_rettype_return_cs::visit_structure (be_structure *node) { *os << "_tao_retval"; } + return 0; } int be_visitor_operation_rettype_return_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // set the alias node + this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -169,6 +178,7 @@ be_visitor_operation_rettype_return_cs::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } @@ -176,9 +186,9 @@ be_visitor_operation_rettype_return_cs::visit_typedef (be_typedef *node) int be_visitor_operation_rettype_return_cs::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << "_tao_retval._retn ()"; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp index 79602578ad9..ddfae38a161 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_vardecl_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_vardecl_cs, + "$Id$") // ************************************************************ // be_visitor_operation_rettype_vardecl_cs @@ -47,18 +42,21 @@ be_visitor_operation_rettype_vardecl_cs:: int be_visitor_operation_rettype_vardecl_cs::visit_array (be_array *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); *os << bt->name () << "_var _tao_retval;"; - *os << be_nl; return 0; @@ -67,13 +65,17 @@ be_visitor_operation_rettype_vardecl_cs::visit_array (be_array *node) int be_visitor_operation_rettype_vardecl_cs::visit_enum (be_enum *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); @@ -87,13 +89,17 @@ be_visitor_operation_rettype_vardecl_cs::visit_enum (be_enum *node) int be_visitor_operation_rettype_vardecl_cs::visit_interface (be_interface *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); @@ -118,13 +124,17 @@ be_visitor_operation_rettype_vardecl_cs::visit_interface_fwd ( be_interface_fwd *node ) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); @@ -147,13 +157,17 @@ be_visitor_operation_rettype_vardecl_cs::visit_interface_fwd ( int be_visitor_operation_rettype_vardecl_cs::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); @@ -166,13 +180,17 @@ be_visitor_operation_rettype_vardecl_cs::visit_valuetype (be_valuetype *node) int be_visitor_operation_rettype_vardecl_cs::visit_valuetype_fwd (be_valuetype_fwd *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); *os << "::" << bt->name () << "_var _tao_retval;\n\n" @@ -182,7 +200,9 @@ be_visitor_operation_rettype_vardecl_cs::visit_valuetype_fwd (be_valuetype_fwd * } int -be_visitor_operation_rettype_vardecl_cs::visit_predefined_type (be_predefined_type *node) +be_visitor_operation_rettype_vardecl_cs::visit_predefined_type ( + be_predefined_type *node + ) { TAO_OutStream *os = this->ctx_->stream (); be_type *bt; @@ -201,28 +221,34 @@ be_visitor_operation_rettype_vardecl_cs::visit_predefined_type (be_predefined_ty switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << bt->name () << "_var _tao_retval (" << bt->name () << "::_nil ());"; + break; case AST_PredefinedType::PT_any: *os << bt->name () << "_var _tao_retval;"; + break; case AST_PredefinedType::PT_void: break; case AST_PredefinedType::PT_longdouble: *os << bt->name () << " _tao_retval = ACE_CDR_LONG_DOUBLE_INITIALIZER;"; + break; case AST_PredefinedType::PT_longlong: *os << bt->name () << " _tao_retval = ACE_CDR_LONGLONG_INITIALIZER;"; + break; default: *os << bt->name () << " _tao_retval = 0;"; + break; } - *os << be_nl << be_nl; + *os << be_nl; return 0; } @@ -230,17 +256,22 @@ be_visitor_operation_rettype_vardecl_cs::visit_predefined_type (be_predefined_ty int be_visitor_operation_rettype_vardecl_cs::visit_sequence (be_sequence *node) { - // we should never directly be here because anonymous sequence return types - // are not allowed - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + // We should never directly be here because anonymous sequence return types + // are not allowed. + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); + *os << bt->name () << "_var _tao_retval;\n" << be_nl; return 0; @@ -253,8 +284,6 @@ be_visitor_operation_rettype_vardecl_cs::visit_string (be_string *node) os->indent (); - // @@ Jeff, this sort of code looks weird to me, on *all* platforms - // sizeof(char) is 1, by definition... if (node->width () == (long) sizeof (char)) { *os << "CORBA::String_var _tao_retval;"; @@ -271,19 +300,23 @@ be_visitor_operation_rettype_vardecl_cs::visit_string (be_string *node) int be_visitor_operation_rettype_vardecl_cs::visit_structure (be_structure *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); - // based on whether we are variable or not, we return a pointer or the - // aggregate type - if (node->size_type () == be_decl::VARIABLE) + // Based on whether we are variable or not, we return a pointer or the + // aggregate type. + if (node->size_type () == AST_Type::VARIABLE) { *os << bt->name () << "_var _tao_retval;" << be_nl; } @@ -301,7 +334,8 @@ be_visitor_operation_rettype_vardecl_cs::visit_structure (be_structure *node) int be_visitor_operation_rettype_vardecl_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // set the alias node + this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -310,6 +344,7 @@ be_visitor_operation_rettype_vardecl_cs::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } @@ -317,19 +352,23 @@ be_visitor_operation_rettype_vardecl_cs::visit_typedef (be_typedef *node) int be_visitor_operation_rettype_vardecl_cs::visit_union (be_union *node) { - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - be_type *bt; // return type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } os->indent (); - // based on whether we are variable or not, we return a pointer or the - // aggregate type - if (node->size_type () == be_decl::VARIABLE) + // Based on whether we are variable or not, we return a pointer or the + // aggregate type. + if (node->size_type () == AST_Type::VARIABLE) { *os << bt->name () << "_var _tao_retval;"; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp index 74034b7c6ab..5f1ae49f1a6 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_vardecl_ss, "$Id$") - +ACE_RCSID (be_visitor_operation, + rettype_vardecl_ss, + "$Id$") // ************************************************************************ // be_visitor_operation_rettype_vardecl_ss @@ -34,8 +29,8 @@ ACE_RCSID(be_visitor_operation, rettype_vardecl_ss, "$Id$") // of the return type. // ************************************************************************ -be_visitor_operation_rettype_vardecl_ss::be_visitor_operation_rettype_vardecl_ss -(be_visitor_context *ctx) +be_visitor_operation_rettype_vardecl_ss:: +be_visitor_operation_rettype_vardecl_ss (be_visitor_context *ctx) : be_visitor_decl (ctx) { } @@ -104,7 +99,7 @@ visit_interface_fwd (be_interface_fwd *node) return 0; } -// like be_compiled_visitor_operation_rettype_vardecl_ss +// Like be_visitor_operation_rettype_vardecl_ss. int be_visitor_operation_rettype_vardecl_ss::visit_valuetype (be_valuetype *node) { @@ -143,6 +138,7 @@ visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << bt->name () << "_var _tao_retval;\n"; break; case AST_PredefinedType::PT_any: @@ -222,7 +218,7 @@ be_visitor_operation_rettype_vardecl_ss::visit_structure (be_structure *node) // Based on whether we are variable or not, we return a pointer or the // aggregate type. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << "::" << bt->name () << "_var _tao_retval;\n"; } @@ -270,7 +266,7 @@ be_visitor_operation_rettype_vardecl_ss::visit_union (be_union *node) // Based on whether we are variable or not, we return a pointer or the // aggregate type. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { *os << "::" << bt->name () << "_var _tao_retval;\n"; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp index 67166a5d8fc..2dbf281187a 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp @@ -18,25 +18,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_smart_proxy_ch, "$Id$") - +ACE_RCSID (be_visitor_operation, + smart_proxy_ch, + "$Id$") // ****************************************************** -// primary visitor for "operation" in client header +// Primary visitor for "operation" in client header. // ****************************************************** -be_visitor_operation_smart_proxy_ch::be_visitor_operation_smart_proxy_ch (be_visitor_context *ctx) +be_visitor_operation_smart_proxy_ch::be_visitor_operation_smart_proxy_ch ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } -be_visitor_operation_smart_proxy_ch::~be_visitor_operation_smart_proxy_ch (void) +be_visitor_operation_smart_proxy_ch::~be_visitor_operation_smart_proxy_ch ( + void + ) { } @@ -46,19 +45,15 @@ be_visitor_operation_smart_proxy_ch::visit_operation (be_operation *node) if (be_global->gen_smart_proxies ()) { + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); + os->indent (); - 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 ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -68,58 +63,36 @@ be_visitor_operation_smart_proxy_ch::visit_operation (be_operation *node) -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_operation_smart_proxy_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype or_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_ch::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; - // STEP 2: generate the operation name + // 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_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_smart_proxy_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; } else { @@ -127,5 +100,4 @@ be_visitor_operation_smart_proxy_ch::visit_operation (be_operation *node) } return 0; - } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp index 715d774c75b..e0740edbd2a 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp @@ -18,26 +18,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_smart_proxy_cs, "$Id$") - +ACE_RCSID (be_visitor_operation, + operation_smart_proxy_cs, + "$Id$") // ************************************************************ // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_smart_proxy_cs::be_visitor_operation_smart_proxy_cs -(be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_operation_smart_proxy_cs::be_visitor_operation_smart_proxy_cs ( + be_visitor_context *ctx + ) + : be_visitor_operation (ctx) { } -be_visitor_operation_smart_proxy_cs::~be_visitor_operation_smart_proxy_cs (void) +be_visitor_operation_smart_proxy_cs::~be_visitor_operation_smart_proxy_cs ( + void + ) { } @@ -49,9 +47,8 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) // 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 - be_interface *intf; - intf = this->ctx_->attribute () + // information from the context. + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); @@ -64,8 +61,8 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) -1); } - // retrieve the operation return type be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -75,30 +72,19 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) -1); } - // STEP 2: generate the return type mapping (same as in the header file) + // STEP 2: generate the return type mapping (same as in the header file). be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_smart_proxy_cs::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } - - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_cs::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // Its necessary to take care of the nested case. The smart proxy classes // are in the same scope as the proxy (i.e. interface) but here the @@ -121,26 +107,16 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ss::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oao_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oao_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt << "\n"; @@ -167,11 +143,10 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) } return 0; - } int be_visitor_operation_smart_proxy_cs::gen_invoke (be_visitor_context &ctx, - be_operation *node) + be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); @@ -180,10 +155,10 @@ int be_visitor_operation_smart_proxy_cs::gen_invoke (be_visitor_context &ctx, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_cs::" "gen_invoke - " @@ -191,21 +166,9 @@ int be_visitor_operation_smart_proxy_cs::gen_invoke (be_visitor_context &ctx, -1); } - // end the upcall *os << be_uidt_nl << ");\n" << be_uidt; + return 0; } -int -be_visitor_operation_smart_proxy_cs::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp index fe21b95ff28..db4d71260a6 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp @@ -1,31 +1,30 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, be_visitor_operation_thru_poa_proxy_impl_ss, "$Id$") - +ACE_RCSID (be_visitor_operation, + be_visitor_operation_thru_poa_proxy_impl_ss, + "$Id$") // ************************************************************ // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_thru_poa_proxy_impl_ss::be_visitor_operation_thru_poa_proxy_impl_ss (be_visitor_context *ctx) +be_visitor_operation_thru_poa_proxy_impl_ss:: +be_visitor_operation_thru_poa_proxy_impl_ss (be_visitor_context *ctx) : be_visitor_operation (ctx) { } -be_visitor_operation_thru_poa_proxy_impl_ss::~be_visitor_operation_thru_poa_proxy_impl_ss (void) +be_visitor_operation_thru_poa_proxy_impl_ss:: +~be_visitor_operation_thru_poa_proxy_impl_ss (void) { //No-Op. } int -be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node) +be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -39,49 +38,48 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node if (!intf) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "bad interface scope\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "bad interface scope\n" + ), + -1 + ); } // retrieve the operation return type be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "Bad return type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "Bad return type\n" + ), + -1 + ); } // STEP 2: generate the return type mapping (same as in the header file) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "codegen for return type failed\n" + ), + -1 + ); } - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - *os << " " << intf->full_thru_poa_proxy_impl_name () << "::"; *os << node->local_name (); @@ -89,26 +87,16 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ss::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oapi_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oapi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt << be_nl; @@ -117,15 +105,18 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node // Declare a return type ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + be_visitor_operation_rettype_vardecl_ss ord_visitor (&ctx); + + if (bt->accept (&ord_visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "codegen for return var decl failed\n" + ), + -1 + ); } if (!this->void_return_type (bt)) @@ -139,7 +130,8 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node *os <<"TAO_Object_Adapter::Servant_Upcall servant_upcall (" << be_idt << be_idt_nl - << "_collocated_tao_target_->_stubobj ()->servant_orb_var ()->orb_core ()" + << "_collocated_tao_target_->_stubobj ()" + << "->servant_orb_var ()->orb_core ()" << be_uidt_nl << ");" << be_uidt_nl << "CORBA::Object_var forward_to;" << be_nl @@ -147,46 +139,32 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node << "_collocated_tao_target_->_object_key ()," << be_nl << "\"" << node->original_local_name () << "\"," << be_nl << "forward_to.out ()"; - if (!be_global->exception_support ()) - *os << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt_nl; - else - *os << be_uidt_nl << ");" << be_uidt_nl; - // check if there is an exception if (!be_global->exception_support ()) - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for checking exception failed\n"), - -1); - } - - if (!be_global->exception_support ()) - os->indent (); - - *os << "servant_upcall.pre_invoke_collocated_request ("; - if (!be_global->exception_support ()) - *os << "ACE_ENV_SINGLE_ARG_PARAMETER"; - *os << ");" << be_nl; + { + *os << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl; + } + else + { + *os << be_uidt_nl << ");" << be_uidt_nl; + } - // check if there is an exception + // Check if there is an exception. if (!be_global->exception_support ()) if (this->gen_check_exception (bt) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for checking exception failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "codegen for checking exception failed\n" + ), + -1 + ); } - if (!be_global->exception_support ()) - os->indent (); - if (!this->void_return_type (bt)) { *os << "return "; @@ -200,17 +178,12 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node << ")" << be_uidt; if (this->gen_invoke (ctx, node) == -1) - return -1; - - if (this->void_return_type (bt)) { - *os << "return;\n"; + return -1; } *os << "}\n\n"; - os->decr_indent (0); - return 0; } @@ -228,46 +201,29 @@ be_visitor_operation_thru_poa_proxy_impl_ss::gen_invoke ( ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "gen_invoke - " - "codegen for making upcall failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "gen_invoke - " + "codegen for making upcall failed\n" + ), + -1 + ); } // End the upcall *os << be_uidt_nl << ");"; - // retrieve the operation return type + // Retrieve the operation return type. be_type *bt = be_type::narrow_from_decl (node->return_type ()); - if (this->void_return_type (bt)) - { - *os << be_uidt << be_uidt_nl; - } - else - { - *os << be_uidt << be_uidt << be_uidt_nl; - } + *os << be_uidt << be_uidt << be_uidt_nl; return 0; } -int -be_visitor_operation_thru_poa_proxy_impl_ss::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp index 08c28a0d6ee..ea3cc13e472 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, tie_sh, "$Id$") - +ACE_RCSID (be_visitor_operation, + tie_sh, + "$Id$") // ************************************************************ -// Operation visitor for server header for TIE class operations +// Operation visitor for server header for TIE class operations. // ************************************************************ -be_visitor_operation_tie_sh::be_visitor_operation_tie_sh (be_visitor_context *ctx) +be_visitor_operation_tie_sh::be_visitor_operation_tie_sh ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -44,16 +41,14 @@ be_visitor_operation_tie_sh::~be_visitor_operation_tie_sh (void) int be_visitor_operation_tie_sh::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + os->indent (); - os->indent (); // start with the current indentation level + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -63,32 +58,20 @@ be_visitor_operation_tie_sh::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_tie_sh::" - "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_operation_tie_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; - // STEP 2: generate the operation name + // STEP 2: generate the operation name. *os << " " << node->local_name (); // STEP 3: generate the argument list with the appropriate mapping. For these @@ -97,25 +80,16 @@ be_visitor_operation_tie_sh::visit_operation (be_operation *node) // we use the _CH state here because the _SH state produces pure virtual // methods. ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_tie_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_tie_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp b/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp index 2a53fe4a408..131fe85fbde 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp @@ -18,21 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, tie_si, "$Id$") - +ACE_RCSID (be_visitor_operation, + tie_si, + "$Id$") // ************************************************************ -// Operation visitor for server inline for TIE class operations +// Operation visitor for server inline for TIE class operations. // ************************************************************ -be_visitor_operation_tie_si::be_visitor_operation_tie_si -(be_visitor_context *ctx) +be_visitor_operation_tie_si::be_visitor_operation_tie_si ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -45,8 +41,7 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_interface *intf = - this->ctx_->interface (); + be_interface *intf = this->ctx_->interface (); if (!intf) { @@ -57,8 +52,9 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) -1); } - // retrieve the operation return type + // Retrieve the operation return type. be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -71,30 +67,19 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) os->indent (); *os << "template <class T> ACE_INLINE\n"; - // generate the return type mapping (same as in the header file) + // Generate the return type mapping (same as in the header file). be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_tie_si::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_tie_si::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; *os << " " << intf->full_skel_name () << "_tie<T>::" << node->local_name () << " "; @@ -103,31 +88,22 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_cs::" - "visit_operation - " - "Bad visitor for argument list\n"), - -1); - } + be_visitor_operation_arglist oao_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oao_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt_nl; - if (bt->node_type () != AST_Decl::NT_pre_defined - || be_predefined_type::narrow_from_decl (bt)->pt () != AST_PredefinedType::PT_void) + be_predefined_type *pdt = be_predefined_type::narrow_from_decl (bt); + + if (pdt == 0 || pdt->pt () != AST_PredefinedType::PT_void) { *os << "return "; } @@ -136,17 +112,17 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument ocau_visitor (&ctx); + + if (node->accept (&ocau_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for making upcall failed\n"), -1); } - // end the upcall + *os << be_uidt_nl; *os << ");" << be_uidt_nl; *os << "}\n\n"; diff --git a/TAO/TAO_IDL/be/be_visitor_root.cpp b/TAO/TAO_IDL/be/be_visitor_root.cpp index 6521d5d8535..f50ee1cb45e 100644 --- a/TAO/TAO_IDL/be/be_visitor_root.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root.cpp @@ -16,12 +16,39 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_constant.h" +#include "be_enum.h" +#include "be_exception.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_module.h" +#include "be_root.h" +#include "be_structure.h" +#include "be_structure_fwd.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_union_fwd.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_helper.h" +#include "be_extern.h" + #include "be_visitor_root.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_interface.h" +#include "be_visitor_interface_fwd.h" +#include "be_visitor_module.h" +#include "be_visitor_structure.h" +#include "be_visitor_structure_fwd.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" +#include "be_visitor_union_fwd.h" +#include "be_visitor_valuetype.h" +#include "be_visitor_valuetype_fwd.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_root/root.cpp" #include "be_visitor_root/root_ch.cpp" #include "be_visitor_root/root_ci.cpp" @@ -35,4 +62,6 @@ #include "be_visitor_root/any_op.cpp" #include "be_visitor_root/cdr_op.cpp" -ACE_RCSID(be, be_visitor_root, "$Id$") +ACE_RCSID (be, + be_visitor_root, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp b/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp index 9d31730b5c7..427dbbb8125 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, any_op, "$Id$") - +ACE_RCSID (be_visitor_root, + any_op, + "$Id$") // *************************************************************************** // Root visitor for generating Any operator declarations in the client header @@ -45,12 +40,13 @@ be_visitor_root_any_op::~be_visitor_root_any_op (void) int be_visitor_root_any_op::visit_root (be_root *node) { - // 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_root::visit_root - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_root/cdr_op.cpp b/TAO/TAO_IDL/be/be_visitor_root/cdr_op.cpp index 36f9214da42..ce1b5ad5c47 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/cdr_op.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/cdr_op.cpp @@ -19,14 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, cdr_op, "$Id$") - +ACE_RCSID (be_visitor_root, + cdr_op, + "$Id$") // *************************************************************************** // Root visitor for generating CDR operator declarations in the client header @@ -49,16 +44,15 @@ be_visitor_root_cdr_op::visit_root (be_root *node) if (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_CDR_OP_CH) { - *os << be_nl - << "#ifndef __ACE_INLINE__\n\n"; + *os << "#ifndef __ACE_INLINE__" << be_nl << be_nl; } - // 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_root_cdr_op::visit_root - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } if (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_CDR_OP_CH) diff --git a/TAO/TAO_IDL/be/be_visitor_root/root.cpp b/TAO/TAO_IDL/be/be_visitor_root/root.cpp index 2bea93a0734..68ee260a2ec 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root, "$Id$") - +ACE_RCSID (be_visitor_root, + root, + "$Id$") // Generic Root visitor be_visitor_root::be_visitor_root (be_visitor_context *ctx) @@ -37,31 +32,31 @@ be_visitor_root::~be_visitor_root (void) { } -// this method must be overridden by the derived root visitors +// This method must be overridden by the derived root visitors. int be_visitor_root::init (void) { return -1; } -// visit the Root node and its scope int be_visitor_root::visit_root (be_root *node) { - // open the appropriate output file based on what state we are in. The + // Open the appropriate output file based on what state we are in. The // overridden "init" method of derived classes will do the job. if (this->init () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::init - " - "failed to initialize context\n"), -1); + "failed to initialize context\n"), + -1); } - // 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_root::visit_root - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } // If we are generating the client header file, this is the place to @@ -70,16 +65,18 @@ int be_visitor_root::visit_root (be_root *node) if (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_CH) { TAO_OutStream *os = this->ctx_->stream (); - - size_t size = be_global->non_local_interfaces.size (); be_interface *i = 0; be_interface_fwd *ifwd = 0; size_t index = 0; + size_t size = be_global->non_local_interfaces.size (); + if (size > 0) { *os << "// Proxy Broker Factory function pointer declarations." - << be_nl << be_nl; + << be_nl; + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; } for (index = 0; index < size; ++index) @@ -98,112 +95,191 @@ int be_visitor_root::visit_root (be_root *node) size = be_global->non_defined_interfaces.size (); + if (size > 0) + { + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + } + for (index = 0; index < size; ++index) { be_global->non_defined_interfaces.dequeue_head (ifwd); - *os << "// External declarations for undefined interface" << be_nl - << "// " << ifwd->full_name () << be_nl; + if (ifwd->is_valuetype ()) + { + *os << "// External declarations for undefined valuetype" + << be_nl + << "// " << ifwd->full_name () << be_nl; + + *os << be_global->stub_export_macro () << be_nl + << "void" << be_nl + << "tao_" << ifwd->flat_name () + << "_add_ref (" + << be_idt << be_idt_nl + << ifwd->full_name () << " *" << be_uidt_nl + << ");" << be_uidt_nl + << be_global->stub_export_macro () << be_nl + << "void" << be_nl + << "tao_" << ifwd->flat_name () + << "_remove_ref (" << be_idt << be_idt_nl + << ifwd->full_name () << " *" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; + } + else + { + *os << "// External declarations for undefined interface" + << be_nl + << "// " << ifwd->full_name () << be_nl; + + *os << be_global->stub_export_macro () << be_nl + << ifwd->full_name () << "_ptr" << be_nl + << "tao_" << ifwd->flat_name () + << "_duplicate (" + << be_idt << be_idt_nl + << ifwd->full_name () << "_ptr" << be_uidt_nl + << ");" << be_uidt_nl + << be_global->stub_export_macro () << be_nl + << "void" << be_nl + << "tao_" << ifwd->flat_name () + << "_release (" << be_idt << be_idt_nl + << ifwd->full_name () << "_ptr" << be_uidt_nl + << ");" << be_uidt_nl + << be_global->stub_export_macro () << be_nl + << ifwd->full_name () << "_ptr" << be_nl + << "tao_" << ifwd->flat_name () + << "_nil (" << be_idt << be_idt_nl + << "void" << be_uidt_nl + << ");" << be_uidt_nl + << be_global->stub_export_macro () << be_nl + << ifwd->full_name () << "_ptr" << be_nl + << "tao_" << ifwd->flat_name () + << "_narrow (" << be_idt << be_idt_nl + << "CORBA::Object *" << be_nl + << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ");" << be_uidt_nl + << be_global->stub_export_macro () << be_nl + << "CORBA::Object *" << be_nl + << "tao_" << ifwd->flat_name () + << "_upcast (" << be_idt << be_idt_nl + << "void *" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; + } + } - *os << be_global->stub_export_macro () << be_nl - << ifwd->full_name () << "_ptr" << be_nl - << "tao_" << ifwd->flat_name () - << "_duplicate (" - << be_idt << be_idt_nl - << ifwd->full_name () << "_ptr" << be_uidt_nl - << ");" << be_uidt_nl - << be_global->stub_export_macro () << be_nl - << "void" << be_nl - << "tao_" << ifwd->flat_name () - << "_release (" << be_idt << be_idt_nl - << ifwd->full_name () << "_ptr" << be_uidt_nl - << ");" << be_uidt_nl - << be_global->stub_export_macro () << be_nl - << ifwd->full_name () << "_ptr" << be_nl - << "tao_" << ifwd->flat_name () - << "_nil (" << be_idt << be_idt_nl - << "void" << be_uidt_nl - << ");" << be_uidt_nl - << be_global->stub_export_macro () << be_nl - << ifwd->full_name () << "_ptr" << be_nl - << "tao_" << ifwd->flat_name () - << "_narrow (" << be_idt << be_idt_nl - << "CORBA::Object *" << be_nl - << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl - << ");" << be_uidt_nl - << be_global->stub_export_macro () << be_nl - << "CORBA::Object *" << be_nl - << "tao_" << ifwd->flat_name () - << "_upcast (" << be_idt << be_idt_nl - << "void *" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; + size = be_global->mixed_parentage_interfaces.size (); + + if (size > 0) + { + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Overrides of CORBA::release and CORBA::is_nil for" + << be_nl + << "// interfaces that inherit from both CORBA::Object" << be_nl + << "// and CORBA::AbstractBase." << be_nl << be_nl + << "TAO_NAMESPACE CORBA" << be_nl + << "{" << be_idt; + } + + for (index = 0; index < size; ++index) + { + be_global->mixed_parentage_interfaces.dequeue_head (i); + + *os << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS void release (" + << i->name () << "_ptr);" << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS CORBA::Boolean is_nil (" + << i->name () << "_ptr);"; + } + + if (size > 0) + { + *os << be_uidt_nl + << "}" << be_nl + << "TAO_NAMESPACE_CLOSE" << be_nl << be_nl; } } - be_visitor *visitor; be_visitor_context ctx (*this->ctx_); - // make one more pass over the entire tree and generate the OBV_ namespaces - // and OBV_ classes + // Make one more pass over the entire tree and generate the OBV_ namespaces + // and OBV_ classes. idl_bool obv = 0; + int status = 0; + switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - obv = 1; - ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CH); - break; + { + obv = 1; + ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CH); + be_visitor_obv_module visitor (&ctx); + status = visitor.visit_scope (node); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - obv = 1; - ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CI); - break; + { + obv = 1; + ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CI); + be_visitor_obv_module visitor (&ctx); + status = visitor.visit_scope (node); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - obv = 1; - ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CS); - break; + { + obv = 1; + ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CS); + be_visitor_obv_module visitor (&ctx); + status = visitor.visit_scope (node); + break; + } default: - break; + break; } - if (obv) - { - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "NUL visitor\n" - ), -1); - } - if (visitor->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "failed to generate OBV_ things\n" - ), -1); - } - delete visitor; + if (obv == 1 && status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root::" + "visit_root - " + "failed to generate OBV_ things\n"), + -1); } // The next thing we need to do is make one more pass thru the entire tree // and generate code for all the <<= and >>= operators for all the // user-defined types. - // - // XXXASG - this part of the code may be conditionally generated because at - // times it is not necessary to have these operators at all. TO-DO. ctx = *this->ctx_; + status = 0; + switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CH); + + if (be_global->any_support ()) + { + be_visitor_root_any_op visitor (&ctx); + status = node->accept (&visitor); + } + + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CS); + + if (be_global->any_support ()) + { + be_visitor_root_any_op visitor (&ctx); + status = node->accept (&visitor); + } + break; + } case TAO_CodeGen::TAO_ROOT_IH: (void) tao_cg->end_implementation_header ( be_global->be_get_implementation_hdr_fname (0) @@ -213,7 +289,6 @@ int be_visitor_root::visit_root (be_root *node) (void) tao_cg->end_server_header (); return 0; case TAO_CodeGen::TAO_ROOT_CI: - break; case TAO_CodeGen::TAO_ROOT_IS: break; case TAO_CodeGen::TAO_ROOT_SI: @@ -243,56 +318,48 @@ int be_visitor_root::visit_root (be_root *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - // *ASG* - this is a tempoaray hack soln so that our CDR operators get - // generated in the *.i file rather than the *.cpp file - if (this->ctx_->state () != TAO_CodeGen::TAO_ROOT_CI - && this->ctx_->state () != TAO_CodeGen::TAO_ROOT_IH - && this->ctx_->state () != TAO_CodeGen::TAO_ROOT_IS) + if (status == -1) { - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "NUL visitor\n" - ), -1); - } - - // generate the << and >> operators for all the user-defined - // data types in the outermost scope - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "failed to generate Any operators\n" - ), -1); - } - delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root::" + "visit_root - " + "failed to generate Any operators\n"), + -1); } - // make one more pass over the entire tree and generate the CDR << and >> - // operators for compiled marshaling. Again, this code can be conditionally - // generated if compiled marshaling is desired. + + // Make one more pass over the entire tree and generate the CDR operators. ctx = *this->ctx_; + status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CH); + be_visitor_root_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CI); + be_visitor_root_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CS); + be_visitor_root_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_IH: case TAO_CodeGen::TAO_ROOT_SI: @@ -305,32 +372,21 @@ int be_visitor_root::visit_root (be_root *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } - } visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "NUL visitor\n" - ), -1); - } - - // generate the << and >> operators for all the user-defined data types in - // the outermost scope - if (node->accept (visitor) == -1) + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_root - " - "failed to generate CDR operators\n" - ), -1); + "failed to generate CDR operators\n"), + -1); } - delete visitor; - // generate any final code such as #endifs + // Generate any final code such as #endifs. switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: @@ -342,29 +398,33 @@ int be_visitor_root::visit_root (be_root *node) return 0; } -// =all common visit methods for root visitor +// All common visit methods for root visitor. -// visit a constant int be_visitor_root::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: @@ -382,149 +442,173 @@ be_visitor_root::visit_constant (be_constant *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_constant - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_root::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; case TAO_CodeGen::TAO_ROOT_CI: case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + case TAO_CodeGen::TAO_ROOT_IH: return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_enum - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an exception int be_visitor_root::visit_exception (be_exception *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: @@ -536,31 +620,20 @@ be_visitor_root::visit_exception (be_exception *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_exception - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_exception - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_exception - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } @@ -568,14 +641,11 @@ be_visitor_root::visit_exception (be_exception *node) int be_visitor_root::visit_interface (be_interface *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 + // 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 + ctx.node (node); + int status = 1; switch (this->ctx_->state ()) { @@ -583,73 +653,135 @@ be_visitor_root::visit_interface (be_interface *node) ctx.state (TAO_CodeGen::TAO_INTERFACE_CH); break; case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CI); + be_visitor_interface_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CS); + be_visitor_interface_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_SH); + be_visitor_interface_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_IH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); + be_visitor_interface_ih visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_SI); + be_visitor_interface_si visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_SS); + be_visitor_interface_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_IS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); + be_visitor_interface_is visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH); + be_visitor_interface_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS); + be_visitor_interface_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH); + be_visitor_interface_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI); + be_visitor_interface_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS); + be_visitor_interface_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } + if (status == 0) + { + return 0; + } + else if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root::" + "visit_interface - " + "failed to accept visitor\n"), + -1); + } + // Change the state depending on the kind of node strategy ctx.state (node->next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; @@ -662,24 +794,25 @@ be_visitor_root::visit_interface (be_interface *node) ctx.state (node->next_state (ctx.state (), 1)); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } @@ -687,39 +820,53 @@ be_visitor_root::visit_interface (be_interface *node) return 0; } -// visit an interface_fwd int be_visitor_root::visit_interface_fwd (be_interface_fwd *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); + be_visitor_interface_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); + be_visitor_interface_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); + be_visitor_interface_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); + be_visitor_interface_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); + be_visitor_interface_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: case TAO_CodeGen::TAO_ROOT_CS: case TAO_CodeGen::TAO_ROOT_SH: @@ -733,173 +880,176 @@ be_visitor_root::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface_fwd - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface_fwd - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_interface_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit a valuetype int be_visitor_root::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CH); + be_visitor_valuetype_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CI); + be_visitor_valuetype_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CS); + be_visitor_valuetype_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH); + be_visitor_valuetype_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI); + be_visitor_valuetype_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS); + be_visitor_valuetype_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH); + be_visitor_valuetype_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS); + be_visitor_valuetype_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_IH: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SH); + be_visitor_valuetype_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SI: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SI); + be_visitor_valuetype_si visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SS: + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_SS); + be_visitor_valuetype_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_IH: case TAO_CodeGen::TAO_ROOT_IS: case TAO_CodeGen::TAO_ROOT_TIE_SH: - return 0; // nothing to do, resp. not yet impl. + return 0; // nothing to do. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - // Change the state depending on the kind of node strategy - ctx.state (node->next_state (ctx.state ())); - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_valuetype - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - delete visitor; - visitor = 0; - - // Do addtional "extra" code generation if necessary - if (node->has_extra_code_generation (ctx.state ())) - { - // Change the state depending on the kind of node strategy - ctx.state (node->next_state (ctx.state (), 1)); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "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_root::" - "visit_valuetype - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - visitor = 0; - } return 0; } -// visit an valuetype_fwd int be_visitor_root::visit_valuetype_fwd (be_valuetype_fwd *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); + be_visitor_valuetype_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); + be_visitor_valuetype_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); + be_visitor_valuetype_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); + be_visitor_valuetype_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: @@ -909,357 +1059,540 @@ be_visitor_root::visit_valuetype_fwd (be_valuetype_fwd *node) case TAO_CodeGen::TAO_ROOT_SS: case TAO_CodeGen::TAO_ROOT_IS: case TAO_CodeGen::TAO_ROOT_IH: - return 0; // nothing to be done + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype_fwd - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype_fwd - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_valuetype_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit a module int be_visitor_root::visit_module (be_module *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CH); + be_visitor_module_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_MODULE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CI); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CS); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: - ctx.state (TAO_CodeGen::TAO_MODULE_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_SH); + be_visitor_module_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SI: - ctx.state (TAO_CodeGen::TAO_MODULE_SI); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_SI); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SS: - ctx.state (TAO_CodeGen::TAO_MODULE_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_SS); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_IS: - ctx.state (TAO_CodeGen::TAO_MODULE_IS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_IS); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_IH: - ctx.state (TAO_CodeGen::TAO_MODULE_IH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_IH); + be_visitor_module_ih visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CH); + be_visitor_module_any_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CS); + be_visitor_module_any_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CH); + be_visitor_module_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CI); + be_visitor_module_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CS); + be_visitor_module_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_module - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_module - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_module - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an structure int be_visitor_root::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + case TAO_CodeGen::TAO_ROOT_IH: return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_root::visit_structure_fwd (be_structure_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_ROOT_CH: + { + ctx.state (TAO_CodeGen::TAO_STRUCT_FWD_CH); + be_visitor_structure_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_CI: + case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: + case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: + case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: + case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: + case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: + case TAO_CodeGen::TAO_ROOT_CS: + case TAO_CodeGen::TAO_ROOT_SH: + case TAO_CodeGen::TAO_ROOT_SI: + case TAO_CodeGen::TAO_ROOT_SS: + case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root::" + "visit_structure_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); + "visit_structure_fwd - " + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit an union int be_visitor_root::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + case TAO_CodeGen::TAO_ROOT_IH: return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_root::visit_union_fwd (be_union_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_ROOT_CH: + { + ctx.state (TAO_CodeGen::TAO_UNION_FWD_CH); + be_visitor_union_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_CI: + case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: + case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: + case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: + case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: + case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: + case TAO_CodeGen::TAO_ROOT_CS: + case TAO_CodeGen::TAO_ROOT_SH: + case TAO_CodeGen::TAO_ROOT_SI: + case TAO_CodeGen::TAO_ROOT_SS: + case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root::" + "visit_union_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" - "visit_union - " - "failed to accept visitor\n" - ), -1); + "visit_interface_fwd - " + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit an typedef int be_visitor_root::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + case TAO_CodeGen::TAO_ROOT_IH: return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_typedef - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_typedef - " - "NUL visitor\n" - ), -1); + "failed to accept visitor"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_typedef - " - "failed to accept visitor" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp index fd9bb00d90e..ff7dba28e3a 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ch, "$Id$") - +ACE_RCSID (be_visitor_root, + root_ch, + "$Id$") // ******************************** // Root visitor for client header @@ -47,10 +42,10 @@ be_visitor_root_ch::init (void) if (tao_cg->start_client_header (be_global->be_get_client_hdr_fname ()) == -1) { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_visitor_root_ch::init - " - "Error opening client header file\n")); - return -1; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root_ch::init - " + "Error opening client header file\n"), + -1); } // Initialize the stream. diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ci.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ci.cpp index a7c9d9e60db..4a6001866d6 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_ci.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ci, "$Id$") - +ACE_RCSID (be_visitor_root, + root_ci, + "$Id$") // ********************************* // Root visitor for client inline @@ -47,10 +42,10 @@ be_visitor_root_ci::init (void) if (tao_cg->start_client_inline (be_global->be_get_client_inline_fname ()) == -1) { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_visitor_root_ci - " - "Error opening client inline file\n")); - return -1; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root_ci - " + "Error opening client inline file\n"), + -1); } this->ctx_->stream (tao_cg->client_inline ()); diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_cs.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_cs.cpp index aea6f39d996..2fcc8acd791 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_cs, "$Id$") - +ACE_RCSID (be_visitor_root, + root_cs, + "$Id$") // *********************************** // Root visitor for client stubs @@ -49,7 +44,8 @@ be_visitor_root_cs::init (void) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root_cs - " - "Error opening client stub file\n"), -1); + "Error opening client stub file\n"), + -1); } // init stream diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ih.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ih.cpp index e913ee653b6..5ff8eea3403 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ih.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_ih.cpp @@ -16,14 +16,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ih, "$Id$") - +ACE_RCSID (be_visitor_root, + root_ih, + "$Id$") // *********************************** // Root visitor for implementation header @@ -41,7 +36,6 @@ be_visitor_root_ih::~be_visitor_root_ih (void) int be_visitor_root_ih::init (void) { - // open the file if (tao_cg->start_implementation_header ( be_global->be_get_implementation_hdr_fname () ) @@ -56,7 +50,6 @@ be_visitor_root_ih::init (void) } - // set the stream and the next state this->ctx_->stream (tao_cg->implementation_header ()); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_is.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_is.cpp index c6b1aeab137..82f3fe275c2 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_is.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_is.cpp @@ -1,3 +1,6 @@ +// +// $Id$ +// // ============================================================================ // // = LIBRARY @@ -14,14 +17,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -//ACE_RCSID(be_visitor_root, root_ss, "$Id$") - +ACE_RCSID (be_visitor_root, + root_is, + "$Id$") // ****************************************************** // Root visitor for implementation skeletons @@ -39,7 +37,7 @@ be_visitor_root_is::~be_visitor_root_is (void) int be_visitor_root_is::init (void) { - // first open the file for writing + // First open the file for writing. if (tao_cg->start_implementation_skeleton ( be_global->be_get_implementation_skel_fname () ) @@ -47,10 +45,10 @@ be_visitor_root_is::init (void) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root_is::init - " - "Error opening implementation skeletons file\n"), -1); + "Error opening implementation skeletons file\n"), + -1); } - // set stream this->ctx_->stream (tao_cg->implementation_skeleton ()); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp index 3443aa6fac7..affeb35db6c 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_sh, "$Id$") - +ACE_RCSID (be_visitor_root, + root_sh, + "$Id$") // *********************************** // Root visitor for server header diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_si.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_si.cpp index dedd3512e93..77cd9ceb807 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_si.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_si, "$Id$") - +ACE_RCSID (be_visitor_root, + root_si, + "$Id$") // *********************************************** // Root visitor for server inline @@ -49,7 +44,8 @@ be_visitor_root_si::init (void) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root_si::init - " - "server inline open failed\n"), -1); + "server inline open failed\n"), + -1); } if (be_global->gen_tie_classes ()) diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ss.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ss.cpp index c661b0ffea1..fcaf4307fac 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_ss.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ss, "$Id$") - +ACE_RCSID (be_visitor_root, + root_ss, + "$Id$") // ****************************************************** // Root visitor for server skeletons @@ -51,7 +46,8 @@ be_visitor_root_ss::init (void) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root_ss::init - " - "Error opening server skeletons file\n"), -1); + "Error opening server skeletons file\n"), + -1); } if (be_global->gen_tie_classes ()) diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp index a15e855d3c9..979e52c743b 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp @@ -18,15 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_root, root_sth, "$Id$") - +ACE_RCSID (be_visitor_root, + root_sth, + "$Id$") // **************************************** // Root visitor for server template header @@ -168,7 +162,7 @@ be_visitor_root_sth::visit_module (be_module *node) if (!node->is_nested ()) { - *os << "#endif /* ACE_HAS_USING_KEYWORD */\n"; + *os << "#endif /* ACE_HAS_USING_KEYWORD */\n\n"; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_scope.cpp b/TAO/TAO_IDL/be/be_visitor_scope.cpp index e2cc13b8793..1b473fa8395 100644 --- a/TAO/TAO_IDL/be/be_visitor_scope.cpp +++ b/TAO/TAO_IDL/be/be_visitor_scope.cpp @@ -19,13 +19,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_argument.h" +#include "be_scope.h" #include "be_visitor_scope.h" +#include "be_visitor_context.h" -ACE_RCSID(be, be_visitor_scope, "$Id$") - +ACE_RCSID (be, + be_visitor_scope, + "$Id$") // ****************************************************** // Generic visitor for a scope. diff --git a/TAO/TAO_IDL/be/be_visitor_sequence.cpp b/TAO/TAO_IDL/be/be_visitor_sequence.cpp index 8bb155d0cd5..c13e473c54a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence.cpp @@ -16,12 +16,30 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_array.h" +#include "be_enum.h" +#include "be_exception.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_predefined_type.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_structure_fwd.h" +#include "be_union.h" +#include "be_union_fwd.h" +#include "be_type.h" +#include "be_typedef.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_helper.h" +#include "be_extern.h" +#include "utl_identifier.h" +#include "nr_extern.h" + #include "be_visitor_sequence.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_sequence/any_op_ch.cpp" #include "be_visitor_sequence/any_op_cs.cpp" #include "be_visitor_sequence/cdr_op_ch.cpp" @@ -52,4 +70,6 @@ #include "be_visitor_sequence/gen_bounded_str_sequence_cs.cpp" #include "be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp" -ACE_RCSID(be, be_visitor_sequence, "$Id$") +ACE_RCSID (be, + be_visitor_sequence, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp index 438370d76c5..20dfd17d723 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + any_op_ch, + "$Id$") // *************************************************************************** // Sequence visitor for generating Any operator declarations in the client header @@ -52,7 +48,7 @@ be_visitor_sequence_any_op_ch::visit_sequence (be_sequence *node) TAO_OutStream *os = this->ctx_->stream (); - // generate the Any <<= and >>= operators + // Generate the Any <<= and >>= operators. os->indent (); *os << be_global->stub_export_macro (); *os << " void" diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp index 4aa81ac77de..36a77410f5a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_sequence, + any_op_cs, + "$Id$") // *************************************************************************** // Sequence visitor for generating Any operator declarations in the client diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/buffer_type.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/buffer_type.cpp index ae3536245da..03c5ebe2613 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/buffer_type.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/buffer_type.cpp @@ -18,21 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, buffer_type, "$Id$") - +ACE_RCSID (be_visitor_sequence, + buffer_type, + "$Id$") // **************************************************************** // We have to generate the buffer type in the constructor // **************************************************************** -be_visitor_sequence_buffer_type:: -be_visitor_sequence_buffer_type (be_visitor_context *ctx) +be_visitor_sequence_buffer_type::be_visitor_sequence_buffer_type ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -49,14 +45,23 @@ be_visitor_sequence_buffer_type::visit_node (be_type *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } + return 0; } @@ -64,10 +69,18 @@ int be_visitor_sequence_buffer_type::visit_predefined_type (be_predefined_type *node) { TAO_OutStream *os = this->ctx_->stream (); - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << node->name () << "_ptr"; + AST_PredefinedType::PredefinedType pt = node->pt (); + + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) + { + *os << node->name () << "_ptr"; + } else - *os << node->name (); + { + *os << node->name (); + } + return 0; } @@ -81,10 +94,16 @@ int be_visitor_sequence_buffer_type::visit_interface (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); + if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH) - *os << node->nested_type_name (this->ctx_->scope (), "_ptr"); + { + *os << node->nested_type_name (this->ctx_->scope (), "_ptr"); + } else - *os << node->name () << "_ptr"; + { + *os << node->name () << "_ptr"; + } + return 0; } @@ -92,10 +111,16 @@ int be_visitor_sequence_buffer_type::visit_interface_fwd (be_interface_fwd *node) { TAO_OutStream *os = this->ctx_->stream (); + if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH) - *os << node->nested_type_name (this->ctx_->scope (), "_ptr"); + { + *os << node->nested_type_name (this->ctx_->scope (), "_ptr"); + } else - *os << node->name () << "_ptr"; + { + *os << node->name () << "_ptr"; + } + return 0; } @@ -135,12 +160,24 @@ be_visitor_sequence_buffer_type::visit_structure (be_structure *node) } int +be_visitor_sequence_buffer_type::visit_structure_fwd (be_structure_fwd *node) +{ + return this->visit_node (node); +} + +int be_visitor_sequence_buffer_type::visit_union (be_union *node) { return this->visit_node (node); } int +be_visitor_sequence_buffer_type::visit_union_fwd (be_union_fwd *node) +{ + return this->visit_node (node); +} + +int be_visitor_sequence_buffer_type::visit_enum (be_enum *node) { return this->visit_node (node); @@ -161,7 +198,8 @@ be_visitor_sequence_buffer_type::visit_array (be_array *node) int be_visitor_sequence_buffer_type::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // set the alias node + this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -170,6 +208,7 @@ be_visitor_sequence_buffer_type::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp index 32c29cc8b76..4c860142bf7 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_sequence, + cdr_op_ch, + "$Id$") // *************************************************************************** // Sequence visitor for generating CDR operator declarations in the client header // *************************************************************************** -be_visitor_sequence_cdr_op_ch::be_visitor_sequence_cdr_op_ch -(be_visitor_context *ctx) +be_visitor_sequence_cdr_op_ch::be_visitor_sequence_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -44,15 +41,15 @@ be_visitor_sequence_cdr_op_ch::~be_visitor_sequence_cdr_op_ch (void) int be_visitor_sequence_cdr_op_ch::visit_sequence (be_sequence *node) { - if (node->cli_hdr_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_hdr_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); - // generate the CDR << and >> operator declarations - be_type *bt = be_type::narrow_from_decl (node); be_typedef *tdef = be_typedef::narrow_from_decl (bt); diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ci.cpp index cff75285ad5..bc92dc2684a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ci.cpp @@ -19,22 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, cdr_op_ci, "$Id$") - +ACE_RCSID (be_visitor_sequence, + cdr_op_ci, + "$Id$") // *************************************************************************** // Sequence visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_sequence_cdr_op_ci::be_visitor_sequence_cdr_op_ci -(be_visitor_context *ctx) +be_visitor_sequence_cdr_op_ci::be_visitor_sequence_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -46,10 +42,12 @@ be_visitor_sequence_cdr_op_ci::~be_visitor_sequence_cdr_op_ci (void) int be_visitor_sequence_cdr_op_ci::visit_sequence (be_sequence *node) { - if (node->cli_inline_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_inline_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp index 22cb2f8d323..0b25d0c741c 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp @@ -19,21 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, cdr_op_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + cdr_op_cs, + "$Id$") // *************************************************************************** // Sequence visitor for generating CDR operator declarations in the client -// stubs file +// stubs file. // *************************************************************************** -be_visitor_sequence_cdr_op_cs::be_visitor_sequence_cdr_op_cs -(be_visitor_context *ctx) +be_visitor_sequence_cdr_op_cs::be_visitor_sequence_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -47,7 +44,7 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) { if (this->ctx_->alias ()) { - // we are here because the base type of the sequence node is + // We are here because the base type of the sequence node is // itself a sequence i.e., this is a case of sequence of // typedef'd sequence. For the case of sequence of // anonymous sequence, see comment below. @@ -55,15 +52,18 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) } else { - if (node->cli_stub_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_stub_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); be_type *bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -78,9 +78,13 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS) - == -1) + int status = + this->gen_anonymous_base_type ( + bt, + TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_array_cdr_op_cs::" @@ -90,21 +94,25 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) } } - // generate the CDR << and >> operator defns + // Generate the CDR << and >> operator defns. - // save the sequence node for further use + // Save the sequence node for further use. this->ctx_->node (node); + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // If we're an anonymous sequence, we must protect against // being declared more than once. if (!this->ctx_->tdef ()) { - *os << "\n#if !defined _TAO_CDR_OP_" + *os << "#if !defined _TAO_CDR_OP_" << node->flat_name () << "_CPP_" << be_nl - << "#define _TAO_CDR_OP_" << node->flat_name () << "_CPP_\n\n"; + << "#define _TAO_CDR_OP_" << node->flat_name () << "_CPP_" + << be_nl << be_nl; } - // set the sub state as generating code for the output operator + // Set the sub state as generating code for the output operator. this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); *os << "CORBA::Boolean operator<< (" << be_idt << be_idt_nl << "TAO_OutputCDR &strm," << be_nl @@ -113,11 +121,13 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) << ")" << be_uidt_nl << "{" << be_idt_nl; - // first encode the sequence length - *os << "if (strm << _tao_sequence.length ())" << be_nl + // First encode the sequence length. + *os << "CORBA::ULong _tao_seq_len = _tao_sequence.length ();" + << be_nl << be_nl; + *os << "if (strm << _tao_seq_len)" << be_idt_nl << "{" << be_idt_nl; - // now encode the sequence elements - *os << "// encode all elements" << be_nl; + // Now encode the sequence elements. + *os << "// Encode all elements." << be_nl; if (bt->node_type () == AST_Decl::NT_sequence) { @@ -135,35 +145,28 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) } } - *os << "}" << be_nl - << "return 0; // error" << be_uidt_nl - << "}\n\n"; + *os << "}" << be_uidt_nl << be_nl + << "return 0;" << be_uidt_nl + << "}" << be_nl << be_nl; - // set the sub state as generating code for the input operator + // Set the sub state as generating code for the input operator. os->indent (); this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); + *os << "CORBA::Boolean operator>> (" << be_idt << be_idt_nl << "TAO_InputCDR &strm," << be_nl << node->name () << " &_tao_sequence" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl; - // first retrieve the length and adjust the sequence length accordingly - *os << "CORBA::ULong _tao_seq_len;" << be_nl; - *os << "if (strm >> _tao_seq_len)" << be_nl + // First retrieve the length and adjust the sequence length accordingly. + *os << "CORBA::ULong _tao_seq_len;" << be_nl << be_nl; + *os << "if (strm >> _tao_seq_len)" << be_idt_nl << "{" << be_idt_nl; - - // Add a sanity check for the length of a sequence. - *os << "// Add a check to the length of the sequence" << be_nl; - *os << "// to make sure it does not exceed the length" << be_nl; - *os << "// of the stream. (See bug 1159.)" << be_nl; - *os << "if (_tao_seq_len > strm.length())" << be_idt_nl; - *os << "return 0;" << be_uidt_nl; - - // now check if the length does not exceed the maximum. We do this only + // Now check if the length does not exceed the maximum. We do this only // for bounded sequences AST_Expression *expr = node->max_size (); - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) + + if (expr == 0 || (expr != 0 && expr->ev () == 0)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -176,8 +179,8 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) { if (expr->ev ()->u.ulval > 0) { - // we are dealing with a bounded sequence. Check if we are within - // bounds + // We are dealing with a bounded sequence. Check if we are within + // bounds. *os << "if (_tao_seq_len <= _tao_sequence.maximum ())" << be_nl << "{" << be_idt_nl; } @@ -191,17 +194,26 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) -1); } - *os << "// set the length of the sequence" << be_nl - << "_tao_sequence.length (_tao_seq_len);" << be_nl; + *os << "// Set the length of the sequence." << be_nl + << "_tao_sequence.length (_tao_seq_len);" << be_nl << be_nl; // Now we do a check for the sequence length to be non zero. - // If length is 0 we return true. + // If length is 0 we return true. *os << "// If length is 0 we return true." << be_nl; - *os << "if (0 >= _tao_seq_len) " << be_idt_nl; - *os << "return 1;" << be_uidt_nl; - + *os << "if (0 >= _tao_seq_len) " << be_idt_nl + << "{" << be_idt_nl; + *os << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + // Add a sanity check for the length of a sequence. + *os << "// Add a check to the length of the sequence" << be_nl; + *os << "// to make sure it does not exceed the length" << be_nl; + *os << "// of the stream. (See bug 58.)" << be_nl; + *os << "if (_tao_seq_len > strm.length ())" << be_idt_nl + << "{" << be_idt_nl; + *os << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; - *os << "// retrieve all the elements" << be_nl; + *os << "// Retrieve all the elements." << be_nl; if (bt->node_type () == AST_Decl::NT_sequence) @@ -222,12 +234,13 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) if (expr->ev ()->u.ulval > 0) { - // we are dealing with a bounded sequence. - *os << "}" << be_uidt_nl; + // We are dealing with a bounded sequence. + *os << "}" << be_uidt << be_uidt_nl; } - *os << "}" << be_nl - << "return 0; // error" << be_uidt_nl - << "}\n\n"; + + *os << "}" << be_uidt_nl << be_nl + << "return 0;" << be_uidt_nl + << "}" << be_nl << be_nl; if (!this->ctx_->tdef ()) { @@ -238,11 +251,10 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) node->cli_stub_cdr_op_gen (1); } + return 0; } -// handle all the base types - int be_visitor_sequence_cdr_op_cs::visit_array (be_array *node) { @@ -280,35 +292,34 @@ be_visitor_sequence_cdr_op_cs::visit_valuetype_fwd (be_valuetype_fwd *node) } int -be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) +be_visitor_sequence_cdr_op_cs::visit_predefined_type ( + be_predefined_type *node + ) { TAO_OutStream *os = this->ctx_->stream (); switch (node->pt ()) { + case AST_PredefinedType::PT_object: 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_sequence_cdr_op_cs::" "visit_predefined_type - " - "Bad primitive type\n" - ), -1); + "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 sequence is a + // We get here if the "type" of individual elements of the sequence is a // primitive type. In this case, we treat the sequence as a single // dimensional sequence (even of it was multi-dimensional), and pass // the total length of the sequence as a cross product of the - // dimensions + // dimensions. - // grab the sequence node be_sequence *sequence = this->ctx_->be_node_as_sequence (); if (!sequence) @@ -320,12 +331,13 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -1); } - // handle octet sequences using the optimizations provided by the TAO ORB - // Core. If these optimizations are not available, then use the normal form + // Handle octet sequences using the optimizations provided by the TAO ORB + // Core. If these optimizations are not available, then use the normal form. if (node->pt () == AST_PredefinedType::PT_octet && sequence->unbounded ()) { *os << "\n#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)" << be_nl; + switch (this->ctx_->sub_state ()) { case TAO_CodeGen::TAO_CDR_INPUT: @@ -376,12 +388,14 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) "bad sub state\n"), -1); } + *os << "\n#else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */" << be_nl; } *os << "return strm."; - // based on our substate, we may be reading from a stream or writing into a - // stream + + // 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: @@ -398,7 +412,7 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -1); } - // determine what kind of sequence are we reading/writing + // Determine what kind of sequence are we reading/writing. switch (node->pt ()) { case AST_PredefinedType::PT_long: @@ -449,7 +463,7 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -1); } - // handle special case to avoid compiler errors + // Handle special case to avoid compiler errors. switch (node->pt ()) { case AST_PredefinedType::PT_char: @@ -478,7 +492,10 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) *os << "_tao_sequence.length ());" << be_uidt_nl; if (node->pt () == AST_PredefinedType::PT_octet && sequence->unbounded ()) - *os << "\n#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */" << be_nl; + { + *os << "\n#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */" << be_nl; + } + return 0; } @@ -503,35 +520,28 @@ be_visitor_sequence_cdr_op_cs::visit_union (be_union *node) int be_visitor_sequence_cdr_op_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 + this->ctx_->alias (node); be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// helper int be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) { TAO_OutStream *os = this->ctx_->stream (); be_sequence *node = this->ctx_->be_node_as_sequence (); - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!node) { ACE_ERROR_RETURN ((LM_ERROR, @@ -541,16 +551,20 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) -1); } - // initialize a boolean variable - *os << "CORBA::Boolean _tao_marshal_flag = 1;" << be_nl; + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); + be_visitor_sequence_base visitor (&ctx); - // we get here if the "type" of individual elements of the sequence is not a - // primitive type. In this case, we are left with no other alternative but to - // encode/decode element by element + // Initialize a boolean variable. + *os << "CORBA::Boolean _tao_marshal_flag = 1;" << be_nl << be_nl; + + // We get here if the "type" of individual elements of the sequence is not a + // primitive type. In this case, we are left with no other alternative but + // to encode/decode element by element. AST_Expression *expr = node->max_size (); - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) + + if (expr == 0 || (expr != 0 && expr->ev () == 0)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -558,11 +572,12 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) "bad sequence dimension\n"), -1); } + if (expr->ev ()->et == AST_Expression::EV_ulong) { - *os << "for (CORBA::ULong i = 0; i < _tao_sequence.length ()" + *os << "for (CORBA::ULong i = 0; i < _tao_seq_len" << " && _tao_marshal_flag; " - << "i++)" << be_nl + << "++i)" << be_idt_nl << "{" << be_idt_nl; } else @@ -574,9 +589,9 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) -1); } - // if the type was a string, an obj ref, or a pseudo-obj, we are dealing with - // a manager type and hence we must use the appropriate in () and out () - // methods. + // If the type was a string, an obj ref, or a pseudo-obj, we are dealing + // with a manager type and hence we must use the appropriate in() and + // out() methods. // switch (this->ctx_->sub_state ()) @@ -585,7 +600,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) switch (bt->node_type ()) { case AST_Decl::NT_array: - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -596,7 +611,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_forany tmp ("; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -608,7 +623,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_alloc ());" << be_nl; *os << "_tao_marshal_flag = (strm >> tmp);" << be_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -619,7 +634,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_copy (_tao_sequence[i], tmp.in ());" << be_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -629,6 +644,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) } *os << "_free (tmp.inout ());" << be_uidt_nl; + break; case AST_Decl::NT_string: case AST_Decl::NT_wstring: @@ -643,9 +659,10 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) "bad string node\n"), -1); } + if (str->max_size ()->ev ()->u.ulval == 0) { - // unbounded + // Unbounded. *os << "_tao_marshal_flag = (strm >> _tao_sequence[i].out ());" << be_uidt_nl; } @@ -661,19 +678,27 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_tao_marshal_flag = (strm >> " << "CORBA::Any::to_wstring (_tao_sequence[i].out (), "; } - *os << str->max_size ()->ev ()->u.ulval << "));" << be_uidt_nl; + + *os << str->max_size ()->ev ()->u.ulval << "));" + << be_uidt_nl; } } break; case AST_Decl::NT_interface: case AST_Decl::NT_interface_fwd: - *os << "_tao_marshal_flag = (strm >> _tao_sequence[i].out ());" << be_uidt_nl; + case AST_Decl::NT_valuetype: + case AST_Decl::NT_valuetype_fwd: + *os << "_tao_marshal_flag = (strm >> _tao_sequence[i].out ());" + << be_uidt_nl; + 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); + // 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, @@ -683,28 +708,37 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) -1); } - if (pt->pt () == AST_PredefinedType::PT_pseudo) + AST_PredefinedType::PredefinedType pdt = pt->pt (); + + if (pdt == AST_PredefinedType::PT_pseudo + || pdt == AST_PredefinedType::PT_object) { *os << "_tao_marshal_flag = (strm >> _tao_sequence[i].out ());" << be_uidt_nl; } else { - *os << "_tao_marshal_flag = (strm >> _tao_sequence[i]);" << be_uidt_nl; + *os << "_tao_marshal_flag = (strm >> _tao_sequence[i]);" + << be_uidt_nl; } } + break; default: - *os << "_tao_marshal_flag = (strm >> _tao_sequence[i]);" << be_uidt_nl; + *os << "_tao_marshal_flag = (strm >> _tao_sequence[i]);" + << be_uidt_nl; + break; } + *os << "}"; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: switch (bt->node_type ()) { case AST_Decl::NT_array: - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -715,7 +749,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_var tmp_var (" << be_idt << be_idt_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -730,21 +764,27 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) // function signature, MSVC++ 5.0 needs the const cast, // and many other compilers just won't do it. *os << "#if defined (_MSC_VER) && (_MSC_VER <= 1100)"; + os->indent (); + *os << be_idt << be_idt_nl; *os << "ACE_const_cast (const " << this->ctx_->node ()->name () << ", _tao_sequence)[i]\n"; *os << "#else"; + os->indent (); + *os << be_nl; *os << "_tao_sequence[i]\n"; *os << "#endif /* defined (_MSC_VER) && (_MSC_VER <= 1100) */"; + os->indent (); + *os << be_uidt_nl; *os << ")" << be_uidt << be_uidt_nl; *os << ");" << be_uidt_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -755,16 +795,22 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_forany tmp (tmp_var.inout ());" << be_nl; *os << "_tao_marshal_flag = (strm << tmp"; + break; case AST_Decl::NT_string: case AST_Decl::NT_wstring: case AST_Decl::NT_interface: case AST_Decl::NT_interface_fwd: + case AST_Decl::NT_valuetype: + case AST_Decl::NT_valuetype_fwd: *os << "_tao_marshal_flag = (strm << _tao_sequence[i].in ()"; + break; case AST_Decl::NT_pre_defined: { - be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); + be_predefined_type *pt = + be_predefined_type::narrow_from_decl (bt); + if (!pt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -774,7 +820,10 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) -1); } - if (pt->pt () == AST_PredefinedType::PT_pseudo) + AST_PredefinedType::PredefinedType pdt = pt->pt (); + + if (pdt == AST_PredefinedType::PT_pseudo + || pdt == AST_PredefinedType::PT_object) { *os << "_tao_marshal_flag = (strm << _tao_sequence[i].in ()"; } @@ -783,13 +832,17 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_tao_marshal_flag = (strm << _tao_sequence[i]"; } } + break; default: *os << "_tao_marshal_flag = (strm << _tao_sequence[i]"; + break; } + *os << ");" << be_uidt_nl << "}"; + break; default: ACE_ERROR_RETURN ((LM_ERROR, @@ -799,9 +852,8 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) -1); } - *os << be_nl; + *os << be_uidt_nl<< be_nl; *os << "return _tao_marshal_flag;" << be_uidt_nl; - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp index 1232a499956..6ef79bbb44e 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, elemtype, "$Id$") - +ACE_RCSID (be_visitor_sequence, + elemtype, + "$Id$") // *********************************************************** // sequence element type visitor for return types of [] methods // *********************************************************** -be_visitor_sequence_elemtype:: -be_visitor_sequence_elemtype (be_visitor_context *ctx) +be_visitor_sequence_elemtype::be_visitor_sequence_elemtype ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -50,14 +46,23 @@ be_visitor_sequence_elemtype::visit_node (be_type *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()) << " &"; + { + *os << bt->nested_type_name (this->ctx_->scope ()) << " &"; + } else - *os << bt->name () << " &"; + { + *os << bt->name () << " &"; + } + return 0; } @@ -68,25 +73,36 @@ be_visitor_sequence_elemtype::visit_predefined_type (be_predefined_type *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: { int is_pseudo_object = ACE_OS::strcmp (node->local_name ()->get_string (), "Object") != 0; + if (is_pseudo_object) { *os << "TAO_Pseudo_Object_Manager<"; } + else if (node->is_abstract ()) + { + *os << "TAO_Abstract_Manager<"; + } else { *os << "TAO_Object_Manager<"; } + if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) { *os << bt->nested_type_name (this->ctx_->scope ()) << ","; @@ -101,10 +117,15 @@ be_visitor_sequence_elemtype::visit_predefined_type (be_predefined_type *node) break; default: if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()) << " &"; + { + *os << bt->nested_type_name (this->ctx_->scope ()) << " &"; + } else - *os << bt->name () << " &"; + { + *os << bt->name () << " &"; + } } + return 0; } @@ -121,19 +142,39 @@ be_visitor_sequence_elemtype::visit_interface (be_interface *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) { - *os << "TAO_Object_Manager<"; + if (node->is_abstract ()) + { + *os << "TAO_Abstract_Manager<"; + } + else + { + *os << "TAO_Object_Manager<"; + } + *os << bt->nested_type_name (this->ctx_->scope ()) << ", "; *os << bt->nested_type_name (this->ctx_->scope (), "_var") << ">"; } else { - *os << "TAO_Object_Manager<"; + if (node->is_abstract ()) + { + *os << "TAO_Abstract_Manager<"; + } + else + { + *os << "TAO_Object_Manager<"; + } + *os << bt->name () << ", "; *os << bt->name () << "_var>"; } @@ -148,9 +189,13 @@ be_visitor_sequence_elemtype::visit_valuetype (be_valuetype *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) { @@ -175,9 +220,13 @@ be_visitor_sequence_elemtype::visit_interface_fwd (be_interface_fwd *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) { @@ -202,9 +251,13 @@ be_visitor_sequence_elemtype::visit_valuetype_fwd (be_valuetype_fwd *node) be_type *bt; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) { @@ -246,12 +299,24 @@ be_visitor_sequence_elemtype::visit_structure (be_structure *node) } int +be_visitor_sequence_elemtype::visit_structure_fwd (be_structure_fwd *node) +{ + return this->visit_node (node); +} + +int be_visitor_sequence_elemtype::visit_union (be_union *node) { return this->visit_node (node); } int +be_visitor_sequence_elemtype::visit_union_fwd (be_union_fwd *node) +{ + return this->visit_node (node); +} + +int be_visitor_sequence_elemtype::visit_enum (be_enum *node) { return this->visit_node (node); @@ -273,6 +338,7 @@ int be_visitor_sequence_elemtype::visit_typedef (be_typedef *node) { this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -281,6 +347,7 @@ be_visitor_sequence_elemtype::visit_typedef (be_typedef *node) "accept on primitive type failed\n"), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp index 460cb93d1bc..625703b4056 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp @@ -20,22 +20,15 @@ // // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_obj_sequence_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_obj_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -63,7 +56,7 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); // !! Branching in either compile time template instantiation // or manual template instantiation. @@ -78,20 +71,20 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) << "// = Initialization and termination methods." << be_nl << be_nl; - // default constructor + // Default constructor. *os << class_name << " (void);" << be_nl; - // constructor + // Constructor. *os << class_name << " (" << be_idt << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl << ");" << be_uidt_nl; - // constructor + // Constructor. *os << class_name << " (" << be_idt << be_idt_nl << "const " << class_name << " &rhs" << be_uidt_nl << ");" << be_uidt_nl; @@ -101,41 +94,39 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) << "const " << class_name << " &rhs" << be_uidt_nl << ");" << be_uidt_nl; - // destructor + // Destructor. *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; - // Accessors + // Accessors. *os << "// = Accessors." << be_nl; be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); + AST_Decl::NodeType nt = pt->node_type (); + int is_pseudo_object = - pt->node_type () == AST_Decl::NT_pre_defined - && prim && prim->pt () == AST_PredefinedType::PT_pseudo - && ACE_OS::strcmp (prim->local_name ()->get_string (), - "Object") != 0; - int is_valuetype = 0; + nt == AST_Decl::NT_pre_defined + && prim + && prim->pt () == AST_PredefinedType::PT_object; // operator[] if (is_pseudo_object) { *os << "TAO_Pseudo_Object_Manager<"; } - else + else if (nt == AST_Decl::NT_valuetype) { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) - is_valuetype = bf->is_valuetype (); - else + *os << "TAO_Valuetype_Manager<"; + } + else if (nt == AST_Decl::NT_interface) + { + if (node->base_type ()->is_abstract ()) { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) - is_valuetype = bff->is_valuetype (); + *os << "TAO_Abstract_Manager<"; } - - if (is_valuetype) - *os << "TAO_Valuetype_Manager<"; else - *os << "TAO_Object_Manager<"; + { + *os << "TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -148,14 +139,14 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) // allocbuf *os << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " **allocbuf (CORBA::ULong length);" << be_nl; // freebuf *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer);" << be_nl << be_nl; @@ -169,13 +160,14 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept(visitor); + bt->accept (&visitor); + *os << "* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *get_buffer (void) const;" << be_nl; @@ -185,24 +177,23 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) << "CORBA::ULong ol" << be_uidt_nl << ");" << be_uidt_nl << be_nl; - if (! (is_pseudo_object || is_valuetype)) + if (! (is_pseudo_object || nt == AST_Decl::NT_valuetype)) { // Pseudo objects do not require these methods. *os << "virtual void _downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src" << be_nl - << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");" << be_uidt_nl; - + << "void* target," << be_nl + << "CORBA_Object *src" << be_nl + << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt_nl; *os << "virtual CORBA_Object* _upcast (void *src) const;"; } + *os << be_uidt_nl << "};" << be_nl; os->gen_endif (); - // generate #endif for AHETI + // Generate #endif for AHETI. os->gen_endif_AHETI (); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp index 23c63bc255d..662f31fea20 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp @@ -19,21 +19,15 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_obj_sequence_ci, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_obj_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -45,7 +39,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) } // Generate the class name. - be_type *pt; + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) { @@ -105,14 +99,15 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Branching in either compile time template instantiation // or manual template instatiation. os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // First generate the static methods since they are used by others. Since @@ -120,7 +115,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // some compilers give lots of warnings. // allocbuf - *os << "ACE_INLINE "; bt->accept (visitor); + *os << "ACE_INLINE "; bt->accept (&visitor); *os << " **" << be_nl; *os << full_class_name << "::allocbuf (CORBA::ULong /* length */) " << "// Allocate storage for a sequence.." << be_nl @@ -129,7 +124,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // The accept is here the first time used and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -142,7 +137,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << be_nl << "ACE_NEW_RETURN (buf, "; - bt->accept (visitor); + bt->accept (&visitor); *os << "*[" << node->max_size () << "], 0);" << be_nl << be_nl @@ -151,26 +146,13 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "buf[i] = "; - int is_valuetype = 0; - { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) - is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) - is_valuetype = bff->is_valuetype (); - } - } - - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "0;"; } else if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -188,7 +170,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) *os << "ACE_INLINE void" << be_nl << full_class_name << "::freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer)" << be_nl << "{" << be_idt_nl @@ -197,7 +179,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "if (buffer[i] != "; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "0)" << be_idt_nl << "{" << be_idt_nl @@ -206,14 +188,14 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) } else if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ())" << be_idt_nl << "{" << be_idt_nl << "CORBA::release (buffer[i]);" << be_nl << "buffer[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();" << be_uidt_nl; } @@ -247,7 +229,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << full_class_name << "::" << class_name << " (CORBA::ULong length," << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release)" << be_uidt_nl @@ -268,21 +250,21 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **tmp1 = allocbuf (" << node->max_size () << ");" << be_nl; - bt->accept(visitor); + bt->accept(&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "** ACE_CAST_CONST, rhs.buffer_);" << be_nl << "for (CORBA::ULong i = 0; i < rhs.length_; i++)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "if (tmp2[i] != 0)" << be_idt_nl << "tmp2[i]->_add_ref ();" << be_uidt_nl @@ -291,16 +273,17 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } *os << be_uidt_nl @@ -326,18 +309,18 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "if (this->release_ && this->buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "if (tmp[i] != 0)" << be_idt_nl << "tmp[i]->_remove_ref ();" << be_uidt_nl @@ -348,7 +331,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -369,25 +352,25 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "TAO_Bounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **tmp1 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl << "for (CORBA::ULong i=0; i < rhs.length_; ++i)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "if (tmp2[i] != 0)" << be_idt_nl << "tmp2[i]->_add_ref ();" << be_uidt_nl @@ -396,16 +379,17 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } *os << be_uidt_nl @@ -419,9 +403,9 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) int is_pseudo_object = pt->node_type () == AST_Decl::NT_pre_defined - && prim && prim->pt () == AST_PredefinedType::PT_pseudo - && ACE_OS::strcmp (prim->local_name ()->get_string (), - "Object") != 0; + && prim + && prim->pt () == AST_PredefinedType::PT_object; + // operator[]. if (is_pseudo_object) { @@ -429,10 +413,18 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) } else { - if (is_valuetype) - *os << "TAO_Valuetype_Manager<"; + if (pt->node_type () == AST_Decl::NT_valuetype) + { + *os << "ACE_INLINE TAO_Valuetype_Manager<"; + } + else if (node->base_type ()->is_abstract ()) + { + *os << "ACE_INLINE TAO_Abstract_Manager<"; + } else - *os << "ACE_INLINE TAO_Object_Manager<"; + { + *os << "ACE_INLINE TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -442,11 +434,11 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "ACE_ASSERT (index < this->maximum_);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **const tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_nl; @@ -456,10 +448,18 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) } else { - if (is_valuetype) - *os << "return TAO_Valuetype_Manager<"; + if (pt->node_type () == AST_Decl::NT_valuetype) + { + *os << "return TAO_Valuetype_Manager<"; + } + else if (node->base_type()->is_abstract ()) + { + *os << "return TAO_Abstract_Manager<"; + } else - *os << "return TAO_Object_Manager<"; + { + *os << "return TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -471,14 +471,14 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // get_buffer *os << "ACE_INLINE "; - bt->accept(visitor); + bt->accept (&visitor); *os << " **" << be_nl; *os << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os << " **result = 0;" << be_nl << "if (orphan == 0)" << be_nl @@ -495,7 +495,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl @@ -509,7 +509,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl << "this->length_ = 0;" << be_nl @@ -524,14 +524,14 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // get_buffer. *os << "ACE_INLINE const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl @@ -542,6 +542,5 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp index f144dd55c62..14e7c6a4703 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp @@ -19,21 +19,15 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_obj_sequence_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_obj_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -80,19 +74,6 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) bt_is_defined = ibt->is_defined (); } - int is_valuetype = 0; - { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) - is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) - is_valuetype = bff->is_valuetype (); - } - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; @@ -118,14 +99,15 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Branching in either compile time template instantiation // or manual template instatiation. os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // First generate the static methods since they are used by others. Since @@ -154,11 +136,11 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_nl @@ -181,21 +163,20 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = nl; i < ol; ++i)" << be_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { - *os << "if (tmp[i] != 0)" << be_idt_nl - << "tmp[i]->_remove_ref ();" << be_uidt_nl + *os << "tao_" << pt->flat_name () << "_remove_ref (tmp[i]);" << be_nl << "tmp[i] = 0;"; } else if (bt_is_defined) @@ -203,7 +184,7 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -220,10 +201,9 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); - if ((pt->node_type () != AST_Decl::NT_pre_defined) + if (pt->node_type () != AST_Decl::NT_pre_defined || (prim - && (prim->pt () == AST_PredefinedType::PT_pseudo) - && (!ACE_OS::strcmp (prim->local_name ()->get_string (), "Object")))) + && prim->pt () == AST_PredefinedType::PT_object)) { // Pseudo objects do not require these methods. *os << "void" << be_nl @@ -234,18 +214,18 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) << ")" << be_uidt_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, target);" << be_nl << "*tmp = "; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_narrow (src ACE_ENV_ARG_PARAMETER);"; } @@ -257,30 +237,30 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) *os << be_nl << "ACE_CHECK;" << be_uidt_nl - << "}\n" << be_nl; + << "}\n" << be_nl; *os << "CORBA_Object*" << be_nl << full_class_name << "::_upcast (void *src) const" << be_nl - << "{" << be_idt_nl; + << "{" << be_idt_nl; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, src);" << be_nl << "return *tmp;"; } else { - *os << "return tao_" << pt->flat_name () << "_upcast (src);"; + *os << "return tao_" << pt->flat_name () << "_upcast (src);"; } *os << be_uidt_nl - << "}" << be_nl; + << "}" << be_nl; } os->gen_endif (); @@ -288,6 +268,5 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp index ee01027a5ff..8a4c1dd9f63 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp @@ -18,24 +18,16 @@ // // ============================================================================ -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_sequence_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -48,9 +40,11 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CH) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CH); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -62,15 +56,16 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) const char * class_name = node->instance_name (); - be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // !! branching in either compile time template instantiation // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl @@ -86,7 +81,7 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) *os << class_name << " (" << be_idt << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" *data," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl @@ -109,32 +104,35 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) // operator[] *os << "// = Accessors." << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" &operator[] (CORBA::ULong i);" << be_nl; // operator[] *os << "const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " &operator[] (CORBA::ULong i) const;" << be_nl << be_nl; // Static Operations *os << "// = Static operations." << be_nl << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " *allocbuf (CORBA::ULong);" << be_nl; // free_buf *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " *buffer);" << be_nl << be_nl; // Implement the TAO_Base_Sequence methods (see Sequence.h) - *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" + << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -143,13 +141,13 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept (visitor); + bt->accept (&visitor); *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " *get_buffer (void) const;" << be_nl; @@ -158,7 +156,7 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) << "CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" *data," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl @@ -171,6 +169,5 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp index 0a239629207..12c65e6b954 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp @@ -18,11 +18,9 @@ // // ============================================================================ -#include "be.h" -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_sequence_ci, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) @@ -33,12 +31,14 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // Retrieve the base type since we may need to do some code // generation for the base type. bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // If we contain an anonymous sequence, @@ -98,14 +98,15 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // !! Branching in either compile time template instantiation // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // First generate the static methods since they are used by others. Since @@ -120,7 +121,7 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // The accept is used the first time here, and if an // error occurs, it will occur here. Later, no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence::" @@ -133,10 +134,14 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << full_class_name << "::allocbuf (CORBA::ULong) " << "// Allocate storage for the sequence." << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *retval = 0;" << be_nl << "ACE_NEW_RETURN (retval, "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "[" << node->max_size () << "], 0);" << be_nl << "return retval;" << be_uidt_nl << "}" << be_nl @@ -145,7 +150,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // free_buf. *os << "ACE_INLINE void " << be_nl << full_class_name << "::freebuf ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *buffer) // Free the sequence." << be_nl << "{" << be_idt_nl << "delete [] buffer;" << be_uidt_nl @@ -164,12 +171,16 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // Constructor. *os << "ACE_INLINE" << be_nl; - *os << full_class_name << "::" << class_name << " (CORBA::ULong length," << be_idt_nl; - bt->accept (visitor); + *os << full_class_name << "::" << class_name + << " (CORBA::ULong length," << be_idt_nl; + + bt->accept (&visitor); + *os <<" *data," << be_nl << "CORBA::Boolean release)" << be_uidt_nl << "// Constructor using the data and memory management flag." << be_nl - << " : TAO_Bounded_Base_Sequence (" << node->max_size () << ", length, data, release)" << be_nl + << " : TAO_Bounded_Base_Sequence (" << node->max_size () + << ", length, data, release)" << be_nl << "{" << be_nl << "}" << be_nl << be_nl; @@ -183,20 +194,26 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "{" << be_idt_nl << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp1 = " << class_name << "::allocbuf (" << node->max_size () << ");" << be_nl << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" * const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -216,7 +233,8 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // operator=. *os << "ACE_INLINE " << full_class_name << " &" << be_nl - << full_class_name << "::operator= (const " << class_name << " &rhs)" << be_nl + << full_class_name << "::operator= (const " + << class_name << " &rhs)" << be_nl << "// Assignment operator. " << be_nl << "{" << be_idt_nl << "if (this == &rhs)" << be_idt_nl @@ -226,24 +244,33 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "{" << be_nl << "}" << be_nl << "else" << be_idt_nl - << "this->buffer_ = " << class_name << "::allocbuf (rhs.maximum_);" << be_uidt_nl + << "this->buffer_ = " << class_name + << "::allocbuf (rhs.maximum_);" << be_uidt_nl << be_nl <<"TAO_Bounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<"* tmp1 = ACE_reinterpret_cast ("; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<"* const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -259,28 +286,40 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // Accessors. *os << "// = Accessors." << be_nl; *os << "ACE_INLINE "; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " &" << be_nl; - *os << full_class_name << "::operator[] (CORBA::ULong i)// operator []" << be_nl + *os << full_class_name << "::operator[] (CORBA::ULong i)" << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl; - *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " &" << be_nl - << full_class_name << "::operator[] (CORBA::ULong i) const// operator []" << be_nl + << full_class_name << "::operator[] (CORBA::ULong i) const" + << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl << "const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* tmp = ACE_reinterpret_cast (const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* ACE_CAST_CONST,this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl @@ -288,11 +327,15 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // get_buffer. *os << "ACE_INLINE "; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *result = 0;" << be_nl << "if (orphan == 0)" << be_nl << "{" << be_idt_nl @@ -306,7 +349,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "else" << be_nl << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_nl @@ -317,7 +362,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "// We set the state back to default and relinquish" << be_nl << "// ownership." << be_nl << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl << "this->length_ = 0;" << be_nl @@ -331,12 +378,16 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // get_buffer. *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl << be_nl; @@ -345,7 +396,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) *os << "ACE_INLINE void " << be_nl << full_class_name << "::replace (CORBA::ULong max," << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *data," << be_nl << "CORBA::Boolean release)" << be_uidt_nl << "{" << be_idt_nl @@ -353,9 +406,13 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "this->length_ = length;" << be_nl << "if (this->buffer_ && this->release_ == 1)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<"* tmp = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* ACE_CAST_CONST, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_uidt_nl << "}" << be_nl @@ -368,6 +425,5 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp index 8bb053c1a9e..bff0ecd7d6a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp @@ -18,21 +18,16 @@ // // ============================================================================ -#include "be.h" -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_sequence_cs, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -45,9 +40,11 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CS) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CS); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" @@ -57,55 +54,48 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) } } -// May not need variable 'pt' at all -#if 0 - // generate the class name - be_type *pt; // base types - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } - else - pt = bt; -#endif /* 0 */ - const char * class_name = node->instance_name (); - static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); + + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer *os << "void " << be_nl - << full_class_name << "::_allocate_buffer (CORBA::ULong /* length */)" << be_nl - << "// allocate a buffer of the requested length. The buffer is allocated for the" << be_nl + << full_class_name << "::_allocate_buffer (CORBA::ULong /* length */)" + << be_nl + << "// allocate a buffer of the requested length. " + << "The buffer is allocated for the" << be_nl << "// right type" << be_nl << "{" << be_idt_nl << "this->buffer_ = " << class_name << "::allocbuf (" @@ -120,9 +110,13 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) << "{" << be_idt_nl << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_nl << "this->buffer_ = 0;" << be_uidt_nl @@ -130,7 +124,8 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) << be_nl; // destructor - *os << full_class_name << "::~" << class_name << " (void) // Dtor." << be_nl + *os << full_class_name << "::~" << class_name + << " (void) // Dtor." << be_nl << "{" << be_idt_nl << "this->_deallocate_buffer ();" << be_uidt_nl << "}" << be_nl @@ -141,6 +136,5 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp index 89fc707468b..77aa4f0f9a7 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp @@ -19,69 +19,21 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_str_sequence_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_str_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_str_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // Generate the class name. - be_type *pt; - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } - else - { - pt = bt; - } - - const char * class_name = node->instance_name (); - - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + const char *class_name = node->instance_name (); - os->gen_ifdef_macro (class_name); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // The accept is used here the first time and if an - // error occurs, it will occur here. Later no check - // for errors will be done. - if (pt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } + os->gen_ifdef_AHETI(); + os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl << ": public TAO_Bounded_Base_Sequence" << be_uidt_nl @@ -156,7 +108,5 @@ be_visitor_sequence_ch::gen_bounded_str_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp index 4837f699946..1d812a7a7ed 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp @@ -20,59 +20,43 @@ // // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_str_sequence_ci, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_str_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_bounded_str_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // first generate the static methods since they are used by others. Since @@ -241,7 +225,5 @@ be_visitor_sequence_ci::gen_bounded_str_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp index dee7d1881bd..f9c52236c97 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp @@ -20,59 +20,43 @@ // // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_str_sequence_cs, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_str_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_str_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer @@ -126,7 +110,5 @@ be_visitor_sequence_cs::gen_bounded_str_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp index 75654b7c89c..5765060d42b 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp @@ -18,69 +18,22 @@ // // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - +ACE_RCSID (be_visitor_sequence, + gen_bounded_wstr_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // Generate the class name. - be_type *pt; - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } - else - { - pt = bt; - } - const char * class_name = node->instance_name (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); - // the accept is here the first time used and if an - // error occurs, it will occur here. Later no check - // for errors will be done. - if (pt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl << ": public TAO_Bounded_Base_Sequence" << be_uidt_nl @@ -155,7 +108,5 @@ be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp index 164e72ff3c3..a53dc89ec60 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp @@ -18,60 +18,46 @@ // // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - +ACE_RCSID (be_visitor_sequence, + gen_bounded_wstr_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_bounded_wstr_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); - // first generate the static methods since they are used by others. Since + // First generate the static methods since they are used by others. Since // they are inlined, their definition needs to come before their use else // some compilers (e.g., g++) produce lots of warnings. @@ -251,7 +237,5 @@ be_visitor_sequence_ci::gen_bounded_wstr_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp index d6c0170bdb2..ea70ec143bc 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp @@ -18,28 +18,14 @@ // // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - +ACE_RCSID (be_visitor_sequence, + gen_bounded_wstr_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_wstr_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; @@ -47,28 +33,26 @@ be_visitor_sequence_cs::gen_bounded_wstr_sequence (be_sequence *node) if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer @@ -123,7 +107,5 @@ be_visitor_sequence_cs::gen_bounded_wstr_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp index d7b421b58d7..a1018f6013c 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp @@ -20,23 +20,15 @@ // // ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_unbounded_obj_sequence_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_unbounded_obj_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -46,8 +38,7 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) "Bad element type\n"), -1); } - // Generate the class name. - be_type *pt; + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) { @@ -60,16 +51,17 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) pt = bt; } - const char * class_name = node->instance_name (); + // Generate the class name. + const char *class_name = node->instance_name (); be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! Branching in either compile time template instantiation - // or manual template instatiation. - os->gen_ifdef_AHETI(); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl @@ -89,7 +81,7 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) << "CORBA::ULong maximum," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl @@ -111,34 +103,30 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) // Accessors *os << "// = Accessors." << be_nl; + AST_Decl::NodeType nt = pt->node_type (); + // operator[] be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); + int is_pseudo_object = - pt->node_type () == AST_Decl::NT_pre_defined - && prim && prim->pt () == AST_PredefinedType::PT_pseudo - && ACE_OS::strcmp (prim->local_name ()->get_string (), - "Object") != 0; - int is_valuetype = 0; + nt == AST_Decl::NT_pre_defined + && prim + && prim->pt () == AST_PredefinedType::PT_object; if (is_pseudo_object) { *os << "TAO_Pseudo_Object_Manager<"; } + else if (nt == AST_Decl::NT_valuetype) + { + *os << "TAO_Valuetype_Manager<"; + } + else if (node->base_type ()->is_abstract ()) + { + *os << "TAO_Abstract_Manager<"; + } else { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) - is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) - is_valuetype = bff->is_valuetype (); - } - - if (is_valuetype) - *os << "TAO_Valuetype_Manager<"; - else *os << "TAO_Object_Manager<"; } @@ -152,14 +140,14 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) // allocbuf *os << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " **allocbuf (CORBA::ULong nelems);" << be_nl; // freebuf *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer);" << be_nl << be_nl; @@ -173,14 +161,14 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept (visitor); + bt->accept (&visitor); *os << "* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *get_buffer (void) const;" << be_nl; @@ -188,27 +176,27 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) *os << "virtual void _shrink_buffer (" << be_idt << be_idt_nl << "CORBA::ULong nl," << be_nl << "CORBA::ULong ol" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; + << ");"; - if (! (is_pseudo_object || is_valuetype)) + if (! (is_pseudo_object || nt == AST_Decl::NT_valuetype)) { // Pseudo objects do not require these methods. - *os << "virtual void _downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src" << be_nl - << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");" << be_uidt_nl; + *os << be_uidt_nl << be_nl + << "virtual void _downcast (" << be_idt << be_idt_nl + << "void* target," << be_nl + << "CORBA_Object *src" << be_nl + << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt_nl; *os << "virtual CORBA_Object* _upcast (void *src) const;"; } - *os << be_uidt_nl << "};" << be_nl; + *os << be_uidt << be_uidt_nl << "};" << be_nl; os->gen_endif (); // endif macro // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp index ca6c891e885..79fe87eda25 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp @@ -19,11 +19,9 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_unbounded_obj_sequence_ci, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_unbounded_obj_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) @@ -104,14 +102,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !Branching in either compile time template instantiation - // or manual template instatiation. - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocbuf. @@ -120,7 +117,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) // The accept is here the first time used and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -133,13 +130,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << full_class_name << "::allocbuf (CORBA::ULong nelems)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **buf = 0;" << be_nl << be_nl << "ACE_NEW_RETURN (buf, " ; - bt->accept (visitor); + bt->accept (&visitor); *os << "*[nelems], 0);" << be_nl << be_nl @@ -147,26 +144,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "buf[i] = "; - int is_valuetype = 0; - { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) - is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) - is_valuetype = bff->is_valuetype (); - } - } - - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "0;"; } else if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -184,7 +168,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) *os << "ACE_INLINE void " << be_nl << full_class_name << "::freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer)" << be_nl << "{" << be_idt_nl @@ -217,7 +201,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << " (CORBA::ULong maximum," << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release)" << be_uidt_nl @@ -236,23 +220,23 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **tmp1 = " << class_name << "::allocbuf (this->maximum_);" << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < rhs.length_; ++i)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "if (tmp2[i] != 0)" << be_idt_nl << "tmp2[i]->_add_ref ();" << be_uidt_nl @@ -261,16 +245,17 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } *os << be_uidt_nl @@ -295,18 +280,18 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "if (this->release_)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "if (tmp[i] != 0)" << be_idt_nl << "tmp[i]->_remove_ref ();" << be_uidt_nl @@ -317,7 +302,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -344,26 +329,26 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "TAO_Unbounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp1 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < rhs.length_; ++i)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { *os << "if (tmp2[i] != 0)" << be_idt_nl << "tmp2[i]->_add_ref ();" << be_uidt_nl @@ -372,17 +357,19 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } + *os << be_uidt_nl << "}" << be_uidt_nl << be_nl << "return *this;" << be_uidt_nl @@ -391,21 +378,30 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) // Operator[]. be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); + int is_pseudo_object = pt->node_type () == AST_Decl::NT_pre_defined - && prim && prim->pt () == AST_PredefinedType::PT_pseudo - && ACE_OS::strcmp (prim->local_name ()->get_string (), - "Object") != 0; + && prim + && prim->pt () == AST_PredefinedType::PT_object; + if (is_pseudo_object) { *os << "ACE_INLINE TAO_Pseudo_Object_Manager<"; } else { - if (is_valuetype) - *os << "ACE_INLINE TAO_Valuetype_Manager<"; + if (pt->node_type () == AST_Decl::NT_valuetype) + { + *os << "ACE_INLINE TAO_Valuetype_Manager<"; + } + else if (node->base_type ()->is_abstract ()) + { + *os << "ACE_INLINE TAO_Abstract_Manager<"; + } else - *os << "ACE_INLINE TAO_Object_Manager<"; + { + *os << "ACE_INLINE TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -416,11 +412,11 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "ACE_ASSERT (index < this->maximum_);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" ** const tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_nl; @@ -430,10 +426,18 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) } else { - if (is_valuetype) - *os << "return TAO_Valuetype_Manager<"; + if (pt->node_type () == AST_Decl::NT_valuetype) + { + *os << "return TAO_Valuetype_Manager<"; + } + else if (node->base_type ()->is_abstract ()) + { + *os << "return TAO_Abstract_Manager<"; + } else - *os << "return TAO_Object_Manager<"; + { + *os << "return TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -445,13 +449,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) // get_buffer *os << "ACE_INLINE "; - bt->accept(visitor); + bt->accept (&visitor); *os << "* *" << be_nl << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os << " **result = 0;" << be_nl << "if (orphan == 0)" << be_nl @@ -468,7 +472,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl @@ -481,7 +485,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "// ownership." << be_nl << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl @@ -498,14 +502,14 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) *os << "ACE_INLINE "; *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl @@ -516,6 +520,5 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp index b9e9880dbdd..f0c57e1a88a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp @@ -19,21 +19,15 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_unbounded_obj_sequence_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_unbounded_obj_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -57,8 +51,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) pt = bt; } - const char *name = - be_decl::narrow_from_decl (pt)->full_name (); + const char *name = be_decl::narrow_from_decl (pt)->full_name (); idl_bool bt_is_defined; @@ -79,19 +72,6 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) bt_is_defined = ibt->is_defined (); } - int is_valuetype = 0; - { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) - is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) - is_valuetype = bff->is_valuetype (); - } - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; @@ -117,14 +97,13 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // Branching in either compile time template instantiation - // or manual template instatiation. - os->gen_ifdef_AHETI(); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer. @@ -135,7 +114,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = 0;" << be_nl << "tmp = " << class_name << "::allocbuf (length);" << be_nl @@ -143,11 +122,11 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "if (this->buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **old = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl @@ -155,25 +134,25 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "if (!this->release_)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { - *os << "if (old[i] != 0)" << be_idt_nl - << "old[i]->_add_ref ();" << be_uidt_nl + *os << "tao_" << pt->flat_name () << "_add_ref (old[i]);" << be_nl << "tmp[i] = old[i];"; } else { *os << "tmp[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (old[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (old[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (old[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (old[i]);"; + } } *os << be_uidt_nl @@ -185,7 +164,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "}" << be_uidt_nl << be_nl << "if (this->release_)" << be_idt_nl << "{" << be_idt_nl - << "delete[] old;" << be_uidt_nl + << "delete [] old;" << be_uidt_nl << "}" << be_uidt << be_uidt_nl << "}" << be_nl << "this->buffer_ = tmp;" << be_uidt_nl @@ -199,20 +178,19 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { - *os << "if (tmp[i] != 0)" << be_idt_nl - << "tmp[i]->_remove_ref ();" << be_uidt_nl + *os << "tao_" << pt->flat_name () << "_remove_ref (tmp[i]);" << be_nl << "tmp[i] = 0;"; } else if (bt_is_defined) @@ -220,7 +198,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -251,20 +229,19 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "::_shrink_buffer (CORBA::ULong nl, CORBA::ULong ol)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = nl; i < ol; ++i)" << be_idt_nl << "{" << be_idt_nl; - if (is_valuetype) + if (pt->node_type () == AST_Decl::NT_valuetype) { - *os << "if (tmp[i] != 0)" << be_idt_nl - << "tmp[i]->_remove_ref ();" << be_uidt_nl + *os << "tao_" << pt->flat_name () << "_remove_ref (tmp[i]);" << be_nl << "tmp[i] = 0;"; } else if (bt_is_defined) @@ -272,7 +249,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -290,10 +267,10 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); - if (! is_valuetype - && (pt->node_type () != AST_Decl::NT_pre_defined) || - (prim && (prim->pt () == AST_PredefinedType::PT_pseudo) && - (!ACE_OS::strcmp (prim->local_name ()->get_string (), "Object")))) + if (pt->node_type () != AST_Decl::NT_valuetype + && (pt->node_type () != AST_Decl::NT_pre_defined) + || (prim && + prim->pt () == AST_PredefinedType::PT_object)) { // Pseudo objects do not require these methods. *os << "void " << be_nl @@ -304,18 +281,18 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << ")" << be_uidt_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, target);" << be_nl << "*tmp = "; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_narrow (src ACE_ENV_ARG_PARAMETER);"; } @@ -331,26 +308,26 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA_Object*" << be_nl << full_class_name << "::_upcast (void *src) const" << be_nl - << "{" << be_idt_nl; + << "{" << be_idt_nl; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, src);" << be_nl << "return *tmp;"; } else { - *os << "return tao_" << pt->flat_name () << "_upcast (src);"; + *os << "return tao_" << pt->flat_name () << "_upcast (src);"; } *os << be_uidt_nl - << "}" << be_nl; + << "}" << be_nl; } os->gen_endif (); @@ -358,6 +335,5 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp index 7a1810b92f9..f66a9d87529 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp @@ -18,22 +18,15 @@ // // ============================================================================ -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_unbounded_sequence_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_unbounded_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -47,9 +40,11 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CH) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CH); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -61,15 +56,15 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) const char * class_name = node->instance_name (); - // get the visitor for the type of the sequence + // Get the visitor for the type of the sequence. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI (); + *os << be_nl << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI (); os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " @@ -92,7 +87,7 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // The accept is used here the first time and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -121,14 +116,14 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // Accessors *os << "// = Accessors." << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" &operator[] (CORBA::ULong i);" << be_nl; // operator[] *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " &operator[] (CORBA::ULong i) const;" << be_nl << be_nl; @@ -136,18 +131,19 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) *os << "// = Static operations." << be_nl << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " *allocbuf (CORBA::ULong size);" << be_nl; *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " *buffer);" << be_nl << be_nl; // Implement the TAO_Base_Sequence methods (see Sequence.h) - *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" + << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -155,12 +151,15 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // deallocate_buffer *os << "virtual void _deallocate_buffer (void);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); + *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *get_buffer (void) const;" << be_nl; // replace @@ -168,7 +167,7 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) << "CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" *data," << be_nl << "CORBA::Boolean release" << be_uidt_nl @@ -181,6 +180,5 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp index efde5904e65..9c558ec65bc 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp @@ -18,39 +18,34 @@ // // ============================================================================ -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_unbounded_sequence_ci, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_unbounded_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // If we contain an anonymous sequence, // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CI) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CI); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -60,12 +55,12 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) } } - // generate the class name - be_type *pt; // base types + // Generate the class name + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) { - // get the primitive base type of this typedef node + // Get the primitive base type of this typedef node. be_typedef *t = be_typedef::narrow_from_decl (bt); pt = t->primitive_base_type (); } @@ -80,27 +75,31 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } - // get the visitor for the type of the sequence + // Get the visitor for the type of the sequence. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // Static operations @@ -110,7 +109,7 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // the accept is here the first time used and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -118,14 +117,19 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) "base type visit failed\n"), -1); } + *os << " *" << be_nl << full_class_name << "::allocbuf (CORBA::ULong size)" << be_nl << "// Allocate storage for the sequence." << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *retval = 0;" << be_nl << "ACE_NEW_RETURN (retval, "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "[size], 0);" << be_nl << "return retval;" << be_uidt_nl << "}" << be_nl @@ -133,7 +137,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) *os << "ACE_INLINE void " << full_class_name << "::freebuf ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *buffer)" << be_nl << "// Free the sequence." << be_nl << "{" << be_idt_nl @@ -143,7 +149,8 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // constructor *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (void) // Default constructor." << be_nl + << full_class_name << "::" << class_name + << " (void) // Default constructor." << be_nl << "{" << be_nl << "}" << be_nl << be_nl; @@ -161,12 +168,16 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // constructor *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (CORBA::ULong maximum," << be_idt_nl + << full_class_name << "::" << class_name + << " (CORBA::ULong maximum," << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *data," << be_nl << "CORBA::Boolean release)" << be_uidt_nl - << ": TAO_Unbounded_Base_Sequence (maximum, length, data, release)" << be_nl + << ": TAO_Unbounded_Base_Sequence (maximum, length, data, release)" + << be_nl << "{" << be_nl << "}" << be_nl << be_nl; @@ -180,18 +191,24 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "{" << be_idt_nl << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp1 = " << class_name << "::allocbuf (this->maximum_);" << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " * const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -222,9 +239,13 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "if (this->maximum_ < rhs.maximum_)" << be_nl << "{" << be_idt_nl << "// free the old buffer" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_nl << "this->buffer_ = " << class_name @@ -237,20 +258,28 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << be_nl << "TAO_Unbounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" *tmp1 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" * const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -266,15 +295,21 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // Accessors *os << "// = Accessors." << be_nl; *os << "ACE_INLINE "; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" &" << be_nl << full_class_name << "::operator[] (CORBA::ULong i)" << be_nl << "// operator []" << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<"* tmp = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl @@ -282,15 +317,21 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // operator[] *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " &" << be_nl << full_class_name << "::operator[] (CORBA::ULong i) const" << be_nl << "// operator []" << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" * const tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* ACE_CAST_CONST, this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl @@ -300,11 +341,15 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl << be_nl; *os << "ACE_INLINE "; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *result = 0;" << be_nl << "if (orphan == 0)" << be_nl << "{" << be_idt_nl @@ -318,7 +363,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "else" << be_nl << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_nl @@ -329,7 +376,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "// We set the state back to default and relinquish" << be_nl << "// ownership." << be_nl << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl << "this->length_ = 0;" << be_nl @@ -343,12 +392,16 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // get_buffer *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl << be_nl; @@ -357,7 +410,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) *os << "ACE_INLINE void" << be_nl << full_class_name << "::replace (CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *data," << be_nl << "CORBA::Boolean release)" << be_nl << "{" << be_idt_nl @@ -365,9 +420,13 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "this->length_ = length;" << be_nl << "if (this->buffer_ && this->release_ == 1)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_uidt_nl << "}" << be_nl @@ -380,6 +439,5 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp index 4fe9def4d30..23546d87070 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp @@ -18,24 +18,16 @@ // // ============================================================================ -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_unbounded_sequence_cs, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_unbounded_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -48,9 +40,11 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CS) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CS); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" @@ -60,69 +54,83 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) } } - // generate the class name - be_type *pt; // base types + // Generate the class name. + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } + { + // Get the primitive base type of this typedef node. + be_typedef *t = be_typedef::narrow_from_decl (bt); + pt = t->primitive_base_type (); + } else - pt = bt; - + { + pt = bt; + } const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } - // get the visitor for the type of the sequence + // Get the visitor for the type of the sequence. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer *os << "void" << be_nl << full_class_name << "::_allocate_buffer (CORBA::ULong length)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* tmp = 0;" << be_nl << "tmp = " << class_name << "::allocbuf (length);" << be_nl << be_nl << "if (this->buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" *old = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *,this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); + *os << "_var::copy (tmp[i], old[i]);" << be_uidt_nl; } else @@ -145,9 +153,13 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *,this->buffer_);" << be_nl << be_nl << class_name << "::freebuf (tmp);" << be_nl @@ -167,6 +179,5 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_base.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_base.cpp index cef298252f5..1277fd82ccf 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_base.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_base.cpp @@ -18,22 +18,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, sequence_base, "$Id$") - +ACE_RCSID (be_visitor_sequence, + sequence_base, + "$Id$") // **************************************************************** // We have to generate the parameters for the template that implements // each sequence type. // **************************************************************** -be_visitor_sequence_base:: -be_visitor_sequence_base (be_visitor_context *ctx) +be_visitor_sequence_base::be_visitor_sequence_base (be_visitor_context *ctx) : be_visitor_decl (ctx) { } @@ -47,7 +41,9 @@ int be_visitor_sequence_base::visit_predefined_type (be_predefined_type *node) { TAO_OutStream *os = this->ctx_->stream (); + *os << node->name (); + return 0; } @@ -133,12 +129,24 @@ be_visitor_sequence_base::visit_structure (be_structure *node) } int +be_visitor_sequence_base::visit_structure_fwd (be_structure_fwd *node) +{ + return this->visit_node (node); +} + +int be_visitor_sequence_base::visit_union (be_union *node) { return this->visit_node (node); } int +be_visitor_sequence_base::visit_union_fwd (be_union_fwd *node) +{ + return this->visit_node (node); +} + +int be_visitor_sequence_base::visit_enum (be_enum *node) { return this->visit_node (node); @@ -176,8 +184,8 @@ be_visitor_sequence_base::visit_typedef (be_typedef *node) } be_visitor_sequence_base_template_args:: - be_visitor_sequence_base_template_args (be_visitor_context *ctx, - be_sequence *seq) +be_visitor_sequence_base_template_args (be_visitor_context *ctx, + be_sequence *seq) : be_visitor_sequence_base (ctx), beseq_ (seq) { @@ -186,7 +194,7 @@ be_visitor_sequence_base_template_args:: be_visitor_sequence_base_template_args:: - ~be_visitor_sequence_base_template_args (void) +~be_visitor_sequence_base_template_args (void) { //no-op } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp index c5c3cdb1cde..d21e37a7b34 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, sequence_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + sequence_ch, + "$Id$") // Root visitor for client header. be_visitor_sequence_ch::be_visitor_sequence_ch (be_visitor_context *ctx) @@ -41,23 +36,17 @@ int be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt = 0; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (bt == 0) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } - - // !! Branching in either compile time template instantiation - // or manual template instatiation. os->gen_ifdef_AHETI (); // This is the instantiation branch. @@ -79,6 +68,17 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) } break; + case be_sequence::MNG_ABSTRACT: + if (node->unbounded ()) + { + *os << "TAO_Unbounded_Abstract_Sequence<"; + } + else + { + *os << "TAO_Bounded_Abstract_Sequence<"; + } + + break; case be_sequence::MNG_PSEUDO: if (node->unbounded ()) { @@ -150,15 +150,12 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) break; } - be_visitor_context *ctx = 0; - ACE_NEW_RETURN (ctx, - be_visitor_context (*this->ctx_), - 0); + be_visitor_context ctx (*this->ctx_); - be_visitor_sequence_base_template_args visitor (ctx, + be_visitor_sequence_base_template_args visitor (&ctx, node); - ctx->state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); + ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); if (bt->accept (&visitor) == -1) { @@ -188,7 +185,7 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) *os << ", "; // So the call to nested_type_name will have "_var" suffix. - ctx->sub_state (TAO_CodeGen::TAO_ARRAY_SEQ_CH_TEMPLATE_VAR); + ctx.sub_state (TAO_CodeGen::TAO_ARRAY_SEQ_CH_TEMPLATE_VAR); if (bt->accept (&visitor) == -1) { @@ -199,7 +196,7 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) -1); } - ctx->sub_state (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN); + ctx.sub_state (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN); } if (node->unbounded ()) @@ -228,7 +225,8 @@ be_visitor_sequence_ch::instantiate_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "gen_instantiate_template_name - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // Generate the appropriate sequence type. @@ -237,6 +235,7 @@ be_visitor_sequence_ch::instantiate_sequence (be_sequence *node) case be_sequence::MNG_PSEUDO: case be_sequence::MNG_OBJREF: case be_sequence::MNG_VALUE: + case be_sequence::MNG_ABSTRACT: if (node->unbounded ()) { this->gen_unbounded_obj_sequence (node); @@ -327,7 +326,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "failed creating name\n"), -1); + "failed creating name\n"), + -1); } if (node->cli_hdr_gen () || node->imported ()) @@ -342,7 +342,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "codegen. for the primitive type sequence\n"), -1); + "codegen. for the primitive type sequence\n"), + -1); } // End of instantiation. @@ -359,7 +360,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } *os << "class " << node->local_name () << ";" << be_nl; @@ -378,6 +380,9 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) << "// *************************************************************" << be_nl << be_nl; + *os << be_nl << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Generate a typedef to a parametrized sequence. *os << "class " << be_global->stub_export_macro () << " " << node->local_name () << " : public "; @@ -415,18 +420,9 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) // Generate the base type for the buffer. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_buffer_type bt_visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "Bad visitor\n"), - -1); - } - - if (bt->accept (visitor) == -1) + if (bt->accept (&bt_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -435,8 +431,6 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) -1); } - delete visitor; - *os << " *buffer, " << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl << ");" << be_uidt_nl; @@ -445,14 +439,11 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) *os << "~" << node->local_name () << " (void);" << be_nl << "static void _tao_any_destructor (void*);" << be_nl; - // Generate the _var_type typedef (only if we are not anonymous), - // but we must protect against certain versions of g++. + // Generate the _var_type typedef (only if we are not anonymous). if (this->ctx_->tdef () != 0) { - *os << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_nl; - *os << "typedef " << node->local_name () << "_var _var_type;\n" - << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl; + *os << "typedef " << node->local_name () << "_var _var_type;" + << be_nl << be_nl; } // TAO provides extensions for octet sequences, first find out if @@ -507,7 +498,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } os->gen_endif (); @@ -538,7 +530,6 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); char namebuf [NAMEBUFSIZE]; - be_type *bt = 0; ACE_OS::memset (namebuf, '\0', @@ -555,7 +546,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) << be_nl << be_nl; // Retrieve base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -585,7 +576,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) *os << namebuf << " (const " << namebuf << " &);" << be_nl; // Fixed-size base types only. - if (bt->size_type () == be_decl::FIXED) + if (bt->size_type () == AST_Type::FIXED) { *os << "// Fixed-size base types only." << be_nl; *os << namebuf << " (const " << node->local_name () @@ -604,7 +595,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) *os << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // Fixed-size base types only. - if (bt->size_type () == be_decl::FIXED) + if (bt->size_type () == AST_Type::FIXED) { *os << "// Fixed-size base types only." << be_nl; *os << namebuf << " &operator= (const " << node->local_name () @@ -624,7 +615,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) *os << "operator " << node->local_name () << " &();" << be_nl; *os << "operator " << node->local_name () << " &() const;" << be_nl; - if (bt->size_type () == be_decl::VARIABLE) + if (bt->size_type () == AST_Type::VARIABLE) { *os << "operator " << node->local_name () << " *&(); // variable-size base types only" << be_nl; @@ -635,17 +626,9 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) // Overloaded [] operators. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_var_defn - " - "Bad visitor\n"), -1); - } + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_sequence::" @@ -685,12 +668,14 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) && nt != AST_Decl::NT_wstring && nt != AST_Decl::NT_interface && nt != AST_Decl::NT_interface_fwd + && nt != AST_Decl::NT_valuetype && nt != AST_Decl::NT_array - && pdt != AST_PredefinedType::PT_pseudo) + && pdt != AST_PredefinedType::PT_pseudo + && pdt != AST_PredefinedType::PT_object) { *os << "const "; - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_sequence::" @@ -702,8 +687,6 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) *os << " operator[] (CORBA::ULong index) const;" << be_nl; } - delete visitor; - *os << be_nl; *os << "// in, inout, out, _retn " << be_nl; @@ -734,7 +717,6 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); char namebuf [NAMEBUFSIZE]; - be_type *bt = 0; ACE_OS::memset (namebuf, '\0', @@ -744,7 +726,7 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) node->local_name ()->get_string ()); // Retrieve base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (bt == 0) { @@ -794,17 +776,9 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) // required be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_out_defn - " - "Bad visitor\n"), -1); - } + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_sequence::" @@ -813,16 +787,12 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) -1); } - delete visitor; - *os << " operator[] (CORBA::ULong index);" << be_uidt_nl << be_nl; *os << "private:" << be_idt_nl; - *os << node->local_name () << " *&ptr_;" << be_nl; *os << "// Assignment from T_var not allowed." << be_nl; *os << "void operator= (const " << node->local_name () << "_var &);" << be_uidt_nl; - *os << "};" << be_nl << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp index 8b902e3326c..0213f8a7498 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp @@ -18,17 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, sequence_ci, "$Id$") - +ACE_RCSID (be_visitor_sequence, + sequence_ci, + "$Id$") // *********************************************************** -// sequence visitor for inline generation +// Sequence visitor for inline generation. // *********************************************************** @@ -76,7 +71,8 @@ be_visitor_sequence_ci::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } if (this->gen_out_impl (node) == -1) @@ -84,7 +80,8 @@ be_visitor_sequence_ci::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } // Generate the endif macro for the sequence type. @@ -106,7 +103,8 @@ be_visitor_sequence_ci::instantiate_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "gen_instantiate_template_name - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // Generate the appropriate sequence type. @@ -115,6 +113,7 @@ be_visitor_sequence_ci::instantiate_sequence (be_sequence *node) case be_sequence::MNG_PSEUDO: case be_sequence::MNG_OBJREF: case be_sequence::MNG_VALUE: + case be_sequence::MNG_ABSTRACT: if (node->unbounded ()) { this->gen_unbounded_obj_sequence (node); @@ -219,12 +218,16 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // Generate the var implementation in the inline file. os->indent (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// *************************************************************" << be_nl; *os << "// Inline operations for class " << fname << be_nl; @@ -234,11 +237,11 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) // Default constuctor. *os << "ACE_INLINE" << be_nl << fname << "::" << lname - << " (void) // default constructor" << be_nl + << " (void)" << be_nl << " " << ": ptr_ (0)" << be_nl << "{}" << be_nl << be_nl; - // Constuctorr from a _ptr. + // Constuctor from a _ptr. *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << " (" << node->local_name () << " *p)" << be_nl; @@ -248,7 +251,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) // Copy constructor. *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << " (const ::" << fname - << " &p) // copy constructor" << be_nl; + << " &p)" << be_nl; *os << "{" << be_idt_nl; *os << "if (p.ptr_)" << be_idt_nl; *os << "ACE_NEW (this->ptr_, ::" << node->name () @@ -258,7 +261,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) *os << "}" << be_nl << be_nl; // Fixed-size base types only. - if (bt->size_type () == be_decl::FIXED) + if (bt->size_type () == AST_Type::FIXED) { *os << "// fixed-size base types only" << be_nl; *os << "ACE_INLINE" << be_nl; @@ -272,7 +275,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) // Destructor. *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; + *os << fname << "::~" << lname << " (void)" << be_nl; *os << "{" << be_idt_nl; *os << "delete this->ptr_;" << be_uidt_nl; *os << "}" << be_nl << be_nl; @@ -317,7 +320,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) << "}\n\n"; // Fixed-size base types only. - if (bt->size_type () == be_decl::FIXED) + if (bt->size_type () == AST_Type::FIXED) { *os << "// fixed-size types only" << be_nl; *os << "ACE_INLINE ::" << fname << " &" << be_nl; @@ -370,7 +373,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) *os << "}" << be_nl << be_nl; // Variable-size base types only. - if (bt->size_type () == be_decl::VARIABLE) + if (bt->size_type () == AST_Type::VARIABLE) { *os << "// variable-size types only" << be_nl; *os << "ACE_INLINE" << be_nl; @@ -388,17 +391,9 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_var_impl - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -442,13 +437,15 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) && nt != AST_Decl::NT_wstring && nt != AST_Decl::NT_interface && nt != AST_Decl::NT_interface_fwd + && nt != AST_Decl::NT_valuetype && nt != AST_Decl::NT_array - && pdt != AST_PredefinedType::PT_pseudo) + && pdt != AST_PredefinedType::PT_pseudo + && pdt != AST_PredefinedType::PT_object) { // Const. *os << "ACE_INLINE const "; - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -463,7 +460,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) *os << "return ACE_const_cast (const "; - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -477,8 +474,6 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) *os << "}" << be_nl << be_nl; } - delete visitor; - // in, inout, out, and _retn. *os << "ACE_INLINE const ::" << node->name () << " &" << be_nl; *os << fname << "::in (void) const" << be_nl; @@ -527,11 +522,21 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) char lname [NAMEBUFSIZE]; - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", node->full_name ()); + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); + + ACE_OS::sprintf (fname, + "%s_out", + node->full_name ()); + + ACE_OS::memset (lname, + '\0', + NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", node->local_name ()->get_string ()); + ACE_OS::sprintf (lname, + "%s_out", + node->local_name ()->get_string ()); // Retrieve base type. be_type *bt = be_type::narrow_from_decl (node->base_type ()); @@ -548,6 +553,9 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) os->indent (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// *************************************************************" << be_nl; *os << "// Inline operations for class " << fname << be_nl; @@ -629,17 +637,9 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_out_impl - " - "Bad visitor\n"), -1); - } + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -648,8 +648,6 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) -1); } - delete visitor; - *os << be_nl; *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; *os << "{" << be_idt_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp index e02b632b837..5677be4cf09 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, sequence_cs, "$Id$") - +ACE_RCSID (be_visitor_sequence, + sequence_cs, + "$Id$") // ************************************************************ // Root visitor for client stub class @@ -40,91 +35,131 @@ be_visitor_sequence_cs::~be_visitor_sequence_cs (void) { } -// XXXASG - this method is same as that in the _ch visitor. So we need some -// abstraction for this - int be_visitor_sequence_cs::gen_base_sequence_class (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" "gen_base_sequence_class - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); - // this is the instantiation branch + // This is the instantiation branch. *os << node->instance_name (); os->gen_else_AHETI(); - // generate the appropriate sequence type + // Generate the appropriate sequence type. switch (node->managed_type ()) { case be_sequence::MNG_OBJREF: if (node->unbounded ()) - *os << "TAO_Unbounded_Object_Sequence<"; + { + *os << "TAO_Unbounded_Object_Sequence<"; + } + else + { + *os << "TAO_Bounded_Object_Sequence<"; + } + + break; + case be_sequence::MNG_ABSTRACT: + if (node->unbounded ()) + { + *os << "TAO_Unbounded_Abstract_Sequence<"; + } else - *os << "TAO_Bounded_Object_Sequence<"; + { + *os << "TAO_Bounded_Abstract_Sequence<"; + } + break; case be_sequence::MNG_PSEUDO: if (node->unbounded ()) - *os << "TAO_Unbounded_Pseudo_Sequence<"; + { + *os << "TAO_Unbounded_Pseudo_Sequence<"; + } else - *os << "TAO_Bounded_Pseudo_Sequence<"; + { + *os << "TAO_Bounded_Pseudo_Sequence<"; + } + break; case be_sequence::MNG_VALUE: if (node->unbounded ()) - *os << "TAO_Unbounded_Valuetype_Sequence<"; + { + *os << "TAO_Unbounded_Valuetype_Sequence<"; + } else - *os << "TAO_Bounded_Valuetype_Sequence<"; + { + *os << "TAO_Bounded_Valuetype_Sequence<"; + } + break; case be_sequence::MNG_STRING: if (node->unbounded ()) - *os << "TAO_Unbounded_String_Sequence"; + { + *os << "TAO_Unbounded_String_Sequence"; + } else - *os << "TAO_Bounded_String_Sequence"; + { + *os << "TAO_Bounded_String_Sequence"; + } + break; case be_sequence::MNG_WSTRING: if (node->unbounded ()) - *os << "TAO_Unbounded_WString_Sequence"; + { + *os << "TAO_Unbounded_WString_Sequence"; + } else - *os << "TAO_Bounded_WString_Sequence"; + { + *os << "TAO_Bounded_WString_Sequence"; + } + break; default: // not a managed type if (bt->base_node_type () == AST_Decl::NT_array) { if (node->unbounded ()) - *os << "TAO_Unbounded_Array_Sequence<"; + { + *os << "TAO_Unbounded_Array_Sequence<"; + } else - *os << "TAO_Bounded_Array_Sequence<"; + { + *os << "TAO_Bounded_Array_Sequence<"; + } } else { if (node->unbounded ()) - *os << "TAO_Unbounded_Sequence<"; + { + *os << "TAO_Unbounded_Sequence<"; + } else - *os << "TAO_Bounded_Sequence<"; + { + *os << "TAO_Bounded_Sequence<"; + } } + break; } - be_visitor_context *ctx; - ACE_NEW_RETURN (ctx, - be_visitor_context (*this->ctx_), - 0); - be_visitor_sequence_base_template_args visitor (ctx,node); - ctx->state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); + be_visitor_context ctx (*this->ctx_); + be_visitor_sequence_base_template_args visitor (&ctx, + node); + ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); if (bt->accept (&visitor) == -1) { @@ -135,7 +170,7 @@ be_visitor_sequence_cs::gen_base_sequence_class (be_sequence *node) -1); } - // find out if the sequence is of a managed type and if it is bounded or not + // Find out if the sequence is of a managed type and if it is bounded or not. if (node->managed_type () == be_sequence::MNG_STRING || node->managed_type () == be_sequence::MNG_WSTRING) { @@ -181,33 +216,31 @@ be_visitor_sequence_cs::gen_base_sequence_class (be_sequence *node) int be_visitor_sequence_cs::visit_sequence (be_sequence *node) { - // generate the constructors - be_type *bt; // type node TAO_OutStream *os = this->ctx_->stream (); if (node->cli_stub_gen () || node->imported ()) - return 0; - - // instantiation + { + return 0; + } if (this->instantiate_sequence (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "codegen. for the primitive type sequence\n"), -1); + "codegen. for the primitive type sequence\n"), + -1); } - // end of instantiation - - // generate the ifdefined macro for the sequence type + // Generate the ifdefined macro for the sequence type. os->gen_ifdef_macro (node->flat_name ()); os->indent (); // start with the current indentation level - // retrieve the base type since we may need to do some code + // Retrieve the base type since we may need to do some code // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -216,6 +249,9 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) "Bad element type\n"), -1); } + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// *************************************************************" << be_nl << "// " << node->name () << be_nl @@ -249,24 +285,19 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) // constructor with the buffer *os << node->name () << "::" << node->local_name () << " ("; + if (node->unbounded ()) { *os << "CORBA::ULong max, "; // unbounded seq takes this extra parameter } + *os << "CORBA::ULong length, "; // generate the base type for the buffer be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad visitor\n"), -1); - } + be_visitor_sequence_buffer_type bt_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&bt_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" @@ -274,48 +305,56 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) "base type visit failed\n"), -1); } - delete visitor; + *os << " *buffer, CORBA::Boolean release)" << be_nl << " : "; - // pass it to the base constructor + + // Pass it to the base constructor. if (this->gen_base_sequence_class (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" "visit_sequence - " - "codegen for base sequence class\n"), -1); + "codegen for base sequence class\n"), + -1); } + *os << " ("; + if (node->unbounded ()) { *os << "max, "; } + *os << "length, buffer, release)" << be_nl << "{}" << be_nl; - // copy constructor + // Copy constructor. *os << node->name () << "::" << node->local_name () << " (const " << node->local_name () << " &seq) // copy ctor" << be_nl << " : "; - // pass it to the base constructor + + // Pass it to the base constructor. if (this->gen_base_sequence_class (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" "visit_sequence - " - "codegen for base sequence class\n"), -1); + "codegen for base sequence class\n"), + -1); } + *os << " (seq)" << be_nl << "{}" << be_nl; - // destructor + // Destructor. *os << node->name () << "::~" << node->local_name () << " (void) // dtor" << be_nl << "{}" << be_nl - << "void " - << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl + << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" + << be_nl << "{" << be_idt_nl << node->local_name () << " *tmp = ACE_static_cast (" << node->local_name () << "*, _tao_void_pointer);" << be_nl @@ -331,9 +370,8 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) int be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) { - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -342,35 +380,44 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) "Bad element type\n"), -1); } - // generate the appropriate sequence type + // Generate the appropriate sequence type. switch (node->managed_type ()) { case be_sequence::MNG_PSEUDO: case be_sequence::MNG_OBJREF: case be_sequence::MNG_VALUE: + case be_sequence::MNG_ABSTRACT: if (node->unbounded ()) - this->gen_unbounded_obj_sequence (node); + { + this->gen_unbounded_obj_sequence (node); + } else - this->gen_bounded_obj_sequence (node); + { + this->gen_bounded_obj_sequence (node); + } + break; - case be_sequence::MNG_STRING: // sequence of strings + case be_sequence::MNG_STRING: if (!node->unbounded ()) - this->gen_bounded_str_sequence (node); - // else - // inheriting from the right class is enough + { + this->gen_bounded_str_sequence (node); + } + break; - case be_sequence::MNG_WSTRING: // sequence of strings + case be_sequence::MNG_WSTRING: if (!node->unbounded ()) - this->gen_bounded_wstr_sequence (node); - // else - // inheriting from the right class is enough + { + this->gen_bounded_wstr_sequence (node); + } + break; - default: // not a managed type + default: if (node->unbounded ()) { // TAO provides extensions for octet sequences, first find out - // if the base type is an octet (or an alias for octet) + // if the base type is an octet (or an alias for octet). be_predefined_type *predef = 0; + if (bt->base_node_type () == AST_Type::NT_pre_defined) { be_typedef* alias = @@ -389,6 +436,7 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) ); } } + if (predef != 0) { if (predef->pt() != AST_PredefinedType::PT_octet) diff --git a/TAO/TAO_IDL/be/be_visitor_structure.cpp b/TAO/TAO_IDL/be/be_visitor_structure.cpp index 53305f2da63..288b9ef1fc4 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure.cpp @@ -18,13 +18,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_field.h" +#include "be_structure.h" +#include "be_helper.h" +#include "be_extern.h" #include "be_visitor_structure.h" +#include "be_visitor_field.h" +#include "be_visitor_typecode.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_structure/structure.cpp" #include "be_visitor_structure/structure_ch.cpp" #include "be_visitor_structure/structure_ci.cpp" @@ -35,4 +38,6 @@ #include "be_visitor_structure/cdr_op_ci.cpp" #include "be_visitor_structure/cdr_op_cs.cpp" -ACE_RCSID(be, be_visitor_structure, "$Id$") +ACE_RCSID (be, + be_visitor_structure, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_structure/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_structure/any_op_ch.cpp index ccade4c7415..20dc1453dfe 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/any_op_ch.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_structure, + any_op_ch, + "$Id$") // *************************************************************************** // Structure visitor for generating Any operator declarations in the client header diff --git a/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp index 0f17e8aaf8d..b7aafca737d 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_structure, + any_op_cs, + "$Id$") // *************************************************************************** // Structure visitor for generating Any operator declarations in the client diff --git a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ch.cpp index 4f561b10d61..4185d0e2669 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ch.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_structure, + cdr_op_ch, + "$Id$") // *************************************************************************** // Structure visitor for generating CDR operator declarations in the client header // *************************************************************************** -be_visitor_structure_cdr_op_ch::be_visitor_structure_cdr_op_ch -(be_visitor_context *ctx) +be_visitor_structure_cdr_op_ch::be_visitor_structure_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_structure (ctx) { } @@ -44,15 +41,18 @@ be_visitor_structure_cdr_op_ch::~be_visitor_structure_cdr_op_ch (void) int be_visitor_structure_cdr_op_ch::visit_structure (be_structure *node) { - if (node->cli_hdr_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_hdr_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); - // generate the CDR << and >> operator declarations + // Generate the CDR << and >> operator declarations. os->indent (); + *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator<< (TAO_OutputCDR &, const " << node->name () << " &);" << be_nl; @@ -61,15 +61,16 @@ be_visitor_structure_cdr_op_ch::visit_structure (be_structure *node) << node->name () << " &);\n"; - // set the substate as generating code for the types defined in our scope + // 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_structure_cdr_op_ch::" "visit_structure - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ci.cpp index 395750ef6a2..0b273e9ebb3 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ci.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_structure, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_structure, + cdr_op_ci, + "$Id$") // *************************************************************************** // Structure visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_structure_cdr_op_ci::be_visitor_structure_cdr_op_ci -(be_visitor_context *ctx) +be_visitor_structure_cdr_op_ci::be_visitor_structure_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_structure (ctx) { } @@ -46,85 +42,102 @@ int be_visitor_structure_cdr_op_ci::visit_structure (be_structure *node) { // already generated and/or we are imported. Don't do anything. - if (node->cli_inline_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_inline_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + 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 + // 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); - // 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_structure_cdr_op_ci" "::visit_structure - " - "codegen for scope failed\n"), -1); + "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 << "ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &strm, " - << "const " << node->name () << " &_tao_aggregate)" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Set the sub state as generating code for the output operator. + this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); + + *os << "ACE_INLINE" << be_nl + << "CORBA::Boolean operator<< (" << be_idt << be_idt_nl + << "TAO_OutputCDR &strm," << be_nl + << "const " << node->name () << " &_tao_aggregate" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; - { - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_cdr_op_field_decl field_decl (new_ctx); - field_decl.visit_scope (node); - } + be_visitor_context new_ctx (*this->ctx_); + be_visitor_cdr_op_field_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 if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure_cdr_op_ci::" "visit_structure - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - *os << be_uidt_nl << ")" - << be_idt_nl + + *os << be_uidt_nl << " )"<< be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << 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 << "ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, " - << node->name () << " &_tao_aggregate)" << be_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + // Set the substate as generating code for the input operator. + this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_INPUT); + + *os << "ACE_INLINE" << be_nl + << "CORBA::Boolean operator>> (" << be_idt << be_idt_nl + << "TAO_InputCDR &strm," << be_nl + << node->name () << " &_tao_aggregate" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; - { - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_cdr_op_field_decl field_decl (new_ctx); - field_decl.visit_scope (node); - } + new_ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + field_decl.visit_scope (node); + *os << "if (" << be_idt_nl; - // 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_structure_cdr_op_ci" "::visit_structure - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - *os << be_uidt_nl << ")" - << be_idt_nl + + *os << be_uidt_nl << " )" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; node->cli_inline_cdr_op_gen (1); return 0; @@ -149,5 +162,6 @@ be_visitor_structure_cdr_op_ci::post_process (be_decl *bd) break; }; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_cs.cpp index db7f2e7cbc6..7c9c1797e4d 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_cs.cpp @@ -18,16 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_structure, + cdr_op_cs, + "$Id$") -#include "be_visitor_structure.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_structure, cdr_op_cs, "$Id$") - -be_visitor_structure_cdr_op_cs::be_visitor_structure_cdr_op_cs (be_visitor_context *ctx) +be_visitor_structure_cdr_op_cs::be_visitor_structure_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_structure (ctx) { } @@ -39,23 +36,25 @@ be_visitor_structure_cdr_op_cs::~be_visitor_structure_cdr_op_cs (void) int be_visitor_structure_cdr_op_cs::visit_structure (be_structure *node) { - if (node->cli_stub_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_stub_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } - // set the substate as generating code for the types defined in our scope + // 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_structure_cdr_op_cs::" "visit_structure - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - node->cli_stub_cdr_op_gen (1); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp index 518345c6d28..33a1ec1fa86 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp @@ -18,16 +18,10 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_structure, + structure, + "$Id$") -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, structure, "$Id$") - - -// generic struct visitor be_visitor_structure::be_visitor_structure (be_visitor_context *ctx) : be_visitor_scope (ctx) { @@ -37,74 +31,83 @@ be_visitor_structure::~be_visitor_structure (void) { } -// visit the Structure node and its scope int be_visitor_structure::visit_structure (be_structure *) { - return -1; // must be overriden + return -1; // Must be overriden. } int be_visitor_structure::visit_field (be_field *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_STRUCT_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CH); + be_visitor_field_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CI); + be_visitor_field_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CS); + be_visitor_field_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); + be_visitor_field_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); + be_visitor_field_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); + be_visitor_field_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure::" "visit_field - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure::" "visit_field - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure::" - "visit_field - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp index c116228fb52..bb5fce26466 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, structure_ch, "$Id$") - +ACE_RCSID (be_visitor_structure, + structure_ch, + "$Id$") // ****************************************************** // for client header @@ -48,19 +44,15 @@ int be_visitor_structure_ch::visit_structure (be_structure *node) { os = this->ctx_->stream (); - *os << "struct " << node->local_name () << ";" << be_nl; *os << "class " << node->local_name () << "_var;" << be_nl << be_nl; *os << "struct " << be_global->stub_export_macro () << " " << node->local_name () << be_nl - << "{" << be_idt << be_nl; + << "{" << be_idt_nl; - // Generate the _ptr_type and _var_type typedefs - // but we must protect against certain versions of g++ - *os << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" + // Generate the _ptr_type and _var_type typedefs. + *os << "typedef " << node->local_name () << "_var _var_type;" << be_nl; - *os << "typedef " << node->local_name () << "_var _var_type;\n" - << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n" << be_nl; *os << "static void _tao_any_destructor (void*);" << be_nl << be_nl; @@ -90,7 +82,7 @@ int be_visitor_structure_ch::visit_structure (be_structure *node) // A class is generated for an out defn only for a variable // length struct. - if (node->size_type () == be_decl::VARIABLE) + if (node->size_type () == AST_Type::VARIABLE) { if (node->gen_out_defn () == -1) { @@ -107,19 +99,20 @@ int be_visitor_structure_ch::visit_structure (be_structure *node) << node->local_name () << "_out;" << be_nl << be_nl; } - be_visitor *visitor; - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) + if (be_global->tc_support ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_ch::" - "visit_structure - " - "TypeCode declaration failed\n" - ), - -1); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); + be_visitor_typecode_decl visitor (&ctx); + + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_structure_ch::" + "visit_structure - " + "TypeCode declaration failed\n"), + -1); + } } node->cli_hdr_gen (I_TRUE); diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_ci.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_ci.cpp index 8271008eb2b..c80cd5f007d 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_ci.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, structure_ci, "$Id$") - +ACE_RCSID (be_visitor_structure, + structure_ci, + "$Id$") // ****************************************************** // for client inline @@ -50,25 +45,32 @@ int be_visitor_structure_ci::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure_ci::" "visit_structure - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } - if (node->size_type () == be_decl::VARIABLE && + + if (node->size_type () == AST_Type::VARIABLE && node->gen_out_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure_ci::" "visit_structure - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } + // all we have to do is to visit the scope if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure_ci::" "visit_structure - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } + node->cli_inline_gen (I_TRUE); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp index 223d8e547d7..e17860f3972 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp @@ -18,18 +18,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_structure.h" -#include "be_visitor_typecode/typecode_defn.h" - -ACE_RCSID(be_visitor_structure, structure_cs, "$Id$") - +ACE_RCSID (be_visitor_structure, + structure_cs, + "$Id$") // *************************************************************************** -// for client stubs +// For client stubs. // *************************************************************************** + be_visitor_structure_cs::be_visitor_structure_cs (be_visitor_context *ctx) : be_visitor_structure (ctx) { @@ -39,8 +35,8 @@ be_visitor_structure_cs::~be_visitor_structure_cs (void) { } -// Visit the structure node and its scope. -int be_visitor_structure_cs::visit_structure (be_structure *node) +int +be_visitor_structure_cs::visit_structure (be_structure *node) { if (!node->cli_stub_gen () && !node->imported ()) { @@ -88,4 +84,5 @@ int be_visitor_structure_cs::visit_structure (be_structure *node) } return 0; + } diff --git a/TAO/TAO_IDL/be/be_visitor_structure_fwd.cpp b/TAO/TAO_IDL/be/be_visitor_structure_fwd.cpp new file mode 100644 index 00000000000..3d9cd997639 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_structure_fwd.cpp @@ -0,0 +1,31 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_visitor_structure_fwd.cpp +// +// = DESCRIPTION +// Visitors for generation of code for be_structure_fwd +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_structure_fwd.h" + +#include "be_visitor_structure_fwd.h" +#include "be_visitor_context.h" +#include "be_helper.h" + +#include "be_visitor_structure_fwd/structure_fwd_ch.cpp" + +ACE_RCSID (be, + be_visitor_structure_fwd, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_structure_fwd/structure_fwd_ch.cpp b/TAO/TAO_IDL/be/be_visitor_structure_fwd/structure_fwd_ch.cpp new file mode 100644 index 00000000000..c923cfa3987 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_structure_fwd/structure_fwd_ch.cpp @@ -0,0 +1,53 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// structure_fwd_ch.cpp +// +// = DESCRIPTION +// Visitor generating code for be_structure_fwd node in the client header. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +ACE_RCSID (be_visitor_structure_fwd, + structure_fwd_ch, + "$Id$") + +be_visitor_structure_fwd_ch::be_visitor_structure_fwd_ch ( + be_visitor_context *ctx + ) + : be_visitor_decl (ctx) +{ +} + +be_visitor_structure_fwd_ch::~be_visitor_structure_fwd_ch (void) +{ +} + +// Visit the interface_fwd_ch node and its scope. +int +be_visitor_structure_fwd_ch::visit_structure_fwd (be_structure_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + if (node->cli_hdr_gen () || node->imported ()) + { + return 0; + } + + // Generate a forward declaration of the class. + *os << "struct " << node->local_name () << ";" << be_nl; + + node->cli_hdr_gen (I_TRUE); + + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode.cpp index 9267ece581e..9f39e9c258a 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode.cpp @@ -18,15 +18,34 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_array.h" +#include "be_enum.h" +#include "be_enum_val.h" +#include "be_exception.h" +#include "be_field.h" +#include "be_interface.h" +#include "be_module.h" +#include "be_predefined_type.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_type.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_union_branch.h" +#include "be_valuetype.h" +#include "be_helper.h" +#include "be_extern.h" +#include "utl_identifier.h" +#include "ast_union_label.h" #include "be_visitor_typecode.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_typecode/typecode_decl.cpp" #include "be_visitor_typecode/typecode_defn.cpp" -ACE_RCSID(be, be_visitor_typecode, "$Id$") +ACE_RCSID (be, + be_visitor_typecode, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp index aac1ea44444..5b371afd375 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typecode.h" - -ACE_RCSID(be_visitor_typecode, typecode_decl, "$Id$") - +ACE_RCSID (be_visitor_typecode, + typecode_decl, + "$Id$") // ****************************************************** // TypeCode declarations @@ -45,6 +40,9 @@ be_visitor_typecode_decl::visit_type (be_type *node) { TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if (node->is_nested ()) { // We have a scoped name. diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp index ad6851a9c3b..b5f83a29753 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp @@ -18,19 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_typecode, + typecode_defn, + "$Id$") -#include "be_visitor_typecode.h" - -ACE_RCSID(be_visitor_typecode, typecode_defn, "$Id$") - - -// // This is an implementation of C++ "scoped lock" idiom in order to // avoid repetitive code. -// class Scoped_Compute_Queue_Guard { public: @@ -48,17 +41,18 @@ Scoped_Compute_Queue_Guard::Scoped_Compute_Queue_Guard ( { if (customer_ != 0) { - // reset the compute queue to set the stage for computing our - // encapsulation length + // Reset the compute queue to set the stage for computing our + // encapsulation length. customer_->queue_reset (customer_->compute_queue_); } } + Scoped_Compute_Queue_Guard::~Scoped_Compute_Queue_Guard (void) { if (customer_ != 0) { - // reset the compute queue since we must not affect computation of other - // nodes + // Reset the compute queue since we must not affect computation of other + // nodes. customer_->queue_reset (customer_->compute_queue_); } } @@ -286,6 +280,9 @@ be_visitor_typecode_defn::visit_type (be_type *node) -1); } + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->indent (); // start from current indentation level // Generate the typecode information here @@ -336,19 +333,11 @@ be_visitor_typecode_defn::visit_type (be_type *node) *os << "CORBA::tk_except"; break; case AST_Decl::NT_interface: - { - // Yet another fruit of interface being a valuetype sometimes :-( - AST_Interface* iface = AST_Interface::narrow_from_decl (node); - if (iface != 0 && iface->is_valuetype ()) - { - *os << "CORBA::tk_value"; - } - else - { - *os << "CORBA::tk_objref"; - } - break; - } + *os << "CORBA::tk_objref"; + break; + case AST_Decl::NT_valuetype: + *os << "CORBA::tk_value"; + break; case AST_Decl::NT_sequence: *os << "CORBA::tk_sequence"; break; @@ -391,6 +380,7 @@ be_visitor_typecode_defn::visit_type (be_type *node) { *os << "TAO_NAMESPACE_TYPE (CORBA::TypeCode_ptr)" << be_nl; be_module *module = be_module::narrow_from_scope (node->defined_in ()); + if (!module || (this->gen_nested_namespace_begin (module) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, @@ -398,17 +388,21 @@ be_visitor_typecode_defn::visit_type (be_type *node) "Error parsing nested name\n"), -1); } - *os << "TAO_NAMESPACE_DEFINE (::CORBA::TypeCode_ptr, _tc_"; + + *os << "TAO_NAMESPACE_DEFINE (" << be_idt << be_idt_nl + << "::CORBA::TypeCode_ptr," << be_nl + << "_tc_"; // Local name generation. *os << node->local_name (); - *os << ", &_tc_TAO_tc_"; + *os << "," << be_nl + << "&_tc_TAO_tc_"; // Flat name generation. *os << node->flat_name (); - *os << ")" << be_nl; + *os << be_uidt_nl << ")" << be_uidt_nl; if (this->gen_nested_namespace_end (module) == -1) { @@ -1285,7 +1279,7 @@ be_visitor_typecode_defn::gen_encapsulation (be_field *node) node->visibility() == AST_Field::vis_PRIVATE ? 0 : 1; os->indent (); // start from current indentation level - *os << visibility << ", // data memeber visibility marker" + *os << visibility << ", // data member visibility marker" << "\n\n"; this->tc_offset_ += sizeof (ACE_CDR::ULong); @@ -2095,7 +2089,7 @@ be_visitor_typecode_defn::gen_encapsulation (be_union_branch *node) this->tc_offset_ += sizeof (ACE_CDR::ULong); break; - case AST_Expression::EV_any: + case AST_Expression::EV_enum: // enum os->print ("0x%08.8x", (unsigned long)ev->u.eval); // size of any aligned to 4 bytes @@ -2178,7 +2172,7 @@ be_visitor_typecode_defn::gen_encapsulation (be_union_branch *node) this->tc_offset_ += sizeof (ACE_CDR::ULong); break; - case AST_Expression::EV_any: + case AST_Expression::EV_enum: // enum os->print ("0x%08.8x", (unsigned long)dv.u.enum_val); // size of short/wchar aligned to 4 bytes @@ -2327,7 +2321,7 @@ be_visitor_typecode_defn::gen_encapsulation (be_valuetype *node) // TAO doesn't support neither CUSTOM nor TRUNCATABLE // valuetypes. So basically need to choose between // VM_NONE = 0 and VM_ABSTRACT = 2 - ACE_CDR::ULong value_modifier = node->is_abstract_valuetype () ? 2 : 0; + ACE_CDR::ULong value_modifier = node->is_abstract () ? 2 : 0; *os << value_modifier << ", // value modifier" << "\n"; @@ -2335,19 +2329,14 @@ be_visitor_typecode_defn::gen_encapsulation (be_valuetype *node) //STEP 4: generate TypeCode of concrete base - AST_Interface *inherited = 0; - if (node->n_inherits () > 0 && - ( // Statefull base valuetype is always first - inherited = - AST_Interface::narrow_from_decl(node->inherits ()[0]) - ) != 0 && - inherited->is_valuetype () && - !inherited->is_abstract () - ) + AST_ValueType *concrete_inherited = node->inherits_concrete (); + + if (concrete_inherited != 0) { // Got non-abstract base valuetype. Now emit its typecode - be_valuetype *vt = be_valuetype::narrow_from_decl(node->inherits ()[0]); + be_valuetype *vt = be_valuetype::narrow_from_decl(concrete_inherited); this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE_NESTED); + if (!vt || vt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -2356,6 +2345,7 @@ be_visitor_typecode_defn::gen_encapsulation (be_valuetype *node) ACE_TEXT ("failed to generate typecode\n")), -1); } + // revert the state to what it was before this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE); } @@ -3270,22 +3260,17 @@ be_visitor_typecode_defn::compute_encap_length (be_valuetype *node) // STEP 5: get encapsulation length for concrete base valuetype - AST_Interface *inherited = 0; - if (node->n_inherits () > 0 && - ( // Statefull abse valuetype is always first - inherited = - AST_Interface::narrow_from_decl(node->inherits ()[0]) - ) != 0 && - inherited->is_valuetype () && - !inherited->is_abstract () - ) + AST_ValueType *concrete_inherited = node->inherits_concrete (); + + if (concrete_inherited != 0) { // Got non-abstract base valuetype. this->computed_tc_size_ = 0; - be_valuetype *vt = be_valuetype::narrow_from_decl(node->inherits ()[0]); + be_valuetype *vt = be_valuetype::narrow_from_decl (concrete_inherited); this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TC_SIZE); + if (!vt || vt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, diff --git a/TAO/TAO_IDL/be/be_visitor_typedef.cpp b/TAO/TAO_IDL/be/be_visitor_typedef.cpp index c9ca1e8818f..964aa163a76 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef.cpp @@ -18,13 +18,28 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_array.h" +#include "be_enum.h" +#include "be_interface.h" +#include "be_predefined_type.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_type.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_extern.h" +#include "be_helper.h" #include "be_visitor_typedef.h" +#include "be_visitor_array.h" +#include "be_visitor_enum.h" +#include "be_visitor_sequence.h" +#include "be_visitor_structure.h" +#include "be_visitor_typecode.h" +#include "be_visitor_union.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_typedef/typedef.cpp" #include "be_visitor_typedef/typedef_ch.cpp" #include "be_visitor_typedef/typedef_ci.cpp" @@ -35,4 +50,6 @@ #include "be_visitor_typedef/cdr_op_ci.cpp" #include "be_visitor_typedef/cdr_op_cs.cpp" -ACE_RCSID(be, be_visitor_typedef, "$Id$") +ACE_RCSID (be, + be_visitor_typedef, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/any_op_ch.cpp index 0d6aec20e8d..2340ba59374 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/any_op_ch.cpp @@ -18,21 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_typedef, + any_op_ch, + "$Id$") // *************************************************************************** // Typedef visitor for generating Any operator declarations in the client header // *************************************************************************** -be_visitor_typedef_any_op_ch::be_visitor_typedef_any_op_ch -(be_visitor_context *ctx) +be_visitor_typedef_any_op_ch::be_visitor_typedef_any_op_ch ( + be_visitor_context *ctx + ) : be_visitor_typedef (ctx) { } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/any_op_cs.cpp index 6d8a868df16..9e01f31dc19 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/any_op_cs.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_typedef, + any_op_cs, + "$Id$") // *************************************************************************** // Typedef visitor for generating Any operator declarations in the client // stubs file // *************************************************************************** -be_visitor_typedef_any_op_cs::be_visitor_typedef_any_op_cs -(be_visitor_context *ctx) +be_visitor_typedef_any_op_cs::be_visitor_typedef_any_op_cs ( + be_visitor_context *ctx + ) : be_visitor_typedef (ctx) { } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ch.cpp index 59c3cfc9187..733e20b1715 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ch.cpp @@ -18,21 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, cdr_op_ch, "$Id$") - +ACE_RCSID (be_visitor_typedef, + cdr_op_ch, + "$Id$") // *************************************************************************** // Typedef visitor for generating Cdr operator declarations in the client header // *************************************************************************** -be_visitor_typedef_cdr_op_ch::be_visitor_typedef_cdr_op_ch -(be_visitor_context *ctx) +be_visitor_typedef_cdr_op_ch::be_visitor_typedef_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_typedef (ctx) { } @@ -51,7 +47,7 @@ be_visitor_typedef_cdr_op_ch::visit_typedef (be_typedef *node) TAO_OutStream *os = this->ctx_->stream (); - // generate the CDR << and >> operator declarations + // Generate the CDR << and >> operator declarations. os->indent (); // In general, we may have a chain of typedefs. i.e., diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ci.cpp index 99b7c108306..573a3125c1f 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ci.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, cdr_op_ci, "$Id$") - +ACE_RCSID (be_visitor_typedef, + cdr_op_ci, + "$Id$") // *************************************************************************** // Typedef visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_typedef_cdr_op_ci::be_visitor_typedef_cdr_op_ci -(be_visitor_context *ctx) +be_visitor_typedef_cdr_op_ci::be_visitor_typedef_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_typedef (ctx) { } @@ -50,12 +46,6 @@ be_visitor_typedef_cdr_op_ci::visit_typedef (be_typedef *node) return 0; } - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator impls - - os->indent (); - // In general, we may have a chain of typedefs. i.e., // typedef sequence<long> X; // typedef X Y; diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_cs.cpp index 91ab655906d..ba1e87f43be 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_cs.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, cdr_op_cs, "$Id$") - +ACE_RCSID (be_visitor_typedef, + cdr_op_cs, + "$Id$") // *************************************************************************** // Typedef visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_typedef_cdr_op_cs::be_visitor_typedef_cdr_op_cs -(be_visitor_context *ctx) +be_visitor_typedef_cdr_op_cs::be_visitor_typedef_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_typedef (ctx) { } @@ -46,13 +42,9 @@ int be_visitor_typedef_cdr_op_cs::visit_typedef (be_typedef *node) { if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator impls - - os->indent (); + { + return 0; + } // In general, we may have a chain of typedefs. i.e., // typedef sequence<long> X; @@ -88,13 +80,14 @@ be_visitor_typedef_cdr_op_cs::visit_typedef (be_typedef *node) // grab the most primitive base type in the chain to avoid recusrsively // going thru this visit method bt = node->primitive_base_type (); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_typedef - " - "bad primitive base type\n" - ), -1); + "bad primitive base type\n"), + -1); } // accept on this base type, but generate code for the typedef node @@ -103,9 +96,10 @@ be_visitor_typedef_cdr_op_cs::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + this->ctx_->alias (0); // reset } else @@ -116,13 +110,14 @@ be_visitor_typedef_cdr_op_cs::visit_typedef (be_typedef *node) // grab the immediate base type node bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_typedef - " - "bad base type\n" - ), -1); + "bad base type\n"), + -1); } // accept on this base type, but generate code for the typedef node @@ -131,8 +126,8 @@ be_visitor_typedef_cdr_op_cs::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } this->ctx_->tdef (0); // reset @@ -148,9 +143,13 @@ be_visitor_typedef_cdr_op_cs::visit_array (be_array *node) be_type *bt; if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!bt->imported () && bt->node_type () == AST_Decl::NT_array) // direct typedef of a base node @@ -162,8 +161,8 @@ be_visitor_typedef_cdr_op_cs::visit_array (be_array *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_array - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } @@ -171,41 +170,18 @@ be_visitor_typedef_cdr_op_cs::visit_array (be_array *node) } int -be_visitor_typedef_cdr_op_cs::visit_enum (be_enum *node) +be_visitor_typedef_cdr_op_cs::visit_sequence (be_sequence *node) { be_type *bt; if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); - else - bt = node; - - if (bt->node_type () == AST_Decl::NT_enum) // direct typedef of a base node - // type { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_enum (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_cs::" - "visit_enum - " - "base class visitor failed \n" - ), -1); - } + bt = this->ctx_->alias (); } - - return 0; -} - -int -be_visitor_typedef_cdr_op_cs::visit_sequence (be_sequence *node) -{ - be_type *bt; - - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); else - bt = node; + { + bt = node; + } if (bt->node_type () == AST_Decl::NT_sequence) // direct typedef of a base node // type @@ -216,8 +192,8 @@ be_visitor_typedef_cdr_op_cs::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_sequence - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } @@ -230,9 +206,13 @@ be_visitor_typedef_cdr_op_cs::visit_structure (be_structure *node) be_type *bt; if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (bt->node_type () == AST_Decl::NT_struct) // direct typedef of a base node // type @@ -243,8 +223,8 @@ be_visitor_typedef_cdr_op_cs::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_structure - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } @@ -257,9 +237,13 @@ be_visitor_typedef_cdr_op_cs::visit_union (be_union *node) be_type *bt; if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (bt->node_type () == AST_Decl::NT_union) // direct typedef of a base node // type @@ -270,8 +254,8 @@ be_visitor_typedef_cdr_op_cs::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cdr_op_cs::" "visit_union - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp index 26c232861b3..baa0f690316 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp @@ -18,17 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef, "$Id$") - +ACE_RCSID (be_visitor_typedef, + typedef, + "$Id$") // ****************************************************** -// Generic Typedef visitor +// Generic typedef visitor. // ****************************************************** be_visitor_typedef::be_visitor_typedef (be_visitor_context *ctx) @@ -40,123 +35,156 @@ be_visitor_typedef::~be_visitor_typedef (void) { } -// visit the Typedef node and its scope int be_visitor_typedef::visit_typedef (be_typedef *) { - return -1; // must be overridden + return -1; // Must be overridden. } -// =all common visit methods for typedef visitor +// All common visit methods for typedef visitor. -// visit a array int be_visitor_typedef::visit_array (be_array *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CH); + be_visitor_array_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CI); + be_visitor_array_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_ARRAY_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CS); + be_visitor_array_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CH); + be_visitor_array_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CS); + be_visitor_array_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); + be_visitor_array_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); + be_visitor_array_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); + be_visitor_array_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_array - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_array - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_array - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_typedef::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; case TAO_CodeGen::TAO_TYPEDEF_CI: return 0; // nothing to be done default: @@ -164,316 +192,287 @@ be_visitor_typedef::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_enum - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an predefined type -int -be_visitor_typedef::visit_predefined_type (be_predefined_type *) -{ - return 0; -} - -// visit an sequence int be_visitor_typedef::visit_sequence (be_sequence *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); + be_visitor_sequence_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); + be_visitor_sequence_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); + be_visitor_sequence_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CH); + be_visitor_sequence_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CS); + be_visitor_sequence_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); + be_visitor_sequence_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI); + be_visitor_sequence_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); + be_visitor_sequence_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_sequence - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_sequence - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_sequence - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } // visit an structure int -be_visitor_typedef::visit_string (be_string *node) +be_visitor_typedef::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; - case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - return 0; // nothing to be done - default: { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_string - " - "Bad context state\n" - ), -1); + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_string - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_string - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -// visit an structure -int -be_visitor_typedef::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_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an union int be_visitor_typedef::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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_union - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp index 6a7af384273..87f974ce764 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef_ch, "$Id$") - +ACE_RCSID(be_visitor_typedef, + typedef_ch, + "$Id$") // ****************************************************** // Typedef visitor for client header @@ -83,8 +78,7 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad primitive base type\n" - ), + "bad primitive base type\n"), -1); } @@ -94,8 +88,7 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), + "failed to accept visitor\n"), -1); } @@ -115,9 +108,8 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad base type\n" - ), - -1); + "bad base type\n"), + -1); } // accept on this base type, but generate code for the typedef node. @@ -126,28 +118,23 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), - -1); + "failed to accept visitor\n"), + -1); } // Generate the typecode decl for this typedef node. - // @@ NW: !bt->is_local () is a hack. There should be a way to - // propagate bt's info up to typedef. - if (!node->imported ()) + if (!node->imported () && be_global->tc_support ()) { - be_visitor *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_decl visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "TypeCode declaration failed\n" - ), + "TypeCode declaration failed\n"), -1); } } @@ -264,8 +251,7 @@ be_visitor_typedef_ch::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_enum - " - "base class visitor failed \n" - ), + "base class visitor failed \n"), -1); } } @@ -339,8 +325,11 @@ be_visitor_typedef_ch::visit_predefined_type (be_predefined_type *node) *os << "typedef " << bt->nested_type_name (scope) << " " << tdef->nested_type_name (scope) << ";" << be_nl; - if ((node->pt () == AST_PredefinedType::PT_pseudo) || - (node->pt () == AST_PredefinedType::PT_any)) + AST_PredefinedType::PredefinedType pt = node->pt (); + + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_any + || pt == AST_PredefinedType::PT_object) { // Typedef the _ptr and _var. *os << "typedef " << bt->nested_type_name (scope, "_ptr") @@ -413,8 +402,8 @@ be_visitor_typedef_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_sequence - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } else @@ -458,8 +447,8 @@ be_visitor_typedef_ch::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_structure - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } @@ -501,8 +490,8 @@ be_visitor_typedef_ch::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_union - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ci.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ci.cpp index b52ec2b573d..8e0587ef0a1 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ci.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef_ci, "$Id$") - +ACE_RCSID (be_visitor_typedef, + typedef_ci, + "$Id$") // ****************************************************** // Typedef visitor for client inline @@ -77,22 +72,24 @@ be_visitor_typedef_ci::visit_typedef (be_typedef *node) // grab the most primitive base type in the chain to avoid recusrsively // going thru this visit method bt = node->primitive_base_type (); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad primitive base type\n" - ), -1); + "bad primitive base type\n"), + -1); } + // accept on this base type if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } this->ctx_->alias (0); @@ -105,26 +102,29 @@ be_visitor_typedef_ci::visit_typedef (be_typedef *node) // grab the immediate base type node bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad base type\n" - ), -1); + "bad base type\n"), + -1); } + // accept on this base type if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } this->ctx_->tdef (0); } + return 0; } @@ -213,6 +213,7 @@ be_visitor_typedef_ci::visit_array (be_array *node) *os << bt->name () << "_free (_tao_src);" << be_uidt_nl; *os << "}\n\n"; } + return 0; } @@ -222,9 +223,13 @@ be_visitor_typedef_ci::visit_sequence (be_sequence *node) be_type *bt; if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (bt->node_type () == AST_Decl::NT_sequence) // direct typedef of a base node // type @@ -235,10 +240,11 @@ be_visitor_typedef_ci::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ci::" "visit_sequence - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } + return 0; } @@ -248,9 +254,13 @@ be_visitor_typedef_ci::visit_structure (be_structure *node) be_type *bt; if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (bt->node_type () == AST_Decl::NT_struct) // direct typedef of a base node // type @@ -261,10 +271,11 @@ be_visitor_typedef_ci::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ci::" "visit_structure - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } + return 0; } @@ -274,9 +285,13 @@ be_visitor_typedef_ci::visit_union (be_union *node) be_type *bt; if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (bt->node_type () == AST_Decl::NT_union) // direct typedef of a base node // type @@ -287,9 +302,10 @@ be_visitor_typedef_ci::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ci::" "visit_union - " - "base class visitor failed \n" - ), -1); + "base class visitor failed \n"), + -1); } } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp index 24e8b23599d..d0cc395424e 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef_cs, "$Id$") - +ACE_RCSID (be_visitor_typedef, + typedef_cs, + "$Id$") // ****************************************************** // Typedef visitor for client stubs @@ -68,82 +63,83 @@ be_visitor_typedef_cs::visit_typedef (be_typedef *node) if (this->ctx_->tdef ()) { - // the fact that we are here indicates that we were generating code for a + // The fact that we are here indicates that we were generating code for a // typedef node whose base type also happens to be another typedef-ed - // (i.e. an alias) node for another (possibly alias) node + // (i.e. an alias) node for another (possibly alias) node. this->ctx_->alias (node); // save this alias - // grab the most primitive base type in the chain to avoid recusrsively - // going thru this visit method + // Grab the most primitive base type in the chain to avoid recusrsively + // going thru this visit method. bt = node->primitive_base_type (); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad primitive base type\n" - ), -1); + "bad primitive base type\n"), + -1); } - // accept on this base type + + // Accept on this base type. if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + this->ctx_->alias (0); } else { - // the context has not stored any "tdef" node. So we must be in here for - // the first time - this->ctx_->tdef (node); // save the typedef node + // The context has not stored any "tdef" node. So we must be in here for + // the first time. + this->ctx_->tdef (node); - // grab the immediate base type node + // Grab the immediate base type node. bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad base type\n" - ), -1); + "bad base type\n"), + -1); } - // accept on this base type + + // Accept on this base type. if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // @@ NW: !bt->is_local () is a hack. There should be a way to - // propagate bt's info up to typedef. - if (!node->imported ()) + if (!node->imported () && be_global->tc_support ()) { - // 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 *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_typecode_defn visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cs::" "visit_typedef - " - "TypeCode definition failed\n" - ), -1); + "TypeCode definition failed\n"), + -1); } } + this->ctx_->tdef (0); } diff --git a/TAO/TAO_IDL/be/be_visitor_union.cpp b/TAO/TAO_IDL/be/be_visitor_union.cpp index 17db8dd01ab..74e16f5ad55 100644 --- a/TAO/TAO_IDL/be/be_visitor_union.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union.cpp @@ -18,13 +18,22 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_enum.h" +#include "be_typedef.h" +#include "be_predefined_type.h" +#include "be_union.h" +#include "be_union_branch.h" +#include "be_helper.h" +#include "be_extern.h" +#include "ast_union_label.h" #include "be_visitor_union.h" +#include "be_visitor_enum.h" +#include "be_visitor_context.h" +#include "be_visitor_union_branch.h" +#include "be_visitor_typecode.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_union/discriminant_ch.cpp" #include "be_visitor_union/discriminant_ci.cpp" #include "be_visitor_union/discriminant_cs.cpp" @@ -38,4 +47,6 @@ #include "be_visitor_union/cdr_op_ci.cpp" #include "be_visitor_union/cdr_op_cs.cpp" -ACE_RCSID(be, be_visitor_union, "$Id$") +ACE_RCSID (be, + be_visitor_union, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_union/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/any_op_ch.cpp index 3c5a274d353..8f1c86c4cbf 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/any_op_ch.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_union, + any_op_ch, + "$Id$") // *************************************************************************** // Union visitor for generating Any operator declarations in the client header @@ -45,7 +41,8 @@ int be_visitor_union_any_op_ch::visit_union (be_union *node) { if (node->cli_hdr_any_op_gen () - || node->imported ()) + || node->imported () + || node->is_local ()) { return 0; } @@ -68,8 +65,6 @@ be_visitor_union_any_op_ch::visit_union (be_union *node) << " operator>>= (const CORBA::Any &, const " << node->name () << " *&);\n"; - - // All we have to do is to visit the scope and generate code. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, diff --git a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp index 7d1f3b73b84..5590f63a5af 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_union, + any_op_cs, + "$Id$") // *************************************************************************** // Union visitor for generating Any operator declarations in the client @@ -53,17 +49,10 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) TAO_OutStream *os = this->ctx_->stream (); - // Generate the Any <<= and >>= operator definitions. + // Generate the Any <<= and >>= operator declarations. os->indent (); - *os << be_nl - << "// TAO_IDL - Generated from " << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - - // Copying insertion oeprator. - - *os << "// Copying insertion." << be_nl - << "void operator<<= (" << be_idt << be_idt_nl + *os << "void operator<<= (" << be_idt << be_idt_nl << "CORBA::Any &_tao_any," << be_nl << "const " << node->name () << " &_tao_elem" << be_uidt_nl << ")" << be_uidt_nl @@ -261,10 +250,7 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) int be_visitor_union_any_op_cs::visit_union_branch (be_union_branch *node) { - be_type *bt; - - // First generate the type information. - bt = be_type::narrow_from_decl (node->field_type ()); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { diff --git a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ch.cpp index 80cb8e824ba..12169e60ba5 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ch.cpp @@ -19,20 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_union, + cdr_op_ch, + "$Id$") // *************************************************************************** // Union visitor for generating CDR operator declarations in the client header // *************************************************************************** -be_visitor_union_cdr_op_ch::be_visitor_union_cdr_op_ch -(be_visitor_context *ctx) +be_visitor_union_cdr_op_ch::be_visitor_union_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_union (ctx) { } @@ -44,15 +41,18 @@ be_visitor_union_cdr_op_ch::~be_visitor_union_cdr_op_ch (void) int be_visitor_union_cdr_op_ch::visit_union (be_union *node) { - if (node->cli_hdr_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_hdr_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); - // generate the CDR << and >> operator declarations + // Generate the CDR << and >> operator declarations. os->indent (); + *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator<< (TAO_OutputCDR &, const " << node->name () << " &);" << be_nl; @@ -61,15 +61,16 @@ be_visitor_union_cdr_op_ch::visit_union (be_union *node) << node->name () << " &);\n"; - // set the substate as generating code for the types defined in our scope + // 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_union_cdr_op_ch::" "visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } node->cli_hdr_cdr_op_gen (1); diff --git a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp index ae148558877..cf17212389f 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp @@ -18,21 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_union, + cdr_op_ci, + "$Id$") // *************************************************************************** // Union visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_union_cdr_op_ci::be_visitor_union_cdr_op_ci -(be_visitor_context *ctx) +be_visitor_union_cdr_op_ci::be_visitor_union_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_union (ctx) { } @@ -45,28 +42,35 @@ int be_visitor_union_cdr_op_ci::visit_union (be_union *node) { // already generated and/or we are imported. Don't do anything. - if (node->cli_inline_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_inline_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } - // set the substate as generating code for the types defined in our scope + // 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_union_cdr_op_ci" "::visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); - // set the sub state as generating code for the output operator + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // 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<< (" << be_idt << be_idt_nl + *os << "ACE_INLINE" << be_nl + << "CORBA::Boolean operator<< (" << be_idt << be_idt_nl << "TAO_OutputCDR &strm," << be_nl << "const " << node->name () << " &_tao_union" << be_uidt_nl << ")" << be_uidt_nl @@ -77,27 +81,28 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) case AST_Expression::EV_bool: *os << "CORBA_Any::from_boolean tmp (_tao_union._d ());" << be_nl << "if ( !(strm << tmp) )" << be_idt_nl; - break; + break; case AST_Expression::EV_char: *os << "CORBA_Any::from_char tmp (_tao_union._d ());" << be_nl << "if ( !(strm << tmp) )" << be_idt_nl; - break; + break; case AST_Expression::EV_wchar: *os << "CORBA_Any::from_wchar tmp (_tao_union._d ());" << be_nl << "if ( !(strm << tmp) )" << be_idt_nl; - break; + break; default: *os << "if ( !(strm << _tao_union._d ()) )" << be_idt_nl; + break; } *os << "{" << be_idt_nl << "return 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "CORBA::Boolean result = 1;" << be_nl + << "}" << be_uidt_nl << be_nl + << "CORBA::Boolean result = 1;" << be_nl << be_nl << "switch (_tao_union._d ())" << be_nl << "{" << be_idt_nl; @@ -106,7 +111,8 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cdr_op_ci::" "visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } // If there is no explicit default case, but there @@ -123,13 +129,14 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) *os << "break;"; } - *os << be_uidt_nl << "}" << be_nl + *os << be_uidt_nl << "}" << be_nl << be_nl << "return result;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; - // set the substate as generating code for the input operator + // Set the substate as generating code for the input operator. this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - *os << "ACE_INLINE CORBA::Boolean operator>> (" << be_idt << be_idt_nl + *os << "ACE_INLINE" << be_nl + << "CORBA::Boolean operator>> (" << be_idt << be_idt_nl << "TAO_InputCDR &strm," << be_nl << node->name () << " &_tao_union" << be_uidt_nl << ")" << be_uidt_nl @@ -147,27 +154,28 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) case AST_Expression::EV_bool: *os << "CORBA_Any::to_boolean tmp (_tao_discriminant);" << be_nl << "if ( !(strm >> tmp) )" << be_idt_nl; - break; + break; case AST_Expression::EV_char: *os << "CORBA_Any::to_char tmp (_tao_discriminant);" << be_nl << "if ( !(strm >> tmp) )" << be_idt_nl; - break; + break; case AST_Expression::EV_wchar: *os << "CORBA_Any::to_wchar tmp (_tao_discriminant);" << be_nl << "if ( !(strm >> tmp) )" << be_idt_nl; - break; + break; default: *os << "if ( !(strm >> _tao_discriminant) )" << be_idt_nl; + break; } *os << "{" << be_idt_nl << "return 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "CORBA::Boolean result = 1;" << be_nl + << "}" << be_uidt_nl << be_nl + << "CORBA::Boolean result = 1;" << be_nl << be_nl << "switch (_tao_discriminant)" << be_nl << "{" << be_idt_nl; @@ -176,7 +184,8 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cdr_op_ci::" "visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } // If there is no explicit default case, but there @@ -194,9 +203,9 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) *os << "break;" << be_uidt << be_uidt_nl; } - *os << "}" << be_nl + *os << "}" << be_nl << be_nl << "return result;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; node->cli_inline_cdr_op_gen (1); return 0; @@ -210,6 +219,14 @@ be_visitor_union_cdr_op_ci::pre_process (be_decl *bd) return 0; } + // Enum val nodes are added just to help check reference + // clashes, since an enum declared in our scope is not itself + // a scope. + if (bd->node_type () == AST_Decl::NT_enum_val) + { + return 0; + } + TAO_OutStream *os = this->ctx_->stream (); be_union_branch* b = @@ -244,13 +261,18 @@ be_visitor_union_cdr_op_ci::pre_process (be_decl *bd) } int -be_visitor_union_cdr_op_ci::post_process (be_decl *) +be_visitor_union_cdr_op_ci::post_process (be_decl *bd) { if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_SCOPE) { return 0; } + if (bd->node_type () == AST_Decl::NT_enum_val) + { + return 0; + } + TAO_OutStream *os = this->ctx_->stream (); *os << be_uidt_nl << "}" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp index 507a62dd743..05092325e82 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp @@ -18,21 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, cdr_op_cs, "$Id$") +ACE_RCSID (be_visitor_union, + cdr_op_cs, + "$Id$") // *************************************************************************** // Union visitor for generating CDR operator declarations in the client // stubs file // *************************************************************************** -be_visitor_union_cdr_op_cs::be_visitor_union_cdr_op_cs -(be_visitor_context *ctx) +be_visitor_union_cdr_op_cs::be_visitor_union_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_union (ctx) { } @@ -45,20 +42,23 @@ int be_visitor_union_cdr_op_cs::visit_union (be_union *node) { // already generated and/or we are imported. Don't do anything. - if (node->cli_stub_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_stub_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } - // set the substate as generating code for the types defined in our scope + // 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_union_cdr_op_cs" "::visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } node->cli_stub_cdr_op_gen (1); diff --git a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp index 8995f570b1e..6e376df059f 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp @@ -18,21 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, discriminant_ch, "$Id$") - +ACE_RCSID (be_visitor_union, + discriminant_ch, + "$Id$") // ************************************************************************* -// be_visitor_discriminant_ch - visitor for discriminant in client header file +// Visitor for discriminant in client header file. // ************************************************************************* -be_visitor_union_discriminant_ch::be_visitor_union_discriminant_ch -(be_visitor_context *ctx) +be_visitor_union_discriminant_ch::be_visitor_union_discriminant_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -71,27 +67,16 @@ be_visitor_union_discriminant_ch::visit_enum (be_enum *node) // 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_union_discriminant_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } + be_visitor_enum_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_discriminant_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - - delete visitor; } // The set method. @@ -143,8 +128,8 @@ be_visitor_union_discriminant_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_discriminant_ch::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); diff --git a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp index 08611d4a894..3e5a4ce5809 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp @@ -18,21 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, discriminant_ci, "$Id$") - +ACE_RCSID (be_visitor_union, + discriminant_ci, + "$Id$") // ************************************************************************* // be_visitor_discriminant_ci - visitor for discriminant in client inline file // ************************************************************************* -be_visitor_union_discriminant_ci::be_visitor_union_discriminant_ci -(be_visitor_context *ctx) +be_visitor_union_discriminant_ci::be_visitor_union_discriminant_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -44,21 +40,24 @@ be_visitor_union_discriminant_ci::~be_visitor_union_discriminant_ci (void) int be_visitor_union_discriminant_ci::visit_enum (be_enum *node) { - TAO_OutStream *os; // output stream be_union *bu = - this->ctx_->be_node_as_union (); // get the enclosing union backend + this->ctx_->be_node_as_union (); 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 (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); // now check if we need to generate the _default () method be_union::DefaultValue dv; + if (bu->default_value (dv) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -67,11 +66,14 @@ be_visitor_union_discriminant_ci::visit_enum (be_enum *node) "computing default value failed\n"), -1); } + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if ((dv.computed_ != 0) && (bu->default_index () == -1)) { // only if all cases are not covered AND there is no explicit // default, we get the _default () method - os->indent (); *os << "// the implicit _default () method" << be_nl; *os << "ACE_INLINE void " << be_nl << bu->name () << "::_default ()" << be_nl @@ -80,13 +82,17 @@ be_visitor_union_discriminant_ci::visit_enum (be_enum *node) be_type* dt = be_type::narrow_from_decl (bu->disc_type ()); + if (dt == 0) - return -1; + { + return -1; + } // Find where was the enum defined, if it was defined in the globa // scope, then it is easy to generate the enum values.... be_scope* scope = be_scope::narrow_from_scope (dt->defined_in ()); + if (scope == 0) { *os << node->value_to_name (dv.u.enum_val); @@ -99,7 +105,6 @@ be_visitor_union_discriminant_ci::visit_enum (be_enum *node) *os << ";" << be_uidt_nl << "}\n\n"; } - os->indent (); // the set method *os << "// accessor to set the discriminant" << be_nl << "ACE_INLINE void" << be_nl @@ -116,28 +121,33 @@ be_visitor_union_discriminant_ci::visit_enum (be_enum *node) << "{" << be_idt_nl << "return this->disc_;" << be_uidt_nl << "}\n\n"; + return 0; } int -be_visitor_union_discriminant_ci::visit_predefined_type (be_predefined_type - *node) +be_visitor_union_discriminant_ci::visit_predefined_type ( + be_predefined_type *node + ) { - TAO_OutStream *os; // output stream be_union *bu = this->ctx_->be_node_as_union (); // 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 (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // now check if we need to generate the _default () method + // Now check if we need to generate the _default () method. be_union::DefaultValue dv; + if (bu->default_value (dv) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -146,29 +156,38 @@ be_visitor_union_discriminant_ci::visit_predefined_type (be_predefined_type "computing default value failed\n"), -1); } + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if ((dv.computed_ != 0) && (bu->default_index () == -1)) { - // only if all cases are not covered AND there is no explicit - // default, we get the _default () method - os->indent (); + // Only if all cases are not covered AND there is no explicit + // default, we get the _default () method. + *os << "// the implicit _default () method" << be_nl; *os << "ACE_INLINE void " << be_nl << bu->name () << "::_default ()" << be_nl << "{" << be_idt_nl << "this->disc_ = "; + switch (bu->udisc_type ()) { case AST_Expression::EV_short: *os << dv.u.short_val; + break; case AST_Expression::EV_ushort: *os << dv.u.ushort_val; + break; case AST_Expression::EV_long: *os << dv.u.long_val; + break; case AST_Expression::EV_ulong: *os << dv.u.ulong_val; + break; case AST_Expression::EV_char: os->print ("'\\%d'", dv.u.char_val); @@ -178,23 +197,26 @@ be_visitor_union_discriminant_ci::visit_predefined_type (be_predefined_type break; case AST_Expression::EV_bool: *os << dv.u.bool_val; + break; case AST_Expression::EV_longlong: case AST_Expression::EV_ulonglong: - // unimplemented + // Unimplemented. default: - // error caught earlier. + // Error caught earlier. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_discriminant_ci::" "visit_predefined_type - " "bad or unimplemented discriminant type\n"), -1); } + *os << ";" << be_uidt_nl << "}\n\n"; } os->indent (); - // the set method + + // The set method. *os << "// accessor to set the discriminant" << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::_d (" << bt->name () @@ -203,33 +225,34 @@ be_visitor_union_discriminant_ci::visit_predefined_type (be_predefined_type << "this->disc_ = discval;" << be_uidt_nl << "}" << be_nl; - // the get method + // The get method. *os << "// accessor to get the discriminant" << be_nl << "ACE_INLINE " << bt->name () << be_nl << bu->name () << "::_d (void) const" << be_nl << "{" << be_idt_nl << "return this->disc_;" << be_uidt_nl << "}\n\n"; + return 0; } int be_visitor_union_discriminant_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 + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // 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_discriminant_ci::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } - this->ctx_->alias (0); + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp index 79f75f66a28..e7c719f34da 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp @@ -18,21 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, discriminant_cs, "$Id$") - +ACE_RCSID (be_visitor_union, + discriminant_cs, + "$Id$") // ************************************************************************* -// be_visitor_discriminant_cs - visitor for discriminant in client stubs +// Visitor for discriminant in client stubs. // ************************************************************************* -be_visitor_union_discriminant_cs::be_visitor_union_discriminant_cs -(be_visitor_context *ctx) +be_visitor_union_discriminant_cs::be_visitor_union_discriminant_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -48,41 +44,36 @@ be_visitor_union_discriminant_cs::visit_enum (be_enum *node) this->ctx_->be_node_as_union (); // 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 (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // 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.node (node); // generate the typecode for the enum ctx.state (TAO_CodeGen::TAO_ENUM_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_discriminant_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_discriminant_cs::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union.cpp b/TAO/TAO_IDL/be/be_visitor_union/union.cpp index 2b04aff5d46..46990af1820 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union.cpp @@ -18,16 +18,10 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_union, + union, + "$Id$") -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, union, "$Id$") - - -// generic struct visitor be_visitor_union::be_visitor_union (be_visitor_context *ctx) : be_visitor_scope (ctx) { @@ -37,86 +31,104 @@ be_visitor_union::~be_visitor_union (void) { } -// visit the Union node and its scope int be_visitor_union::visit_union (be_union *) { - return -1; // must be overriden + return -1; // Must be overriden. } int be_visitor_union::visit_union_branch (be_union_branch *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 + // 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 + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_UNION_PUBLIC_CH: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); + be_visitor_union_branch_public_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PRIVATE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); + be_visitor_union_branch_private_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_CI: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CI); + be_visitor_union_branch_public_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); + be_visitor_union_branch_public_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); + be_visitor_union_branch_public_assign_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS); - break; - case TAO_CodeGen::TAO_UNION_PUBLIC_ACCESS_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ACCESS_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS); + be_visitor_union_branch_public_reset_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CH); + be_visitor_union_branch_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CI); + be_visitor_union_branch_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CS); + be_visitor_union_branch_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union::" "visit_union_branch - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union::" "visit_union_branch - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union::" - "visit_union_branch - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp index 4744bff8f77..7a60fc6bbbb 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp @@ -18,17 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_union.h" -#include "be_visitor_typecode/typecode_decl.h" - -ACE_RCSID(be_visitor_union, union_ch, "$Id$") - +ACE_RCSID (be_visitor_union, + union_ch, + "$Id$") // ****************************************************** -// for client header +// For client header. // ****************************************************** be_visitor_union_ch::be_visitor_union_ch (be_visitor_context *ctx) @@ -40,200 +35,197 @@ be_visitor_union_ch::~be_visitor_union_ch (void) { } -// Visit the Union node and its scope. int be_visitor_union_ch::visit_union (be_union *node) { - TAO_OutStream *os; - be_type *bt; + if (node->cli_hdr_gen () || node->imported ()) + { + return 0; + } // 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); - if (!node->cli_hdr_gen () && !node->imported ()) - { - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // Generate the ifdefined macro for the union type. - os->gen_ifdef_macro (node->flat_name ()); + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; - *os << "class " << node->local_name () << ";" << be_nl; - *os << "class " << node->local_name () << "_var;" << be_nl << be_nl; + // Generate the ifdefined macro for the union type. + os->gen_ifdef_macro (node->flat_name ()); - *os << "class " << be_global->stub_export_macro () << " " - << node->local_name () << be_nl - << "{" << be_nl - << "public:" << be_idt_nl + *os << "class " << node->local_name () << "_var;" << be_nl << be_nl; - // Generate default and copy constructors. - << node->local_name () << " (void);" << be_nl - << node->local_name () << " (const " << node->local_name () - << " &);" << be_nl - // Generate destructor. - << "~" << node->local_name () << " (void);" << be_nl; + *os << "class " << be_global->stub_export_macro () << " " + << node->local_name () << be_nl + << "{" << be_nl + << "public:" << be_idt_nl - *os << "static void _tao_any_destructor (void*);" - << be_nl << be_nl; + // Generate default and copy constructors. + << node->local_name () << " (void);" << be_nl + << node->local_name () << " (const " << node->local_name () + << " &);" << be_nl + // Generate destructor. + << "~" << node->local_name () << " (void);" << be_nl; - // Generate assignment operator. - *os << node->local_name () << " &operator= (const " - << node->local_name () << " &);" << be_nl << be_nl; + *os << "static void _tao_any_destructor (void*);" + << be_nl << be_nl; - // Retrieve the disriminant type. - bt = be_type::narrow_from_decl (node->disc_type ()); + // Generate assignment operator. + *os << node->local_name () << " &operator= (const " + << node->local_name () << " &);" << be_nl << be_nl; - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "bad disciminant type\n"), - -1); - } + // Retrieve the disriminant type. + be_type *bt = be_type::narrow_from_decl (node->disc_type ()); - // The discriminant type may have to be defined here if it was an enum - // declaration inside of the union statement. + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_ch::" + "visit_union - " + "bad disciminant type\n"), + -1); + } - ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CH); - be_visitor_union_discriminant_ch visitor (&ctx); + // The discriminant type may have to be defined here if it was an enum + // declaration inside of the union statement. - if (bt->accept (&visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - " visit_union - " - "codegen for discriminant failed\n"), -1); - } + ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CH); + be_visitor_union_discriminant_ch ud_visitor (&ctx); - // Generate the _var_type typedef - // but we must protect against certain versions of g++. - *os << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_nl; - *os << "typedef " << node->local_name () << "_var _var_type;\n" - << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl; + if (bt->accept (&ud_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_ch::" + " visit_union - " + "codegen for discriminant failed\n"), + -1); + } - // Now generate the public defn for the union branch members. For this, - // set our state to reflect what we are aiming to do. - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); + // Generate the _var_type typedef. + *os << "typedef " << node->local_name () << "_var _var_type;" + << be_nl << be_nl; - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "codegen for public defn of union members\n"), - -1); - } + // Now generate the public defn for the union branch members. For this, + // set our state to reflect what we are aiming to do. + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); - // Now check if we need to generate the _default () method. - be_union::DefaultValue dv; + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_ch::" + "visit_union - " + "codegen for public defn of union members\n"), + -1); + } - if (node->default_value (dv) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "computing default value failed\n"), - -1); - } + // Now check if we need to generate the _default () method. + be_union::DefaultValue dv; - if ((dv.computed_ != 0) && (node->default_index () == -1)) - { - // Only if all cases are not covered AND there is no explicit - // default, we get the _default () method. - *os << "void _default (void);"; - } + if (node->default_value (dv) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_ch::" + "visit_union - " + "computing default value failed\n"), + -1); + } - *os << be_uidt_nl; + if ((dv.computed_ != 0) && (node->default_index () == -1)) + { + // Only if all cases are not covered AND there is no explicit + // default, we get the _default () method. + *os << "void _default (void);"; + } - // Now generate the private data members of the union. - *os << "private:" << be_idt_nl; - *os << bt->nested_type_name (node) << " disc_;" << be_nl; - *os << bt->nested_type_name (node) << " holder_;" << be_nl << be_nl; - // Emit the ACE_NESTED_CLASS macro. + *os << be_uidt_nl; - // The members are inside of a union. - *os << "union" << be_nl; - *os << "{" << be_idt_nl; - this->ctx_->state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); + // Now generate the private data members of the union. + *os << "private:" << be_idt_nl; + *os << bt->nested_type_name (node) << " disc_;" << be_nl; + *os << bt->nested_type_name (node) << " holder_;" << be_nl << be_nl; + // Emit the ACE_NESTED_CLASS macro. - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "codegen for private members of union\n"), -1); - } + // The members are inside of a union. + *os << "union" << be_nl; + *os << "{" << be_idt_nl; - *os << be_uidt_nl; - *os << "} u_;" << be_nl << be_nl; + this->ctx_->state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); - // The reset method (TAO extension). - *os << "// TAO extension." << be_nl; - *os << "void _reset (" << bt->nested_type_name (node) - << ", CORBA::Boolean /* finalize */);" << be_nl; - *os << "// Frees any allocated storage." << be_uidt_nl; - *os << "}; //" << node->name () << be_nl << be_nl; + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_ch::" + "visit_union - " + "codegen for private members of union\n"), + -1); + } - if (be_global->tc_support ()) - { - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - be_visitor_typecode_decl tc_visitor (&ctx); - - if (tc_visitor.visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "TypeCode declaration failed\n"), - -1); - } - } + *os << be_uidt_nl; + *os << "} u_;" << be_nl << be_nl; - os->gen_endif (); + // The reset method (TAO extension). + *os << "// TAO extension." << be_nl; + *os << "void _reset (" << bt->nested_type_name (node) + << ", CORBA::Boolean /* finalize */);" << be_nl; + *os << "// Frees any allocated storage." << be_uidt_nl; + *os << "}; //" << node->name () << be_nl << be_nl; - // Generate the ifdefined macro for the _var type. - os->gen_ifdef_macro (node->flat_name (), "_var"); + if (be_global->tc_support ()) + { + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); + be_visitor_typecode_decl tc_visitor (&ctx); - // Generate var definition. - if (node->gen_var_defn () == -1) + if (node->accept (&tc_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ch::" "visit_union - " - "codegen for _var\n"), + "TypeCode declaration failed\n"), -1); } + } - os->gen_endif (); + os->gen_endif (); - // Generate the ifdefined macro for the array type. - os->gen_ifdef_macro (node->flat_name (), "_out"); + // Generate the ifdefined macro for the _var type. + os->gen_ifdef_macro (node->flat_name (), "_var"); - // A class is generated for an out defn only for a variable - // length struct. - if (node->size_type () == be_decl::VARIABLE) - { - if (node->gen_out_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "codegen for _out\n"), - -1); - } - } - else + // Generate var definition. + if (node->gen_var_defn () == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_ch::" + "visit_union - " + "codegen for _var\n"), -1); + } + + os->gen_endif (); + + // Generate the ifdefined macro for the array type. + os->gen_ifdef_macro (node->flat_name (), "_out"); + + // A class is generated for an out defn only for a variable + // length struct. + if (node->size_type () == AST_Type::VARIABLE) + { + if (node->gen_out_defn () == -1) { - *os << "typedef " << node->local_name () << " &" - << node->local_name () << "_out;" << be_nl << be_nl; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_ch::" + "visit_union - " + "codegen for _out\n"), -1); } - - os->gen_endif (); - node->cli_hdr_gen (I_TRUE); + } + else + { + *os << "typedef " << node->local_name () << " &" + << node->local_name () << "_out;" << be_nl << be_nl; } + os->gen_endif (); + node->cli_hdr_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp index 8edc9fa72a0..fdfac26e17a 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp @@ -18,17 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, union_ci, "$Id$") - +ACE_RCSID (be_visitor_union, + union_ci, + "$Id$") // ****************************************************** -// for client inline +// For client inline. // ****************************************************** be_visitor_union_ci::be_visitor_union_ci (be_visitor_context *ctx) @@ -40,21 +35,14 @@ be_visitor_union_ci::~be_visitor_union_ci (void) { } -// visit the Union node and its scope int be_visitor_union_ci::visit_union (be_union *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type 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 - + ctx.node (node); if (!node->cli_inline_gen () && !node->imported ()) { - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); *os << "// *************************************************************" << be_nl; @@ -64,70 +52,75 @@ int be_visitor_union_ci::visit_union (be_union *node) // the discriminant type may have to be defined here if it was an enum // declaration inside of the union statement. - bt = be_type::narrow_from_decl (node->disc_type ()); + be_type *bt = be_type::narrow_from_decl (node->disc_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "bad discriminant type\n"), -1); + "bad discriminant type\n"), + -1); } - ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CI); // set current code - // gen state - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ci::" - "visit_union - " - "bad visitor\n"), -1); - } - // generate code for the discriminant - if (bt->accept (visitor) == -1) + ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CI); + + be_visitor_union_discriminant_ci visitor (&ctx); + + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit union - " - "codegen for discrminant failed\n"), -1); + "codegen for discrminant failed\n"), + -1); } - // now generate the implementation of the access methods for the - // union. For this set our state + // Now generate the implementation of the access methods for the + // union. For this set our state. this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CI); + if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - // generate the ifdefined macro for the array type + // Generate the ifdefined macro for the array type. os->gen_ifdef_macro (node->flat_name (), "_var"); + if (node->gen_var_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } + os->gen_endif (); - // generate the ifdefined macro for the array type then generate the _out - // impl + // Generate the ifdefined macro for the array type then generate the + // _out impl os->gen_ifdef_macro (node->flat_name (), "_out"); - if (node->size_type () == be_decl::VARIABLE + + if (node->size_type () == AST_Type::VARIABLE && node->gen_out_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } + os->gen_endif (); node->cli_inline_gen (I_TRUE); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp index 344a86f3c85..755939de49d 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_union.h" -#include "be_visitor_typecode/typecode_defn.h" - -ACE_RCSID(be_visitor_union, union_cs, "$Id$") - +ACE_RCSID (be_visitor_union, + union_cs, + "$Id$") // ****************************************************** // For client stubs. @@ -43,143 +38,152 @@ be_visitor_union_cs::~be_visitor_union_cs (void) // Visit the Union_cs node and its scope. int be_visitor_union_cs::visit_union (be_union *node) { - TAO_OutStream *os; - be_type *bt = 0; - - if (!node->cli_stub_gen () && !node->imported ()) + if (node->cli_stub_gen () || node->imported ()) { - os = this->ctx_->stream (); - - be_visitor_context ctx (*this->ctx_); - // The discriminant type may have to be defined here if it was an enum - // declaration inside of the union statement. We need to generate its - // typecode. - - bt = be_type::narrow_from_decl (node->disc_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs::" - "visit_union - " - "bad discriminant type\n"), -1); - } + return 0; + } - ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CS); - be_visitor_union_discriminant_cs disc_visitor (&ctx); + TAO_OutStream *os = this->ctx_->stream (); - if (bt->accept (&disc_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs::" - "visit union - " - "codegen for discrminant failed\n"), - -1); - } + be_visitor_context ctx (*this->ctx_); + // The discriminant type may have to be defined here if it was an enum + // declaration inside of the union statement. We need to generate its + // typecode. - // First generate code for any of the members (if required, e.g., - // anonymous sequences, structs, unions, arrays). - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); + be_type *bt = be_type::narrow_from_decl (node->disc_type ()); - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs" - "visit_union - " - "codegen for scope failed\n"), - -1); - } + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_cs::" + "visit_union - " + "bad discriminant type\n"), -1); + } - // Now generate the operations on the union such as the copy constructor - // and the assignment operator. + ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CS); + be_visitor_union_discriminant_cs disc_visitor (&ctx); - *os << "// *************************************************************" - << be_nl; - *os << "// Operations for union " << node->name () << be_nl - << "// TAO_IDL - Generated from" << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl; - *os << "// *************************************************************\n\n"; + if (bt->accept (&disc_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_cs::" + "visit union - " + "codegen for discrminant failed\n"), + -1); + } - // Generate the copy constructor and the assignment operator here. - os->indent (); - *os << node->name () << "::" << node->local_name () << " (void)" << be_nl - << "{" << be_idt_nl - << "ACE_OS::memset (&this->disc_, 0, sizeof (this->disc_));" << be_nl - << "ACE_OS::memset (&this->u_, 0, sizeof (this->u_));" << be_nl - << "this->disc_ = "; + // First generate code for any of the members (if required, e.g., + // anonymous sequences, structs, unions, arrays). + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); - // The default constructor must initialize the discriminator - // to the first case label value found in the union declaration - // so that, if the uninitialized union is inserted into an Any, - // the Any destructor's call to deep_free() will work properly. - UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_cs" + "visit_union - " + "codegen for scope failed\n"), + -1); + } + // Now generate the operations on the union such as the copy constructor + // and the assignment operator. + + *os << "// *************************************************************" + << be_nl; + *os << "// Operations for union " << node->name () << be_nl + << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; + *os << "// *************************************************************\n\n"; + + // Generate the copy constructor and the assignment operator here. + os->indent (); + *os << node->name () << "::" << node->local_name () << " (void)" << be_nl + << "{" << be_idt_nl + << "ACE_OS::memset (&this->disc_, 0, sizeof (this->disc_));" << be_nl + << "ACE_OS::memset (&this->u_, 0, sizeof (this->u_));" << be_nl + << "this->disc_ = "; + + // The default constructor must initialize the discriminator + // to the first case label value found in the union declaration + // so that, if the uninitialized union is inserted into an Any, + // the Any destructor's call to deep_free() will work properly. + UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + be_union_branch *ub = 0; + + // In case we have some bogus enum values from an enum declared + // in our scope. + while (ub == 0) + { // Just get the union's first member. AST_Decl *d = si.item (); - be_union_branch *ub = be_union_branch::narrow_from_decl (d); + ub = be_union_branch::narrow_from_decl (d); + si.next (); + } - // Get the first label in its list. - AST_UnionLabel *ul = ub->label (0); + // Get the first label in its list. + AST_UnionLabel *ul = ub->label (0); - if (ul->label_kind () == AST_UnionLabel::UL_label) - { - ub->gen_label_value (os); - } - else - { - ub->gen_default_label_value (os, node); - } + if (ul->label_kind () == AST_UnionLabel::UL_label) + { + ub->gen_label_value (os); + } + else + { + ub->gen_default_label_value (os, node); + } - *os << ";"; + *os << ";"; - *os << be_uidt_nl << "}" << be_nl << be_nl; + *os << be_uidt_nl << "}" << be_nl << be_nl; - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); - // So we know we are generating the copy constructor. - this->ctx_->sub_state (TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR); + // So we know we are generating the copy constructor. + this->ctx_->sub_state (TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR); - *os << node->name () << "::" << node->local_name () - << " (const ::" << node->name () << " &u)" - << be_nl; - *os << "{" << be_idt_nl; - *os << "this->disc_ = u.disc_;" << be_nl; - *os << "switch (this->disc_)" << be_nl; - *os << "{" << be_idt_nl; + *os << node->name () << "::" << node->local_name () + << " (const ::" << node->name () << " &u)" + << be_nl; + *os << "{" << be_idt_nl; + *os << "this->disc_ = u.disc_;" << be_nl; + *os << "switch (this->disc_)" << be_nl; + *os << "{" << be_idt_nl; - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs" - "visit_union - " - "codegen for copy ctor failed\n"), - -1); - } + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_cs" + "visit_union - " + "codegen for copy ctor failed\n"), + -1); + } - // If there is no explicit default case, but there - // is an implicit one, and the discriminant is an enum, - // we need this to avert warnings in some compilers that - // not all case values are included. If there is no - // implicit default case, or the discriminator is not - // an enum, this does no harm. - if (node->default_index () == -1) - { - *os << "default:" << be_nl - << "break;"; - } + // If there is no explicit default case, but there + // is an implicit one, and the discriminant is an enum, + // we need this to avert warnings in some compilers that + // not all case values are included. If there is no + // implicit default case, or the discriminator is not + // an enum, this does no harm. + if (node->default_index () == -1) + { + *os << "default:" << be_nl + << "break;"; + } - *os << be_uidt_nl << "}" << be_uidt_nl - << "}" << be_nl << be_nl; + *os << be_uidt_nl << "}" << be_uidt_nl + << "}" << be_nl << be_nl; - *os << "// destructor" << be_nl - << node->name () << "::~" << node->local_name () - << " (void)" << be_nl - << "{" << be_idt_nl - << "// finalize" << be_nl - << "this->_reset (this->disc_, 1);" << be_uidt_nl - << "}" << be_nl << be_nl; + *os << "// destructor" << be_nl + << node->name () << "::~" << node->local_name () + << " (void)" << be_nl + << "{" << be_idt_nl + << "// finalize" << be_nl + << "this->_reset (this->disc_, 1);" << be_uidt_nl + << "}" << be_nl << be_nl; + if (!node->is_local ()) + { *os << "void " << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl @@ -188,116 +192,115 @@ int be_visitor_union_cs::visit_union (be_union *node) << node->local_name () << "*, _tao_void_pointer);" << be_nl << "delete tmp;" << be_uidt_nl << "}\n" << be_nl; + } - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); + + // Reset this for generating the assignment operator. + this->ctx_->sub_state (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN); + + // Assignment operator. + os->indent (); + *os << "// assignment operator" << be_nl; + *os << node->name () << " &" << be_nl; + *os << node->name () << "::operator= (const ::" + << node->name () << " &u)" << be_nl; + *os << "{" << be_idt_nl; + // First check for self-assignment. + *os << "if (&u == this)" << be_idt_nl + << "{" << be_idt_nl + << "return *this;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + // Reset and set the discriminant. + *os << "this->_reset (u.disc_, 0);" << be_nl; + *os << "this->disc_ = u.disc_;" << be_nl << be_nl; + // now switch based on the disc value + *os << "switch (this->disc_)" << be_nl; + *os << "{" << be_idt_nl; + + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_cs" + "visit_union - " + "codegen for assign op failed\n"), + -1); + } - // Reset this for generating the assignment operator. - this->ctx_->sub_state (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN); + // If there is no explicit default case, but there + // is an implicit one, and the discriminant is an enum, + // we need this to avert warnings in some compilers that + // not all case values are included. If there is no + // implicit default case, or the discriminator is not + // an enum, this does no harm. + if (node->default_index () == -1) + { + *os << "default:" << be_nl + << "break;" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } - // Assignment operator. - os->indent (); - *os << "// assignment operator" << be_nl; - *os << node->name () << " &" << be_nl; - *os << node->name () << "::operator= (const ::" - << node->name () << " &u)" << be_nl; - *os << "{" << be_idt_nl; - // First check for self-assignment. - *os << "if (&u == this)" << be_idt_nl - << "{" << be_idt_nl - << "return *this;" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - // Reset and set the discriminant. - *os << "this->_reset (u.disc_, 0);" << be_nl; - *os << "this->disc_ = u.disc_;" << be_nl << be_nl; - // now switch based on the disc value - *os << "switch (this->disc_)" << be_nl; - *os << "{" << be_idt_nl; - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs" - "visit_union - " - "codegen for assign op failed\n"), - -1); - } + *os << "}" << be_nl << be_nl; + *os << "return *this;" << be_uidt_nl; + *os << "}\n\n"; + + // The reset method. + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS); + os->indent (); + *os << "// reset method to reset old values of a union" << be_nl; + *os << "void " << node->name () << "::_reset (" << bt->name () + << ", CORBA::Boolean /*finalize*/)" << be_nl; + *os << "{" << be_idt_nl; + *os << "switch (this->disc_)" << be_nl; + *os << "{" << be_idt_nl; + + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_cs" + "visit_union - " + "codegen for reset failed\n"), + -1); + } - // If there is no explicit default case, but there - // is an implicit one, and the discriminant is an enum, - // we need this to avert warnings in some compilers that - // not all case values are included. If there is no - // implicit default case, or the discriminator is not - // an enum, this does no harm. - if (node->default_index () == -1) - { - *os << "default:" << be_nl - << "break;" << be_uidt_nl; - } - else - { - *os << be_uidt_nl; - } + // If there is no explicit default case, but there + // is an implicit one, and the discriminant is an enum, + // we need this to avert warnings in some compilers that + // not all case values are included. If there is no + // implicit default case, or the discriminator is not + // an enum, this does no harm. + if (node->default_index () == -1) + { + os->decr_indent (0); + *os << "default:" << be_nl; + os->incr_indent (); + *os << "break;"; + } - *os << "}" << be_nl << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // The reset method. - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS); - os->indent (); - *os << "// reset method to reset old values of a union" << be_nl; - *os << "void " << node->name () << "::_reset (" << bt->name () - << ", CORBA::Boolean /*finalize*/)" << be_nl; - *os << "{" << be_idt_nl; - *os << "switch (this->disc_)" << be_nl; - *os << "{" << be_idt_nl; - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs" - "visit_union - " - "codegen for reset failed\n"), - -1); - } + *os << be_uidt_nl << "}" << be_uidt_nl + << "}\n\n"; - // If there is no explicit default case, but there - // is an implicit one, and the discriminant is an enum, - // we need this to avert warnings in some compilers that - // not all case values are included. If there is no - // implicit default case, or the discriminator is not - // an enum, this does no harm. - if (node->default_index () == -1) - { - os->decr_indent (0); - *os << "default:" << be_nl; - os->incr_indent (); - *os << "break;"; - } + if (!node->is_local () && be_global->tc_support ()) + { + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); + ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - *os << be_uidt_nl << "}" << be_uidt_nl - << "}\n\n"; + be_visitor_typecode_defn tc_visitor (&ctx); - if (be_global->tc_support ()) + if (tc_visitor.visit_union (node) == -1) { - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - - be_visitor_typecode_defn tc_visitor (&ctx); - - if (tc_visitor.visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs::" - "visit_union - " - "TypeCode definition failed\n"), - -1); - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_cs::" + "visit_union - " + "TypeCode definition failed\n"), + -1); } - - node->cli_stub_gen (I_TRUE); } + node->cli_stub_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch.cpp index 0898d4cc7ad..21dd19b7c64 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch.cpp @@ -17,17 +17,34 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_array.h" +#include "be_enum.h" +#include "be_interface.h" +#include "be_interface_fwd.h" +#include "be_predefined_type.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_union_branch.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_helper.h" +#include "ast_union_label.h" +#include "utl_identifier.h" #include "be_visitor_union_branch.h" +#include "be_visitor_array.h" +#include "be_visitor_enum.h" +#include "be_visitor_sequence.h" +#include "be_visitor_structure.h" +#include "be_visitor_union.h" +#include "be_visitor_context.h" -// include all the individual files #include "be_visitor_union_branch/private_ch.cpp" #include "be_visitor_union_branch/public_assign_cs.cpp" #include "be_visitor_union_branch/public_reset_cs.cpp" -#include "be_visitor_union_branch/public_access_cs.cpp" #include "be_visitor_union_branch/public_ch.cpp" #include "be_visitor_union_branch/public_ci.cpp" #include "be_visitor_union_branch/public_cs.cpp" @@ -35,4 +52,6 @@ #include "be_visitor_union_branch/cdr_op_ci.cpp" #include "be_visitor_union_branch/cdr_op_cs.cpp" -ACE_RCSID(be, be_visitor_union_branch, "$Id$") +ACE_RCSID (be, + be_visitor_union_branch, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp index d066471016b..50a96af0e65 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp @@ -19,276 +19,203 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, cdr_op_ch, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + cdr_op_ch, + "$Id$") // ********************************************** -// visitor for union_branch in the client header file +// Visitor for union_branch in the client header file. // ********************************************** -// constructor -be_visitor_union_branch_cdr_op_ch::be_visitor_union_branch_cdr_op_ch (be_visitor_context *ctx) +be_visitor_union_branch_cdr_op_ch::be_visitor_union_branch_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_cdr_op_ch::~be_visitor_union_branch_cdr_op_ch (void) { } -// visit the union_branch node int be_visitor_union_branch_cdr_op_ch::visit_union_branch (be_union_branch *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a union_branch can be +// Visit operations on all possible data types that a union_branch can be. -// visit array type int be_visitor_union_branch_cdr_op_ch::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. + // This is the case for anonymous arrays. - // 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.node (node); - // first generate the struct declaration ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_union_branch_cdr_op_ch::visit_enum (be_enum *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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.node (node); - // first generate the enum declaration ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit sequence type int be_visitor_union_branch_cdr_op_ch::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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.node (node); - // first generate the sequence declaration ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit structure type int be_visitor_union_branch_cdr_op_ch::visit_structure (be_structure *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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.node (node); - // first generate the struct declaration ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit typedefed type int be_visitor_union_branch_cdr_op_ch::visit_typedef (be_typedef *node) { - // save the node for use in code generation and - // indicate that the union_branch of the union_branch node - // is a typedefed quantity this->ctx_->alias (node); - // 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_union_branch_cdr_op_ch::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } + this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_union_branch_cdr_op_ch::visit_union (be_union *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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.node (node); - // first generate the enum declaration ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp index 6545710d540..dd4e8b98fd1 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp @@ -18,18 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_union_branch.h" -#include "be_visitor_array.h" -#include "be_visitor_enum.h" -#include "be_visitor_sequence.h" -#include "be_visitor_structure.h" -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union_branch, cdr_op_ci, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + cdr_op_ci, + "$Id$") // ********************************************** // Visitor for union_branch in the client stubs file. @@ -295,7 +286,7 @@ be_visitor_union_branch_cdr_op_ci::visit_interface (be_interface *node) { case TAO_CodeGen::TAO_CDR_INPUT: *os << node->name () << "_var _tao_union_tmp;" << be_nl - << "result = strm >> _tao_union_tmp.inout ();" << be_nl + << "result = strm >> _tao_union_tmp.inout ();" << be_nl << be_nl << "if (result)" << be_idt_nl << "{" << be_idt_nl << "_tao_union." @@ -350,7 +341,7 @@ be_visitor_union_branch_cdr_op_ci::visit_interface_fwd (be_interface_fwd *node) { case TAO_CodeGen::TAO_CDR_INPUT: *os << node->name () << "_var _tao_union_tmp;" << be_nl - << "result = strm >> _tao_union_tmp.inout ();" << be_nl + << "result = strm >> _tao_union_tmp.inout ();" << be_nl << be_nl << "if (result)" << be_idt_nl << "{" << be_idt_nl << "_tao_union." @@ -383,6 +374,116 @@ be_visitor_union_branch_cdr_op_ci::visit_interface_fwd (be_interface_fwd *node) } int +be_visitor_union_branch_cdr_op_ci::visit_valuetype (be_valuetype *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + // Retrieve the union_branch node. + be_union_branch *f = this->ctx_->be_node_as_union_branch (); + + if (!f) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_branch_cdr_op_ci::" + "visit_valuetype - " + "cannot retrieve union_branch 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 << node->name () << "_var _tao_union_tmp;" << be_nl + << "result = strm >> _tao_union_tmp.inout ();" << be_nl << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." + << f->local_name () << " (_tao_union_tmp.in ());" << be_nl + << "_tao_union._d (_tao_discriminant);" << be_uidt_nl + << "}" << be_uidt; + + break; + + case TAO_CodeGen::TAO_CDR_OUTPUT: + *os << "result = strm << _tao_union." + << f->local_name () << " ();"; + break; + + case TAO_CodeGen::TAO_CDR_SCOPE: + // Nothing to be done because an interface cannot be declared inside a + // union. + break; + + default: + // Error. + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_branch_cdr_op_ci::" + "visit_valuetype - " + "bad sub state\n"), + -1); + } + + return 0; +} + +int +be_visitor_union_branch_cdr_op_ci::visit_valuetype_fwd (be_valuetype_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + // Retrieve the union_branch node. + be_union_branch *f = this->ctx_->be_node_as_union_branch (); + + if (!f) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_branch_cdr_op_ci::" + "visit_valuetype_fwd - " + "cannot retrieve union_branch 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 << node->name () << "_var _tao_union_tmp;" << be_nl + << "result = strm >> _tao_union_tmp.inout ();" << be_nl << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." + << f->local_name () << " (_tao_union_tmp.in ());" << be_nl + << "_tao_union._d (_tao_discriminant);" << be_uidt_nl + << "}" << be_uidt; + + break; + + case TAO_CodeGen::TAO_CDR_OUTPUT: + *os << "result = strm << _tao_union." + << f->local_name () << " ();"; + break; + + case TAO_CodeGen::TAO_CDR_SCOPE: + // Nothing to be done because an interface cannot be forward declared + // inside a union. + break; + + default: + // Error. + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_branch_cdr_op_ci::" + "visit_valuetype_fwd - " + "bad sub state\n"), + -1); + } + + return 0; +} + +int be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *node) { TAO_OutStream *os = this->ctx_->stream (); @@ -399,24 +500,30 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no -1); } + AST_PredefinedType::PredefinedType pt = node->pt (); + // 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: + if (pt == AST_PredefinedType::PT_object) + { + char *local_name = node->local_name ()->get_string (); + + *os << "CORBA::Object_var _tao_union_tmp;" << be_nl; + + *os << "result = strm >> _tao_union_tmp.out ();" << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () << " (_tao_union_tmp.in ());"; - if (node->pt () == AST_PredefinedType::PT_pseudo) + } + else if (pt == AST_PredefinedType::PT_pseudo) { char *local_name = node->local_name ()->get_string (); - if (!ACE_OS::strcmp (local_name, "TypeCode")) - { - *os << "CORBA::TypeCode_var _tao_union_tmp;" << be_nl; - } - else if (!ACE_OS::strcmp (local_name, "Object")) - { - *os << "CORBA::Object_var _tao_union_tmp;" << be_nl; - } + *os << "CORBA::TypeCode_var _tao_union_tmp;" << be_nl; //@@TODO - case for ValueBase. @@ -426,7 +533,7 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no << "_tao_union." << f->local_name () << " (_tao_union_tmp.in ());"; } - else if (node->pt () == AST_PredefinedType::PT_char) + else if (pt == AST_PredefinedType::PT_char) { *os << "CORBA::Char _tao_union_tmp;" << be_nl << "CORBA::Any::to_char _tao_union_helper " @@ -437,7 +544,7 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no << "_tao_union." << f->local_name () << " (_tao_union_tmp);"; } - else if (node->pt () == AST_PredefinedType::PT_wchar) + else if (pt == AST_PredefinedType::PT_wchar) { *os << "CORBA::WChar _tao_union_tmp;" << be_nl << "CORBA::Any::to_wchar _tao_union_helper " @@ -448,7 +555,7 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no << "_tao_union." << f->local_name () << " (_tao_union_tmp);"; } - else if (node->pt () == AST_PredefinedType::PT_octet) + else if (pt == AST_PredefinedType::PT_octet) { *os << "CORBA::Octet _tao_union_tmp;" << be_nl << "CORBA::Any::to_octet _tao_union_helper " @@ -459,7 +566,7 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no << "_tao_union." << f->local_name () << " (_tao_union_tmp);"; } - else if (node->pt () == AST_PredefinedType::PT_boolean) + else if (pt == AST_PredefinedType::PT_boolean) { *os << "CORBA::Boolean _tao_union_tmp;" << be_nl << "CORBA::Any::to_boolean _tao_union_helper " @@ -490,26 +597,27 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no *os << "result = "; - if (node->pt () == AST_PredefinedType::PT_pseudo) + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { *os << "strm << _tao_union." << f->local_name () << " ();"; } - else if (node->pt () == AST_PredefinedType::PT_char) + else if (pt == AST_PredefinedType::PT_char) { *os << "strm << CORBA::Any::from_char (_tao_union." << f->local_name () << " ());"; } - else if (node->pt () == AST_PredefinedType::PT_wchar) + else if (pt == AST_PredefinedType::PT_wchar) { *os << "strm << CORBA::Any::from_wchar (_tao_union." << f->local_name () << " ());"; } - else if (node->pt () == AST_PredefinedType::PT_octet) + else if (pt == AST_PredefinedType::PT_octet) { *os << "strm << CORBA::Any::from_octet (_tao_union." << f->local_name () << " ());"; } - else if (node->pt () == AST_PredefinedType::PT_boolean) + else if (pt == AST_PredefinedType::PT_boolean) { *os << "strm << CORBA::Any::from_boolean (_tao_union." << f->local_name () << " ());"; diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp index 37bbb15f6a4..0be5d282013 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp @@ -18,132 +18,82 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, cdr_op_cs, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + cdr_op_cs, + "$Id$") // ********************************************** -// visitor for union_branch in the client stubs file +// Visitor for union_branch in the client stubs file. // ********************************************** -// constructor -be_visitor_union_branch_cdr_op_cs::be_visitor_union_branch_cdr_op_cs (be_visitor_context *ctx) +be_visitor_union_branch_cdr_op_cs::be_visitor_union_branch_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_cdr_op_cs::~be_visitor_union_branch_cdr_op_cs (void) { } -// visit the union_branch node int be_visitor_union_branch_cdr_op_cs::visit_union_branch (be_union_branch *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_union_branch_cdr_op_cs::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined - + // 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. - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // This is the case for anonymous arrays. 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.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_union_branch_cdr_op_cs::visit_enum (be_enum *node) { - 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_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } return 0; } @@ -152,134 +102,91 @@ be_visitor_union_branch_cdr_op_cs::visit_sequence (be_sequence *node) { 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.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_union_branch_cdr_op_cs::visit_structure (be_structure *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_union_branch_cdr_op_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 + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // 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); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_union_branch_cdr_op_cs::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp index 3b71f0e6d59..884c849fef8 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp @@ -19,21 +19,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, private_ch, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + private_ch, + "$Id$") // ********************************************** // visitor for union_branch in the client header generating the private information // ********************************************** // Constructor. -be_visitor_union_branch_private_ch::be_visitor_union_branch_private_ch (be_visitor_context *ctx) +be_visitor_union_branch_private_ch::be_visitor_union_branch_private_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -54,8 +51,7 @@ be_visitor_union_branch_private_ch::visit_union_branch (be_union_branch *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_union_branch - " - "Bad union_branch type\n" - ), + "Bad union_branch type\n"), -1); } @@ -66,16 +62,13 @@ be_visitor_union_branch_private_ch::visit_union_branch (be_union_branch *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), + "codegen for union_branch type failed\n"), -1); } return 0; } -// Visit operations on all possible data types that a union_branch can be. - int be_visitor_union_branch_private_ch::visit_array (be_array *node) { @@ -83,7 +76,7 @@ be_visitor_union_branch_private_ch::visit_array (be_array *node) be_decl *bu = this->ctx_->scope (); be_type *bt; - // Check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) { bt = this->ctx_->alias (); @@ -98,8 +91,7 @@ be_visitor_union_branch_private_ch::visit_array (be_array *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_array - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -144,8 +136,7 @@ be_visitor_union_branch_private_ch::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_enum - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -179,8 +170,7 @@ be_visitor_union_branch_private_ch::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_interface - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -214,8 +204,75 @@ be_visitor_union_branch_private_ch::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_interface_fwd - " - "bad context information\n" - ), + "bad context information\n"), + -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + *os << bt->nested_type_name (bu, "_var") + << " *" << ub->local_name () << "_;" << be_nl; + + return 0; +} + +int +be_visitor_union_branch_private_ch::visit_valuetype (be_valuetype *node) +{ + be_decl *ub = this->ctx_->node (); + be_decl *bu = 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_union_branch_private_ch::" + "visit_interface - " + "bad context information\n"), + -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + *os << bt->nested_type_name (bu, "_var") + << " *" << ub->local_name () << "_;" << be_nl; + + return 0; +} + +int +be_visitor_union_branch_private_ch::visit_valuetype_fwd (be_valuetype_fwd *node) +{ + be_decl *ub = this->ctx_->node (); + be_decl *bu = 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_union_branch_private_ch::" + "visit_interface_fwd - " + "bad context information\n"), -1); } @@ -251,25 +308,21 @@ be_visitor_union_branch_private_ch::visit_predefined_type ( ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_predefined_type - " - "bad context information\n" - ), + "bad context information\n"), -1); } TAO_OutStream *os = this->ctx_->stream (); - if (node->pt () == AST_PredefinedType::PT_pseudo) + if (node->pt () == AST_PredefinedType::PT_object) + { + *os << bt->name () << "_var" + << " *" << ub->local_name () << "_;" << be_nl; + } + else if (node->pt () == AST_PredefinedType::PT_pseudo) { - // Cannot have an object inside of a union. - // Check if we are dealing with a CORBA::Object - if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) - { - *os << bt->name () << "_var" - << " *" << ub->local_name () << "_;" << be_nl; - } - else - *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << "_;" << be_nl; + *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () + << "_;" << be_nl; } else if (node->pt () == AST_PredefinedType::PT_any) { @@ -309,8 +362,7 @@ be_visitor_union_branch_private_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_sequence - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -335,8 +387,7 @@ be_visitor_union_branch_private_ch::visit_string (be_string *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_string - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -376,15 +427,14 @@ be_visitor_union_branch_private_ch::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_structure - " - "bad context information\n" - ), + "bad context information\n"), -1); } TAO_OutStream *os = this->ctx_->stream (); // If we are variable sized, we need a pointer type. - if (node->size_type () == be_decl::VARIABLE + if (node->size_type () == AST_Type::VARIABLE || node->has_constructor ()) { *os << bt->nested_type_name (bu) << " *" << ub->local_name () @@ -412,8 +462,7 @@ be_visitor_union_branch_private_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_typedef - " - "Bad primitive type\n" - ), + "Bad primitive type\n"), -1); } @@ -443,8 +492,7 @@ be_visitor_union_branch_private_ch::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_union - " - "bad context information\n" - ), + "bad context information\n"), -1); } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_access_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_access_cs.cpp deleted file mode 100644 index bce48e20e18..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_access_cs.cpp +++ /dev/null @@ -1,446 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// public_access_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Union Branch in the client inline file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, public_access_cs, "$Id$") - - -// ***************************************************** -// visitor for union_branch in the client -// stubs file for the access method -// ***************************************************** - -// constructor -be_visitor_union_branch_public_access_cs:: -be_visitor_union_branch_public_access_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -// destructor -be_visitor_union_branch_public_access_cs:: -~be_visitor_union_branch_public_access_cs (void) -{ -} - -// visit the union_branch node -int -be_visitor_union_branch_public_access_cs:: -visit_union_branch (be_union_branch *node) -{ - TAO_OutStream *os; - be_type *bt; // union_branch's type - - os = this->ctx_->stream (); - // first generate the type information - bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cs::" - "visit_union_branch - " - "Bad union_branch type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - - for (unsigned long i = 0; - i < node->label_list_length (); - ++i) - { - // check if we are printing the default case - if (node->label (i)->label_kind () == AST_UnionLabel::UL_default) - *os << "default:"; - else - { - *os << "case "; - node->gen_label_value (os, i); - *os << ":"; - } - if (i == (node->label_list_length () - 1)) - *os << be_idt_nl; - else - *os << be_nl; - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cs::" - "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); - } - return 0; -} - -// =visit operations on all possible data types that a union_branch can be - -int -be_visitor_union_branch_public_access_cs::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // 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_union_branch_public_access_cs::" - "visit_enum - " - "bad context information\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 (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->full_name (), - bt->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", bt->full_name ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->full_name ()); - } - - os = this->ctx_->stream (); - *os << "if (alloc_flag)" << be_idt_nl - << "this->u_." << ub->local_name () << "_ = " << fname - << "_alloc ();" << be_uidt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_enum (be_enum *) -{ - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_access_cs::" - "visit_enum - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - *os << "ACE_UNUSED_ARG (alloc_flag);" << be_nl - << "return &this->u_." << ub->local_name () << "_;" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_interface (be_interface *node) -{ - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // 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_union_branch_public_access_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - *os << "if (alloc_flag)" << be_idt_nl - << "ACE_NEW_RETURN (this->u_." << ub->local_name () << "_, " - << "(" - << bt->name () << "_var), 0);" << be_uidt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_interface_fwd (be_interface_fwd *) -{ - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_access_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - *os << "ACE_UNUSED_ARG (alloc_flag);" << be_nl - << "return (CORBA::Object_ptr) &this->u_." << ub->local_name () - << "_->inout ();" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // 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_union_branch_public_access_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "ACE_UNUSED_ARG (alloc_flag);" << be_nl - << "return &this->u_." << ub->local_name () << "_;" << be_uidt_nl; - break; - case AST_PredefinedType::PT_any: - *os << "if (alloc_flag)" << be_idt_nl - << "ACE_NEW_RETURN (this->u_." << ub->local_name () - << "_, " << bt->name () << ", 0);" << be_uidt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - break; - case AST_PredefinedType::PT_void: - *os << "ACE_UNUSED_ARG (alloc_flag);" << be_nl; - break; - default: - *os << "ACE_UNUSED_ARG (alloc_flag);" << be_nl - << "return &this->u_." << ub->local_name () << "_;" << be_uidt_nl; - } - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // 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_union_branch_public_access_cs::" - "visit_sequence - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - *os << "if (alloc_flag)" << be_idt_nl - << "ACE_NEW_RETURN (this->u_." << ub->local_name () - << "_, " << bt->name () << ", 0);" << be_uidt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_string (be_string *) -{ - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_access_cs::" - "visit_string - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - *os << "ACE_UNUSED_ARG (alloc_flag);" << be_nl - << "return &this->u_." << ub->local_name () << "_;" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // 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_union_branch_public_access_cs::" - "visit_structure - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - if (bt->size_type () == be_type::VARIABLE - || node->has_constructor ()) - { - *os << "if (alloc_flag)" << be_idt_nl - << "ACE_NEW_RETURN (this->u_." << ub->local_name () - << "_, " << bt->name () << ", 0);" << be_uidt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - } - else - { - *os << "ACE_UNUSED_ARG (alloc_flag);" << be_nl - << "return &this->u_." << ub->local_name () << "_;" << be_uidt_nl; - } - - return 0; -} - -int -be_visitor_union_branch_public_access_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_union_branch_public_access_cs::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // 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_union_branch_public_access_cs::" - "visit_union - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - *os << "if (alloc_flag)" << be_idt_nl - << "ACE_NEW_RETURN (this->u_." << ub->local_name () - << "_, " << bt->name () << ", 0);" << be_uidt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp index 6349e48d814..1f04625d53c 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp @@ -18,14 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, public_assign_cs, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + public_assign_cs, + "$Id$") // ********************************************** // visitor for union_branch in the client stubs file generating the code for @@ -33,21 +28,23 @@ ACE_RCSID(be_visitor_union_branch, public_assign_cs, "$Id$") // ********************************************** // constructor -be_visitor_union_branch_public_assign_cs::be_visitor_union_branch_public_assign_cs -(be_visitor_context *ctx) +be_visitor_union_branch_public_assign_cs:: +be_visitor_union_branch_public_assign_cs (be_visitor_context *ctx) : be_visitor_decl (ctx) { } // destructor -be_visitor_union_branch_public_assign_cs::~be_visitor_union_branch_public_assign_cs -(void) +be_visitor_union_branch_public_assign_cs:: +~be_visitor_union_branch_public_assign_cs (void) { } // visit the union_branch node int -be_visitor_union_branch_public_assign_cs::visit_union_branch (be_union_branch *node) +be_visitor_union_branch_public_assign_cs::visit_union_branch ( + be_union_branch *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -386,6 +383,146 @@ be_visitor_union_branch_public_assign_cs::visit_interface_fwd ( } int +be_visitor_union_branch_public_assign_cs::visit_valuetype (be_valuetype *node) +{ + be_union_branch *ub = + this->ctx_->be_node_as_union_branch (); // get union branch + be_union *bu = + this->ctx_->be_scope_as_union (); // 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_union_branch_public_assign_cs::" + "visit_valuetype - " + "bad context information\n" + ), -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + idl_bool bt_is_defined = node->is_defined (); + + *os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl + << "{" << be_idt_nl + << "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl + << "}" << be_uidt_nl + << "else" << be_idt_nl + << "{" << be_idt_nl; + + // So the template will work with the macro. + *os << "typedef " + << bt->name () << "_var OBJECT_FIELD;" << be_nl; + *os << "CORBA::add_ref (u.u_." << ub->local_name () + << "_->ptr ());" << be_nl; + + if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR) + { + // We are generating the copy constructor. + *os << "ACE_NEW (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (u.u_." << ub->local_name () << "_->ptr ())" + << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + } + else + { + // We are generating the assignment operator. + *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (u.u_." << ub->local_name () << "_->ptr ())," + << be_nl + << "*this" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + } + + *os << "}" << be_uidt << be_uidt_nl; + + return 0; +} + +int +be_visitor_union_branch_public_assign_cs::visit_valuetype_fwd ( + be_valuetype_fwd *node + ) +{ + be_union_branch *ub = + this->ctx_->be_node_as_union_branch (); // get union branch + be_union *bu = + this->ctx_->be_scope_as_union (); // 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_union_branch_public_assign_cs::" + "visit_valuetype_fwd - " + "bad context information\n" + ), -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + idl_bool bt_is_defined = node->full_definition ()->is_defined (); + + *os << "if (u.u_." << ub->local_name () << "_ == 0)" << be_idt_nl + << "{" << be_idt_nl + << "this->u_." << ub->local_name () << "_ = 0;" << be_uidt_nl + << "}" << be_uidt_nl + << "else" << be_idt_nl + << "{" << be_idt_nl; + + // So the template will work with the macro. + *os << "typedef " + << bt->name () << "_var OBJECT_FIELD;" << be_nl; + + if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR) + { + // We are generating the copy constructor. + *os << "ACE_NEW (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (u.u_." << ub->local_name () << "_->ptr ())" + << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + } + else + { + // We are generating the assignment operator. + *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (u.u_." << ub->local_name () << "_->ptr ())," + << be_nl + << "*this" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + } + + *os << "}" << be_uidt << be_uidt_nl; + + return 0; +} + +int be_visitor_union_branch_public_assign_cs::visit_predefined_type ( be_predefined_type *node ) @@ -420,36 +557,38 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type ( // set the discriminant to the appropriate label switch (node->pt ()) { - case AST_PredefinedType::PT_pseudo: - if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) + case AST_PredefinedType::PT_object: + // So the template will work with the macro. + *os << "typedef CORBA::Object_var OBJECT_FIELD;" << be_nl; + + if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR) { - // So the template will work with the macro. - *os << "typedef CORBA::Object_var OBJECT_FIELD;" << be_nl; - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR) - // We are generating the copy constructor. - *os << "ACE_NEW (" << be_idt << be_idt_nl - << "this->u_." << ub->local_name () << "_," << be_nl - << "OBJECT_FIELD (CORBA::Object" - << "::_duplicate (u.u_." << ub->local_name () - << "_->ptr ()))" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; - else - // We are generating the assignment operator. - *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl - << "this->u_." << ub->local_name () << "_," << be_nl - << "OBJECT_FIELD (CORBA::Object" - << "::_duplicate (u.u_." << ub->local_name () - << "_->ptr ()))," << be_nl - << "*this" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; + // We are generating the copy constructor. + *os << "ACE_NEW (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (CORBA::Object" + << "::_duplicate (u.u_." << ub->local_name () + << "_->ptr ()))" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; } else { - *os << "this->u_." << ub->local_name () << "_ = " - << bt->name () << "::_duplicate (u.u_." - << ub->local_name () << "_);" << be_uidt_nl; + // We are generating the assignment operator. + *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (CORBA::Object" + << "::_duplicate (u.u_." << ub->local_name () + << "_->ptr ()))," << be_nl + << "*this" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; } + + break; + case AST_PredefinedType::PT_pseudo: + *os << "this->u_." << ub->local_name () << "_ = " + << bt->name () << "::_duplicate (u.u_." + << ub->local_name () << "_);" << be_uidt_nl; + break; case AST_PredefinedType::PT_any: if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR) @@ -483,6 +622,7 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type ( << ");" << be_uidt << be_uidt_nl << "}" << be_uidt << be_uidt_nl; } + break; case AST_PredefinedType::PT_void: break; @@ -490,6 +630,7 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type ( *os << "// set the value" << be_nl << "this->u_." << ub->local_name () << "_ = " << "u.u_." << ub->local_name () << "_;" << be_uidt_nl; + break; } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp index 4d184a3099d..0341c745ea1 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp @@ -18,32 +18,25 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, public_ch, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + public_ch, + "$Id$") // ********************************************** -// visitor for union_branch in the client header file +// Visitor for union_branch in the client header file. // ********************************************** -// Constructor. -be_visitor_union_branch_public_ch::be_visitor_union_branch_public_ch -(be_visitor_context *ctx) +be_visitor_union_branch_public_ch::be_visitor_union_branch_public_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// Destructor. be_visitor_union_branch_public_ch::~be_visitor_union_branch_public_ch (void) { } -// Visit the union_branch node. int be_visitor_union_branch_public_ch::visit_union_branch (be_union_branch *node) { @@ -66,8 +59,7 @@ be_visitor_union_branch_public_ch::visit_union_branch (be_union_branch *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), + "codegen for union_branch type failed\n"), -1); } @@ -76,7 +68,6 @@ be_visitor_union_branch_public_ch::visit_union_branch (be_union_branch *node) // Visit operations on all possible data types that a union_branch can be. -// Visit array type. int be_visitor_union_branch_public_ch::visit_array (be_array *node) { @@ -99,8 +90,7 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_array - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -112,26 +102,12 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) { // 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); - - // 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_union_branch_public_ch::" - "visit_array - " - "Bad visitor\n" - ), - -1); - } + be_visitor_array_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" @@ -141,8 +117,6 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) -1); } - delete visitor; - // Now use this array as a "type" for the subsequent declarator // the set method. *os << "void " << ub->local_name () << " (" @@ -166,7 +140,6 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) return 0; } -// Visit enum type. int be_visitor_union_branch_public_ch::visit_enum (be_enum *node) { @@ -189,47 +162,29 @@ be_visitor_union_branch_public_ch::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_enum - " - "bad context information\n" - ), + "bad context information\n"), -1); } TAO_OutStream *os = this->ctx_->stream (); // Not a typedef and bt is defined inside the union. - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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); - - // 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_union_branch_public_ch::" - "visit_enum - " - "Bad visitor\n" - ), - -1); - } + be_visitor_enum_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_enum - " - "codegen failed\n" - ), + "codegen failed\n"), -1); } - - delete visitor; } // Now use this enum as a "type" for the subsequent declarator @@ -244,7 +199,6 @@ be_visitor_union_branch_public_ch::visit_enum (be_enum *node) return 0; } -// Visit interface type. int be_visitor_union_branch_public_ch::visit_interface (be_interface *node) { @@ -267,8 +221,7 @@ be_visitor_union_branch_public_ch::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_interface - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -281,10 +234,10 @@ be_visitor_union_branch_public_ch::visit_interface (be_interface *node) // Get method. *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () << " (void) const;" << be_nl << be_nl; + return 0; } -// Visit interface forward type. int be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) { @@ -307,8 +260,7 @@ be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_interface_fwd - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -325,7 +277,6 @@ be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) return 0; } -// Visit valuetype type. int be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *node) { @@ -348,8 +299,7 @@ be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_valuetype - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -366,7 +316,6 @@ be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *node) return 0; } -// Visit valuetype forward type. int be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { @@ -389,8 +338,7 @@ be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_valuetype_fwd - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -407,7 +355,6 @@ be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_fwd *node) return 0; } -// Visit predefined type. int be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *node) { @@ -430,8 +377,7 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_predefined_type - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -440,6 +386,7 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: *os << "void " << ub->local_name () << " (" << bt->nested_type_name (bu, "_ptr") << ");" << be_nl; *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () @@ -447,10 +394,10 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no break; case AST_PredefinedType::PT_any: *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ");" << be_nl; - *os << "const " << bt->nested_type_name (bu) << " " + << bt->nested_type_name (bu) << " &);" << be_nl; + *os << "const " << bt->nested_type_name (bu) << " &" << ub->local_name () << " (void) const;" << be_nl << be_nl; - *os << bt->nested_type_name (bu) << " " + *os << bt->nested_type_name (bu) << " &" << ub->local_name () << " (void);" << be_nl << be_nl; break; case AST_PredefinedType::PT_void: @@ -465,7 +412,6 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no return 0; } -// visit sequence type int be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) { @@ -488,8 +434,7 @@ be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_sequence - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -499,47 +444,25 @@ be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // 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); - - // 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_union_branch_public_ch::" - "visit_sequence - " - "Bad visitor\n" - ), - -1); - } + be_visitor_sequence_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_sequence - " - "codegen failed\n" - ), + "codegen failed\n"), -1); } - delete visitor; - - // Generate the anonymous sequence member typedef - // but we must protect against certain versions of g++. + // Generate the anonymous sequence member typedef. // This provides a consistent name to use instead of the // implementation-specific name. - *os << "\n#if !defined (__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_nl - << "typedef " << bt->nested_type_name (bu) - << " _" << ub->local_name () << "_seq;\n"; - *os << "#endif /* ! __GNUC__ || ACE_HAS_GNUG_PRE_2_8 */" - << be_nl << be_nl; + *os << "typedef " << bt->nested_type_name (bu) + << " _" << ub->local_name () << "_seq;" << be_nl << be_nl; } *os << "void " << ub->local_name () << " (const " @@ -553,7 +476,6 @@ be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) return 0; } -// Visit string type. int be_visitor_union_branch_public_ch::visit_string (be_string *node) { @@ -565,8 +487,7 @@ be_visitor_union_branch_public_ch::visit_string (be_string *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_string - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -597,7 +518,6 @@ be_visitor_union_branch_public_ch::visit_string (be_string *node) return 0; } -// Visit structure type. int be_visitor_union_branch_public_ch::visit_structure (be_structure *node) { @@ -620,8 +540,7 @@ be_visitor_union_branch_public_ch::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_structure - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -631,37 +550,19 @@ be_visitor_union_branch_public_ch::visit_structure (be_structure *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // 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.node (node); 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_union_branch_public_ch::" - "visit_structure - " - "Bad visitor\n" - ), - -1); - } + be_visitor_structure_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_structure - " - "codegen failed\n" - ), + "codegen failed\n"), -1); } - - delete visitor; } *os << "void " << ub->local_name () << " (const " @@ -675,7 +576,6 @@ be_visitor_union_branch_public_ch::visit_structure (be_structure *node) return 0; } -// Visit typedefed type. int be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) { @@ -689,8 +589,7 @@ be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_spec_ch::" "visit_typedef - " - "Bad primitive type\n" - ), + "Bad primitive type\n"), -1); } @@ -698,7 +597,6 @@ be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) return 0; } -// Visit union type. int be_visitor_union_branch_public_ch::visit_union (be_union *node) { @@ -732,36 +630,19 @@ be_visitor_union_branch_public_ch::visit_union (be_union *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // 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); - - // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_ch visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_union - " - "Bad visitor\n" - ), + "codegen failed\n"), -1); } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_union - " - "codegen failed\n" - ), - -1); - } - - delete visitor; } *os << "void " << ub->local_name () << " (const " diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp index 593c57366b6..cd85b6701f1 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp @@ -18,17 +18,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, public_ci, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + public_ci, + "$Id$") // ***************************************************** -// visitor for union_branch in the client inline file +// Visitor for union_branch in the client inline file. // ***************************************************** // constructor @@ -55,33 +50,31 @@ be_visitor_union_branch_public_ci::visit_union_branch (be_union_branch *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cs::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cs::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a union_branch can be +// Visit operations on all possible data types that a union_branch can be. int be_visitor_union_branch_public_ci::visit_array (be_array *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -99,45 +92,35 @@ be_visitor_union_branch_public_ci::visit_array (be_array *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_enum - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); - // If bt is not a typedef and is defined inside the union + // If bt is not a typedef and is defined inside the union. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { // 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_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // 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_union_branch_public_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } + be_visitor_array_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - - delete visitor; } // For anonymous arrays, the type name has a _ prepended. We compute the @@ -180,44 +163,50 @@ be_visitor_union_branch_public_ci::visit_array (be_array *node) } // Set method. - os->indent (); - *os << "// accessor to set the member" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << fname - << " val)// set" << be_nl + << " val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl + << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = " << fname << "_dup (val);" << be_uidt_nl << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << fname << "_slice *" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -225,13 +214,11 @@ be_visitor_union_branch_public_ci::visit_array (be_array *node) int be_visitor_union_branch_public_ci::visit_enum (be_enum *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // heck if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) { bt = this->ctx_->alias (); @@ -246,50 +233,56 @@ be_visitor_union_branch_public_ci::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_enum - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. - os->indent (); - *os << "// accessor to set the member" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << " val)// set" << be_nl + << " val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl + << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = val;" << be_uidt_nl << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -297,10 +290,8 @@ be_visitor_union_branch_public_ci::visit_enum (be_enum *node) int be_visitor_union_branch_public_ci::visit_interface (be_interface *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -318,35 +309,41 @@ be_visitor_union_branch_public_ci::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. - os->indent (); - *os << "// accessor to set the member" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl + << "_ptr val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -373,12 +370,12 @@ be_visitor_union_branch_public_ci::visit_interface (be_interface *node) << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << "_ptr " << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return this->u_." << ub->local_name () << "_->ptr ();" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -386,10 +383,8 @@ be_visitor_union_branch_public_ci::visit_interface (be_interface *node) int be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -406,36 +401,42 @@ be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_interface - " - "bad context information\n" - ), -1); + "visit_interface_fwd - " + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. - os->indent (); - *os << "// accessor to set the member" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl + << "_ptr val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -462,12 +463,189 @@ be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *node) << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << "_ptr " << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return this->u_." << ub->local_name () << "_->ptr ();" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; + + return 0; +} + +int +be_visitor_union_branch_public_ci::visit_valuetype (be_valuetype *node) +{ + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); + 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_union_branch_public_ci::" + "visit_valuetype - " + "bad context information\n"), + -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + // Set method. + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl + << "ACE_INLINE void" << be_nl + << bu->name () << "::" << ub->local_name () << " (" << bt->name () + << " *val)" << be_nl + << "{" << be_idt_nl + << "// Set the discriminant value." << be_nl + << "this->_reset ("; + + if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) + { + ub->gen_label_value (os); + + *os << ", 0);" << be_nl + << "this->disc_ = "; + + ub->gen_label_value (os); + } + // Default label. + else + { + ub->gen_default_label_value (os, bu); + + *os << ", 0);" << be_nl + << "this->disc_ = "; + + ub->gen_default_label_value (os, bu); + } + + idl_bool bt_is_defined = node->is_defined (); + + *os << ";" << be_nl + << "CORBA::add_ref (val);" << be_nl + << "typedef " + << bt->nested_type_name (bu, "_var") + << " OBJECT_FIELD;" << be_nl + << "ACE_NEW (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (val)" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + // Get method. + *os << "// Retrieve the member." << be_nl + << "ACE_INLINE " << bt->name () << "_ptr " << be_nl + << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl + << "{" << be_idt_nl + << "return this->u_." << ub->local_name () << "_->ptr ();" << be_uidt_nl + << "}" << be_nl << be_nl; + + return 0; +} + +int +be_visitor_union_branch_public_ci::visit_valuetype_fwd (be_valuetype_fwd *node) +{ + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); + 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_union_branch_public_ci::" + "visit_valuetype_fwd - " + "bad context information\n"), + -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + // Set method. + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl + << "ACE_INLINE void" << be_nl + << bu->name () << "::" << ub->local_name () << " (" << bt->name () + << " *val)" << be_nl + << "{" << be_idt_nl + << "// Set the discriminant value." << be_nl + << "this->_reset ("; + + if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) + { + ub->gen_label_value (os); + + *os << ", 0);" << be_nl + << "this->disc_ = "; + + ub->gen_label_value (os); + } + // Default label. + else + { + ub->gen_default_label_value (os, bu); + + *os << ", 0);" << be_nl + << "this->disc_ = "; + + ub->gen_default_label_value (os, bu); + } + + idl_bool bt_is_defined = node->full_definition ()->is_defined (); + + *os << ";" << be_nl + << "typedef " + << bt->nested_type_name (bu, "_var") + << " OBJECT_FIELD;" << be_nl + << "ACE_NEW (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl; + + if (bt_is_defined) + { + *os << "OBJECT_FIELD (" << bt->name () << "::"; + } + else + { + *os << "OBJECT_FIELD (tao_" << node->flat_name (); + } + + *os << "_duplicate (val))" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + // Get method. + *os << "// Retrieve the member." << be_nl + << "ACE_INLINE " << bt->name () << "_ptr " << be_nl + << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl + << "{" << be_idt_nl + << "return this->u_." << ub->local_name () << "_->ptr ();" << be_uidt_nl + << "}" << be_nl << be_nl; return 0; } @@ -477,10 +655,8 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( be_predefined_type *node ) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -498,111 +674,125 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. - os->indent (); - *os << "// accessor to set the member" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name (); - if (node->pt () == AST_PredefinedType::PT_pseudo) + AST_PredefinedType::PredefinedType pt = node->pt (); + + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) { *os << "_ptr"; } + else if (pt == AST_PredefinedType::PT_any) + { + *os << " &"; + } *os << " val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl; - switch (node->pt ()) + switch (pt) { - case AST_PredefinedType::PT_pseudo: - if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) - { - *os << "typedef CORBA::Object_var OBJECT_FIELD;" << be_nl - << "ACE_NEW (" << be_idt << be_idt_nl - << "this->u_." << ub->local_name () << "_," << be_nl - << "OBJECT_FIELD (CORBA::Object::_duplicate (val))" - << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; - } - else - { - *os << "this->u_." << ub->local_name () << "_ = " - << bt->name () << "::_duplicate (val);" << be_uidt_nl; - } + case AST_PredefinedType::PT_object: + *os << "typedef CORBA::Object_var OBJECT_FIELD;" << be_nl + << "ACE_NEW (" << be_idt << be_idt_nl + << "this->u_." << ub->local_name () << "_," << be_nl + << "OBJECT_FIELD (CORBA::Object::_duplicate (val))" + << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + break; + case AST_PredefinedType::PT_pseudo: + *os << "this->u_." << ub->local_name () << "_ = " + << bt->name () << "::_duplicate (val);" << be_uidt_nl; + break; case AST_PredefinedType::PT_any: *os << "ACE_NEW (" << be_idt << be_idt_nl << "this->u_." << ub->local_name () << "_," << be_nl << bt->name () << " (val)" << be_uidt_nl << ");" << be_uidt << be_uidt_nl; - break; + break; case AST_PredefinedType::PT_void: break; - default: - *os << "// set the value" << be_nl + *os << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = val;" << be_uidt_nl; + + break; } *os << "}" << be_nl << be_nl; - switch (node->pt ()) + switch (pt) { - case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << "_ptr" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl; + *os << "return this->u_." << ub->local_name () + << "_->ptr ();" << be_uidt_nl; + *os << "}" << be_nl << be_nl; - if (!ACE_OS::strcmp (bt->local_name ()->get_string (), "Object")) - { - *os << "return this->u_." << ub->local_name () - << "_->ptr ();" << be_uidt_nl; - } - else - { - *os << "return this->u_." << ub->local_name () - << "_;" << be_uidt_nl; - } + break; + case AST_PredefinedType::PT_pseudo: + // Get method. + *os << "// Retrieve the member." << be_nl + << "ACE_INLINE " << bt->name () << "_ptr" << be_nl + << bu->name () << "::" << ub->local_name () + << " (void) const" << be_nl + << "{" << be_idt_nl; + *os << "return this->u_." << ub->local_name () + << "_;" << be_uidt_nl; + *os << "}" << be_nl << be_nl; - *os << "}\n\n"; break; case AST_PredefinedType::PT_any: // Get method with read-only access. *os << "// retrieve the member" << be_nl - << "ACE_INLINE const " << bt->name () << be_nl + << "ACE_INLINE const " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -611,12 +801,12 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( // Get method with read/write access *os << "// retrieve the member" << be_nl - << "ACE_INLINE " << bt->name () << be_nl + << "ACE_INLINE " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; break; case AST_PredefinedType::PT_void: break; @@ -628,7 +818,9 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( << " (void) const" << be_nl << "{" << be_idt_nl << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; + + break; } return 0; @@ -637,10 +829,8 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( int be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -658,69 +848,66 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_sequence - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); - // If bt is not a typedef and is defined inside the union + // If bt is not a typedef and is defined inside the union. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { // 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_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // First generate 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_union_branch_public_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } + be_visitor_sequence_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - - delete visitor; } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (1) Set from a const. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -732,7 +919,7 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) << "}" << be_nl << be_nl; // Readonly get method. - *os << "// readonly get method " << be_nl + *os << "// Readonly get method." << be_nl << "ACE_INLINE const " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -740,12 +927,12 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) << "}" << be_nl << be_nl; // Read/write get method. - *os << "// read/write get method " << be_nl + *os << "// Read/write get method." << be_nl << "ACE_INLINE " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -753,18 +940,16 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) int be_visitor_union_branch_public_ci::visit_string (be_string *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_string - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -772,8 +957,10 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) // Three methods to set the string value. // (1) Set method from char* or wchar*. - os->indent (); - *os << "// accessor to set the member" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl; if (node->width () == (long) sizeof (char)) @@ -788,22 +975,26 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) *os << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -813,7 +1004,7 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) << "}" << be_nl << be_nl; // (2) Set method from const char * or const wchar *. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name (); @@ -826,27 +1017,31 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) *os << " (const CORBA::WChar *val)" << be_nl << "{" << be_idt_nl; } - *os << "// set the discriminant val" << be_nl + *os << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl + << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = "; if (node->width () == (long) sizeof (char)) @@ -861,7 +1056,7 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) } // (3) Set from const String_var& or WString_var& - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name (); @@ -875,27 +1070,31 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) } *os << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl; + << "// Set the value." << be_nl; if (node->width () == (long) sizeof (char)) { @@ -925,7 +1124,7 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) << " (void) const // get method" << be_nl << "{" << be_idt_nl << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -933,10 +1132,8 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) int be_visitor_union_branch_public_ci::visit_structure (be_structure *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -954,8 +1151,8 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_structure - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -967,56 +1164,53 @@ be_visitor_union_branch_public_ci::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_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // First generate the struct 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_union_branch_public_ci::" - "visit_structure - " - "Bad visitor\n" - ), -1); - } + be_visitor_structure_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_structure - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - - delete visitor; } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (1) Set from a const. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -1038,7 +1232,7 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) *os << "}" << be_nl << be_nl; // Readonly get method. - *os << "// readonly get method " << be_nl + *os << "// Readonly get method." << be_nl << "ACE_INLINE const " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl; @@ -1056,7 +1250,7 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) *os << "}" << be_nl << be_nl; // Read/write get method. - *os << "// read/write get method " << be_nl + *os << "// Read/write get method." << be_nl << "ACE_INLINE " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl; @@ -1071,7 +1265,7 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) *os << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; } - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -1090,8 +1284,8 @@ be_visitor_union_branch_public_ci::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); @@ -1101,10 +1295,8 @@ be_visitor_union_branch_public_ci::visit_typedef (be_typedef *node) int be_visitor_union_branch_public_ci::visit_union (be_union *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -1122,8 +1314,8 @@ be_visitor_union_branch_public_ci::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_union - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -1135,56 +1327,53 @@ be_visitor_union_branch_public_ci::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_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_ci visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_union - " - "Bad visitor\n" - ), -1); + "codegen failed\n"), + -1); } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_union - " - "codegen failed\n" - ), -1); - } - - delete visitor; } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (1) Set from a const. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -1196,7 +1385,7 @@ be_visitor_union_branch_public_ci::visit_union (be_union *node) << "}" << be_nl << be_nl; // Readonly get method. - *os << "// readonly get method " << be_nl + *os << "// Readonly get method." << be_nl << "ACE_INLINE const " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -1204,12 +1393,12 @@ be_visitor_union_branch_public_ci::visit_union (be_union *node) << "}" << be_nl << be_nl; // Read/write get method. - *os << "// read/write get method " << be_nl + *os << "// Read/write get method." << be_nl << "ACE_INLINE " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp index 5d8424c9b92..b71a82bb660 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp @@ -18,244 +18,170 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, public_cs, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + public_cs, + "$Id$") // ********************************************** -// visitor for union_branch in the client stubs file +// Visitor for union_branch in the client stubs file. // ********************************************** -// constructor -be_visitor_union_branch_public_cs::be_visitor_union_branch_public_cs (be_visitor_context *ctx) +be_visitor_union_branch_public_cs::be_visitor_union_branch_public_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_public_cs::~be_visitor_union_branch_public_cs (void) { } -// visit the union_branch node int be_visitor_union_branch_public_cs::visit_union_branch (be_union_branch *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } + return 0; } -// visit array type int be_visitor_union_branch_public_cs::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be - // defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be + // defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // anonymous array case - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Anonymous array case. 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.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_union_branch_public_cs::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 - - // generate the typcode for enums + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ENUM_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; + return 0; } -// visit sequence type int be_visitor_union_branch_public_cs::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be - // defined + // If not a typedef and we are defined in the use scope, we must be + // defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // anonymous array case - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Anonymous sequence case. 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.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit string type int be_visitor_union_branch_public_cs::visit_string (be_string *) { return 0; } -// visit structure type int be_visitor_union_branch_public_cs::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 - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; + return 0; } -// visit union type int be_visitor_union_branch_public_cs::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 - - // generate the inline code for union + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_reset_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_reset_cs.cpp index 3f5e80ba612..523b1e310c1 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_reset_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_reset_cs.cpp @@ -18,28 +18,21 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.h" - -ACE_RCSID(be_visitor_union_branch, public_reset_cs, "$Id$") - +ACE_RCSID (be_visitor_union_branch, + public_reset_cs, + "$Id$") // ***************************************************** // visitor for union_branch in the client // stubs file for the reset method // ***************************************************** -// constructor be_visitor_union_branch_public_reset_cs:: be_visitor_union_branch_public_reset_cs (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_public_reset_cs:: ~be_visitor_union_branch_public_reset_cs (void) { @@ -47,33 +40,31 @@ be_visitor_union_branch_public_reset_cs:: // visit the union_branch node int -be_visitor_union_branch_public_reset_cs:: -visit_union_branch (be_union_branch *node) +be_visitor_union_branch_public_reset_cs::visit_union_branch ( + be_union_branch *node + ) { - TAO_OutStream *os; - be_type *bt; // union_branch's type + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); - os = this->ctx_->stream (); - // first generate the type information - bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cs::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } this->ctx_->node (node); // save the node - for (unsigned long i = 0; - i < node->label_list_length (); - ++i) + for (unsigned long i = 0; i < node->label_list_length (); ++i) { // check if we are printing the default case if (node->label (i)->label_kind () == AST_UnionLabel::UL_default) - *os << "default:"; + { + *os << "default:"; + } else { *os << "case "; @@ -91,52 +82,56 @@ visit_union_branch (be_union_branch *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cs::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } + return 0; } -// =visit operations on all possible data types that a union_branch can be - int be_visitor_union_branch_public_reset_cs::visit_array (be_array *node) { - TAO_OutStream *os; // output stream be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); 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 (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_enum - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - // for anonymous arrays, the type name has a _ prepended. We compute the + // For anonymous arrays, the type name has a _ prepended. We compute the // full_name with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and + 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); + 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 + // 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 ()) { @@ -151,15 +146,16 @@ be_visitor_union_branch_public_reset_cs::visit_array (be_array *node) } else { - // typedefed node ACE_OS::sprintf (fname, "%s", bt->full_name ()); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); + *os << fname << "_free (this->u_." << ub->local_name () << "_);" << be_nl << "this->u_." << ub->local_name () << "_ = 0;" << be_nl << "break;" << be_uidt_nl; + return 0; } @@ -167,17 +163,17 @@ int be_visitor_union_branch_public_reset_cs::visit_enum (be_enum *) { be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_enum - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -190,20 +186,21 @@ int be_visitor_union_branch_public_reset_cs::visit_interface (be_interface *) { be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); + *os << "delete this->u_." << ub->local_name () << "_;" << be_nl << "this->u_." << ub->local_name () @@ -217,19 +214,77 @@ int be_visitor_union_branch_public_reset_cs::visit_interface_fwd (be_interface_fwd *) { be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" - "visit_interface - " - "bad context information\n" - ), -1); + "visit_interface_fwd - " + "bad context information\n"), + -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + *os << "delete this->u_." + << ub->local_name () << "_;" << be_nl + << "this->u_." << ub->local_name () + << "_ = 0;" << be_nl + << "break;" << be_uidt_nl; + + return 0; +} + +int +be_visitor_union_branch_public_reset_cs::visit_valuetype (be_valuetype *) +{ + be_union_branch *ub = + this->ctx_->be_node_as_union_branch (); + be_union *bu = + this->ctx_->be_scope_as_union (); + + if (!ub || !bu) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_branch_public_reset_cs::" + "visit_valuetype - " + "bad context information\n"), + -1); + } + + TAO_OutStream *os = this->ctx_->stream (); + + *os << "delete this->u_." + << ub->local_name () << "_;" << be_nl + << "this->u_." << ub->local_name () + << "_ = 0;" << be_nl + << "break;" << be_uidt_nl; + + return 0; +} + +int +be_visitor_union_branch_public_reset_cs::visit_valuetype_fwd (be_valuetype_fwd *) +{ + be_union_branch *ub = + this->ctx_->be_node_as_union_branch (); + be_union *bu = + this->ctx_->be_scope_as_union (); + + if (!ub || !bu) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_union_branch_public_reset_cs::" + "visit_valuetype_fwd - " + "bad context information\n"), + -1); } + TAO_OutStream *os = this->ctx_->stream (); + *os << "delete this->u_." << ub->local_name () << "_;" << be_nl << "this->u_." << ub->local_name () @@ -240,40 +295,43 @@ be_visitor_union_branch_public_reset_cs::visit_interface_fwd (be_interface_fwd * } int -be_visitor_union_branch_public_reset_cs::visit_predefined_type (be_predefined_type *node) +be_visitor_union_branch_public_reset_cs::visit_predefined_type ( + be_predefined_type *node + ) { be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_predefined_type - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); switch (node->pt ()) { + case AST_PredefinedType::PT_object: + *os << "delete this->u_." + << ub->local_name () << "_;" << be_nl; + *os << "this->u_." << ub->local_name () + << "_ = 0;" << be_nl + << "break;" << be_uidt_nl; + + break; case AST_PredefinedType::PT_pseudo: - if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) - { - *os << "delete this->u_." - << ub->local_name () << "_;" << be_nl; - } - else - { - *os << "CORBA::release (this->u_." - << ub->local_name () << "_);" << be_nl; - } + *os << "CORBA::release (this->u_." + << ub->local_name () << "_);" << be_nl; *os << "this->u_." << ub->local_name () << "_ = 0;" << be_nl << "break;" << be_uidt_nl; + break; case AST_PredefinedType::PT_any: *os << "delete this->u_." @@ -281,12 +339,16 @@ be_visitor_union_branch_public_reset_cs::visit_predefined_type (be_predefined_ty << "this->u_." << ub->local_name () << "_ = 0;" << be_nl << "break;" << be_uidt_nl; + break; case AST_PredefinedType::PT_void: break; default: *os << "break;" << be_uidt_nl; + + break; } + return 0; } @@ -294,20 +356,21 @@ int be_visitor_union_branch_public_reset_cs::visit_sequence (be_sequence *) { be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_sequence - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); + *os << "delete this->u_." << ub->local_name () << "_;" << be_nl << "this->u_." @@ -322,17 +385,17 @@ int be_visitor_union_branch_public_reset_cs::visit_string (be_string *node) { be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_string - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -358,28 +421,32 @@ be_visitor_union_branch_public_reset_cs::visit_string (be_string *node) int be_visitor_union_branch_public_reset_cs::visit_structure (be_structure *node) { - TAO_OutStream *os; // output stream be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); 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 (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_structure - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); + + TAO_OutStream *os = this->ctx_->stream (); + if (bt->size_type () == be_type::VARIABLE || node->has_constructor ()) { @@ -398,18 +465,18 @@ be_visitor_union_branch_public_reset_cs::visit_structure (be_structure *node) int be_visitor_union_branch_public_reset_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 + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // 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_reset_cs::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); @@ -420,20 +487,21 @@ int be_visitor_union_branch_public_reset_cs::visit_union (be_union *) { be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch + this->ctx_->be_node_as_union_branch (); be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_reset_cs::" "visit_union - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); + *os << "delete this->u_." << ub->local_name () << "_;" << be_nl << "this->u_." diff --git a/TAO/TAO_IDL/be/be_visitor_union_fwd.cpp b/TAO/TAO_IDL/be/be_visitor_union_fwd.cpp new file mode 100644 index 00000000000..79ed60e34cc --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_union_fwd.cpp @@ -0,0 +1,31 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// be_visitor_union_fwd.cpp +// +// = DESCRIPTION +// Visitors for generation of code for be_union_fwd +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "be_union_fwd.h" + +#include "be_visitor_union_fwd.h" +#include "be_visitor_context.h" +#include "be_helper.h" + +#include "be_visitor_union_fwd/union_fwd_ch.cpp" + +ACE_RCSID (be, + be_visitor_union_fwd, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_union_fwd/union_fwd_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_fwd/union_fwd_ch.cpp new file mode 100644 index 00000000000..ad86bed923b --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_union_fwd/union_fwd_ch.cpp @@ -0,0 +1,53 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// union_fwd_ch.cpp +// +// = DESCRIPTION +// Visitor generating code for be_union_fwd node in the client header. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +ACE_RCSID (be_visitor_union_fwd, + union_fwd_ch, + "$Id$") + +be_visitor_union_fwd_ch::be_visitor_union_fwd_ch ( + be_visitor_context *ctx + ) + : be_visitor_decl (ctx) +{ +} + +be_visitor_union_fwd_ch::~be_visitor_union_fwd_ch (void) +{ +} + +// Visit the interface_fwd_ch node and its scope. +int +be_visitor_union_fwd_ch::visit_union_fwd (be_union_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + if (node->cli_hdr_gen () || node->imported ()) + { + return 0; + } + + // Generate a forward declaration of the class. + *os << "class " << node->local_name () << ";" << be_nl; + + node->cli_hdr_gen (I_TRUE); + + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype.cpp index 662f378433f..fd38a0cb138 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype.cpp @@ -18,20 +18,58 @@ // // ============================================================================ +#include "be_argument.h" +#include "be_array.h" +#include "be_attribute.h" +#include "be_constant.h" +#include "be_enum.h" +#include "be_exception.h" +#include "be_factory.h" +#include "be_field.h" +#include "be_interface_fwd.h" +#include "be_module.h" +#include "be_predefined_type.h" +#include "be_operation.h" +#include "be_sequence.h" +#include "be_string.h" +#include "be_structure.h" +#include "be_structure_fwd.h" +#include "be_typedef.h" +#include "be_union.h" +#include "be_union_fwd.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_helper.h" +#include "be_extern.h" +#include "utl_identifier.h" -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be_visitor_argument.h" +#include "be_visitor_array.h" #include "be_visitor_valuetype.h" +#include "be_visitor_field.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_operation.h" +#include "be_visitor_sequence.h" +#include "be_visitor_structure.h" +#include "be_visitor_structure_fwd.h" +#include "be_visitor_typecode.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" +#include "be_visitor_union_fwd.h" +#include "be_visitor_context.h" #include "be_visitor_valuetype/valuetype.cpp" #include "be_visitor_valuetype/valuetype_ch.cpp" +#include "be_visitor_valuetype/valuetype_ci.cpp" +#include "be_visitor_valuetype/valuetype_cs.cpp" +#include "be_visitor_valuetype/valuetype_sh.cpp" +#include "be_visitor_valuetype/valuetype_si.cpp" +#include "be_visitor_valuetype/valuetype_ss.cpp" #include "be_visitor_valuetype/valuetype_obv_ch.cpp" #include "be_visitor_valuetype/valuetype_obv_ci.cpp" #include "be_visitor_valuetype/valuetype_obv_cs.cpp" -#include "be_visitor_valuetype/valuetype_ci.cpp" -#include "be_visitor_valuetype/valuetype_cs.cpp" #include "be_visitor_valuetype/any_op_ch.cpp" #include "be_visitor_valuetype/any_op_cs.cpp" #include "be_visitor_valuetype/cdr_op_ch.cpp" @@ -54,3 +92,6 @@ #include "be_visitor_valuetype/valuetype_init_cs.cpp" #include "be_visitor_valuetype/valuetype_init_arglist_ch.cpp" +ACE_RCSID (be, + be_visitor_valuetype, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp index 129104f1a06..1fa8514f202 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp @@ -18,33 +18,33 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, ami_exception_holder_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + ami_exception_holder_ch, + "$Id$") // ****************************************************** -// Interface visitor for client header +// Interface visitor for client header. // ****************************************************** -be_visitor_valuetype_ami_exception_holder_ch::be_visitor_valuetype_ami_exception_holder_ch (be_visitor_context *ctx) +be_visitor_valuetype_ami_exception_holder_ch:: +be_visitor_valuetype_ami_exception_holder_ch (be_visitor_context *ctx) : be_visitor_valuetype (ctx) { } -be_visitor_valuetype_ami_exception_holder_ch::~be_visitor_valuetype_ami_exception_holder_ch (void) +be_visitor_valuetype_ami_exception_holder_ch:: +~be_visitor_valuetype_ami_exception_holder_ch (void) { } int -be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *node) +be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype ( + be_valuetype *node + ) { TAO_OutStream *os = this->ctx_->stream (); - // Generate the implemenation of the Messaging aware ORB + // Generate the implemenation of the Messaging aware ORB. *os << be_nl << "class _tao_" << node->local_name () << be_idt_nl << ": public "; @@ -58,17 +58,15 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *nod << " public virtual OBV_Messaging::ExceptionHolder," << be_nl << " public virtual CORBA::DefaultValueRefCountBase" << be_uidt_nl << "{" << be_nl; - *os << "public:" << be_idt_nl; - *os << "_tao_" << node->local_name () << " ();" << be_nl << be_nl; - *os << "~_tao_" << node->local_name () << " ();" << be_nl << be_nl; if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ami_exception_holder_cs::" + "(%N:%l) be_visitor_valuetype_ami_" + "exception_holder_cs::" "visit_valuetype - " "codegen for scope failed\n"), -1); @@ -76,36 +74,28 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *nod *os << be_uidt_nl << "};" << be_nl << be_nl; + return 0; } int -be_visitor_valuetype_ami_exception_holder_ch::visit_operation (be_operation *node) +be_visitor_valuetype_ami_exception_holder_ch::visit_operation ( + be_operation *node + ) { be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_ih visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ami_exception_holder_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_valuetype_ami_exception_holder_ch::" + "(%N:%l) be_visitor_valuetype_" + "ami_exception_holder_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp index 8d22f9cdae1..924091b2ace 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp @@ -18,56 +18,58 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, ami_exception_holder_cs, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + ami_exception_holder_cs, + "$Id$") // ************************************************************ // Interface visitor for client stubs // ************************************************************ -be_visitor_valuetype_ami_exception_holder_cs::be_visitor_valuetype_ami_exception_holder_cs (be_visitor_context *ctx) +be_visitor_valuetype_ami_exception_holder_cs:: +be_visitor_valuetype_ami_exception_holder_cs (be_visitor_context *ctx) : be_visitor_valuetype (ctx) { } -be_visitor_valuetype_ami_exception_holder_cs::~be_visitor_valuetype_ami_exception_holder_cs (void) +be_visitor_valuetype_ami_exception_holder_cs:: +~be_visitor_valuetype_ami_exception_holder_cs (void) { } int -be_visitor_valuetype_ami_exception_holder_cs::visit_valuetype (be_valuetype *node) +be_visitor_valuetype_ami_exception_holder_cs::visit_valuetype ( + be_valuetype *node + ) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); - os = this->ctx_->stream (); - - if (node->is_nested () && - node->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "OBV_"; + if (node->is_nested () + && node->defined_in ()->scope_node_type () == AST_Decl::NT_module) + { + *os << "OBV_"; + } *os << node->compute_name ("_tao_", "") << "::" << node->compute_local_name ("_tao_", "") << " () { }" << be_nl << be_nl; - if (node->is_nested () && - node->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "OBV_"; + if (node->is_nested () + && node->defined_in ()->scope_node_type () == AST_Decl::NT_module) + { + *os << "OBV_"; + } *os << node->compute_name ("_tao_", "") << "::~" << node->compute_local_name ("_tao_", "") << " () { }" << be_nl << be_nl; - // generate code for the elements of the interface + // Generate code for the elements of the interface if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ami_exception_holder_cs::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } return 0; @@ -79,28 +81,16 @@ be_visitor_valuetype_ami_exception_holder_cs::visit_operation (be_operation *nod { be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_AMI_EXCEPTION_HOLDER_RAISE_OPERATION_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_ami_exception_holder_operation_cs visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ami_exception_holder_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_valuetype_ami_exception_holder_ch::" - "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp index 008b53322a9..69cf3eb4a34 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp @@ -20,13 +20,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, any_op_ch, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + any_op_ch, + "$Id$") // *************************************************************************** // Valuetype visitor for generating Any operator declarations. @@ -69,7 +65,7 @@ be_visitor_valuetype_any_op_ch::visit_valuetype (be_valuetype *node) *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator>>= (const CORBA::Any &, " - << node->name () << " *&);\n"; + << node->name () << " *&);" << be_nl; node->cli_hdr_any_op_gen (1); diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp index 1c685d835a4..74232a8ed5a 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp @@ -18,13 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, any_op_cs, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + any_op_cs, + "$Id$") // *************************************************************************** // Valuetype visitor for generating Any operator declarations in the client @@ -45,37 +41,47 @@ be_visitor_valuetype_any_op_cs::~be_visitor_valuetype_any_op_cs (void) int be_visitor_valuetype_any_op_cs::visit_valuetype (be_valuetype *node) { - if (node->cli_stub_any_op_gen () || node->imported ()) + if (node->cli_stub_any_op_gen () + || node->imported () + || node->is_local ()) { return 0; } TAO_OutStream *os = this->ctx_->stream (); - os->indent (); + // Generate the Any <<= and >>= operator declarations - // Generate the Any <<= and >>= operator declarations. + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - *os << be_global->stub_export_macro () << " void" << be_nl - << "operator<<= (CORBA::Any &any, " << node->name () - << " *value) // copying" << be_nl + *os << "// Copying." << be_nl + << "void" << be_nl + << "operator<<= (" << be_idt << be_idt_nl + << "CORBA::Any &any," << be_nl + << node->name () << " *value" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl - << "TAO_OutputCDR stream;" << be_nl - << "if (stream << value)" << be_nl + << "TAO_OutputCDR stream;" << be_nl << be_nl + << "if (stream << value)" << be_idt_nl << "{" << be_idt_nl << "any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << ", " << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl - << "stream.begin ());" << be_uidt << be_uidt << be_uidt_nl - << "}" << be_uidt_nl + << "stream.begin ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << be_nl; - *os << be_global->stub_export_macro () << " void" << be_nl - << "operator<<= (CORBA::Any &any, " << node->name () - << " **value) // non-copying" << be_nl + *os << "// Non-copying." << be_nl + << "void" << be_nl + << "operator<<= (" << be_idt << be_idt_nl + << "CORBA::Any &any," << be_nl + << node->name ()<< " **value" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl - << "TAO_OutputCDR stream;" << be_nl - << "if (stream << *value)" << be_nl + << "TAO_OutputCDR stream;" << be_nl << be_nl + << "if (stream << *value)" << be_idt_nl << "{" << be_idt_nl << "any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << ", " << be_nl @@ -83,56 +89,65 @@ be_visitor_valuetype_any_op_cs::visit_valuetype (be_valuetype *node) << "stream.begin ()," << be_nl << "1," << be_nl << "*value," << be_nl - << node->name () << "::_tao_any_destructor);" - << be_uidt << be_uidt << be_uidt_nl - << "}" << be_uidt_nl + << node->name () << "::_tao_any_destructor" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << be_nl; - *os << be_global->stub_export_macro () << " CORBA::Boolean" << be_nl - << "operator>>= (const CORBA::Any &any, " - << node->name () << " *&value)" << be_nl + *os << "CORBA::Boolean" << be_nl + << "operator>>= (" << be_idt << be_idt_nl + << "const CORBA::Any &any," << be_nl + << node->name () << " *&value" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "value = 0;" << be_nl - << "CORBA::TypeCode_var type = any.type ();" << be_nl << be_nl - << "CORBA::Boolean result = type->equivalent (" << node->tc_name () - << " ACE_ENV_ARG_PARAMETER);" << be_nl + << "CORBA::TypeCode_var type = any.type ();" << be_nl + << "CORBA::Boolean result =" << be_idt_nl + << "type->equivalent (" << be_idt << be_idt_nl + << node->tc_name () << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl << be_nl - << "if (!result)" << be_nl + << "if (!result)" << be_idt_nl << "{" << be_idt_nl << "return 0; // not equivalent" << be_uidt_nl - << "}" << be_nl - << "if (any.any_owns_data ())" << be_nl + << "}" << be_uidt_nl << be_nl + << "if (any.any_owns_data ())" << be_idt_nl << "{" << be_idt_nl - << "const " << node->name () << " *const_holder = " + << "const " << node->name () << " *const_holder =" << be_idt_nl << "ACE_static_cast (" << be_idt << be_idt_nl - << "const " << node->name () << "*," << be_nl - << "any.value ());" << be_uidt << be_uidt_nl - << "value = ACE_const_cast (" << be_idt << be_idt_nl - << node->name () << "*," << be_nl - << "const_holder);" << be_uidt << be_uidt_nl + << "const " << node->name () << " *," << be_nl + << "any.value ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "value =" << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->name () << " *," << be_nl + << "const_holder" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // else any does not own the data + << "}" << be_uidt_nl + << "else" << be_idt_nl // else any does not own the data << "{" << be_idt_nl << node->name () << " *tmp;" << be_nl << "TAO_InputCDR stream (" << be_idt << be_idt_nl << "any._tao_get_cdr ()," << be_nl - << "any._tao_byte_order ());" << be_uidt << be_uidt_nl - << "if (stream >> tmp)" << be_nl + << "any._tao_byte_order ()" << be_uidt_nl + << ");" << be_uidt_nl << be_nl + << "if (stream >> tmp)" << be_idt_nl << "{" << be_idt_nl << "((CORBA::Any *)&any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_static_cast (void *, tmp)," << be_nl - << node->name () << "::_tao_any_destructor);" << be_uidt << be_uidt_nl + << node->name () << "::_tao_any_destructor" << be_uidt_nl + << ");" << be_uidt_nl << "value = tmp;" << be_nl << "return 1;" << be_uidt_nl - << "}" << be_nl - << be_uidt_nl - << "}" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl << "{" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp index b3a255b16cb..bb183c26b31 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp @@ -20,23 +20,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_valuetype, arglist, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + arglist, + "$Id$") // ************************************************************ -// operation visitor to generate the argument list. +// 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 +// visitors to avoid code duplication and tight coupling. // ************************************************************ -be_visitor_obv_operation_arglist::be_visitor_obv_operation_arglist (be_visitor_context - *ctx) +be_visitor_obv_operation_arglist::be_visitor_obv_operation_arglist ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -52,6 +48,7 @@ be_visitor_obv_operation_arglist::is_amh_exception_holder (be_operation *node) be_interface *iface = be_interface::narrow_from_scope (scope); int is_an_amh_exception_holder = 0; + if (iface != 0) { const char *amh_underbar = "AMH_"; @@ -63,16 +60,16 @@ be_visitor_obv_operation_arglist::is_amh_exception_holder (be_operation *node) amh_underbar[3] == node_name[3] ) // node name starts with "AMH_" { - //ACE_DEBUG ((LM_DEBUG, "Passed first test of amh_excepholder \n")); const char *last_E = ACE_OS::strrchr (iface->full_name (), 'E'); + if (last_E != 0 && ACE_OS::strcmp (last_E, "ExceptionHolder") == 0) { - //ACE_DEBUG ((LM_DEBUG, "obv_operation: Passed second test of amh_excepholder \n")); is_an_amh_exception_holder = 1; } } } + return is_an_amh_exception_holder; } @@ -100,26 +97,9 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) { // Use ACE_ENV_SINGLE_ARG_DECL or ACE_ENV_ARG_DECL depending on // whether the operation node has parameters. - const char *env_decl; - /********************************************************************/ - // If it is an AMH raise operation, we do not need the Environment - // variable. - if (amh_valuetype) - { - if (node->argument_count () > 0) - env_decl = " ACE_ENV_ARG_DECL_NOT_USED"; - else - env_decl = " ACE_ENV_SINGLE_ARG_DECL_NOT_USED"; - } - /********************************************************************/ - else - { - if (node->argument_count () > 0) - env_decl = " ACE_ENV_ARG_DECL"; - else - env_decl = " ACE_ENV_SINGLE_ARG_DECL"; - } - *os << env_decl; + const char *env_decl = (node->argument_count () > 0 + ? " ACE_ENV_ARG_DECL" + : "ACE_ENV_SINGLE_ARG_DECL"); if (!amh_valuetype) { @@ -146,7 +126,7 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) *os << be_uidt_nl; } - *os << ")" << be_uidt; + *os << ")"; be_visitor_context ctx = *this->ctx_; be_visitor_operation operation_visitor (&ctx); @@ -164,12 +144,10 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) // Each method is pure virtual in the Valuetype class. // BUT, not if it is an AMH ExceptionHolder! /***********************************************************/ - if (amh_valuetype) + if (is_amh_exception_holder (node)) { - *os << be_uidt_nl - << "{ this->exception->_raise (); }" - << be_uidt_nl - << be_nl; + *os << "{ this->exception->_raise (); }" + << be_uidt_nl; } /***********************************************************/ else @@ -182,11 +160,11 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CH: - *os << ";" << be_uidt_nl; + *os << ";" << be_nl; break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CS: default: - *os << be_uidt_nl; + *os << be_nl; } return 0; @@ -195,17 +173,14 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) 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 + // 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, @@ -217,10 +192,9 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) // 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 + // information from the context. // %! use AST_Interface - be_valuetype *intf; - intf = this->ctx_->attribute () + be_valuetype *intf = this->ctx_->attribute () ? be_valuetype::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_valuetype::narrow_from_scope (op->defined_in ()); @@ -232,14 +206,13 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) "Bad interface\n"), -1); } - ctx.scope (intf); // set new scope - // snipped from - // be_visitor_args_arglist::visit_argument (be_argument *node) + ctx.scope (intf); ctx.node (node); // save the argument node - // retrieve the type + // Retrieve the type. be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -249,24 +222,27 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) -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 () + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); + be_visitor_args_arglist visitor (&ctx); + status = bt->accept (&visitor); + 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; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS); + be_visitor_args_arglist visitor (&ctx); + status = bt->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -277,26 +253,15 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) } } - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { 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; } @@ -306,21 +271,26 @@ be_visitor_obv_operation_arglist::post_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); - switch (this->ctx_->state ()) + 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 << ", "; + } + else { - 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; + *os << ""; } + + 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 index 51c3b5aa54a..2b8790ce4fc 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ch.cpp @@ -20,17 +20,13 @@ // // ============================================================================ +ACE_RCSID (be_visitor_valuetype, + cdr_op_ch, + "$Id$") -#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_cdr_op_ch::be_visitor_valuetype_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_valuetype (ctx) { } @@ -48,10 +44,6 @@ be_visitor_valuetype_cdr_op_ch::visit_valuetype (be_valuetype *node) } TAO_OutStream *os = this->ctx_->stream (); - os->indent (); //start with whatever indentation level we are at now - - - if (!node->cli_hdr_cdr_op_gen ()) { // Generate helper functions declaration. @@ -60,12 +52,12 @@ be_visitor_valuetype_cdr_op_ch::visit_valuetype (be_valuetype *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cdr_op_ch::" "visit_valuetype - " - "codegen for helper functions failed\n"), -1); + "codegen for helper functions failed\n"), + -1); } - // generate the CDR << and >> operator declarations (prototypes) - - os->indent (); //start with whatever indentation level we are at now + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *os << be_global->stub_export_macro () << " " << "CORBA::Boolean operator<< (TAO_OutputCDR &, const " @@ -78,29 +70,25 @@ be_visitor_valuetype_cdr_op_ch::visit_valuetype (be_valuetype *node) node->cli_hdr_cdr_op_gen (1); } - - // set the substate as generating code for the types defined in our scope + // 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); + "codegen for scope failed\n"), + -1); } - //@@ Boris: that's suck! - if (!node->is_abstract_valuetype ()) + if (!node->is_abstract ()) { - // functions that marshal state - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_valuetype_marshal_ch visitor (new_ctx); + // Functions that marshal state. + be_visitor_context new_ctx (*this->ctx_); + be_visitor_valuetype_marshal_ch visitor (&new_ctx); visitor.visit_valuetype (node); } - - 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 index ad77ab00e28..7ef0373f2b7 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_ci.cpp @@ -20,18 +20,13 @@ // // ============================================================================ +ACE_RCSID (be_visitor_valuetype, + cdr_op_ci, + "$Id$") -#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_cdr_op_ci::be_visitor_valuetype_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_valuetype (ctx) { } @@ -43,9 +38,11 @@ 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. + // Already generated and/or we are imported. Don't do anything. if (node->cli_inline_cdr_op_gen () || node->imported ()) - return 0; + { + return 0; + } // Generate helper functions implementation. if (node->gen_helper_inline () == -1) @@ -53,45 +50,31 @@ be_visitor_valuetype_cdr_op_ci::visit_valuetype (be_valuetype *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cdr_op_ci::" "visit_valuetype - " - "codegen for helper functions failed\n"), -1); + "codegen for helper functions failed\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); - os->indent (); //start with whatever indentation level we are at now - - // Generate CDR << and >> operator signatures - //@@ Boris: Can I move this to be_valuetype? (as with _var, _out, etc?) + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - //This is just declaration so no ACE_INLINE + // This is just declaration so no ACE_INLINE *os << be_global->stub_export_macro () << " " << "CORBA::Boolean operator<< (TAO_OutputCDR &, const " << node->full_name () << " *);" << be_nl; *os << be_global->stub_export_macro () << " " << "CORBA::Boolean operator>> (TAO_InputCDR &, " - << node->full_name () << " *&);" << be_nl; - - - - // Generate marshaling code if any - - // @@ Boris: the next statement is patrue anymore since I moved code - // to stubs. - - // 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 + << node->full_name () << " *&);" << be_nl << be_nl; - // 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); + "codegen for scope failed\n"), + -1); } node->cli_inline_cdr_op_gen (I_TRUE); diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp index 574b3cd3131..597784321ae 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp @@ -21,17 +21,13 @@ // // ============================================================================ +ACE_RCSID (be_visitor_valuetype, + valuetype_cdr_op_cs, + "$Id$") -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_cdr_op_cs, "$Id$") - -be_visitor_valuetype_cdr_op_cs::be_visitor_valuetype_cdr_op_cs -(be_visitor_context *ctx) +be_visitor_valuetype_cdr_op_cs::be_visitor_valuetype_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_valuetype (ctx) { } @@ -43,9 +39,11 @@ be_visitor_valuetype_cdr_op_cs::~be_visitor_valuetype_cdr_op_cs (void) int be_visitor_valuetype_cdr_op_cs::visit_valuetype (be_valuetype *node) { - // already generated and/or we are imported. Don't do anything. + // Already generated and/or we are imported. Don't do anything. if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; + { + return 0; + } // Generate helper functions implementation. if (node->gen_helper_stubs () == -1) @@ -53,79 +51,65 @@ be_visitor_valuetype_cdr_op_cs::visit_valuetype (be_valuetype *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cdr_op_cs::" "visit_valuetype - " - "codegen for helper functions failed\n"), -1); + "codegen for helper functions failed\n"), + -1); } - // Generate marshaling code - - TAO_OutStream *os = this->ctx_->stream (); - // @@ Boris: Do I need to let our children a chance to generate anything? - // Sounds fair ;-) - - // @@ Boris: the next statement is not true anymore since this is a CS - - // 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); + "codegen for scope failed\n"), + -1); } - // set the sub state as generating code for the output operator + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Set the sub state as generating code for the output operator. this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_OUTPUT); *os << "CORBA::Boolean" << be_nl - << "operator<< (TAO_OutputCDR &strm, const " - << node->full_name () - << " *_tao_valuetype)" << be_nl + << "operator<< (" << be_idt << be_idt_nl + << "TAO_OutputCDR &strm," << be_nl + << "const " << node->full_name () + << " *_tao_valuetype" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; - *os << "return CORBA_ValueBase::_tao_marshal (strm," << be_idt_nl - << "ACE_const_cast (" << node->full_name () << "*, _tao_valuetype)," << be_nl - << "(ptr_arith_t) &" << node->full_name() <<"::_downcast);" - << be_uidt<< be_uidt_nl - << "}\n\n"; + *os << "return" << be_idt_nl + << "CORBA_ValueBase::_tao_marshal (" << be_idt << be_idt_nl + << "strm," << be_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->full_name () << " *," << be_nl + << "_tao_valuetype" << be_uidt_nl + << ")," << be_uidt_nl + << "(ptr_arith_t) &" << node->full_name () <<"::_downcast" + << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; - // set the substate as generating code for the input operator - //this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); *os << "CORBA::Boolean" << be_nl - << "operator>> (TAO_InputCDR &strm, " + << "operator>> (" << be_idt << be_idt_nl + << "TAO_InputCDR &strm," << be_nl << node->full_name () - << " *&_tao_valuetype)" << be_nl + << " *&_tao_valuetype" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; - *os << "return " << node->full_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->full_name() <<"::_downcast);" + *os << "return " << node->full_name () + << "::_tao_unmarshal (strm, _tao_valuetype);" << be_uidt_nl - << "if (retval) {" << be_idt_nl - << "_tao_valuetype = " << node->full_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"; + << "}" << be_nl << be_nl; - //@@ Boris: ment to be refactored - 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); - } + if (!node->is_abstract ()) + { + // Functions that marshal state. + be_visitor_context new_ctx (*this->ctx_); + be_visitor_valuetype_marshal_cs visitor (&new_ctx); + visitor.visit_valuetype (node); + } node->cli_stub_cdr_op_gen (I_TRUE); - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp index 494b8378eb1..0d4a7238d01 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp @@ -18,277 +18,202 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_valuetype, field_cdr_op_ch, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + field_cdr_op_ch, + "$Id$") // ********************************************** -// visitor for field in the client header file +// Visitor for field in the client header file. // ********************************************** -// constructor -be_visitor_valuetype_field_cdr_ch::be_visitor_valuetype_field_cdr_ch (be_visitor_context *ctx) +be_visitor_valuetype_field_cdr_ch::be_visitor_valuetype_field_cdr_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx), - pre_ (""), post_ ("") + pre_ (""), + post_ ("") { } -// destructor be_visitor_valuetype_field_cdr_ch::~be_visitor_valuetype_field_cdr_ch (void) { } -// visit the field node int be_visitor_valuetype_field_cdr_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_cdr_ch::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be -// visit array type int be_visitor_valuetype_field_cdr_ch::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // This is the case for anonymous arrays. 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 struct declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_valuetype_field_cdr_ch::visit_enum (be_enum *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit sequence type int be_visitor_valuetype_field_cdr_ch::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // 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 ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit structure type int be_visitor_valuetype_field_cdr_ch::visit_structure (be_structure *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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 struct declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit typedefed type int be_visitor_valuetype_field_cdr_ch::visit_typedef (be_typedef *node) { - // save the node for use in code generation and + // Save the node for use in code generation and // indicate that the field of the field node - // is a typedefed quantity + // is a typedefed quantity. this->ctx_->alias (node); - // make a decision based on the primitive base type + // 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_valuetype_field_cdr_ch::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } + this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_valuetype_field_cdr_ch::visit_union (be_union *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } 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 index bb9549c5b1c..d77e0de7886 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp @@ -19,109 +19,112 @@ // // ============================================================================ -#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$") - +ACE_RCSID (be_visitor_valuetype, + field_cdr_op_ci, + "$Id$") // ********************************************** -// visitor for field in the client stubs file +// Visitor for field in the client inline file. // ********************************************** -// constructor -be_visitor_valuetype_field_cdr_ci::be_visitor_valuetype_field_cdr_ci (be_visitor_context *ctx) +be_visitor_valuetype_field_cdr_ci::be_visitor_valuetype_field_cdr_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx), - pre_ (""), post_ ("") + 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); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (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); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // for anonymous arrays, the type name has a _ prepended. We compute + // For anonymous arrays, the type name has a _ prepended. We compute // the full_name with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and + char fname [NAMEBUFSIZE]; + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); - // 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 + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // for anonymous arrays ... - // we have to generate a name for us that has an underscore + // 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 + // 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->full_name (), + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + node->full_name ()); } } else { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->full_name ()); + // Typedefed node. + ACE_OS::sprintf (fname, + "%s", + node->full_name ()); } - // check what is the code generation substate. Are we generating + // 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 ()) { @@ -134,74 +137,58 @@ be_visitor_valuetype_field_cdr_ci::visit_array (be_array *node) << "_tao_" << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } - // if not a typedef and we are defined in the use scope, we must be defined - + // 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 + // This is the case for anonymous arrays. 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.node (node); 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) + be_visitor_array_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -212,70 +199,56 @@ be_visitor_valuetype_field_cdr_ci::visit_enum (be_enum *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_enum - " - "bad sub state\n" - ), -1); + "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 + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); 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) + be_visitor_enum_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_enum - " - "codegen failed\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -286,39 +259,39 @@ be_visitor_valuetype_field_cdr_ci::visit_interface (be_interface *) *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 + // Nothing to be done because an interface cannit be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_interface - " - "bad sub state\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -329,39 +302,39 @@ be_visitor_valuetype_field_cdr_ci::visit_interface_fwd (be_interface_fwd *) *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 + // Nothing to be done because an interface cannit be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_interface_fwd - " - "bad sub state\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -372,39 +345,39 @@ be_visitor_valuetype_field_cdr_ci::visit_valuetype (be_valuetype *) *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 + // Nothing to be done because a valuetype cannit be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_valuetype - " - "bad sub state\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -415,91 +388,118 @@ be_visitor_valuetype_field_cdr_ci::visit_valuetype_fwd (be_valuetype_fwd *) *os << "(strm << " << pre_ << f->local_name () << post_ << ").in ()"; break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an valuetype cannot be declared inside a - // structure + // Nothing to be done because a valuetype cannot be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_valuetype_fwd - " - "bad sub state\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + AST_PredefinedType::PredefinedType pt = node->pt (); + + // 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_ << "))"; + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) + { + *os << "(strm >> " << pre_ << f->local_name () << post_ + << ".out ())"; + } + else if (pt == AST_PredefinedType::PT_char) + { + *os << "(strm >> CORBA::Any::to_char (" << pre_ + << f->local_name () << post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_wchar) + { + *os << "(strm >> CORBA::Any::to_wchar (" << pre_ + << f->local_name () << post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_octet) + { + *os << "(strm >> CORBA::Any::to_octet (" << pre_ + << f->local_name () << post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_boolean) + { + *os << "(strm >> CORBA::Any::to_boolean (" << pre_ + << f->local_name () << post_ << "))"; + } else - *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; + { + *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_ << "))"; + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) + { + *os << "(strm << " << pre_ << f->local_name () + << post_ << ".in ())"; + } + else if (pt == AST_PredefinedType::PT_char) + { + *os << "(strm << CORBA::Any::from_char (" << pre_ + << f->local_name () << post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_wchar) + { + *os << "(strm << CORBA::Any::from_wchar (" << pre_ + << f->local_name () << post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_octet) + { + *os << "(strm << CORBA::Any::from_octet (" << pre_ + << f->local_name () << post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_boolean) + { + *os << "(strm << CORBA::Any::from_boolean (" << pre_ + << f->local_name () << post_ << "))"; + } else - *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; + { + *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; + } break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done + // Nothing to be done. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } return 0; @@ -508,21 +508,21 @@ be_visitor_valuetype_field_cdr_ci::visit_predefined_type (be_predefined_type *no int be_visitor_valuetype_field_cdr_ci::visit_sequence (be_sequence *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n" ), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -533,72 +533,59 @@ be_visitor_valuetype_field_cdr_ci::visit_sequence (be_sequence *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_sequence - " - "bad sub state\n" - ), -1); + "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 + // Not a typedef AND + // node is defined inside the valuetype. { - // 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 + // Anonymous sequence. 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.node (node); 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) + be_visitor_sequence_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -609,39 +596,38 @@ be_visitor_valuetype_field_cdr_ci::visit_string (be_string *) *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done + // Nothing to be done. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -652,92 +638,77 @@ be_visitor_valuetype_field_cdr_ci::visit_structure (be_structure *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_structure - " - "bad sub state\n" - ), -1); + "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 + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); 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) + be_visitor_structure_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_struct - " - "codegen failed\n" - ), -1); + "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 + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // 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); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // 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 ()) { @@ -748,56 +719,44 @@ be_visitor_valuetype_field_cdr_ci::visit_union (be_union *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_union - " - "bad sub state\n" - ), -1); + "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 + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // 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.node (node); 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) + be_visitor_union_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_union - " - "codegen failed\n" - ), -1); + "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_valuetype_field_cdr_decl::be_visitor_valuetype_field_cdr_decl ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -814,89 +773,101 @@ 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); + "Bad field type\n"), + -1); } // @@ Shouldn't this be saved in the visitor and not the context?! - this->ctx_->node (node); // save the node + this->ctx_->node (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); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // 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); + "cannot retrieve field node\n"), + -1); } - // retrieve the valuetype scope in which the code is generated + // 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); + "cannot retrieve valuetype node\n"), + -1); } - // for anonymous arrays, the type name has a _ prepended. We compute + // For anonymous arrays, the type name has a _ prepended. We compute // the full_name with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and + char fname [NAMEBUFSIZE]; + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope + // 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 + // the parent'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->full_name (), + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + node->full_name ()); } } else { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->full_name ()); + // Typedefed node. + ACE_OS::sprintf (fname, + "%s", + node->full_name ()); } - // check what is the code generation substate. Are we generating code for + // 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 ()) { @@ -914,32 +885,29 @@ be_visitor_valuetype_field_cdr_decl::visit_array (be_array *node) return 0; case TAO_CodeGen::TAO_CDR_SCOPE: default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_decl::" - "visit_array - " - "bad sub state\n" - ), -1); + "visit_array - "), + -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 + this->ctx_->alias (node); 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); + "Bad primitive type\n"), + -1); } this->ctx_->alias (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 index 0cd37403575..f443ff1dd7a 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp @@ -20,27 +20,22 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_valuetype, + field_ch, + "$Id$") -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_valuetype_field_ch::be_visitor_valuetype_field_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { - setenclosings ("",";"); + 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) { @@ -69,9 +64,8 @@ be_visitor_valuetype_field_ch::visit_field (be_field *node) return 0; } -// =Visit operations on all possible data types (valuetype state member). +// Visit operations on all possible data types (valuetype state member). -// visit array type int be_visitor_valuetype_field_ch::visit_array (be_array *node) { @@ -100,30 +94,19 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) TAO_OutStream *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. + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) + { + // This is the case of an anonymous array inside a valuetype. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // 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); - } + be_visitor_array_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -132,12 +115,11 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) -1); } - delete visitor; // Now use this array as a "type" for the subsequent declarator // the set method. *os << pre_op () << "void " << ub->local_name () << " (" << "_" << bt->local_name () << ")" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // The get method. *os << pre_op () << "const _" << bt->local_name () << "_slice * " << ub->local_name () @@ -151,8 +133,7 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) // Now use this array as a "type" for the subsequent declarator. // The set method. *os << pre_op () << "void " << ub->local_name () << " (" - << bt->name () << ")" << post_op () << " // set" - << be_nl; + << bt->name () << ")" << post_op () << be_nl; // The get method. *os << pre_op() << bt->name () << "_slice *" << ub->local_name () @@ -160,13 +141,12 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) // The get (read/write) method. *os << pre_op () << "const " << bt->name () << "_slice *" << ub->local_name () - << " (void) const" << post_op () << "\n\n"; + << " (void) const" << post_op () << be_nl << be_nl; } return 0; } -// Visit enum type. int be_visitor_valuetype_field_ch::visit_enum (be_enum *node) { @@ -195,28 +175,18 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) TAO_OutStream *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 + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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); - - // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_enum_ch 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) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -224,24 +194,19 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) "codegen failed\n"), -1); } - - delete visitor; } // Now use this enum as a "type" for the subsequent declarator // the set method. *os << pre_op () << "void " << ub->local_name () << " (" - << bt->name () << ")" << post_op () << " // set" - << be_nl; + << bt->name () << ")" << post_op () << be_nl; // The get method. *os << pre_op () << bt->name () << " " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } -// Visit interface type. int be_visitor_valuetype_field_ch::visit_interface (be_interface *node) { @@ -270,20 +235,21 @@ be_visitor_valuetype_field_ch::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op() << "void " << ub->local_name () << " (" << bt->name () << "_ptr" - << ")" << post_op() << " // set" << be_nl; + << ")" << post_op() << be_nl; // Get method. *os << pre_op() << bt->name () << "_ptr " << ub->local_name () - << " (void) const" << post_op() << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op() << be_nl << be_nl; return 0; } -// Visit interface forward type. int be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node) { @@ -312,20 +278,21 @@ be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << "_ptr" - << ")" << post_op () << " // set" << be_nl; + << ")" << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << "_ptr " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } -// Visit valuetype type. int be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node) { @@ -354,20 +321,21 @@ be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << " *" - << ")" << post_op () << " // set" << be_nl; + << ")" << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << " *" << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } -// Visit valuetype forward type. int be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { @@ -396,20 +364,21 @@ be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << " *" - << ")" << post_op () << " // set" << be_nl; + << ")" << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << " *" << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } -// Visit predefined type. int be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) { @@ -438,34 +407,35 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: - // set method. + case AST_PredefinedType::PT_object: + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << "_ptr)" - << post_op () << " // set" << be_nl; - // Get method. + << post_op () << be_nl; + // Get method. *os << pre_op () << bt->name () << "_ptr " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; break; case AST_PredefinedType::PT_any: // Set method. *os << pre_op () << "void " << ub->local_name () << " (" - << bt->name () << ")" - << post_op () << " // set" << be_nl; + << bt->name () << " &)" + << post_op () << be_nl; // Get method (read-only). - *os << pre_op () << "const " << bt->name () << " " + *os << pre_op () << "const " << bt->name () << " &" << ub->local_name () << " (void) const" - << post_op () << " // get method" - << be_nl << be_nl; + << post_op () << be_nl << be_nl; // Get method (read/write). - *os << pre_op () << bt->name () << " " + *os << pre_op () << bt->name () << " &" << ub->local_name () << " (void)" - << post_op () << " // get method" - << be_nl << be_nl; + << post_op () << be_nl << be_nl; break; case AST_PredefinedType::PT_void: break; @@ -473,16 +443,15 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << ")" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << " " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; } + return 0; } -// Visit sequence type. int be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) { @@ -511,29 +480,19 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Not a typedef and bt is defined here. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // 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); - - // 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); - } + be_visitor_sequence_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -542,18 +501,14 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) -1); } - delete visitor; - - // Generate the anonymous sequence member typedef - // but we must protect against certain versions of g++. + // Generate the anonymous sequence member typedef. // This provides a consistent name to use instead of the // implementation-specific name. os->decr_indent (0); - *os << "#if !defined (__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_idt_nl - << "typedef " << bt->nested_type_name (bu) - << " _" << ub->local_name () << "_seq;" << be_uidt_nl; - *os << "#endif /* ! __GNUC__ || ACE_HAS_GNUG_PRE_2_8 */\n" << be_nl; + + *os << "typedef " << bt->nested_type_name (bu) + << " _" << ub->local_name () << "_seq;" << be_nl; + os->incr_indent (); } @@ -561,21 +516,19 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) // Set method. *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Read-only. *os << pre_op () << "const " << bt->name () << " &" << ub->local_name () << " (void) const" - << post_op () << " // get method (read only)" << be_nl; + << post_op () << be_nl; // Read/write. *os << pre_op () << bt->name () << " &" << ub->local_name () << " (void)" - << post_op () << " // get method (read/write only)" - << be_nl << be_nl; + << post_op () << be_nl << be_nl; return 0; } -// Visit string type. int be_visitor_valuetype_field_ch::visit_string (be_string *node) { @@ -593,44 +546,44 @@ be_visitor_valuetype_field_ch::visit_string (be_string *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Three methods to set the string value. if (node->width () == (long) sizeof (char)) { *os << pre_op () << "void " << ub->local_name () << " (char *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const char *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const CORBA::String_var&)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method. *os << pre_op () << "const char *" << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; } else { *os << pre_op () << "void " << ub->local_name () << " (CORBA::WChar *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const CORBA::WChar *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const CORBA::WString_var&)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method. *os << pre_op() << "const CORBA::WChar *" << ub->local_name () - << " (void) const" << post_op() << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op() << be_nl << be_nl; } return 0; } -// Visit structure type. int be_visitor_valuetype_field_ch::visit_structure (be_structure *node) { @@ -659,29 +612,19 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Not a typedef and bt is defined here. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // 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); - - // 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); - } + be_visitor_structure_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -689,27 +632,23 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) "codegen failed\n"), -1); } - - delete visitor; } // Set method. *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Read-only. *os << pre_op () << "const " << bt->name () << " &"; *os << ub->local_name () << " (void) const" - << post_op () << " // get method (read only)" << be_nl + << post_op () << be_nl // Read/write. << pre_op () << bt->name () << " &" << ub->local_name () - << " (void)" << post_op () << " // get method (read/write only)" - << be_nl << be_nl; + << " (void)" << post_op () << be_nl << be_nl; return 0; } -// Visit typedefed type. int be_visitor_valuetype_field_ch::visit_typedef (be_typedef *node) { @@ -731,7 +670,6 @@ be_visitor_valuetype_field_ch::visit_typedef (be_typedef *node) return 0; } -// Visit union type. int be_visitor_valuetype_field_ch::visit_union (be_union *node) { @@ -760,29 +698,19 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Not a typedef and bt is defined here. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // 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); + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); - // 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) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -790,42 +718,39 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) "codegen failed\n"), -1); } - - delete visitor; } // Set method. *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Read-only. *os << pre_op () << "const " << bt->name () << " &" << ub->local_name () << " (void) const" - << post_op () << " // get method (read only)" - << be_nl; + << post_op () << be_nl; // Read/write. *os << pre_op () << bt->name () << " &" << ub->local_name () - << " (void)" << post_op () << " // get method (read/write only)" - << be_nl << be_nl; + << " (void)" << post_op () << be_nl << be_nl; return 0; } void -be_visitor_valuetype_field_ch::setenclosings (const char *pre, const char *post) +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 () +be_visitor_valuetype_field_ch::pre_op (void) { return pre_op_; } const char* -be_visitor_valuetype_field_ch::post_op () +be_visitor_valuetype_field_ch::post_op (void) { return post_op_; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp index 25e78d69a86..4678af40c7d 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp @@ -20,112 +20,95 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_valuetype, + field_ci, + "$Id$") -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, field_ci, "$Id$") - - -// constructor -be_visitor_valuetype_field_ci:: -be_visitor_valuetype_field_ci (be_visitor_context *ctx) +be_visitor_valuetype_field_ci::be_visitor_valuetype_field_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx), in_obv_space_ (0) { setenclosings (""); } -// destructor -be_visitor_valuetype_field_ci:: -~be_visitor_valuetype_field_ci (void) +be_visitor_valuetype_field_ci::~be_visitor_valuetype_field_ci (void) { } -// visit the field node int -be_visitor_valuetype_field_ci:: -visit_field (be_field *node) +be_visitor_valuetype_field_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_field_cs::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (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); + "codegen for field type failed\n"), + -1); } + return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be. int be_visitor_valuetype_field_ci::visit_array (be_array *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_array - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the valuetype + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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.node (node); 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_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -170,56 +153,45 @@ be_visitor_valuetype_field_ci::visit_predefined_type (be_predefined_type *) int be_visitor_valuetype_field_ci::visit_sequence (be_sequence *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_sequence - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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.node (node); 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_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -234,56 +206,45 @@ be_visitor_valuetype_field_ci::visit_string (be_string *) int be_visitor_valuetype_field_ci::visit_structure (be_structure *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_structure - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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.node (node); 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_ci::" - "visit_structure - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_structure - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -298,56 +259,45 @@ be_visitor_valuetype_field_ci::visit_typedef (be_typedef *) int be_visitor_valuetype_field_ci::visit_union (be_union *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_union - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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.node (node); 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_ci::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -356,22 +306,26 @@ be_visitor_valuetype_field_ci::visit_union (be_union *node) void be_visitor_valuetype_field_ci::setenclosings (const char *pre) { - pre_op_ = pre; + this->pre_op_ = pre; } const char* be_visitor_valuetype_field_ci::pre_op () { - return pre_op_; + return this->pre_op_; } -// retrieve the fully scoped skeleton name +// Retrieve the fully scoped skeleton name. void be_visitor_valuetype_field_ci::op_name (be_valuetype *node, TAO_OutStream *os) { if (this->in_obv_space_) - *os << node->full_obv_skel_name (); + { + *os << node->full_obv_skel_name (); + } else - *os << node->name (); + { + *os << node->name (); + } } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp index 3a80831f824..bbc42c3e500 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp @@ -20,686 +20,774 @@ // derived from be_visitor_union_branch/public_ci.cpp // // ============================================================================ +ACE_RCSID (be_visitor_valuetype, + field_cs, + "$Id$") -#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_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) +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_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); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (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); + "codegen for field type failed\n"), + -1); } + return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_array - " - "bad context information\n" - ), -1); + "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 valuetype + + TAO_OutStream *os = this->ctx_->stream (); + + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - 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) + be_visitor_array_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } - // for anonymous arrays, the type name has a _ prepended. We compute the + // For anonymous arrays, the type name has a _ prepended. We compute the // full_name with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and + char fname [NAMEBUFSIZE]; + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); - // 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 + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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 - + // 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 parent'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->full_name (), + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), bt->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", bt->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + bt->full_name ()); } } else { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->full_name ()); + // Typedefed node. + ACE_OS::sprintf (fname, + "%s", + bt->full_name ()); } - // 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 << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *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)" << be_nl + << "{" << be_idt_nl; *os << fname << "_copy (" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << 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 << "// 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 + << 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 + *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"; + *os << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl; + *os << "}" << be_nl << be_nl; + 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_enum - " - "bad context information\n" - ), -1); + "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 + TAO_OutStream *os = this->ctx_->stream (); + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *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 (); + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << bt->name () + << " val)/" << be_nl + << "{" << be_idt_nl; + *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;\n"; - os->decr_indent (); + << 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" + *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 (); + << "{" << be_idt_nl; + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";\n"; - os->decr_indent (); - *os << "}\n\n"; + << bu->field_pd_prefix() << ub->local_name () + << bu->field_pd_postfix () + << ";" << be_uidt_nl; + + *os << "}" << be_nl << be_nl; + 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *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)" << be_nl + << "{" << be_idt_nl; + *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = " << bt->name () << "::_duplicate (val);" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << 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" + *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 (); + << "{" << be_idt_nl; + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << ".ptr ();" << be_uidt_nl; + + *os << "}" << be_nl << be_nl; + 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *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)" << be_nl + << "{" << be_idt_nl; + *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = " << bt->name () << "::_duplicate (val);" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; + + *os << "// Retrieve the member" << be_nl + << this->pre_op () << bt->name () << "_ptr " << be_nl; + + this->op_name (bu, + os); - // 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" + *os << "::" << ub->local_name () << " () const" << be_nl - << "{\n"; - os->incr_indent (); + << "{" << be_idt_nl; + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << ".ptr ();" << be_uidt_nl; + + *os << "}" << be_nl << be_nl; + 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "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 (); + TAO_OutStream *os = this->ctx_->stream (); + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *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)" << be_nl + << "{" << be_idt_nl; + *os << "CORBA::add_ref (val);" << be_nl << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = val;" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << 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" + *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 (); + << "{" << be_idt_nl; + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << ".ptr ();" << be_uidt_nl; + + *os << "}" << be_nl << be_nl; + 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "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 + TAO_OutStream *os = this->ctx_->stream (); + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *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 (); + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << bt->name () + << "* val)" << be_nl + << "{" << be_idt_nl; + *os << "CORBA::add_ref (val);" << be_nl << "this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = val;" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; + + *os << "// Retrieve the member." << be_nl + << this->pre_op () << bt->name () << " *" << 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" + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " () const" << be_nl - << "{\n"; - os->incr_indent (); + << "{" << be_idt_nl; + *os << "return this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix() - << ".ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix + () + << ".ptr ();" << be_uidt_nl; + + *os << "}" << be_nl << be_nl; + 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_decl *ub = this->ctx_->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 + + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_predef... - " - "bad context information\n" - ), -1); + "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); + TAO_OutStream *os = this->ctx_->stream (); + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *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 + + AST_PredefinedType::PredefinedType pt = node->pt (); + + if (pt == AST_PredefinedType::PT_pseudo + || pt == AST_PredefinedType::PT_object) + { + *os << "_ptr"; + } + else if (pt == AST_PredefinedType::PT_any) + { + *os << " &"; + } + + *os << " val)" << 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 << "ACE_NEW (" << be_idt << be_idt_nl - << "this->" << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << "," << be_nl - << bt->name () << " (val)" << be_uidt_nl - << ");" << be_uidt << 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 (pt) + { + case AST_PredefinedType::PT_pseudo: + case AST_PredefinedType::PT_object: + *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 () << " = 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; + + break; + } + + *os << "}" << be_nl << 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); + case AST_PredefinedType::PT_object: + *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->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; + 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 << "// 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() + << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}" << be_nl; + << "}" << be_nl << be_nl; + + *os << "// Retrieve the member" << be_nl + << this->pre_op () << bt->name () << " &" << be_nl; + + this->op_name (bu, + os); - // 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() + << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; + 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 << "// 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() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; - } + << "}" << be_nl << be_nl; + + break; + } + 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_sequence - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); + + TAO_OutStream *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.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - 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) + be_visitor_sequence_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (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 << "// 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() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = val;" << be_uidt_nl; - *os << "}" << be_nl << 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 << "// 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() + << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}" << be_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 << "// 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() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix() << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -707,27 +795,31 @@ be_visitor_valuetype_field_cs::visit_sequence (be_sequence *node) int be_visitor_valuetype_field_cs::visit_string (be_string *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->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); + "bad context information\n"), + -1); } + TAO_OutStream *os = this->ctx_->stream (); - // three methods to set the string value + // Three methods to set the string value. + + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // (1) set method from char* or wchar* - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl + // (1) Set method from char* or wchar*. + os->indent (); + + *os << "// Accessor to set the member." << be_nl << this->pre_op () << "void" << be_nl; + this->op_name (bu, os); @@ -742,16 +834,17 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << 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 << be_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 * or const wchar* - *os << "// accessor to set the member" << be_nl + // (2) Set method from const char * or const wchar*. + *os << "// Accessor to set the member." << be_nl << this->pre_op () << "void" << be_nl; + this->op_name (bu, os); *os << "::" << ub->local_name (); @@ -765,12 +858,12 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << " (const CORBA::WChar *val)" << be_nl; } - *os << "{\n"; - os->incr_indent (); + *os << "{" << be_idt_nl; - *os << "// set the value" << be_nl + *os << "// Set the value." << be_nl << "this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = "; if (node->width () == (long) sizeof (char)) @@ -782,13 +875,15 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << "CORBA::wstring_dup (val);" << be_uidt_nl; } - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; - // (3) set from const String_var& - *os << "// accessor to set the member" << 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 (); if (node->width () == (long) sizeof (char)) @@ -801,8 +896,6 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) } *os << "{" << be_idt_nl; - *os << ";" << be_nl; - *os << "// set the value" << be_nl; if (node->width () == (long) sizeof (char)) @@ -816,13 +909,12 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << "_var = val;" << be_nl << "this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = " << ub->local_name () << "_var._retn ();" << be_uidt_nl; + *os << "}" << be_nl << be_nl; - *os << "}" << be_nl; - - // get method if (node->width () == (long) sizeof (char)) { *os << this->pre_op () << "const char *" << be_nl; @@ -834,140 +926,113 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) 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 () + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; + 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_structure - " - "bad context information\n" - ), -1); + "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 + TAO_OutStream *os = this->ctx_->stream (); + + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - 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) + be_visitor_structure_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_structure - " - "codegen failed\n" - ), -1); + "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 << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // (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 << "ACE_NEW (" << be_idt << be_idt_nl - << "this->" << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << "," << be_nl - << bt->name () << " (val)" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; - -// This was replaced by the above output statement, but this doesn't work -// *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 << "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 << "// 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 << "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 << "// 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"; + *os << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << ";" << be_uidt_nl; + *os << "}" << be_nl << be_nl; return 0; } @@ -975,18 +1040,16 @@ be_visitor_valuetype_field_cs::visit_structure (be_structure *node) 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 + this->ctx_->alias (node); 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); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); @@ -996,104 +1059,95 @@ be_visitor_valuetype_field_cs::visit_typedef (be_typedef *node) 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_decl *ub = this->ctx_->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 + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_union - " - "bad context information\n" - ), -1); + "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 + TAO_OutStream *os = this->ctx_->stream (); + + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // 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.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CS); - 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) + be_visitor_union_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "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 << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *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 << "ACE_NEW (" << be_idt << be_idt_nl - << "this->" << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << "_var," << be_nl + << "this->" << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << "_var," << be_nl << bt->name () << " (val)" << be_uidt_nl << ");" << be_uidt << be_uidt_nl; + *os << "}" << be_nl; -// This was replaced by the above output statement, but this doesn't work -// *os << "this->" -// << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() -// << "_var = new " << bt->name () -// << " (val);" << be_uidt_nl; + *os << "// Readonly get method." << be_nl + << this->pre_op () << "const " << bt->name () << " &" << be_nl; - *os << "}" << be_nl; + this->op_name (bu, + os); - // 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() + << 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 << "// 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() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -1101,22 +1155,26 @@ be_visitor_valuetype_field_cs::visit_union (be_union *node) void be_visitor_valuetype_field_cs::setenclosings (const char *pre) { - pre_op_ = pre; + this->pre_op_ = pre; } const char* be_visitor_valuetype_field_cs::pre_op () { - return pre_op_; + return this->pre_op_; } -// retrieve the fully scoped skeleton name +// 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 (); + { + *os << node->full_obv_skel_name (); + } else - *os << node->name (); + { + *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 index 4688584e439..a4fa8a2aeb6 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp @@ -20,14 +20,9 @@ // // ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, marshal_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + marshal_ch, + "$Id$") // *************************************************************************** // Structure visitor for generating declarations diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp index e2df4c9c46d..836c462aeb8 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp @@ -19,15 +19,9 @@ // // ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, marshal_cs, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + marshal_cs, + "$Id$") be_visitor_valuetype_marshal_cs::be_visitor_valuetype_marshal_cs ( be_visitor_context *ctx @@ -46,6 +40,9 @@ 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 << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "CORBA::Boolean" << be_nl; this->class_name (node, os); @@ -72,14 +69,20 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->class_name (inh, os); - *os << "::_tao_marshal_state (strm)) return 0;" << be_nl; + *os << "::_tao_marshal_state (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } // Can access base class only via virtual function. else { - *os << "if (!this->_tao_marshal__" + *os << "if (! this->_tao_marshal__" << inh->flat_name () - << " (strm)) return 0;" << be_nl; + << " (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } } @@ -93,12 +96,16 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->gen_fields (node, *this->ctx_); - *os << be_uidt_nl << ")" - << be_idt_nl + *os << be_uidt_nl + << " )" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; // Set the substate as generating code for the input operator. this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_INPUT); @@ -127,13 +134,19 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->class_name (inh, os); - *os << "::_tao_unmarshal_state (strm)) return 0;" << be_nl; + *os << "::_tao_unmarshal_state (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } else // only can access base class via virtual function { - *os << "if (!this->_tao_unmarshal__" + *os << "if (! this->_tao_unmarshal__" << inh->flat_name () - << " (strm)) return 0;" << be_nl; + << " (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } } @@ -146,12 +159,16 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->gen_fields (node, *this->ctx_); - *os << be_uidt_nl << ")" - << be_idt_nl + *os << be_uidt_nl + << " )" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; return 0; } @@ -199,6 +216,7 @@ be_visitor_valuetype_marshal_cs::gen_fields (be_valuetype *node, "bad node in this scope\n"), -1); } + be_field *field = be_field::narrow_from_decl (d); if (field) diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp index e53d67fa7d2..0fea9926210 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp @@ -20,15 +20,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be_visitor_obv_module, obv_module, "$Id$") - +ACE_RCSID (be_visitor_obv_module, + obv_module, + "$Id$") // ************************************************************ -// Module visitor for server header +// OBV module visitor for server header. // ************************************************************ be_visitor_obv_module::be_visitor_obv_module (be_visitor_context *ctx) @@ -40,19 +37,10 @@ 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 (); + TAO_OutStream *os = this->ctx_->stream (); if (node->has_nested_valuetype ()) { @@ -60,25 +48,30 @@ be_visitor_obv_module::visit_module (be_module *node) { os->indent (); - *os << "TAO_NAMESPACE "; // << idl_global->skel_export_macro () + *os << "TAO_NAMESPACE "; if (!node->is_nested ()) - // we are outermost module, so prepend + { + // We are outermost module, so prepend. *os << " OBV_" << node->local_name () << be_nl; + } else - // we are inside another module + { + // 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); + "codegen for scope failed\n"), + -1); } if (this->ctx_->state () == TAO_CodeGen::TAO_MODULE_OBV_CH) @@ -87,6 +80,7 @@ be_visitor_obv_module::visit_module (be_module *node) *os << "}\nTAO_NAMESPACE_CLOSE\n\n"; } } + return 0; } @@ -94,11 +88,9 @@ be_visitor_obv_module::visit_module (be_module *node) 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 + ctx.node (node); + int status = 1; switch (this->ctx_->state ()) { @@ -106,8 +98,13 @@ be_visitor_obv_module::visit_valuetype (be_valuetype *node) 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; + { + // This context state is not involved in any strategies. + ctx.state (TAO_CodeGen::TAO_VALUETYPE_OBV_CI); + be_visitor_valuetype_obv_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_OBV_CS: ctx.state (TAO_CodeGen::TAO_VALUETYPE_OBV_CS); break; @@ -117,60 +114,76 @@ be_visitor_obv_module::visit_valuetype (be_valuetype *node) "(%N:%l) be_visitor_obv_module::" "visit_valuetype - " "Bad context state\n" - ), -1); + ), + -1); } } - // Change the state depending on the kind of node strategy + if (status == 0) + { + return 0; + } + else if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_obv_module::" + "visit_valuetype - " + "failed to accept visitor\n"), + -1); + } + + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state ())); 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); + "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); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; - // Do addtional "extra" code generation if necessary + // Do addtional "extra" code generation if necessary. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); 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); + "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); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index 1866aebc56d..73193e5cdda 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -19,10 +19,9 @@ // // ============================================================================ -#include "be_visitor_valuetype.h" -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_valuetype, valuetype, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype, + "$Id$") be_visitor_valuetype::be_visitor_valuetype (be_visitor_context *ctx) : be_visitor_scope (ctx) @@ -44,7 +43,6 @@ int be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { int n_processed = 0; - this->elem_number_ = 0; for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); @@ -63,21 +61,20 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) AST_Field *field = AST_Field::narrow_from_decl (d); - if (field && field->visibility() == AST_Field::vis_PRIVATE) + if (field && field->visibility () == AST_Field::vis_PRIVATE) { - continue; // ignore private fields in this run + 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) } be_decl *bd = be_decl::narrow_from_decl (d); - // set the scope node as "node" in which the code is being + // 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 + // for code generation. this->ctx_->scope (node->decl ()); - - // set the node to be visited this->ctx_->node (bd); this->elem_number_++; @@ -89,7 +86,7 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) -1); } - } // end of for loop + } this->elem_number_ = 0; @@ -129,8 +126,6 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) // for code generation. this->ctx_->scope (node->decl ()); - - // Set the node to be visited. this->ctx_->node (bd); this->elem_number_++; @@ -167,21 +162,16 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) this->ctx_->node (node); this->ctx_->attribute (node); - be_operation *op = 0; - ACE_NEW_RETURN (op, - be_operation (node->field_type (), - AST_Operation::OP_noflags, - node->name (), - 0, - 0), - -1); + be_operation get_op (node->field_type (), + AST_Operation::OP_noflags, + node->name (), + 0, + 0); - op->set_name ((UTL_IdList *) node->name ()->copy ()); + get_op.set_name ((UTL_IdList *) node->name ()->copy ()); - if (!op || this->visit_operation (op) == -1) + if (this->visit_operation (&get_op) == -1) { - delete op; - op = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -189,66 +179,39 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) -1); } - delete op; - op = 0; - if (node->readonly ()) { // Nothing else to do. return 0; } - // The set method. - // The return type is "void". + Identifier id ("void"); - Identifier *id = 0; - UTL_ScopedName *sn = 0; + UTL_ScopedName sn (&id, + 0); - ACE_NEW_RETURN (id, - Identifier ("void"), - -1); - - ACE_NEW_RETURN (sn, - UTL_ScopedName (id, - 0), - -1); - - be_predefined_type *rt = 0; - ACE_NEW_RETURN (rt, - be_predefined_type (AST_PredefinedType::PT_void, - sn), - -1); + be_predefined_type rt (AST_PredefinedType::PT_void, + &sn); // Argument type is the same as the attribute type. - be_argument *arg = 0; - ACE_NEW_RETURN (arg, - be_argument (AST_Argument::dir_IN, - node->field_type (), - node->name ()), - -1); + be_argument arg (AST_Argument::dir_IN, + node->field_type (), + node->name ()); - arg->set_name ((UTL_IdList *) node->name ()->copy ()); + arg.set_name ((UTL_IdList *) node->name ()->copy ()); // Create the operation. - ACE_NEW_RETURN (op, - be_operation (rt, - AST_Operation::OP_noflags, - node->name (), - 0, - 0), - -1); - - op->set_name ((UTL_IdList *) node->name ()->copy ()); - op->add_argument_to_scope (arg); - - if (!op || this->visit_operation (op) == -1) + be_operation set_op (&rt, + AST_Operation::OP_noflags, + node->name (), + 0, + 0); + + set_op.set_name ((UTL_IdList *) node->name ()->copy ()); + set_op.be_add_argument (&arg); + + if (this->visit_operation (&set_op) == -1) { - delete op; - op = 0; - delete arg; - arg = 0; - delete rt; - rt = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -256,12 +219,6 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) -1); } - delete op; - op = 0; - delete rt; - rt = 0; - delete arg; - arg = 0; return 0; } @@ -269,22 +226,26 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) 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); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -310,18 +271,7 @@ be_visitor_valuetype::visit_constant (be_constant *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_constant - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -330,44 +280,61 @@ be_visitor_valuetype::visit_constant (be_constant *node) -1); } - delete visitor; return 0; } 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); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + 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; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -388,18 +355,7 @@ be_visitor_valuetype::visit_enum (be_enum *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_enum - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -408,56 +364,74 @@ be_visitor_valuetype::visit_enum (be_enum *node) -1); } - delete visitor; - return 0; -} - - -int -be_visitor_valuetype::visit_operation (be_operation *) -{ - // Is overridden in derived visitors. return 0; } int be_visitor_valuetype::visit_exception (be_exception *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); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; - + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_SH: case TAO_CodeGen::TAO_VALUETYPE_IH: case TAO_CodeGen::TAO_VALUETYPE_SI: @@ -485,18 +459,7 @@ be_visitor_valuetype::visit_exception (be_exception *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_exception - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" @@ -505,47 +468,74 @@ be_visitor_valuetype::visit_exception (be_exception *node) -1); } - delete visitor; return 0; } 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); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -565,67 +555,147 @@ be_visitor_valuetype::visit_structure (be_structure *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_structure - " - "NULL visitor\n"), + "failed to accept visitor\n"), -1); } - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_valuetype::visit_structure_fwd (be_structure_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_VALUETYPE_CH: + { + ctx.state (TAO_CodeGen::TAO_STRUCT_FWD_CH); + be_visitor_structure_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_VALUETYPE_CI: + case TAO_CodeGen::TAO_VALUETYPE_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_SH: + case TAO_CodeGen::TAO_VALUETYPE_IH: + case TAO_CodeGen::TAO_VALUETYPE_SI: + case TAO_CodeGen::TAO_VALUETYPE_SS: + case TAO_CodeGen::TAO_VALUETYPE_IS: + 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_COLLOCATED_SH: + case TAO_CodeGen::TAO_VALUETYPE_COLLOCATED_SS: + case TAO_CodeGen::TAO_VALUETYPE_MARSHAL_CH: + case TAO_CodeGen::TAO_VALUETYPE_MARSHAL_CS: + case TAO_CodeGen::TAO_VALUETYPE_INIT_CH: + case TAO_CodeGen::TAO_VALUETYPE_INIT_CI: + case TAO_CodeGen::TAO_VALUETYPE_INIT_CS: + case TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype::" + "visit_structure_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" - "visit_structure - " + "visit_structure_fwd - " "failed to accept visitor\n"), -1); } - delete visitor; return 0; } 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); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -645,67 +715,147 @@ be_visitor_valuetype::visit_union (be_union *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_union - " - "NULL visitor\n"), + "failed to accept visitor\n"), -1); } - if (node->accept (visitor) == -1) + return 0; +} + +int +be_visitor_valuetype::visit_union_fwd (be_union_fwd *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); + int status = 0; + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_VALUETYPE_CH: + { + ctx.state (TAO_CodeGen::TAO_UNION_FWD_CH); + be_visitor_union_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_VALUETYPE_CI: + case TAO_CodeGen::TAO_VALUETYPE_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_SH: + case TAO_CodeGen::TAO_VALUETYPE_IH: + case TAO_CodeGen::TAO_VALUETYPE_SI: + case TAO_CodeGen::TAO_VALUETYPE_SS: + case TAO_CodeGen::TAO_VALUETYPE_IS: + 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_COLLOCATED_SH: + case TAO_CodeGen::TAO_VALUETYPE_COLLOCATED_SS: + case TAO_CodeGen::TAO_VALUETYPE_MARSHAL_CH: + case TAO_CodeGen::TAO_VALUETYPE_MARSHAL_CS: + case TAO_CodeGen::TAO_VALUETYPE_INIT_CH: + case TAO_CodeGen::TAO_VALUETYPE_INIT_CI: + case TAO_CodeGen::TAO_VALUETYPE_INIT_CS: + case TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH: + return 0; // nothing to be done + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype::" + "visit_union_fwd - " + "Bad context state\n"), + -1); + } + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" - "visit_union - " + "visit_union_fwd - " "failed to accept visitor\n"), -1); } - delete visitor; return 0; } 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); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -725,18 +875,7 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_typedef - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -745,7 +884,6 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) -1); } - delete visitor; return 0; } @@ -762,7 +900,6 @@ int be_visitor_valuetype::gen_pd (be_valuetype *node) { int n_processed = 0; - this->elem_number_ = 0; for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); @@ -778,20 +915,22 @@ be_visitor_valuetype::gen_pd (be_valuetype *node) "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 + // Set the node to be visited. this->ctx_->node (field); this->elem_number_++; @@ -812,13 +951,10 @@ int be_visitor_valuetype::gen_field_pd (be_field *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - be_valuetype *vt; - 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 ()); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); + be_valuetype *vt = be_valuetype::narrow_from_scope (node->defined_in ()); if (!bt || !vt) { @@ -833,12 +969,12 @@ be_visitor_valuetype::gen_field_pd (be_field *node) // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - be_visitor_field_ch visitor (&ctx); - if (bt->accept(&visitor) == -1) + *os << be_nl; + + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -849,8 +985,9 @@ be_visitor_valuetype::gen_field_pd (be_field *node) // Now output the field name. *os << " " << vt->field_pd_prefix () - << node->local_name () - << vt->field_pd_postfix() << ";" << be_nl; + << node->local_name () + << vt->field_pd_postfix () << ";"; + return 0; } @@ -859,7 +996,7 @@ be_visitor_valuetype::gen_field_pd (be_field *node) int be_visitor_valuetype::gen_init_defn (be_valuetype *node) { - if (node->is_abstract_valuetype ()) + if (node->is_abstract ()) { return 0; } @@ -885,7 +1022,7 @@ be_visitor_valuetype::gen_init_defn (be_valuetype *node) int be_visitor_valuetype::gen_init_impl (be_valuetype *node) { - if (node->is_abstract_valuetype ()) + if (node->is_abstract ()) { return 0; } @@ -973,11 +1110,11 @@ be_visitor_valuetype::determine_factory_style (be_valuetype* node) } // end of for loop } // end of if - if(!have_operation && !have_factory) + if (!have_operation && !have_factory) { factory_style = FS_CONCRETE_FACTORY; } - else if(have_operation && !have_factory) + else if (have_operation && !have_factory) { factory_style = FS_NO_FACTORY; } @@ -990,7 +1127,7 @@ be_visitor_valuetype::determine_factory_style (be_valuetype* node) } idl_bool -be_visitor_valuetype::have_operation(be_valuetype* node) +be_visitor_valuetype::have_operation (be_valuetype* node) { // Check whatever scope we get for operations/attributes. @@ -1030,24 +1167,24 @@ be_visitor_valuetype::have_operation(be_valuetype* node) AST_Decl::NodeType node_type = d->node_type(); - if(node_type == AST_Decl::NT_op) + if (node_type == AST_Decl::NT_op) { have_operation = 1; continue; } - if(node_type == AST_Decl::NT_attr) + if (node_type == AST_Decl::NT_attr) { have_operation = 1; continue; } - if(node_type == AST_Decl::NT_factory) + if (node_type == AST_Decl::NT_factory) { continue; } - if(node_type == AST_Decl::NT_field) + if (node_type == AST_Decl::NT_field) { continue; } @@ -1055,35 +1192,26 @@ be_visitor_valuetype::have_operation(be_valuetype* node) } // end of for loop } // end of if - //Now traverse inheritance tree. - int i; // loop index - - AST_Interface *iface = - AST_Interface::narrow_from_scope (node); + // Now traverse inheritance tree. + long i; // loop index + long n_inherits = node->n_inherits (); + AST_Interface **inherits = node->inherits (); - for (i = 0; i < iface->n_inherits (); ++i) + for (i = 0; i < n_inherits; ++i) { - AST_Interface *inherited = - AST_Interface::narrow_from_decl (iface->inherits ()[i]); - - if (!inherited || !inherited->is_valuetype()) - { - continue; - } - - be_valuetype *vt = be_valuetype::narrow_from_decl(node->inherits ()[i]); + be_valuetype *vt = be_valuetype::narrow_from_decl (inherits[i]); if (vt != 0) { have_operation = have_operation || - be_visitor_valuetype::have_operation(vt); + be_visitor_valuetype::have_operation (vt); - if(have_operation) + if (have_operation) { break; } } - } // end of for loop + } return have_operation; } @@ -1094,26 +1222,15 @@ be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) // VT needs RefCounter if it has concrete factory and // none of its base VT has ref_counter - if (determine_factory_style(node) != FS_CONCRETE_FACTORY) + if (determine_factory_style (node) != FS_CONCRETE_FACTORY) { return 0; } // Now go thru our base VTs and see if one has already. - - int i; // loop index - - for (i = 0; i < node->n_inherits (); ++i) + for (int i = 0; i < node->n_inherits (); ++i) { - AST_Interface *inherited = - AST_Interface::narrow_from_decl (node->inherits ()[i]); - - if (!inherited || !inherited->is_valuetype()) - { - continue; - } - - be_valuetype *vt = be_valuetype::narrow_from_decl(node->inherits ()[i]); + be_valuetype *vt = be_valuetype::narrow_from_decl (node->inherits ()[i]); if (vt != 0) { @@ -1122,7 +1239,7 @@ be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) return 0; } } - } // end of for loop + } return 1; } @@ -1132,7 +1249,7 @@ be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) { // Just try to find a VT with concrete factory in inheritance tree. - if(node == 0) + if (node == 0) { return 0; } @@ -1143,19 +1260,8 @@ be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) } // Now go thru our base VTs. - - int i; // loop index - - for (i = 0; i < node->n_inherits (); ++i) + for (int i = 0; i < node->n_inherits (); ++i) { - AST_Interface *inherited = - AST_Interface::narrow_from_decl (node->inherits ()[i]); - - if (!inherited || !inherited->is_valuetype()) - { - continue; - } - be_valuetype *vt = be_valuetype::narrow_from_decl (node->inherits ()[i]); if (vt != 0) @@ -1165,7 +1271,7 @@ be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) return 1; } } - } // end of for loop + } 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 index 83079b6f2c5..d9e7dab2036 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp @@ -20,14 +20,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_ch, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + valuetype_ch, + "$Id$") // ****************************************************** // Valuetype visitor for client header @@ -46,60 +41,61 @@ be_visitor_valuetype_ch::~be_visitor_valuetype_ch (void) int be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os = this->ctx_->stream (); - - if (!node->cli_hdr_gen () && !node->imported ()) + if (node->cli_hdr_gen () || node->imported ()) { - *os << "// Valuetype class" << be_nl; + return 0; + } - // == STEP 1: Generate the class name and class names we inherit == + TAO_OutStream *os = this->ctx_->stream (); + int status = 0; - // Forward declaration. - *os << "class " << node->local_name () << ";" << be_nl; + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - os->gen_ifdef_macro (node->flat_name (), "_ptr"); + // == STEP 1: Generate the class name and class names we inherit == - *os << "typedef " << node->local_name () - << " *" << node->local_name () << "_ptr;" << be_nl; + // Forward declaration. + *os << "class " << node->local_name () << ";" << be_nl; - os->gen_endif (); + os->gen_ifdef_macro (node->flat_name (), "_ptr"); - // Generate the ifdefined macro for the _var type. - os->gen_ifdef_macro (node->flat_name (), "_var"); + *os << "typedef " << node->local_name () + << " *" << node->local_name () << "_ptr;" << be_nl; - // 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 (); - os->gen_endif (); + // Generate the ifdefined macro for the _var type. + os->gen_ifdef_macro (node->flat_name (), "_var"); - // Generate the ifdef macro for the _out class. - os->gen_ifdef_macro (node->flat_name (), "_out"); + // 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); + } - // Generate the _out declaration - if (node->gen_out_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "codegen for _out failed\n"), -1); - } + os->gen_endif (); - // generate the endif macro. - os->gen_endif (); - } + // Generate the ifdef macro for the _out class. + os->gen_ifdef_macro (node->flat_name (), + "_out"); - if (node->imported ()) + // Generate the _out declaration. + if (node->gen_out_defn () == -1) { - return 0; + 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 (); + // Now the valuetype definition itself. os->gen_ifdef_macro (node->flat_name ()); @@ -111,33 +107,19 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) // (ordinary (not abstract) interfaces ignored). *os << be_idt_nl <<": "; - int i; // loop index - int n_inherits_valuetypes = 0; - idl_bool valuebase_inherited = 0; - if (node->n_inherits () > 0) + long i; // loop index + be_valuetype *inherited = 0; + long n_inherits = node->n_inherits (); + + if (n_inherits > 0) { - for (i = 0; i < node->n_inherits (); i++) + for (i = 0; i < 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]); + inherited = + be_valuetype::narrow_from_decl (node->inherits ()[i]); - if (!inherited->is_valuetype () - && !inherited->is_abstract ()) - { - continue; - } - - ++ n_inherits_valuetypes; - - if (inherited->is_valuetype()) - { - valuebase_inherited = 1; - } - - if (n_inherits_valuetypes > 1) + if (i > 0) { *os << ","; @@ -164,37 +146,28 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) *os << "public virtual "; *os << inherited->nested_type_name (scope); } // end of for loop + } - if (n_inherits_valuetypes > 0) - { - if (n_inherits_valuetypes > 1) - { - *os << be_uidt; - } - - *os << be_uidt_nl; - } - } - - /************************************************************************** + /*********************************************************************** ** This is where we diverge for an ExceptionHolder ValueType. ** This is how we proceed: ** 1) Identify it is an AMH_ExceptionHolder class. ** 2) Inherit from CORBA_DefaultValueBaseRef i.e. provide a CONCRETE ** implementation for this ValueType! This is because the alternative ** design of deriving a concrete-exception-holder class that the IDL - ** compiler again has to generate is superflous, unnecessary, more code - ** bloat and unnecessary information for the app-programmer. The + ** compiler again has to generate is superflous, unnecessary, more + ** coe bloat and unnecessary information for the app-programmer. The ** changes required for this (n the *C.h file) are: - ** 2.1) Generate the raise_method as non-abstract and provide a definition - ** in place - ** 2.2) Generate a new constructor that takes in a CORBA::Exception* + ** 2.1) Generate the raise_method as non-abstract and provide a + ** definition in place + ** 2.2) Generate a new constructor that takes in a + CORBA::Exception* ** 2.3) Make the destructor public (instead of protected) ** 2.4) Generate a private CORBA::Exception* field. ** 2.5) Generate the tao_marshal and tao_unmarshal methods as ** non-abstarct. ** 2.6) Generate the right throw spec for the AMH ExceptionHolders - ***************************************************************************/ + ************************************************************************/ /****************************************************************/ // 1) Find out if the ValueType is an AMH_*ExceptionHolder, the @@ -204,55 +177,67 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) int is_an_amh_exception_holder = 0; const char *amh_underbar = "AMH_"; const char *node_name = node->local_name (); + if( amh_underbar[0] == node_name[0] && amh_underbar[1] == node_name[1] && amh_underbar[2] == node_name[2] && amh_underbar[3] == node_name[3] ) // node name starts with "AMH_" { - //ACE_DEBUG ((LM_DEBUG, "Passed first test of amh_excepholder \n")); const char *last_E = ACE_OS::strrchr (node->full_name (), 'E'); + if (last_E != 0 && ACE_OS::strcmp (last_E, "ExceptionHolder") == 0) { - //ACE_DEBUG ((LM_DEBUG, "visit_valuetype: Passed second test of amh_excepholder \n")); is_an_amh_exception_holder = 1; } } /*******************************************************************/ - if (!valuebase_inherited) + // We do not inherit from any valuetype, hence we do so from the base + // CORBA::ValueBase class. + if (n_inherits > 0) { - // We do not inherit from any valuetype, hence we do so from the base - // CORBA::ValueBase class. - if (n_inherits_valuetypes > 1) - { - *os << ", "; - } + *os << "," << be_nl; + } - /*********************************************************************/ - // 2 - if (is_an_amh_exception_holder) + /*********************************************************************/ + // 2 + if (is_an_amh_exception_holder) + { + *os << "public virtual CORBA_DefaultValueRefCountBase" + << be_uidt_nl; + } + /*********************************************************************/ + else + { + *os << "public virtual CORBA_ValueBase" << be_uidt_nl; + } + + if (node->supports_abstract ()) + { + status = + node->traverse_supports_list_graphs ( + be_valuetype::abstract_supports_helper, + os, + I_TRUE + ); + + if (status == -1) { - *os << "public virtual CORBA_DefaultValueRefCountBase" - << be_uidt_nl; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_valuetype - " + "traversal of supported interfaces failed\n"), + -1); } - /*********************************************************************/ - else - *os << "public virtual CORBA_ValueBase" << be_uidt_nl; } // Generate the body. - *os << "{" << be_nl + *os << be_uidt << be_uidt_nl + << "{" << be_nl << "public:" << be_idt_nl - - // Generate the _ptr_type and _var_type typedef - // but we must protect against certain versions of g++ - << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_nl - << "typedef " << node->local_name () << "* _ptr_type;" << be_nl - << "typedef " << node->local_name () << "_var _var_type;\n" - << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl; + << "typedef " << node->local_name () << "_var _var_type;" << be_nl; /***********************************************************************/ // 2.2, 2.3 @@ -262,7 +247,8 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) *os << node->local_name () << " (CORBA::Exception *ex)" << be_nl << "{ this->exception = ex; }" << be_nl << be_nl; // and the destructor - *os << "virtual ~" << node->local_name () << " ();\n" << be_nl; + *os << "virtual ~" << node->local_name () << " (void);" + << be_nl << be_nl; } /***********************************************************************/ @@ -278,12 +264,11 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << node->local_name () << " *&" << be_uidt_nl << ");" << be_uidt_nl << "virtual const char* " - << "_tao_obv_repository_id () const;" + << "_tao_obv_repository_id (void) const;" << be_nl << "static const char* " - << "_tao_obv_static_repository_id ();" << be_nl << be_nl; + << "_tao_obv_static_repository_id (void);" << be_nl << be_nl; - // Ugly TAO any support routine *os << "static void _tao_any_destructor (void *);" << be_nl << be_nl; @@ -298,29 +283,56 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) -1); } - // Protected member: + // Generate pure virtual declarations of the operations in our + // supported interfaces. + status = + node->traverse_supports_list_graphs ( + be_visitor_valuetype_ch::gen_supported_ops, + os + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_valuetype - " + "traversal of supported interfaces failed\n"), + -1); + } + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__; + + // If we inherit from both CORBA::ValueBase and CORBA::AbstractBase, + // we have to add this to avoid ambiguity. + if (node->supports_abstract ()) + { + *os << be_nl << be_nl << "virtual void _add_ref (void) = 0;" << be_nl; + *os << "virtual void _remove_ref (void) = 0;"; + } // Generate the "protected" constructor so that users cannot // instantiate us. - *os << be_uidt_nl << "protected:" << be_idt_nl + *os << be_uidt_nl << be_nl << "protected:" << be_idt_nl << node->local_name () - << " ();" << be_nl; + << " (void);" << be_nl; if (!is_an_amh_exception_holder) - *os << "virtual ~" << node->local_name () << " ();\n" << be_nl; + { + *os << "virtual ~" << node->local_name () << " (void);" + << be_nl << 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 ()) + if (!node->is_abstract ()) { *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. } if (is_an_amh_exception_holder) { @@ -362,11 +374,12 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "_tao_unmarshal_state (TAO_InputCDR &);" << be_uidt_nl << be_nl; *os << "private:" << be_idt_nl; + this->gen_pd (node); } else // Need a way to access the state of derived OBV_ classes. { - if (!node->is_abstract_valuetype ()) + if (!node->is_abstract ()) { *os << be_uidt_nl << "protected:" << be_idt_nl; /*********************************************************/ @@ -394,51 +407,39 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) } *os << be_uidt_nl << "};" << be_nl; - os->gen_endif (); + os->gen_endif (); // Generate the _init -related declarations. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_valuetype_init_ch visitor (&ctx); - if (!visitor) + if (visitor.visit_valuetype (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "NULL visitor.\n" - ), -1); + "failed to generate _init construct.\n"), + -1); } - if (visitor->visit_valuetype(node) == -1) + // Step last: generate typecode declaration. + if (be_global->tc_support ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "failed to generate _init construct.\n" - ), -1); - } + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); + be_visitor_typecode_decl visitor (&ctx); - delete visitor; - - // Step last: generate typecode declaration - { - be_visitor *visitor; - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_structure - " - "TypeCode declaration failed\n" - ), - -1); - } - } + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_structure - " + "TypeCode declaration failed\n"), + -1); + } + } node->cli_hdr_gen (I_TRUE); @@ -450,7 +451,6 @@ int be_visitor_valuetype_ch::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; this->ctx_->node (node); // save the node @@ -458,7 +458,7 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) *os << "virtual "; // STEP I: Generate the return type. - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -472,20 +472,10 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) // Grab the right visitor to generate the return type. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype or_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_operation - " @@ -493,8 +483,6 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) -1); } - delete visitor; - // STEP 2: Generate the operation name. *os << " " << node->local_name (); @@ -502,20 +490,10 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ch::" - "visit_operation - " - "Bad visitor to argument list\n"), - -1); - } + be_visitor_obv_operation_arglist ooa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&ooa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ch::" "visit_operation - " @@ -523,8 +501,6 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) -1); } - delete visitor; - return 0; } @@ -538,38 +514,27 @@ be_visitor_valuetype_ch::visit_field (be_field *node) 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); - } + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_FIELD_OBV_CH); + be_visitor_valuetype_field_ch visitor (&ctx); if (vt->opt_accessor ()) { - visitor->setenclosings ("",";"); + visitor.setenclosings ("",";"); } else { - visitor->setenclosings ("virtual "," = 0;"); + visitor.setenclosings ("virtual "," = 0;"); } - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_obv_ch::" - "visit_field - codegen failed\n"), + "visit_field - codegen failed\n"), -1); } - delete visitor; return 0; } @@ -578,6 +543,7 @@ void be_visitor_valuetype_ch::begin_public (void) { TAO_OutStream *os = this->ctx_->stream (); + *os << "public:" << be_idt_nl; } @@ -585,5 +551,59 @@ void be_visitor_valuetype_ch::begin_private (void) { TAO_OutStream *os = this->ctx_->stream (); + *os << be_uidt_nl << "protected:" << be_idt_nl; } + +int +be_visitor_valuetype_ch::gen_supported_ops (be_interface *, + be_interface *base, + TAO_OutStream *os) +{ + // We inherit from abstract supported interfaces, so no need + // to declare their pure virtual operations again in our scope. + if (base->is_abstract ()) + { + return 0; + } + + AST_Decl *d = 0; + be_visitor_context ctx; + ctx.stream (os); + + for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "gen_supported_ops - " + "bad node in this scope\n"), + -1); + } + + AST_Decl::NodeType nt = d->node_type (); + be_visitor_valuetype_ch visitor (&ctx); + + if (nt == AST_Decl::NT_op) + { + be_operation *op = be_operation::narrow_from_decl (d); + + if (visitor.visit_operation (op) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "gen_supported_ops - " + "failed to accept visitor\n"), + -1); + } + } + } + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp index 6fa624a44fe..0717c18d30c 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp @@ -19,18 +19,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_ci, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + valuetype_ci, + "$Id$") // ************************************************** -// Valuetype visitor for client inline +// Valuetype visitor for client inline. // ************************************************** + be_visitor_valuetype_ci::be_visitor_valuetype_ci (be_visitor_context *ctx) : be_visitor_valuetype (ctx), opt_accessor_ (0) @@ -44,71 +40,86 @@ 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; + { + return 0; + } - //@@ What is that? - // need to access it in visit_field () if (node->opt_accessor ()) - this->opt_accessor_ = 1; + { + this->opt_accessor_ = 1; + } + + TAO_OutStream *os = this->ctx_->stream (); - os = this->ctx_->stream (); + os->indent (); - os->indent (); // start from the current indentation level + *os << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // 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 << node->name () << "::" << node->local_name () << " (void)" << be_nl; + + if (node->supports_abstract ()) + { + *os << "{" << be_idt; + + int status = + node->traverse_supports_list_graphs ( + be_valuetype::gen_abstract_init_helper, + os, + I_TRUE + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ci::" + "visit_valuetype - " + "traversal of supported interfaces failed\n"), + -1); + } + + *os << be_uidt_nl << "}" << be_nl << be_nl; + } + else + { + *os << "{}" << be_nl << be_nl; + } *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::~" << node->local_name () << - " () // destructor" << be_nl; + *os << node->name () << "::~" << node->local_name () << " (void)" << be_nl; *os << "{}\n" << be_nl; *os << "ACE_INLINE const char* " << be_nl - << node->name() << "::_tao_obv_static_repository_id ()" << be_nl + << node->name () << "::_tao_obv_static_repository_id ()" << be_nl << "{" << be_idt_nl << "return \"" << node->repoID () << "\";" << be_uidt_nl << "}\n\n"; - // 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); + "codegen for scope failed\n"), + -1); } - // Generate the _init -related code. + // Generate the _init-related code. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_valuetype_init_ci visitor (&ctx); - if (!visitor) + if (visitor.visit_valuetype (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ci::" "visit_valuetype - " - "NULL visitor.\n" - ), -1); + "failed to generate _init construct.\n"), + -1); } - if (visitor->visit_valuetype(node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ci::" - "visit_valuetype - " - "failed to generate _init construct.\n" - ), -1); - } - - delete visitor; - return 0; } @@ -118,22 +129,19 @@ 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 "); + be_visitor_context ctx (*this->ctx_); + be_visitor_valuetype_field_cs visitor (&ctx); + visitor.in_obv_space_ = 0; + visitor.setenclosings ("ACE_INLINE "); - if (visitor->visit_field (node) == -1) + if (visitor.visit_field (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ci::" "visit_field - " - "visit_field failed\n" - ), -1); + "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 index fa658ecdffb..529fd388412 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp @@ -19,17 +19,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_cs, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + valuetype_cs, + "$Id$") // ************************************************************ -// Valuetype visitor for client stubs +// Valuetype visitor for client stubs. // ************************************************************ be_visitor_valuetype_cs::be_visitor_valuetype_cs (be_visitor_context *ctx) @@ -44,43 +39,61 @@ 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; } - // 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 *visitor; - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_cs::" - "visit_valuetype - " - "TypeCode definition failed\n" - ), -1); - } - } + if (be_global->tc_support ()) + { + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); + ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); + be_visitor_typecode_defn tc_visitor (&ctx); + + if (node->accept (&tc_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_cs::" + "visit_valuetype - " + "TypeCode definition failed\n"), + -1); + } + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Global functions to allow non-defined forward declared interfaces + // access to some methods in the full definition. + *os << "void" << be_nl + << "tao_" << node->flat_name () + << "_add_ref (" << be_idt << be_idt_nl + << node->full_name () << " *p" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "CORBA::add_ref (p);" << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "void" << be_nl + << "tao_" << node->flat_name () + << "_remove_ref (" << be_idt << be_idt_nl + << node->full_name () << " *p" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "CORBA::remove_ref (p);" << be_uidt_nl + << "}" << be_nl << be_nl; - // Generate methods for _var class + // Generate methods for _var class. if (node->gen_var_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cs::" "visit_valuetype - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } // Generate methods for _out class @@ -89,91 +102,151 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cs::" "visit_valuetype - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // 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 + *os << node->name () << " *" << be_nl << node->name () + << "::_downcast (CORBA::ValueBase *v)" << be_nl + << "{" << be_idt_nl + << "if (v == 0)" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "return (" << node->local_name () << " *) " + << "v->_tao_obv_narrow ((ptr_arith_t) &_downcast);" << be_uidt_nl + << "}" << be_nl << 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 + *os << "const char *" << be_nl + << node->name () << "::_tao_obv_repository_id (void) const" << be_nl + << "{" << be_idt_nl + << "return this->_tao_obv_static_repository_id ();" << be_uidt_nl + << "}" << be_nl << be_nl; // The _tao_obv_narrow method - << "void* " << node->name() + *os << "void *" << be_nl << 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; + << "{" << be_idt_nl + << "if (type_id == (ptr_arith_t) &_downcast)" << be_idt_nl + << "{" << be_idt_nl + << "return this;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "void *rval = 0;" << be_nl; // Find the possible base classes. int n_inherits_downcastable = 0; + AST_Interface *inherited = 0; - for (int i = 0; i < node->n_inherits (); i++) + for (int i = 0; i < node->n_inherits (); ++i) { - AST_Interface *inherited = - AST_Interface::narrow_from_decl (node->inherits ()[i]); + inherited = node->inherits ()[i]; + + ++n_inherits_downcastable; - if (inherited->is_valuetype()) + *os << be_nl + << "if (rval == 0)" << be_idt_nl + << "{" << be_idt_nl + << "rval = "; + + AST_Decl::NodeType nt = + inherited->defined_in ()->scope_node_type (); + + if (nt == AST_Decl::NT_module) { - ++n_inherits_downcastable; - *os << "if (rval == 0)" << be_idt_nl - << "rval = "; + be_scope *scope = + be_scope::narrow_from_scope (inherited->defined_in ()); + be_decl *scope_decl = scope->decl (); - if (inherited->defined_in ()->scope_node_type () == AST_Decl::NT_module) - { - be_decl *scope = be_scope::narrow_from_scope (inherited->defined_in ())->decl (); - *os << "ACE_NESTED_CLASS (" - << scope->name() << "," - << inherited->local_name () << ")"; - } - else + *os << "ACE_NESTED_CLASS (" + << scope_decl->name () << "," + << inherited->local_name () << ")"; + } + else + { + *os << inherited->name (); + } + + *os << "::_tao_obv_narrow (type_id);" << be_uidt_nl + << "}" << be_uidt_nl; + } + + if (node->supports_abstract ()) + { + long size = node->n_supports (); + AST_Interface *supported = 0; + + for (long i = 0; i < size; ++i) + { + supported = node->supports ()[i]; + + if (supported->is_abstract ()) { - *os << inherited->name (); + *os << be_nl + << "if (rval == 0)" << be_idt_nl + << "{" << be_idt_nl + << "rval = "; + + AST_Decl::NodeType supported_nt = + supported->defined_in ()->scope_node_type (); + + if (supported_nt == AST_Decl::NT_module) + { + be_scope *supported_scope = + be_scope::narrow_from_scope (supported->defined_in ()); + be_decl *supported_scope_decl = supported_scope->decl (); + + *os << "ACE_NESTED_CLASS (" + << supported_scope_decl->name () << "," + << supported->local_name () << ")"; + } + else + { + *os << supported->name (); + } + + *os << "::_tao_obv_narrow (type_id);" << be_uidt_nl + << "}" << be_uidt_nl; } - - *os << "::_tao_obv_narrow (type_id);" << be_uidt_nl; } } - *os << "return rval;" << be_uidt_nl - << "}\n\n"; + *os << be_nl << "return rval;" << be_uidt_nl + << "}" << be_nl << be_nl; - // Ugly TAO any support routine *os << "void" << be_nl << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl << "{" << be_idt_nl - << node->local_name () << " *tmp = ACE_static_cast (" - << node->local_name () << "*, _tao_void_pointer);" << be_nl + << node->local_name () << " *tmp =" << be_idt_nl + << "ACE_static_cast (" << be_idt << be_idt_nl + << node->local_name () << " *," << be_nl + << "_tao_void_pointer" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << "delete tmp;" << be_uidt_nl << "}" << be_nl << be_nl; // Nothing to marshal if abstract valuetype. - if (!node->is_abstract_valuetype ()) + if (!node->is_abstract ()) { - // The virtual _tao_marshal_v method + // The virtual _tao_marshal_v method. *os << "CORBA::Boolean " << node->name () - << "::_tao_marshal_v (TAO_OutputCDR & strm)" + << "::_tao_marshal_v (TAO_OutputCDR & strm)" << be_nl - << "{" << be_idt_nl - << "return "; + << "{" << be_idt_nl + << "return "; + if (node->opt_accessor ()) { - be_decl *scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *scope = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + *os << "ACE_NESTED_CLASS (" << scope->name () << "," << node->local_name () << ")" @@ -187,15 +260,18 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) *os << "}\n" << be_nl; - // The virtual _tao_unmarshal_v method + // The virtual _tao_unmarshal_v method. *os << "CORBA::Boolean " << node->name () - << "::_tao_unmarshal_v (TAO_InputCDR & strm)" + << "::_tao_unmarshal_v (TAO_InputCDR & strm)" << be_nl - << "{" << be_idt_nl - << "return "; + << "{" << be_idt_nl + << "return "; + if (node->opt_accessor ()) { - be_decl *scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *scope = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + *os << "ACE_NESTED_CLASS (" << scope->name () << "," << node->local_name () << ")" @@ -210,89 +286,78 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) *os << "}\n" << be_nl; } - // The static T::_tao_unmarshal method ---------------------------- + // The static T::_tao_unmarshal method *os << "CORBA::Boolean " << node->name() - << "::_tao_unmarshal (TAO_InputCDR &strm, " - << node->local_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->local_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->local_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 code for the elements of the valuetype + << "::_tao_unmarshal (" << be_idt << be_idt_nl + << "TAO_InputCDR &strm," << be_nl + << node->local_name () << " *&new_object" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "CORBA::ValueBase *base = 0;" << be_nl + << "CORBA::ValueFactory_var factory;" << be_nl + << "CORBA::Boolean retval =" << be_idt_nl + << "CORBA::ValueBase::_tao_unmarshal_pre (" << be_idt << be_idt_nl + << "strm," << be_nl + << "factory," << be_nl + << "base," << be_nl + << node->local_name () << "::_tao_obv_static_repository_id ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << be_nl + << "if (retval == 0)" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "if (factory.in () != 0)" << be_idt_nl + << "{" << be_idt_nl + << "base = factory->create_for_unmarshal ();" << be_nl << be_nl + << "if (base == 0)" << be_idt_nl + << "{" << be_idt_nl + << "return 0; // %! except.?" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "retval = base->_tao_unmarshal_v (strm);" << be_nl << be_nl + << "if (retval == 0)" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_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->local_name () << "::_downcast (base);" << be_nl + << "return retval;" << be_uidt_nl + << "}" << be_nl << be_nl; + + if (node->supports_abstract ()) + { + *os << "CORBA::ValueBase *" << be_nl + << node->name () << "::_tao_to_value (void)" << be_nl + << "{" << be_idt_nl + << "return this;" << be_uidt_nl + << "}" << be_nl << be_nl; + } + + // 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); + "codegen for scope failed\n"), + -1); } - // Generate the _init -related code. + // Generate the _init-related code. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "NULL visitor.\n" - ), -1); - } + be_visitor_valuetype_init_cs vi_visitor (&ctx); - if (visitor->visit_valuetype(node) == -1) + if (vi_visitor.visit_valuetype (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "failed to generate _init construct.\n" - ), -1); + "failed to generate _init construct.\n"), + -1); } - delete visitor; - - - // 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_init.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init.cpp index 780004ba2d8..84a56777620 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init.cpp @@ -20,13 +20,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_init, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_init, + "$Id$") be_visitor_valuetype_init::be_visitor_valuetype_init ( be_visitor_context *ctx diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp index 5b621ca3272..ee8ef8cbdcb 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp @@ -19,23 +19,20 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +ACE_RCSID (be_visitor_valuetype_init, + arglist_ch, + "$Id$") -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype_init, arglist_ch, "$Id$") - - -be_visitor_valuetype_init_arglist_ch:: -be_visitor_valuetype_init_arglist_ch (be_visitor_context *ctx) +be_visitor_valuetype_init_arglist_ch::be_visitor_valuetype_init_arglist_ch ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } -be_visitor_valuetype_init_arglist_ch:: -~be_visitor_valuetype_init_arglist_ch (void) +be_visitor_valuetype_init_arglist_ch::~be_visitor_valuetype_init_arglist_ch ( + void + ) { } @@ -43,10 +40,11 @@ int be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) { TAO_OutStream& os = *(this->ctx_->stream ()); - os << " (" << be_idt // idt = 1 - << be_idt_nl; // idt = 2 - // all we do is hand over code generation to our scope + os << " (" << be_idt + << be_idt_nl; + + // All we do is hand over code generation to our scope. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -56,8 +54,8 @@ be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) -1); } - os << be_uidt_nl // idt = 1 - << ")" << be_uidt; // idt = 0 + os << be_uidt_nl + << ")" << be_uidt; return 0; } @@ -65,15 +63,20 @@ be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) int be_visitor_valuetype_init_arglist_ch::visit_argument (be_argument *node) { - // get the visitor that will dump the argument's mapping in the operation + // Get the visitor that will dump the argument's mapping in the operation // signature. be_visitor_context ctx (*this->ctx_); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); + be_visitor_args_arglist visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -84,20 +87,8 @@ be_visitor_valuetype_init_arglist_ch::visit_argument (be_argument *node) } } - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_init_arglist_ch::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_init_arglist_ch::" "visit_argument - " @@ -105,7 +96,6 @@ be_visitor_valuetype_init_arglist_ch::visit_argument (be_argument *node) -1); } - delete visitor; return 0; } @@ -114,7 +104,7 @@ be_visitor_valuetype_init_arglist_ch::post_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); - // if we are not the last node in the list of arguments, generate a comma. + // If we are not the last node in the list of arguments, generate a comma. if (!this->last_node (bd)) { *os << "," << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp index ffa84c7497c..cb507e4ca8b 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp @@ -20,13 +20,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_init_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_init_ch, + "$Id$") be_visitor_valuetype_init_ch::be_visitor_valuetype_init_ch ( be_visitor_context *ctx @@ -42,11 +38,10 @@ be_visitor_valuetype_init_ch::~be_visitor_valuetype_init_ch (void) int be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) { - - if (node->is_abstract_valuetype ()) - { - return 0; - } + if (node->is_abstract ()) + { + return 0; + } // There are three possible situations. // (1) If there is no initializers but at least one operation. @@ -61,9 +56,10 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) FactoryStyle factory_style = determine_factory_style (node); - if(factory_style == FS_NO_FACTORY) // nothing to do + if (factory_style == FS_NO_FACTORY) { - return 0; // bail out + // Nothing to do. + return 0; } TAO_OutStream& os = *(this->ctx_->stream ()); @@ -72,27 +68,24 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) os.gen_ifdef_macro (node->flat_name (), "_init"); - //@@ If I'm generating concrete class I need a RefCounter + //@@ If I'm generating concrete class I need a RefCounter. os << "class " << be_global->stub_export_macro () << " " << node->local_name () << "_init : public virtual CORBA_ValueFactoryBase" << be_nl; - // generate the body + // Generate the body. os << "{" << be_nl << "public:" << be_idt_nl; - if(factory_style == FS_CONCRETE_FACTORY) + if (factory_style == FS_CONCRETE_FACTORY) { - // public ctor - os << node->local_name () << "_init ();" << be_nl; + // Public constructor. + os << node->local_name () << "_init (void);" << be_nl; } - // virtual public dtor - os << "virtual ~" << node->local_name () << "_init ();" << be_nl; - + // Virtual destructor. + os << "virtual ~" << node->local_name () << "_init (void);"; - // custom methods - os << be_nl; if (this->visit_valuetype_scope (node) == -1) { @@ -103,42 +96,44 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) -1); } - os << be_nl; + // Generate _downcast method. + os << be_nl << be_nl + << "static " << node->local_name () << "_init* " + << "_downcast (CORBA_ValueFactoryBase* );"; - // generate _downcast method - os << "static " << node->local_name () << "_init* " - << "_downcast (CORBA_ValueFactoryBase* );" << be_nl; - - if(factory_style == FS_CONCRETE_FACTORY) + if (factory_style == FS_CONCRETE_FACTORY) { //@@ Boris: create_for_unmarshal is still public... // generate create_for_unmarshal - os << be_nl - << "virtual CORBA_ValueBase* " - << "create_for_unmarshal" << " " - << "(void);" << be_nl; + os << be_nl << be_nl + << "virtual CORBA::ValueBase *" + << "create_for_unmarshal (void);"; + + if (node->supports_abstract ()) + { + os << be_nl << be_nl + << "virtual CORBA::AbstractBase_ptr " + << "create_for_unmarshal_abstract (void);"; + } } - os << be_nl; + os << be_nl << be_nl; - // propriate extensions + // Proprietary extensions. os << "// TAO-specific extensions" << be_uidt_nl << "public:" << be_idt_nl; + os << "virtual const char* tao_repository_id (void);"; - os << "virtual const char* tao_repository_id (void);\n"; - - if(factory_style == FS_ABSTRACT_FACTORY) + if (factory_style == FS_ABSTRACT_FACTORY) { - // protected ctor - os << be_uidt_nl + // Protected constructor. + os << be_uidt_nl << be_nl << "protected:" << be_idt_nl; - os << node->local_name () << "_init ();"; - } - os << be_uidt_nl << "};" << be_nl; + os << be_uidt_nl << "};" << be_nl << be_nl; // Generate the endif macro. os.gen_endif (); @@ -166,20 +161,10 @@ be_visitor_valuetype_init_ch::visit_factory (be_factory *node) // we grab a visitor that generates the parameter listing. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH); - be_visitor* visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_init_ch::" - "visit_factory - " - "Bad visitor to argument list\n"), - -1); - } + be_visitor_valuetype_init_arglist_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_init_arglist__ch::" "visit_operation - " @@ -187,9 +172,7 @@ be_visitor_valuetype_init_ch::visit_factory (be_factory *node) -1); } - delete visitor; - - // make pure virtual + // Make pure virtual. os << " = 0;" << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp index 87ef979a821..670597cad6c 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp @@ -20,13 +20,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_init_ci, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_init_ci, + "$Id$") be_visitor_valuetype_init_ci::be_visitor_valuetype_init_ci ( be_visitor_context *ctx @@ -40,7 +36,7 @@ be_visitor_valuetype_init_ci::~be_visitor_valuetype_init_ci (void) } int -be_visitor_valuetype_init_ci::visit_valuetype (be_valuetype *) +be_visitor_valuetype_init_ci::visit_valuetype (be_valuetype *node) { return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp index 5c4d7caf51c..bda1a103b02 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp @@ -20,14 +20,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype.h" - -ACE_RCSID(be_visitor_valuetype, valuetype_init_cs, "$Id$") - +ACE_RCSID (be_visitor_valuetype, + valuetype_init_cs, + "$Id$") be_visitor_valuetype_init_cs::be_visitor_valuetype_init_cs ( be_visitor_context *ctx @@ -43,7 +38,7 @@ be_visitor_valuetype_init_cs::~be_visitor_valuetype_init_cs (void) int be_visitor_valuetype_init_cs::visit_valuetype (be_valuetype *node) { - if (node->is_abstract_valuetype ()) + if (node->is_abstract ()) { return 0; } @@ -61,34 +56,40 @@ be_visitor_valuetype_init_cs::visit_valuetype (be_valuetype *node) FactoryStyle factory_style = determine_factory_style (node); - if(factory_style == FS_NO_FACTORY) // nothing to do + if (factory_style == FS_NO_FACTORY) { - return 0; // bail out + return 0; } - - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - - os->indent (); // start with whatever indentation level we are at + TAO_OutStream *os = this->ctx_->stream (); 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->full_name ()); + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); + ACE_OS::sprintf (fname, + "%s_init", + node->full_name ()); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_init", node->local_name ()); + ACE_OS::memset (lname, + '\0', + NAMEBUFSIZE); + ACE_OS::sprintf (lname, + "%s_init", + node->local_name ()); + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // ctor - *os << fname << "::" << lname << " ()" << be_nl + *os << fname << "::" << lname << " (void)" << be_nl << "{" << be_nl << "}\n"; // dtor *os << be_nl - << fname << "::~" << lname << " ()" << be_nl + << fname << "::~" << lname << " (void)" << be_nl << "{" << be_nl << "}\n"; //tao_repository_id @@ -98,25 +99,45 @@ be_visitor_valuetype_init_cs::visit_valuetype (be_valuetype *node) << "{" << be_idt_nl << "return " << node->full_name () << "::_tao_obv_static_repository_id ();" - << be_uidt_nl << "}\n"; + << be_uidt_nl << "}"; - if(factory_style == FS_CONCRETE_FACTORY) + if (factory_style == FS_CONCRETE_FACTORY) { // generate create_for_unmarshal() - *os << be_nl - << "CORBA_ValueBase* " << be_nl + *os << be_nl << be_nl + << "CORBA_ValueBase *" << be_nl << fname << "::create_for_unmarshal" << " " << "(void)" << be_nl << "{" << be_idt_nl - << "CORBA_ValueBase* ret_val = 0;" << be_nl - << "ACE_NEW_RETURN(ret_val, " << be_nl - << " OBV_" << node->full_name () << ", " << be_nl - << " 0);" << be_nl + << "CORBA_ValueBase *ret_val = 0;" << be_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "ret_val," << be_nl + << "OBV_" << node->full_name () << "," << be_nl + << "0" << be_uidt_nl + << ");" << be_uidt_nl << "return ret_val;" - << be_uidt_nl << "}\n"; + << be_uidt_nl << "}"; + + if (node->supports_abstract ()) + { + *os << be_nl << be_nl + << "CORBA::AbstractBase_ptr" << be_nl + << fname << "::create_for_unmarshal_abstract (void)" << be_nl + << "{" << be_idt_nl + << "CORBA_AbstractBase *ret_val = 0;" << be_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "ret_val," << be_nl + << "OBV_" << node->full_name () << "," << be_nl + << "0" << be_uidt_nl + << ");" << be_uidt_nl + << "return ret_val;" + << be_uidt_nl << "}"; + } } + *os << be_nl << be_nl; + 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 index 7ea87ebec20..45e70d1190b 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp @@ -22,14 +22,9 @@ // // ============================================================================ -#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$") - +ACE_RCSID (be_visitor_valuetype, + valuetype_obv_ch, + "$Id$") // ****************************************************** // Valuetype visitor for client header @@ -50,7 +45,7 @@ int be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) { // Only visit non-abstract non-imported valuetype. - if (node->is_abstract_valuetype () || node->imported ()) + if (node->is_abstract () || node->imported ()) { return 0; } @@ -104,14 +99,14 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) // int i = 0; + AST_Interface *inherited = 0; + for (; i < node->n_inherits (); ++i) { - AST_Interface *inherited = - AST_Interface::narrow_from_decl(node->inherits ()[i]); + inherited = node->inherits ()[i]; - // we need only concrete valuetypes - if (!inherited->is_valuetype () - || inherited->is_abstract ()) + // We need only concrete valuetypes. + if (inherited->is_abstract ()) { continue; } @@ -151,10 +146,18 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) -1); } + // If we inherit from both CORBA::ValueBase and CORBA::AbstractBase, + // we have to add this to avoid ambiguity. + if (node->supports_abstract ()) + { + *os << "virtual void _add_ref (void);" << be_nl; + *os << "virtual void _remove_ref (void);"; + } + // Map fields to private data. if (!node->opt_accessor ()) { - *os << be_uidt_nl << "protected:" << be_idt_nl; + *os << be_nl << be_uidt_nl << "protected:" << be_idt_nl; *os << "virtual CORBA::Boolean _tao_marshal__" << node->flat_name () << " (TAO_OutputCDR &);" << be_nl; *os << "virtual CORBA::Boolean _tao_unmarshal__" @@ -164,7 +167,7 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) << "CORBA::Boolean " << "_tao_unmarshal_state (TAO_InputCDR &);" << be_uidt_nl << be_nl; - *os << "private:" << be_idt_nl; + *os << "private:" << be_idt; this->gen_pd (node); } @@ -192,31 +195,19 @@ be_visitor_valuetype_obv_ch::visit_field (be_field *node) // 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); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_FIELD_OBV_CH); + be_visitor_valuetype_field_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_obv_ch::" - "visit_field - bad visitor\n"), - -1); - } - - visitor->setenclosings ("virtual ",";"); + visitor.setenclosings ("virtual ",";"); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_obv_ch::" "visit_field - codegen failed\n"), -1); } - - delete visitor; } return 0; 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 index c2bdf1529a5..40067e536c2 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ci.cpp @@ -22,14 +22,9 @@ // // ============================================================================ -#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$") - +ACE_RCSID (be_visitor_valuetype, + valuetype_obv_ci, + "$Id$") // ****************************************************** // Valuetype visitor for OBV_ class implementation @@ -50,8 +45,10 @@ int be_visitor_valuetype_obv_ci::visit_valuetype (be_valuetype *node) { // only visit non-abstract valuetype - if (node->is_abstract_valuetype ()) - return 0; + if (node->is_abstract ()) + { + return 0; + } TAO_OutStream *os; // output stream 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 index e3fc33230fb..f4d115dfd23 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp @@ -22,14 +22,9 @@ // // ============================================================================ -#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$") - +ACE_RCSID (be_visitor_valuetype, + valuetype_obv_cs, + "$Id$") // ****************************************************** // Valuetype visitor for OBV_ class implementation @@ -50,41 +45,67 @@ int be_visitor_valuetype_obv_cs::visit_valuetype (be_valuetype *node) { // only visit non-abstract non-imported valuetype - if (node->is_abstract_valuetype () || node->imported ()) - return 0; + if (node->is_abstract () || node->imported ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // OBV_ class has no accessors or modifiers if we are optimizing // or the valuetype is abstract. - if (!(node->opt_accessor () || node->is_abstract_valuetype () )) + if (!node->opt_accessor ()) { - os->indent (); - *os << "CORBA::Boolean " << be_nl + *os << "CORBA::Boolean" << be_nl << node->full_obv_skel_name () << "::_tao_marshal__" << node->flat_name () - << " (TAO_OutputCDR &strm)" + << " (TAO_OutputCDR &strm)" << be_nl << "{" << be_idt_nl - << "return _tao_marshal_state (strm);" << be_nl - << be_uidt_nl << "}\n"; + << "return _tao_marshal_state (strm);" << be_uidt_nl + << "}" << be_nl << be_nl; - *os << "CORBA::Boolean " + *os << "CORBA::Boolean" << be_nl << node->full_obv_skel_name () << "::_tao_unmarshal__" << node->flat_name () - << " (TAO_InputCDR &strm)" + << " (TAO_InputCDR &strm)" << be_nl << "{" << be_idt_nl - << "return _tao_unmarshal_state (strm);" << be_nl - << be_uidt_nl << "}\n"; + << "return _tao_unmarshal_state (strm);" << be_uidt_nl + << "}" << be_nl; 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); + "visit_scope failed\n"), + -1); } - } + + // If we inherit from both CORBA::ValueBase and CORBA::AbstractBase, + // we have to add this to avoid ambiguity. + if (node->supports_abstract ()) + { + *os << be_nl << "void" << be_nl + << node->full_obv_skel_name () + << "::_add_ref (void)" << be_nl + << "{" << be_idt_nl + << "this->CORBA_DefaultValueRefCountBase::_add_ref ();" + << be_uidt_nl + << "}" << be_nl; + + *os << be_nl << "void" << be_nl + << node->full_obv_skel_name () + << "::_remove_ref (void)" << be_nl + << "{" << be_idt_nl + << "this->CORBA_DefaultValueRefCountBase::_remove_ref ();" + << be_uidt_nl + << "}" << be_nl << be_nl; + } + } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_sh.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_sh.cpp new file mode 100644 index 00000000000..54d3bdb0bd5 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_sh.cpp @@ -0,0 +1,135 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// valuetype_sh.cpp +// +// = DESCRIPTION +// Visitor generating code for value types in the server header +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +ACE_RCSID (be_visitor_valuetype, + valuetype_sh, + "$Id$") + + +// ************************************************************ +// Valuetype visitor for server header. +// ************************************************************ + +be_visitor_valuetype_sh::be_visitor_valuetype_sh (be_visitor_context *ctx) + : be_visitor_valuetype (ctx) +{ +} + +be_visitor_valuetype_sh::~be_visitor_valuetype_sh (void) +{ +} + +int +be_visitor_valuetype_sh::visit_valuetype (be_valuetype *node) +{ + if (node->srv_hdr_gen () || node->imported () || node->is_abstract ()) + { + return 0; + } + + AST_Interface *concrete = node->supports_concrete (); + + // We generate a skeleton class only if the valuetype supports a + // non-abstract interface. + if (concrete == 0) + { + return 0; + } + + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + ACE_CString class_name; + + // We shall have a POA_ prefix only if we are at the topmost level. + if (!node->is_nested ()) + { + // We are outermost. + class_name += "POA_"; + class_name += node->local_name (); + } + else + { + class_name += node->local_name (); + } + + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Generate the skeleton class name. + *os << "class " << class_name.c_str () << ";" << be_nl; + + // Generate the _ptr declaration. + *os << "typedef " << class_name.c_str () << " *" << class_name.c_str () + << "_ptr;" << be_nl; + + // Forward class declaration. + *os << "// Forward Classes Declaration" << be_nl; + + if (be_global->gen_thru_poa_collocation ()) + { + *os << "class " << node->thru_poa_proxy_impl_name () << ";" << be_nl; + } + + if (be_global->gen_direct_collocation ()) + { + *os << "class " << node->direct_proxy_impl_name () << ";" << be_nl; + } + + if (be_global->gen_thru_poa_collocation () + || be_global->gen_direct_collocation ()) + { + *os << "class " << node->strategized_proxy_broker_name () + << ";" << be_nl; + } + + *os << be_nl; + + // Now generate the class definition. + *os << "class " << be_global->skel_export_macro () + << " " << class_name.c_str () << be_idt_nl << ": " << be_idt; + + *os << "public virtual " << "POA_" + << concrete->name (); + + *os << be_uidt << be_uidt_nl + << "{" << be_nl + << "protected:" << be_idt_nl + << class_name.c_str () << " (void);\n" << be_uidt_nl + << "public:" << be_idt_nl; + + // No copy constructor for locality constraint interface. + *os << class_name.c_str () << " (const " << class_name.c_str () + << "& rhs);" << be_nl + << "virtual ~" << class_name.c_str () << " (void);" << be_nl << be_nl; + + *os << "::" << node->full_name () << " *_this (" << be_idt << be_idt_nl + << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; + + // The _interface_repository_id method. + *os << "virtual const char* _interface_repository_id " + << "(void) const;" << be_uidt_nl; + + *os << "};\n\n"; + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_si.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_si.cpp new file mode 100644 index 00000000000..d878c4f3957 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_si.cpp @@ -0,0 +1,44 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// valuetype_si.cpp +// +// = DESCRIPTION +// Visitor generating code for Interfaces in the server inline file +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +ACE_RCSID (be_visitor_valuetype, + valuetype_si, + "$Id$") + + +// ************************************************************************ +// Valuetype visitor for server inline +// ************************************************************************ + +be_visitor_valuetype_si::be_visitor_valuetype_si (be_visitor_context *ctx) + : be_visitor_valuetype (ctx) +{ +} + +be_visitor_valuetype_si::~be_visitor_valuetype_si (void) +{ +} + +int +be_visitor_valuetype_si::visit_valuetype (be_valuetype *node) +{ + // Nothing needed for now, but the visitor is here just in case. + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp new file mode 100644 index 00000000000..004da7bfd1b --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp @@ -0,0 +1,203 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// valuetype_ss.cpp +// +// = DESCRIPTION +// Visitor generating code for Interfaces in the server skeletons file. +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include "nr_extern.h" + +ACE_RCSID (be_visitor_valuetype, + valuetype_ss, + "$Id$") + + +// ************************************************************ +// Interface visitor for server skeletons. +// ************************************************************ + +be_visitor_valuetype_ss::be_visitor_valuetype_ss (be_visitor_context *ctx) + : be_visitor_valuetype (ctx) +{ +} + +be_visitor_valuetype_ss::~be_visitor_valuetype_ss (void) +{ +} + +int +be_visitor_valuetype_ss::visit_valuetype (be_valuetype *node) +{ + if (node->srv_skel_gen () || node->imported () || node->is_abstract ()) + { + return 0; + } + + AST_Interface *concrete = node->supports_concrete (); + + // We generate a skeleton class only if the valuetype supports a + // non-abstract interface. + if (concrete == 0) + { + return 0; + } + + // Generate the normal skeleton as usual. + + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + ACE_CString full_skel_name_holder = + this->generate_full_skel_name (node); + + const char *full_skel_name = full_skel_name_holder.c_str (); + + ACE_CString flat_name_holder = + this->generate_flat_name (node); + + const char *flat_name = flat_name_holder.c_str (); + + *os << be_nl << "// TAO_IDL - Generated from " << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // Find if we are at the top scope or inside some module, + // pre-compute the prefix that must be added to the local name in + // each case. + const char *local_name_prefix = ""; + + if (!node->is_nested ()) + { + local_name_prefix = "POA_"; + } + + ACE_CString node_local_name_holder = + this->generate_local_name (node); + + const char *node_local_name = node_local_name_holder.c_str (); + + *os << full_skel_name << "::" + << local_name_prefix << node_local_name + << " (void)" << be_nl + << "{}" << be_nl << be_nl; + + *os << full_skel_name << "::" + << local_name_prefix << node_local_name << " (" + << "const " << local_name_prefix << node_local_name << "& rhs)"; + + *os << be_idt_nl + << ": "; + + if (concrete->is_nested ()) + { + AST_Decl *scope = ScopeAsDecl (concrete->defined_in ()); + + *os << "ACE_NESTED_CLASS (POA_" << scope->name () << ", " + << concrete->local_name () << ") (rhs)"; + } + else + { + be_interface *bd = be_interface::narrow_from_decl (concrete); + *os << bd->full_skel_name () << " (rhs)"; + } + + *os << be_uidt_nl << "{}" << be_nl << be_nl; + + *os << full_skel_name << "::~" + << local_name_prefix << node_local_name + << " (void)" << be_nl + << "{}" << be_nl << be_nl; + + // the _this () operation. + *os << node->full_name () << " *" << be_nl + << node->full_skel_name () + << "::_this (ACE_ENV_SINGLE_ARG_DECL)" << be_nl + << "{" << be_idt_nl + << "TAO_Stub *stub = this->_create_stub (ACE_ENV_SINGLE_ARG_PARAMETER);" + << be_nl + << "ACE_CHECK_RETURN (0);" << be_nl << be_nl + << "TAO_Stub_Auto_Ptr safe_stub (stub);" << be_nl; + + *os << "CORBA::Object_ptr tmp = CORBA::Object::_nil ();" << be_nl + << be_nl + << "if (stub->servant_orb_var ()->orb_core ()->" + << "optimize_collocation_objects ())" << be_idt_nl + << "{" << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "tmp," << be_nl + << "CORBA::Object (" << be_idt << be_idt_nl + << "stub," << be_nl + << "1," << be_nl + << "this" << be_uidt_nl + << ")," << be_uidt_nl + << "0" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl + << "else" << be_idt_nl + << "{" << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "tmp," << be_nl + << "CORBA::Object (" << be_idt << be_idt_nl + << "stub," << be_nl + << "0," << be_nl + << "this" << be_uidt_nl + << ")," << be_uidt_nl + << "0" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + *os << "CORBA::Object_var obj = tmp;" << be_nl + << "(void) safe_stub.release ();" << be_nl + << "return "; + + if (concrete->is_nested ()) + { + UTL_Scope *parent_scope = concrete->defined_in (); + AST_Decl *parent_decl = ScopeAsDecl (parent_scope); + + *os << "ACE_NESTED_CLASS (" + << parent_decl->name () << ", " + << concrete->local_name (); + } + else + { + *os << concrete->name (); + } + + *os << "::_unchecked_narrow (obj.in ());" + << be_uidt_nl + << "}" << be_nl << be_nl; + + return 0; +} + +ACE_CString +be_visitor_valuetype_ss::generate_flat_name (be_valuetype *node) +{ + return ACE_CString (node->flat_name ()); +} + +ACE_CString +be_visitor_valuetype_ss::generate_local_name (be_valuetype *node) +{ + return ACE_CString (node->local_name ()); +} + +ACE_CString +be_visitor_valuetype_ss::generate_full_skel_name (be_valuetype *node) +{ + return ACE_CString (node->full_skel_name ()); +} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd.cpp index fc13b3c768c..bcc4a2200da 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd.cpp @@ -18,20 +18,20 @@ // // ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be_valuetype.h" +#include "be_valuetype_fwd.h" +#include "be_extern.h" +#include "be_helper.h" #include "be_visitor_valuetype_fwd.h" +#include "be_visitor_context.h" -// include all the individual files - -// Not implemented yet. #include "be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp" #include "be_visitor_valuetype_fwd/valuetype_fwd_ci.cpp" #include "be_visitor_valuetype_fwd/cdr_op_ch.cpp" #include "be_visitor_valuetype_fwd/cdr_op_ci.cpp" -ACE_RCSID(be, be_visitor_valuetype_fwd, "$Id$") +ACE_RCSID (be, + be_visitor_valuetype_fwd, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ch.cpp index 31ebdf15ef8..778efd94f32 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ch.cpp @@ -21,14 +21,9 @@ // // ================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype_fwd.h" - -ACE_RCSID(be_visitor_valuetype_fwd, valuetype_fwd_cdr_op_ch, "$Id$") - +ACE_RCSID (be_visitor_valuetype_fwd, + cdr_op_ch, + "$Id$") be_visitor_valuetype_fwd_cdr_op_ch::be_visitor_valuetype_fwd_cdr_op_ch ( be_visitor_context *ctx @@ -64,20 +59,12 @@ be_visitor_valuetype_fwd_cdr_op_ch::visit_valuetype_fwd ( return 0; } - // Generate helper functions declaration. - if (bfd->gen_helper_header () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_cdr_op_ch::" - "visit_valuetype - " - "codegen for helper functions failed\n"), -1); - } - TAO_OutStream *os = this->ctx_->stream (); // generate the CDR << and >> operator declarations (prototypes) - //@@ Boris: Can I move this to be_valuetype? (as with _var, _out, etc?) + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; *os << be_global->stub_export_macro () << " CORBA::Boolean operator<< (TAO_OutputCDR &, const " @@ -88,6 +75,7 @@ be_visitor_valuetype_fwd_cdr_op_ch::visit_valuetype_fwd ( << node->full_name () << " *&);" << be_nl; node->cli_hdr_cdr_op_gen (I_TRUE); + bfd->cli_hdr_cdr_op_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ci.cpp index 436fa441618..2a237f3d5a6 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/cdr_op_ci.cpp @@ -20,27 +20,25 @@ // // ================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype_fwd.h" - -ACE_RCSID(be_visitor_valuetype_fwd, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_valuetype_fwd, + cdr_op_ci, + "$Id$") // **************************************************************** // Interface visitor for generating CDR operator declarations in the // client header // **************************************************************** -be_visitor_valuetype_fwd_cdr_op_ci:: -be_visitor_valuetype_fwd_cdr_op_ci (be_visitor_context *ctx) +be_visitor_valuetype_fwd_cdr_op_ci::be_visitor_valuetype_fwd_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -be_visitor_valuetype_fwd_cdr_op_ci:: -~be_visitor_valuetype_fwd_cdr_op_ci (void) +be_visitor_valuetype_fwd_cdr_op_ci::~be_visitor_valuetype_fwd_cdr_op_ci ( + void + ) { } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp index 01a7497e552..8126f1674ee 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp @@ -20,14 +20,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype_fwd.h" - -ACE_RCSID(be_visitor_valuetype_fwd, valuetype_fwd_ch, "$Id$") - +ACE_RCSID (be_visitor_valuetype_fwd, + valuetype_fwd_ch, + "$Id$") be_visitor_valuetype_fwd_ch::be_visitor_valuetype_fwd_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) @@ -104,7 +99,6 @@ be_visitor_valuetype_fwd_ch::visit_valuetype_fwd (be_valuetype_fwd *node) os->gen_endif (); node->cli_hdr_gen (I_TRUE); - bfd->cli_hdr_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ci.cpp index ba6aa3972f0..b24a18a32b2 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ci.cpp @@ -19,13 +19,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_valuetype_fwd.h" - -ACE_RCSID(be_visitor_valuetype_fwd, valuetype_fwd_ci, "$Id$") +ACE_RCSID (be_visitor_valuetype_fwd, + valuetype_fwd_ci, + "$Id$") be_visitor_valuetype_fwd_ci::be_visitor_valuetype_fwd_ci ( be_visitor_context *ctx |