diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-15 19:18:27 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-15 19:18:27 +0000 |
commit | 8c3acf83c6ebdb83436580b7ce4d30b9bb067e9d (patch) | |
tree | d2e6d4a4a12a28acc83417dd1e1f99258656a90a /TAO/TAO_IDL/be | |
parent | f0c2268cbafbbb544c3f29529f8f87a56d230287 (diff) | |
download | ATCD-ACE-4_6_22.tar.gz |
This commit was manufactured by cvs2svn to create tag 'ACE-4_6_22'.ACE-4_6_22
Diffstat (limited to 'TAO/TAO_IDL/be')
235 files changed, 0 insertions, 54086 deletions
diff --git a/TAO/TAO_IDL/be/be_args.cpp b/TAO/TAO_IDL/be/be_args.cpp deleted file mode 100644 index ae99845193c..00000000000 --- a/TAO/TAO_IDL/be/be_args.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// $Id$ - -/* - -COPYRIGHT - -Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United -States of America. All Rights Reserved. - -This product is protected by copyright and distributed under the following -license restricting its use. - -The Interface Definition Language Compiler Front End (CFE) is made -available for your use provided that you include this license and copyright -notice on all media and documentation and the software program in which -this product is incorporated in whole or part. You may copy and extend -functionality (but may not remove functionality) of the Interface -Definition Language CFE without charge, but you are not authorized to -license or distribute it to anyone else except as part of a product or -program developed by you or with the express written consent of Sun -Microsystems, Inc. ("Sun"). - -The names of Sun Microsystems, Inc. and any of its subsidiaries or -affiliates may not be used in advertising or publicity pertaining to -distribution of Interface Definition Language CFE as permitted herein. - -This license is effective until terminated by Sun for failure to comply -with this license. Upon termination, you shall destroy or return all code -and documentation for the Interface Definition Language CFE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF -ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS -FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF -DEALING, USAGE OR TRADE PRACTICE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT -ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES -TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT. - -SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH -RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY -INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF. - -IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR -ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL -DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -Use, duplication, or disclosure by the government is subject to -restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in -Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR -52.227-19. - -Sun, Sun Microsystems and the Sun logo are trademarks or registered -trademarks of Sun Microsystems, Inc. - -SunSoft, Inc. -2550 Garcia Avenue -Mountain View, California 94043 - -NOTE: - -SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are -trademarks or registered trademarks of Sun Microsystems, Inc. - - */ - -// be_args.cc - Collect command line arguments for the BE - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_args, "$Id$") - -/* - * Prepare an argument for a BE - * - * Since this is the dummy BE, it doesn't do anything with the passed string - */ -void -BE_prep_arg(char *s, idl_bool) -{ - const char arg_macro[]="export_macro="; - const char arg_include[]="export_include="; - - char* last = 0; - for (char* arg = ACE_OS::strtok_r (s, ",", &last); - arg != 0; - arg = ACE_OS::strtok_r (0, ",", &last)) - { - if (ACE_OS::strstr (arg, arg_macro) == arg) - { - char* val = arg + sizeof (arg_macro) - 1; - idl_global->export_macro (val); - } - else if (ACE_OS::strstr (arg, arg_include) == arg) - { - char* val = arg + sizeof (arg_include) - 1; - idl_global->export_include (val); - } - else - { - cerr << idl_global->prog_name () - << ": invalid or unknown argument <" - << arg - << "> to back end\n"; - } - } -} diff --git a/TAO/TAO_IDL/be/be_argument.cpp b/TAO/TAO_IDL/be/be_argument.cpp deleted file mode 100644 index f6ae7a8f713..00000000000 --- a/TAO/TAO_IDL/be/be_argument.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_argument.cpp -// -// = DESCRIPTION -// Extension of class AST_Argument that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_argument, "$Id$") - -/* - * BE_Argument - */ - -be_argument::be_argument (void) -{ -} - -be_argument::be_argument (AST_Argument::Direction d, AST_Type *ft, - UTL_ScopedName *n, UTL_StrList *p) - : AST_Argument (d, ft, n, p), - AST_Field (AST_Decl::NT_argument, ft, n, p), - AST_Decl (AST_Decl::NT_argument, n, p) -{ -} - - -int -be_argument::accept (be_visitor *visitor) -{ - return visitor->visit_argument (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_argument, AST_Argument, be_decl) -IMPL_NARROW_FROM_DECL (be_argument) diff --git a/TAO/TAO_IDL/be/be_array.cpp b/TAO/TAO_IDL/be/be_array.cpp deleted file mode 100644 index 34c77c9e340..00000000000 --- a/TAO/TAO_IDL/be/be_array.cpp +++ /dev/null @@ -1,357 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_array.cpp -// -// = DESCRIPTION -// Extension of class AST_Array that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_array, "$Id$") - -/* - * BE_Array - */ -be_array::be_array (void) - : tao_name_ (0) -{ -} - -be_array::be_array (UTL_ScopedName *n, unsigned long ndims, UTL_ExprList *dims) - : AST_Array (n, ndims, dims), - AST_Decl (AST_Decl::NT_array, n, NULL), - tao_name_ (0) -{ -} - -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 == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - 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, "_%04.4x", ((int)expr->ev ()->u.ulval)); - ACE_OS::strcat (this->tao_name_, buf); - } - return this->tao_name_; -} - -int -be_array::create_name (void) -{ - char namebuf [NAMEBUFSIZE]; - unsigned long i; - UTL_ScopedName *n = NULL; - be_decl *scope; // scope in which we are defined - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); // reset the buffer - // retrieve the base type - // the name always starts this way - - be_type *bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "create_name - " - "bad base type\n"), - 0); - } - - ACE_OS::sprintf (namebuf, "_tao_array_%s", bt->local_name ()->get_string ()); - // now append dimensions - for (i = 0; i < this->n_dims (); i++) - { - AST_Expression *expr = this->dims ()[i]; // retrieve the ith - - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "create_name - " - "bad array dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - ACE_OS::sprintf (namebuf, "%s_%d", namebuf, ((int)expr->ev ()->u.ulval)); - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "create_name - " - "bad dimension value\n"), - -1); - } - } - - // 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 () ; - - // add our local name as the last component - n->nconc (new UTL_ScopedName (new Identifier (ACE_OS::strdup - (namebuf), 1, - 0, I_FALSE), - NULL)); - // 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. - return -1; - } - return 0; -} - -// Code generation - -int -be_array::gen_dimensions (TAO_OutStream *os, unsigned short slice) -{ - unsigned long i; // loop index - - // print our dimensions - for (i = (slice?1:0); i < this->n_dims (); i++) - { - AST_Expression *expr = this->dims ()[i]; // retrieve the ith - - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "gen_dimensions - " - "bad array dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - *os << "[" << ((int)expr->ev ()->u.ulval) << "]"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "gen_dimensions - " - "bad dimension value\n"), - -1); - } - } - return 0; -} - -int -be_array::gen_typecode (void) -{ - TAO_OutStream *os; // output stream - - os = tao_cg->client_stubs (); - os->indent (); // start from whatever indentation level we were at - - *os << "CORBA::tk_array, // typecode kind" << be_nl; - *os << this->tc_encap_len () << ", // encapsulation length" << be_idt << "\n"; - // now emit the encapsulation - if (this->gen_encapsulation () == -1) - { - } - // *os << (this->dims () [0]) << "," << be_nl; - return 0; -} - -// generate encapsulation -// An encapsulation for ourselves will be necessary when we are part of some -// other IDL type and a typecode for that other type is being generated. This -// will comprise our typecode kind. IDL types with parameters will additionally -// have the encapsulation length and the entire typecode description - -int -be_array::gen_encapsulation (void) -{ - TAO_OutStream *os; // output stream - be_type *bt; // base type - unsigned long i; - - os = tao_cg->client_stubs (); - os->indent (); // start from the current indentation level - - // retrieve the base type - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::gen_encapsulation - " - "bad base type\n"), - -1); - } - - for (i=0; i < (this->n_dims () - 1); i++) - { - unsigned long rem_encap_len; - - *os << "TAO_ENCAP_BYTE_ORDER, // byte order" << be_nl; - *os << "CORBA::tk_array, // typecode kind" << be_nl; - rem_encap_len - = (this->n_dims () - (i+1))*(4+4) - + (this->n_dims () - (i+2))*(4+4) - + bt->tc_size (); - *os << rem_encap_len << ", // encapsulation length" << be_idt_nl; - } - *os << "TAO_ENCAP_BYTE_ORDER, // byte order\n"; - if (bt->gen_typecode () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::gen_encapsulation - " - "base type tyepcode gen failed\n"), - -1); - } - os->indent (); - for (i = (this->n_dims ()-1); i > 0; i--) - { - *os << this->dims ()[i] << "," << be_uidt_nl; - } - *os << this->dims ()[0] << be_uidt << ",\n"; - return 0; -} - -// compute typecode size -long -be_array::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the - // actual encapsulation - return 4 + 4 + this->tc_encap_len (); -} - -long -be_array::tc_encap_len (void) -{ - // Suppose "N" is the number of dimensions, then for a N dimensional array, - // we will have N encapsulations. The innermost encapsulation will hold the - // typecode of the real base type. - // Thus, we will have N byte order flags and dimensions, and N-1 tk_array - // enumerations, encapsulation lengths, and dimensions. - - if (this->encap_len_ == -1) // not computed yet - { - be_type *bt; // base type - - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_ERROR ((LM_ERROR, - "be_array::tc_encap_len - bad base type\n")); - return 0; - } - this->encap_len_ = - this->n_dims () * (4+4) // N byte order flags and dims - + (this->n_dims ()-1)* (4+4); // N-1 of Enum and encap lengths - // to this you add the typecode size of the underlying type - this->encap_len_ += bt->tc_size (); - } - return this->encap_len_; -} - -// 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) -{ - return visitor->visit_array (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_array, AST_Array, be_type) -IMPL_NARROW_FROM_DECL (be_array) diff --git a/TAO/TAO_IDL/be/be_attribute.cpp b/TAO/TAO_IDL/be/be_attribute.cpp deleted file mode 100644 index 28c377c9797..00000000000 --- a/TAO/TAO_IDL/be/be_attribute.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_attribute.cpp -// -// = DESCRIPTION -// Extension of class AST_Attribute that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_attribute, "$Id$") - -/* - * BE_Attribute - */ -be_attribute::be_attribute (void) -{ -} - -be_attribute::be_attribute (idl_bool ro, AST_Type *ft, UTL_ScopedName *n, - UTL_StrList *p) - : AST_Attribute (ro, ft, n, p), - AST_Field (AST_Decl::NT_attr, ft, n, p), - AST_Decl (AST_Decl::NT_attr, n, p) -{ -} - -int -be_attribute::accept (be_visitor *visitor) -{ - return visitor->visit_attribute (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_attribute, AST_Attribute, be_decl) -IMPL_NARROW_FROM_DECL (be_attribute) diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp deleted file mode 100644 index 0403cdf56f9..00000000000 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ /dev/null @@ -1,1011 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_codegen.cpp -// -// = DESCRIPTION -// Code generation -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_codegen, "$Id$") - -TAO_CodeGen *tao_cg = 0; - -/* BE global Data */ -TAO_CodeGen::TAO_CodeGen (void) - : client_header_ (0), - client_stubs_ (0), - client_inline_ (0), - server_header_ (0), - implementation_header_(0), - implementation_skeleton_(0), - server_template_header_ (0), - server_skeletons_ (0), - server_template_skeletons_ (0), - server_inline_ (0), - server_template_inline_ (0), - gperf_input_stream_ (0), - gperf_input_filename_ (0), - curr_os_ (0), - visitor_factory_ (0), - strategy_ (TAO_PERFECT_HASH) -{ -} - -// destructor -TAO_CodeGen::~TAO_CodeGen (void) -{ - delete this->client_header_; - delete this->server_header_; - delete this->implementation_header_; - delete this->implementation_skeleton_; - delete this->server_template_header_; - delete this->client_stubs_; - delete this->server_skeletons_; - delete this->server_template_skeletons_; - delete this->client_inline_; - delete this->server_inline_; - delete this->server_template_inline_; - this->curr_os_ = 0; - // delete this->visitor_factory_; -} - -// visitor factory method -be_visitor * -TAO_CodeGen::make_visitor (be_visitor_context *ctx) -{ - - if (!this->visitor_factory_) - { - ACE_ERROR_RETURN ((LM_ERROR, - "TAO_CodeGen::make_visitor - " - "No Visitor Factory\n\n"), - 0); - } - - return this->visitor_factory_->make_visitor (ctx); -} - -// change the string to all upcase -const char * -TAO_CodeGen::upcase (const char *str) -{ - static char upcase_str [NAMEBUFSIZE]; - - ACE_OS::memset (upcase_str, '\0', NAMEBUFSIZE); - // convert letters in str to upcase - for (unsigned int i=0; i < ACE_OS::strlen (str); i++) - { - if (isalpha (str [i])) - { - upcase_str[i] = toupper (str [i]); - } - else - { - // copy it as it is - upcase_str[i] = str[i]; - } - } - return upcase_str; -} - -// set the client header stream -int -TAO_CodeGen::start_client_header (const char *fname) -{ - // @@ We are making use of "included_idl_files" that is in the - // idl_global. We need to make sure the validity of those files. - idl_global->validate_included_idl_files (); - - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->client_header_ = factory->make_outstream (); - if (!this->client_header_) - { - return -1; - } - - if (this->client_header_->open (fname, TAO_OutStream::TAO_CLI_HDR) == -1) - return -1; - else - { - // now generate the #if !defined clause - static char macro_name [NAMEBUFSIZE]; - - ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); - const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) - { - // File seems to have no extension, so let us take the name - // as it is. - if (fname == 0) - // bad file name - return -1; - else - suffix = fname; - } - - ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - // convert letters in fname to upcase - for (int i=0; i < (suffix - fname); i++) - { - if (isalpha (fname [i])) - macro_name[i+9] = toupper (fname [i]); - else if (isdigit (fname [i])) - macro_name[i+9] = fname[i]; - else - macro_name[i+9] = '_'; - } - - ACE_OS::strcat (macro_name, "_H_"); - - // generate the #ifndef ... #define statements - this->client_header_->print ("#ifndef %s\n", macro_name); - this->client_header_->print ("#define %s\n\n", macro_name); - - // Including standard files - - // switch between changing or non-changing standard include files - // include files, so that #include statements can be - // generated with ""s or <>s respectively, for the standard include - // files (e.g. tao/corba.h) - *this->client_header_ << "#include "; - - if (idl_global->changing_standard_include_files () == 1) - *this->client_header_ << "\""; - else - *this->client_header_ << "<"; - - *this->client_header_ << "tao/corba.h"; - - if (idl_global->changing_standard_include_files () == 1) - *this->client_header_ << "\"\n"; - else - *this->client_header_ << ">\n"; - - // Other include files - - if (idl_global->export_include () != 0) - { - *this->client_header_ << "#include \"" - << idl_global->export_include () - << "\"\n"; - } - - // We must include all the skeleton headers corresponding to - // IDL files included by the current IDL file. - // We will use the included IDL file names as they appeared - // in the original main IDL file, not the one which went - // thru CC preprocessor. - for (size_t j = 0; - j < idl_global->n_included_idl_files (); - j++) - { - char* idl_name = - idl_global->included_idl_files ()[j]; - - // Make a String out of it. - String idl_name_str = idl_name; - - // Make sure this file was actually got included, not - // ignored by some #if defined compiler directive. - - - // Get the clnt header from the IDL file name. - const char* client_hdr = - IDL_GlobalData::be_get_client_hdr (&idl_name_str, 1); - - // Sanity check and then print. - if (client_hdr != 0) - { - this->client_header_->print ("#include \"%s\"\n", - client_hdr); - } - else - { - ACE_ERROR ((LM_WARNING, - "WARNING, invalid file '%s' included\n", - idl_name)); - } - } - *this->client_header_ << "\n"; - - // generate the TAO_EXPORT_MACRO macro - *this->client_header_ << "#if defined (TAO_EXPORT_MACRO)\n"; - *this->client_header_ << "#undef TAO_EXPORT_MACRO\n"; - *this->client_header_ << "#endif\n"; - *this->client_header_ << "#define TAO_EXPORT_MACRO " - << idl_global->export_macro () - << be_nl; - - *this->client_header_ << "#if defined(_MSC_VER)\n" - << "#pragma warning(disable:4250)\n" - << "#endif /* _MSC_VER */\n\n"; - - return 0; - } -} - -// get the client header stream -TAO_OutStream * -TAO_CodeGen::client_header (void) -{ - return this->client_header_; -} - -// set the client stub stream -int -TAO_CodeGen::start_client_stubs (const char *fname) -{ - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->client_stubs_ = factory->make_outstream (); - if (!this->client_stubs_) - { - return -1; - } - - if (this->client_stubs_->open (fname, TAO_OutStream::TAO_CLI_IMPL) == -1) - { - return -1; - } - - // generate the include statement for the client header. We just - // need to put only the base names. Path info is not required. - *this->client_stubs_ << "#include \"" << - idl_global->be_get_client_hdr_fname (1) << "\"\n\n"; - - *this->client_stubs_ << "#include \"" << - idl_global->be_get_server_hdr_fname (1) << "\"\n\n"; - - // generate the code that includes the inline file if not included in the - // header file - *this->client_stubs_ << "#if !defined (__ACE_INLINE__)\n"; - *this->client_stubs_ << "#include \"" << - idl_global->be_get_client_inline_fname (1) << "\"\n"; - *this->client_stubs_ << "#endif /* !defined INLINE */\n\n"; - return 0; -} - -// get the client stubs stream -TAO_OutStream * -TAO_CodeGen::client_stubs (void) -{ - return this->client_stubs_; -} - -// set the client inline stream -int -TAO_CodeGen::start_client_inline (const char *fname) -{ - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->client_inline_ = factory->make_outstream (); - if (!this->client_inline_) - { - return -1; - } - - return this->client_inline_->open (fname, TAO_OutStream::TAO_CLI_INL); -} - -// get the client inline stream -TAO_OutStream * -TAO_CodeGen::client_inline (void) -{ - return this->client_inline_; -} - -// set the server header stream. -int -TAO_CodeGen::start_server_header (const char *fname) -{ - // @@ We are making use of "included_idl_files" that is in the - // idl_global. We need to make sure the validity of those files. - idl_global->validate_included_idl_files (); - - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->server_header_ = factory->make_outstream (); - if (!this->server_header_) - { - return -1; - } - - if (this->server_header_->open (fname, TAO_OutStream::TAO_SVR_HDR) == -1) - return -1; - else - { - // now generate the #if !defined clause - static char macro_name [NAMEBUFSIZE]; - - ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); - const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) - { - // File seems to have no extension, so let us take the name - // as it is. - if (fname == 0) - // bad file name - return -1; - else - suffix = fname; - } - - ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - // convert letters in fname to upcase - for (int i=0; i < (suffix - fname); i++) - if (isalpha (fname [i])) - macro_name[i+9] = toupper (fname [i]); - else if (isdigit (fname [i])) - macro_name[i+9] = fname[i]; - else - macro_name[i+9] = '_'; - - ACE_OS::strcat (macro_name, "_H_"); - - this->server_header_->print ("#ifndef %s\n", macro_name); - this->server_header_->print ("#define %s\n\n", macro_name); - - // We must include all the skeleton headers corresponding to - // IDL files included by the current IDL file. - // We will use the included IDL file names as they appeared - // in the original main IDL file, not the one which went - // thru CC preprocessor. - for (size_t j = 0; - j < idl_global->n_included_idl_files (); - ++j) - { - char* idl_name = - idl_global->included_idl_files ()[j]; - - // String'ifying the name. - String idl_name_str (idl_name); - - const char* server_hdr = - IDL_GlobalData::be_get_server_hdr (&idl_name_str, 1); - - this->server_header_->print ("#include \"%s\"\n", - server_hdr); - } - // the server header should include the client header - *this->server_header_ << "#include \"" << - idl_global->be_get_client_hdr_fname (1) << "\"\n\n"; - - *this->server_header_ << "#if defined(_MSC_VER)\n" - << "#pragma warning(disable:4250)\n" - << "#endif /* _MSC_VER */\n\n"; - - return 0; - } -} - -// get the server header stream -TAO_OutStream * -TAO_CodeGen::server_header (void) -{ - return this->server_header_; -} - -// set the server header stream -int -TAO_CodeGen::start_server_template_header (const char *fname) -{ - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->server_template_header_ = factory->make_outstream (); - if (!this->server_template_header_) - return -1; - - if (this->server_template_header_->open (fname, - TAO_OutStream::TAO_SVR_TMPL_HDR) - == -1) - return -1; - else - { - // now generate the #if !defined clause - static char macro_name [NAMEBUFSIZE]; - - ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); - const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) - { - // File seems to have no extension, so let us take the name - // as it is. - if (fname == 0) - // bad file name - return -1; - else - suffix = fname; - } - ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - // convert letters in fname to upcase - for (int i=0; i < (suffix - fname); i++) - if (isalpha (fname [i])) - macro_name[i+9] = toupper (fname [i]); - else if (isdigit (fname [i])) - macro_name[i+9] = fname[i]; - else - macro_name[i+9] = '_'; - - ACE_OS::strcat (macro_name, "_H_"); - - this->server_template_header_->print ("#ifndef %s\n", macro_name); - this->server_template_header_->print ("#define %s\n\n", macro_name); - - *this->server_template_header_ << "#if defined(_MSC_VER)\n" - << "#pragma warning(disable:4250)\n" - << "#endif /* _MSC_VER */\n\n"; - - return 0; - } -} - -// get the server header stream -TAO_OutStream * -TAO_CodeGen::server_template_header (void) -{ - return this->server_template_header_; -} - -// set the server skeletons stream -int -TAO_CodeGen::start_server_skeletons (const char *fname) -{ - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->server_skeletons_ = factory->make_outstream (); - if (!this->server_skeletons_) - { - return -1; - } - - if (this->server_skeletons_->open (fname, TAO_OutStream::TAO_SVR_IMPL) == -1) - { - return -1; - } - - // generate the include statement for the server header - *this->server_skeletons_ << "#include \"" << - idl_global->be_get_server_hdr_fname (1) << "\"\n\n"; - - // generate the code that includes the inline file if not included in the - // header file - *this->server_skeletons_ << "#if !defined (__ACE_INLINE__)\n"; - *this->server_skeletons_ << "#include \"" << - idl_global->be_get_server_inline_fname (1) << "\"\n"; - *this->server_skeletons_ << "#endif /* !defined INLINE */\n\n"; - return 0; -} - -// Get the server skeletons stream. -TAO_OutStream * -TAO_CodeGen::server_skeletons (void) -{ - return this->server_skeletons_; -} - -// Start the server template skeleton stream. -int -TAO_CodeGen::start_server_template_skeletons (const char *fname) -{ - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->server_template_skeletons_ = factory->make_outstream (); - if (!this->server_template_skeletons_) - { - return -1; - } - - if (this->server_template_skeletons_->open (fname, - TAO_OutStream::TAO_SVR_TMPL_IMPL) - == -1) - return -1; - else - { - // now generate the #if !defined clause - static char macro_name [NAMEBUFSIZE]; - - ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); - const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) - { - // File seems to have no extension, so let us take the name - // as it is. - if (fname == 0) - // bad file name - return -1; - else - suffix = fname; - } - - ACE_OS::sprintf (macro_name, "_TAO_IDL_"); - // convert letters in fname to upcase - for (int i=0; i < (suffix - fname); i++) - if (isalpha (fname [i])) - macro_name[i+9] = toupper (fname [i]); - else if (isdigit (fname [i])) - macro_name[i+9] = fname[i]; - else - macro_name[i+9] = '_'; - - ACE_OS::strcat (macro_name, "_CPP_"); - - this->server_template_skeletons_->print ("#ifndef %s\n", macro_name); - this->server_template_skeletons_->print ("#define %s\n\n", macro_name); - - *this->server_template_skeletons_ << "#if defined(_MSC_VER)\n" - << "#pragma warning(disable:4250)\n" - << "#endif /* _MSC_VER */\n\n"; - - // generate the include statement for the server header - *this->server_template_skeletons_ << "#include \"" << - idl_global->be_get_server_template_hdr_fname (1) << "\"\n\n"; - - // generate the code that includes the inline file if not included in the - // header file - *this->server_template_skeletons_ << "#if !defined (__ACE_INLINE__)\n"; - *this->server_template_skeletons_ << "#include \"" << - idl_global->be_get_server_template_inline_fname (1) << "\"\n"; - *this->server_template_skeletons_ << "#endif /* !defined INLINE */\n\n"; - return 0; - - } -} - -// get the server template skeletons stream -TAO_OutStream * -TAO_CodeGen::server_template_skeletons (void) -{ - return this->server_template_skeletons_; -} - -// set the server inline stream -int -TAO_CodeGen::start_server_inline (const char *fname) -{ - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->server_inline_ = factory->make_outstream (); - if (!this->server_inline_) - { - return -1; - } - - return this->server_inline_->open (fname, TAO_OutStream::TAO_SVR_INL); -} - -// get the server inline stream -TAO_OutStream * -TAO_CodeGen::server_inline (void) -{ - return this->server_inline_; -} - -// set the server template inline stream -int -TAO_CodeGen::start_server_template_inline (const char *fname) -{ - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->server_template_inline_ = factory->make_outstream (); - if (!this->server_template_inline_) - { - return -1; - } - - return this->server_template_inline_->open (fname, TAO_OutStream::TAO_SVR_INL); -} - -// get the server template inline stream -TAO_OutStream * -TAO_CodeGen::server_template_inline (void) -{ - return this->server_template_inline_; -} - - -// set the server header stream. -int -TAO_CodeGen::start_implementation_header (const char *fname) -{ - // @@ We are making use of "included_idl_files" that is in the - // idl_global. We need to make sure the validity of those files. - - - idl_global->validate_included_idl_files (); - - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->implementation_header_ = factory->make_outstream (); - if (!this->implementation_header_) - { - return -1; - } - - if (this->implementation_header_->open (fname, TAO_OutStream::TAO_IMPL_HDR) == -1) - return -1; - else - { - // now generate the #ifndef clause - static char macro_name [NAMEBUFSIZE]; - - ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); - const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) - { - // File seems to have no extension, so let us take the name - // as it is. - if (fname == 0) - // bad file name - return -1; - else - suffix = fname; - } - - for (int i=0; i < (suffix - fname); i++) - if (isalpha (fname [i])) - macro_name[i] = toupper (fname [i]); - else if (isdigit (fname [i])) - macro_name[i] = fname[i]; - else - macro_name[i] = '_'; - - ACE_OS::strcat (macro_name, "_H_"); - - this->implementation_header_->print ("#ifndef %s\n", macro_name); - this->implementation_header_->print ("#define %s\n\n", macro_name); - - // We must include all the skeleton headers corresponding to - // IDL files included by the current IDL file. - // We will use the included IDL file names as they appeared - // in the original main IDL file, not the one which went - // thru CC preprocessor. - for (size_t j = 0; - j < idl_global->n_included_idl_files (); - ++j) - { - char* idl_name = - idl_global->included_idl_files ()[j]; - - // Stringifying the name. - String idl_name_str (idl_name); - - const char* implementation_hdr = - IDL_GlobalData::be_get_implementation_hdr (&idl_name_str, 1); - - this->implementation_header_->print ("#include \"%s\"\n", - implementation_hdr); - } - - *this->implementation_header_ << "#if !defined (ACE_LACKS_PRAGMA_ONCE)\n" - << "#pragma once\n" - << "#endif /* ACE_LACKS_PRAGMA_ONCE */\n\n"; - - const char* server_hdr = - IDL_GlobalData::be_get_server_hdr_fname (1); - - *this->implementation_header_<< "#include \""<<server_hdr<<"\"\n\n"; - - return 0; - } -} - - -// get the implementation header stream -TAO_OutStream * -TAO_CodeGen::implementation_header (void) -{ - return this->implementation_header_; -} - - -// set the implementation skeleton stream. -int -TAO_CodeGen::start_implementation_skeleton (const char *fname) -{ - // @@ We are making use of "included_idl_files" that is in the - // idl_global. We need to make sure the validity of those files. - idl_global->validate_included_idl_files (); - - // retrieve the singleton instance to the outstream factory - TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); - - // retrieve a specialized instance - this->implementation_skeleton_ = factory->make_outstream (); - if (!this->implementation_skeleton_) - { - return -1; - } - - if (this->implementation_skeleton_->open (fname, TAO_OutStream::TAO_IMPL_SKEL) == -1) - return -1; - else - { - - - - static char macro_name [NAMEBUFSIZE]; - - ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); - const char *suffix = ACE_OS::strrchr (fname, '.'); - - - if (suffix == 0) - { - // File seems to have no extension, so let us take the name - // as it is. - if (fname == 0) - // bad file name - return -1; - else - suffix = fname; - } - - // convert letters in fname to upcase - for (int i=0; i < (suffix - fname); i++) - if (isalpha (fname [i])) - macro_name[i] = fname [i]; - else - macro_name[i] = fname[i]; - - - const char* impl_hdr = - IDL_GlobalData::be_get_implementation_hdr_fname (); - - this->implementation_skeleton_->print ("#include \"%s\"\n\n", impl_hdr); - - return 0; - } -} - - -// get the implementation header stream -TAO_OutStream * -TAO_CodeGen::implementation_skeleton (void) -{ - return this->implementation_skeleton_; -} - -// put the last #endif in the client and server headers -int -TAO_CodeGen::end_client_header (void) -{ - // generate the <<= and >>= operators here - - // insert the code to include the inline file - *this->client_header_ << "\n#if defined (__ACE_INLINE__)\n"; - *this->client_header_ << "#include \"" << - idl_global->be_get_client_inline_fname (1) << "\"\n"; - *this->client_header_ << "#endif /* defined INLINE */\n\n"; - - *this->client_header_ << "#if defined(_MSC_VER)\n" - << "#pragma warning(default:4250)\n" - << "#endif /* _MSC_VER */\n"; - - // code to put the last #endif - *this->client_header_ << "\n#endif /* ifndef */\n"; - return 0; -} - -int -TAO_CodeGen::end_server_header (void) -{ - // insert the template header - *this->server_header_ << "#include \"" << - idl_global->be_get_server_template_hdr_fname (1) << "\"\n"; - - // insert the code to include the inline file - *this->server_header_ << "\n#if defined (__ACE_INLINE__)\n"; - *this->server_header_ << "#include \"" << - idl_global->be_get_server_inline_fname (1) << "\"\n"; - *this->server_header_ << "#endif /* defined INLINE */\n\n"; - - *this->server_header_ << "#if defined(_MSC_VER)\n" - << "#pragma warning(default:4250)\n" - << "#endif /* _MSC_VER */\n"; - - // code to put the last #endif - *this->server_header_ << "\n#endif /* ifndef */\n"; - return 0; -} - -int -TAO_CodeGen::end_implementation_header (const char *fname) -{ - static char macro_name [NAMEBUFSIZE]; - - ACE_OS::memset (macro_name, '\0', NAMEBUFSIZE); - const char *suffix = ACE_OS::strrchr (fname, '.'); - if (suffix == 0) - { - // File seems to have no extension, so let us take the name - // as it is. - if (fname == 0) - // bad file name - return -1; - else - suffix = fname; - } - - - // convert letters in fname to upcase - for (int i=0; i < (suffix - fname); i++) - if (isalpha (fname [i])) - macro_name[i] = toupper (fname [i]); - else if (isdigit (fname [i])) - macro_name[i] = fname[i]; - else - macro_name[i] = '_'; - - ACE_OS::strcat (macro_name, "_H_"); - - - // code to put the last #endif - //*this->implementation_header_ << "\n#endif /* %s */\n"; - this->implementation_header_->print ("\n#endif /* %s */\n", macro_name); - return 0; -} - -int -TAO_CodeGen::end_server_template_header (void) -{ - // insert the code to include the inline file - *this->server_template_header_ << "\n#if defined (__ACE_INLINE__)\n"; - *this->server_template_header_ << "#include \"" << - idl_global->be_get_server_template_inline_fname (1) << "\"\n"; - *this->server_template_header_ << "#endif /* defined INLINE */\n\n"; - - // insert the code to include the template source file - *this->server_template_header_ - << "\n#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)\n"; - *this->server_template_header_ << "#include \"" << - idl_global->be_get_server_template_skeleton_fname (1) << "\"\n"; - *this->server_template_header_ << "#endif /* defined REQUIRED SOURCE */\n\n"; - - // insert the code to include the template pragma - *this->server_template_header_ - << "\n#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)\n"; - *this->server_template_header_ << "#pragma implementation (\"" << - idl_global->be_get_server_template_skeleton_fname (1) << "\")\n"; - *this->server_template_header_ << "#endif /* defined REQUIRED PRAGMA */\n\n"; - - *this->server_template_header_ << "#if defined(_MSC_VER)\n" - << "#pragma warning(default:4250)\n" - << "#endif /* _MSC_VER */\n"; - - // code to put the last #endif - *this->server_template_header_ << "\n#endif /* ifndef */\n"; - return 0; -} - -int -TAO_CodeGen::end_server_template_skeletons (void) -{ - // code to put the last #endif - *this->server_template_skeletons_ << "\n#endif /* ifndef */\n"; - return 0; -} - -// We use the following helper functions to pass information. This class is the -// best place to pass such information rather than passing information through -// global variables spread everywhere. This class is a singleton and is -// effectively a global. - -void -TAO_CodeGen::gperf_input_stream (TAO_OutStream *os) -{ -#if !defined (linux) - // This causes a seg fault on Linux RH 5.1. Let it leak . . . - delete this->gperf_input_stream_; -#endif /* ! linux */ - this->gperf_input_stream_ = os; -} - -TAO_OutStream * -TAO_CodeGen::gperf_input_stream (void) -{ - return this->gperf_input_stream_; -} - -void -TAO_CodeGen::gperf_input_filename (char *filename) -{ - delete[] this->gperf_input_filename_; - this->gperf_input_filename_ = ACE::strnew (filename); -} - -char * -TAO_CodeGen::gperf_input_filename (void) -{ - return this->gperf_input_filename_; -} - -void -TAO_CodeGen::outstream (TAO_OutStream *os) -{ - this->curr_os_ = os; -} - -TAO_OutStream * -TAO_CodeGen::outstream (void) -{ - return this->curr_os_; -} - -void -TAO_CodeGen::node (be_decl *n) -{ - this->node_ = n; -} - -be_decl * -TAO_CodeGen::node (void) -{ - return this->node_; -} - -void -TAO_CodeGen::config_visitor_factory (void) -{ - // What strategy are we interested in? Interpreted or Compiled Marshaling? - // This is the top level distinction we make and strategize our visitor - // factory object accordingly - if (idl_global->compiled_marshaling ()) - this->visitor_factory_ = TAO_COMPILED_VISITOR_FACTORY::instance (); - else - this->visitor_factory_ = TAO_INTERPRETIVE_VISITOR_FACTORY::instance (); -} - -void -TAO_CodeGen::lookup_strategy (LOOKUP_STRATEGY s) -{ - this->strategy_ = s; -} - -TAO_CodeGen::LOOKUP_STRATEGY -TAO_CodeGen::lookup_strategy (void) const -{ - return this->strategy_; -} - -#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>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Singleton<TAO_CodeGen, ACE_SYNCH_RECURSIVE_MUTEX> -#pragma instantiate ACE_Singleton<TAO_OutStream_Factory, ACE_SYNCH_RECURSIVE_MUTEX> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/TAO_IDL/be/be_constant.cpp b/TAO/TAO_IDL/be/be_constant.cpp deleted file mode 100644 index 9a184a592b0..00000000000 --- a/TAO/TAO_IDL/be/be_constant.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_constant.cpp -// -// = DESCRIPTION -// Extension of class AST_Constant that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_constant, "$Id$") - -/* - * BE_Constant - */ -be_constant::be_constant (void) -{ - this->size_type (be_decl::FIXED); -} - -be_constant::be_constant (AST_Expression::ExprType et, - AST_Expression *v, - UTL_ScopedName *n, - UTL_StrList *p) - : AST_Constant (et, v, n, p), - AST_Decl (AST_Decl::NT_const, n, p) -{ - this->size_type (be_decl::FIXED); -} - -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: - case AST_Expression::EV_ulonglong: - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wchar: - case AST_Expression::EV_wstring: - return NULL; - } - return NULL; -} - -int -be_constant::accept (be_visitor *visitor) -{ - return visitor->visit_constant (this); -} - -// 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 deleted file mode 100644 index b11ee3133ff..00000000000 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ /dev/null @@ -1,711 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_decl.cpp -// -// = DESCRIPTION -// Extension of class AST_Decl that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_decl, "$Id$") - -// Default Constructor -be_decl::be_decl (void) - : cli_hdr_gen_ (I_FALSE), - cli_stub_gen_ (I_FALSE), - cli_inline_gen_ (I_FALSE), - srv_hdr_gen_ (I_FALSE), - impl_hdr_gen_ (I_FALSE), - srv_skel_gen_ (I_FALSE), - impl_skel_gen_ (I_FALSE), - srv_inline_gen_ (I_FALSE), - cli_hdr_any_op_gen_ (I_FALSE), - 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), - fullname_ (0), - flatname_ (0), - repoID_ (0), - prefix_ (0), - size_type_ (be_decl::SIZE_UNKNOWN), - encap_len_ (-1) -{ -} - -// Constructor -be_decl::be_decl (AST_Decl::NodeType type, - UTL_ScopedName *n, - UTL_StrList *pragmas) - : AST_Decl (type, n, pragmas), - cli_hdr_gen_ (I_FALSE), - cli_stub_gen_ (I_FALSE), - cli_inline_gen_ (I_FALSE), - srv_hdr_gen_ (I_FALSE), - impl_hdr_gen_ (I_FALSE), - srv_skel_gen_ (I_FALSE), - impl_skel_gen_ (I_FALSE), - srv_inline_gen_ (I_FALSE), - cli_hdr_any_op_gen_ (I_FALSE), - cli_stub_any_op_gen_ (I_FALSE), - cli_hdr_cdr_op_gen_ (I_FALSE), - cli_stub_cdr_op_gen_ (I_FALSE), - fullname_ (0), - flatname_ (0), - repoID_ (0), - prefix_ (0), - size_type_ (be_decl::SIZE_UNKNOWN), - encap_len_ (-1) -{ -} - -//destructor -be_decl::~be_decl (void) -{ -} - -int -be_decl::gen_encapsulation (void) -{ - // do nothing - return 0; -} - -long -be_decl::tc_encap_len (void) -{ - return -1; -} - -// 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); - - // st 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; -} - -// compute stringified fully scoped name -void -be_decl::compute_fullname (void) -{ - if (fullname_) - return; - else - { - long namelen; - UTL_IdListActiveIterator *i; - long first = I_TRUE; - long second = I_FALSE; - - // in the first loop compute the total length - namelen = 0; - i = new UTL_IdListActiveIterator (this->name ()); - while (!(i->is_done ())) - { - if (!first) - namelen += 2; // for "::" - else if (second) - first = second = I_FALSE; - // print the identifier - namelen += ACE_OS::strlen (i->item ()->get_string ()); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - - this->fullname_ = new char [namelen+1]; - this->fullname_[0] = '\0'; - first = I_TRUE; - second = I_FALSE; - i = new UTL_IdListActiveIterator (this->name ()); - while (!(i->is_done ())) - { - if (!first) - ACE_OS::strcat (this->fullname_, "::"); - else if (second) - first = second = I_FALSE; - // print the identifier - ACE_OS::strcat (this->fullname_, i->item ()->get_string ()); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - } - return; -} - -const char* -be_decl::fullname (void) -{ - if (!this->fullname_) - compute_fullname (); - - return this->fullname_; -} - -// compute stringified flattened fully scoped name -void -be_decl::compute_flatname (void) -{ - if (flatname_) - return; - else - { - long namelen; - UTL_IdListActiveIterator *i; - long first = I_TRUE; - long second = I_FALSE; - - // in the first loop compute the total length - namelen = 0; - i = new UTL_IdListActiveIterator (this->name ()); - - while (!(i->is_done ())) - { - if (!first) - namelen += 1; // for "_" - else if (second) - first = second = I_FALSE; - // print the identifier - namelen += ACE_OS::strlen (i->item ()->get_string ()); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - - this->flatname_ = new char [namelen+1]; - this->flatname_[0] = '\0'; - first = I_TRUE; - second = I_FALSE; - i = new UTL_IdListActiveIterator (this->name ()); - while (!(i->is_done ())) - { - if (!first) - ACE_OS::strcat (this->flatname_, "_"); - else if (second) - first = second = I_FALSE; - // print the identifier - ACE_OS::strcat (this->flatname_, i->item ()->get_string ()); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - } - return; -} - - - - -const char* -be_decl::flatname (void) -{ - if (!this->flatname_) - compute_flatname (); - - return this->flatname_; -} - - - - -// compute stringified repository ID -void -be_decl::compute_repoID (void) -{ - if (repoID_) - return; - else - { - long namelen; - UTL_IdListActiveIterator *i; - long first = I_TRUE; - long second = I_FALSE; - - // in the first loop compute the total length - namelen = 8; // for the prefix "IDL:" and suffix ":1.0" - namelen += ACE_OS::strlen (this->prefix ()) + 1; - i = new UTL_IdListActiveIterator (this->name ()); - while (!(i->is_done ())) - { - if (!first) - namelen += 1; // for "/" - else if (second) - first = second = I_FALSE; - // print the identifier - namelen += ACE_OS::strlen (i->item ()->get_string ()); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - - this->repoID_ = new char [namelen+1]; - this->repoID_[0] = '\0'; - ACE_OS::sprintf (this->repoID_, "%s", "IDL:"); - ACE_OS::strcat (this->repoID_, this->prefix ()); - - // Add the "/" only if there is a prefix - if (ACE_OS::strcmp (this->prefix (), "") != 0) - ACE_OS::strcat (this->repoID_, "/"); - - i = new UTL_IdListActiveIterator (this->name ()); - first = I_TRUE; - second = I_FALSE; - while (!(i->is_done ())) - { - if (!first) - ACE_OS::strcat (this->repoID_, "/"); - else if (second) - first = second = I_FALSE; - // print the identifier - ACE_OS::strcat (this->repoID_, i->item ()->get_string ()); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - ACE_OS::strcat (this->repoID_, ":1.0"); - } - return; -} - -const char * -be_decl::repoID (void) -{ - if (!this->repoID_) - compute_repoID (); - - return this->repoID_; -} - -void -be_decl::compute_prefix () -{ - const char* pragma = 0; - if (this->pragmas () != 0) - { - for (UTL_StrlistActiveIterator i (this->pragmas ()); - !i.is_done (); - i.next ()) - { - const char* s = i.item ()->get_string (); - - if (ACE_OS::strncmp (s, "#pragma prefix", 14) == 0) - { - pragma = s; - } - } - } - - if (pragma != 0) - { - // Skip the space and the " also... - const char* tmp = pragma + 16; - const char* end = ACE_OS::strchr (tmp, '"'); - - if (end == 0) - { - idl_global->err ()->syntax_error - (IDL_GlobalData::PS_PragmaPrefixSyntax); - this->prefix_ = ACE::strnew (""); - return; - } - int l = end - tmp; - this->prefix_ = new char[l+1]; - ACE_OS::strncpy (this->prefix_, tmp, end - tmp); - this->prefix_[l] = 0; - return; - } - - // Could not find it in the local scope, try to recurse to the top - // scope... - if (this->defined_in () == 0) - this->prefix_ = ACE::strnew (""); - else - { - be_scope* scope = - be_scope::narrow_from_scope (this->defined_in ()); - if (scope == 0) - this->prefix_ = ACE::strnew (""); - else - this->prefix_ = ACE::strnew (scope->decl()->prefix ()); - } -} - -const char* -be_decl::prefix (void) -{ - if (!this->prefix_) - compute_prefix (); - return this->prefix_; -} - -// converts a string name into an array of 4 byte longs -int -be_decl::tc_name2long (const char *name, ACE_UINT32 *&larr, long &arrlen) -{ - const int bytes_per_word = sizeof(ACE_UINT32); - static ACE_UINT32 buf [NAMEBUFSIZE]; - long slen; - long i; - - slen = ACE_OS::strlen (name) + 1; // 1 for NULL terminating - - // compute the number of bytes necessary to hold the name rounded to - // the next multiple of 4 (i.e., size of long) - arrlen = slen / bytes_per_word + (slen % bytes_per_word ? 1:0); - - ACE_OS::memset (buf, 0, sizeof(buf)); - larr = buf; - ACE_OS::memcpy (buf, name, slen); - for (i = 0; i < arrlen; i++) - larr [i] = ACE_HTONL (larr [i]); - return 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 && d->node_type () != AST_Decl::NT_root) - return I_TRUE; - - return I_FALSE; -} - -// return the length in bytes to hold the repoID inside a typecode. This -// comprises 4 bytes indicating the length of the string followed by the actual -// string represented as longs. -long -be_decl::repoID_encap_len (void) -{ - long slen; - - slen = ACE_OS::strlen (this->repoID ()) + 1; // + 1 for NULL terminating char - // the number of bytes to hold the string must be a multiple of 4 since this - // will be represented as an array of longs - return 4 + 4 * (slen/4 + (slen%4 ? 1:0)); -} - -// return the length in bytes to hold the name inside a typecode. This -// comprises 4 bytes indicating the length of the string followed by the actual -// string represented as longs. -long -be_decl::name_encap_len (void) -{ - long slen; - - slen = ACE_OS::strlen (this->local_name ()->get_string ()) + 1; - - // the number of bytes to hold the string must be a multiple of 4 since this - // will be represented as an array of longs - return 4 + 4 * (slen/4 + (slen%4 ? 1:0)); -} - -// compute the size type of the node in question -int -be_decl::compute_size_type (void) -{ - return 0; -} - -// return the scope created by this node (if one exists, else NULL) -be_scope * -be_decl::scope (void) -{ - be_decl *d = this; - - switch (this->node_type()) { - case AST_Decl::NT_interface_fwd: - /* - * Resolve forward declared interface by looking at full_definition() - * field and iterating - */ - d = be_interface::narrow_from_decl ((be_interface_fwd::narrow_from_decl - (this))->full_definition ()); - /* - * Fall through - */ - case AST_Decl::NT_interface: - return be_interface::narrow_from_decl (d); - case AST_Decl::NT_module: - return be_module::narrow_from_decl (d); - case AST_Decl::NT_root: - return be_root::narrow_from_decl (d); - case AST_Decl::NT_except: - return be_exception::narrow_from_decl (d); - case AST_Decl::NT_union: - return be_union::narrow_from_decl (d); - case AST_Decl::NT_struct: - return be_structure::narrow_from_decl (d); - case AST_Decl::NT_enum: - return be_enum::narrow_from_decl (d); - case AST_Decl::NT_op: - return be_operation::narrow_from_decl (d); - case AST_Decl::NT_sequence: - return be_sequence::narrow_from_decl (d); - default: - return (be_scope *)0; - } -} - -// boolean methods to test if code was already generated -idl_bool -be_decl::cli_hdr_gen (void) -{ - return this->cli_hdr_gen_; -} - -idl_bool -be_decl::cli_stub_gen (void) -{ - return this->cli_stub_gen_; -} - -idl_bool -be_decl::cli_hdr_any_op_gen (void) -{ - return this->cli_hdr_any_op_gen_; -} - -idl_bool -be_decl::cli_stub_any_op_gen (void) -{ - return this->cli_stub_any_op_gen_; -} - -idl_bool -be_decl::cli_hdr_cdr_op_gen (void) -{ - return this->cli_hdr_cdr_op_gen_; -} - -idl_bool -be_decl::cli_stub_cdr_op_gen (void) -{ - return this->cli_stub_cdr_op_gen_; -} - -idl_bool -be_decl::cli_inline_cdr_op_gen (void) -{ - return this->cli_inline_cdr_op_gen_; -} - -idl_bool -be_decl::cli_inline_gen (void) -{ - return this->cli_inline_gen_; -} - -idl_bool -be_decl::srv_hdr_gen (void) -{ - return this->srv_hdr_gen_; -} - -idl_bool -be_decl::impl_hdr_gen (void) -{ - return this->impl_hdr_gen_; -} - -idl_bool -be_decl::srv_skel_gen (void) -{ - return this->srv_skel_gen_; -} - -idl_bool -be_decl::impl_skel_gen (void) -{ - return this->impl_skel_gen_; -} - -idl_bool -be_decl::srv_inline_gen (void) -{ - return this->srv_inline_gen_; -} - -// set the flag indicating that code generation is done -void -be_decl::cli_hdr_gen (idl_bool val) -{ - this->cli_hdr_gen_ = val; -} - -void -be_decl::cli_stub_gen (idl_bool val) -{ - this->cli_stub_gen_ = val; -} - -void -be_decl::cli_hdr_any_op_gen (idl_bool val) -{ - this->cli_hdr_any_op_gen_ = val; -} - -void -be_decl::cli_stub_any_op_gen (idl_bool val) -{ - this->cli_stub_any_op_gen_ = val; -} - -void -be_decl::cli_hdr_cdr_op_gen (idl_bool val) -{ - this->cli_hdr_cdr_op_gen_ = val; -} - -void -be_decl::cli_stub_cdr_op_gen (idl_bool val) -{ - this->cli_stub_cdr_op_gen_ = val; -} - -void -be_decl::cli_inline_cdr_op_gen (idl_bool val) -{ - this->cli_inline_cdr_op_gen_ = val; -} - -void -be_decl::cli_inline_gen (idl_bool val) -{ - this->cli_inline_gen_ = val; -} - -void -be_decl::srv_hdr_gen (idl_bool val) -{ - this->srv_hdr_gen_ = val; -} - -void -be_decl::impl_hdr_gen (idl_bool val) -{ - this->impl_hdr_gen_ = val; -} - - -void -be_decl::srv_skel_gen (idl_bool val) -{ - this->srv_skel_gen_ = val; -} - -void -be_decl::srv_inline_gen (idl_bool val) -{ - this->srv_inline_gen_ = val; -} - -int -be_decl::accept (be_visitor *visitor) -{ - return visitor->visit_decl (this); -} - -idl_bool -be_decl::is_child (be_decl *node) -{ - if (this->defined_in ()) - { - be_decl *bd; - - bd = be_scope::narrow_from_scope (this->defined_in ())->decl (); - if (!bd) - return 0; - - if (!ACE_OS::strcmp (bd->fullname (), node->fullname ())) - return 1; // true - } - return 0; // not a child -} - -// 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 deleted file mode 100644 index e80f8704cf0..00000000000 --- a/TAO/TAO_IDL/be/be_enum.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_enum.cpp -// -// = DESCRIPTION -// Extension of class AST_Enum that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_enum, "$Id$") - -/* - * BE_Enum - */ -be_enum::be_enum (void) -{ - this->size_type (be_decl::FIXED); -} - -be_enum::be_enum (UTL_ScopedName *n, UTL_StrList *p) - : AST_Enum (n, p), - AST_Decl (AST_Decl::NT_enum, n, p), - UTL_Scope (AST_Decl::NT_enum), - member_count_ (-1) -{ - this->size_type (be_decl::FIXED); -} - -// compute total number of members -int -be_enum::compute_member_count (void) -{ - UTL_ScopeActiveIterator *si; // iterator - AST_Decl *d; // temp node - - this->member_count_ = 0; - - // if there are elements in this scope - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - if (!d->imported ()) - { - this->member_count_++; - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -// return the member count -int -be_enum::member_count (void) -{ - if (this->member_count_ == -1) - this->compute_member_count (); - - return this->member_count_; -} - - -// generate typecode. -// Typecode for enum comprises the enumerated value followed by the -// encapsulation of the parameters - -int -be_enum::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "CORBA::tk_enum, // typecode kind" << nl; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - return this->gen_encapsulation (); -} - -int -be_enum::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; - // generate repoID - *cs << (ACE_OS::strlen (this->repoID ())+1) << ", "; - - ACE_UINT32 *arr; - (void)this->tc_name2long (this->repoID (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // repository ID = " << this->repoID () << nl; - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << nl; - // generate the member count - *cs << this->member_count () << ", // member count\n"; - cs->incr_indent (0); - // hand over to the scope to generate the typecode for elements - if (be_scope::gen_encapsulation () == -1) - { - ACE_ERROR ((LM_ERROR, "be_structure: cannot generate code for members\n")); - return -1; - } - cs->decr_indent (0); - return 0; -} - -// compute typecode size -long -be_enum::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the - // actual encapsulation length - return 4 + 4 + this->tc_encap_len (); -} - -// return encapsulation length -long -be_enum::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - this->encap_len_ = 4; // holds the byte order flag - - this->encap_len_ += this->repoID_encap_len (); // repoID storage - - // do the same thing for the local name - this->encap_len_ += this->name_encap_len (); - - this->encap_len_ += 4; // to hold the member count - - // compute encap length for members - this->encap_len_ += be_scope::tc_encap_len (); - } - return this->encap_len_; -} - -int -be_enum::accept (be_visitor *visitor) -{ - return visitor->visit_enum (this); -} - -// Narrowing -IMPL_NARROW_METHODS3 (be_enum, AST_Enum, be_scope, be_type) -IMPL_NARROW_FROM_DECL (be_enum) -IMPL_NARROW_FROM_SCOPE (be_enum) diff --git a/TAO/TAO_IDL/be/be_enum_val.cpp b/TAO/TAO_IDL/be/be_enum_val.cpp deleted file mode 100644 index 3a52a779278..00000000000 --- a/TAO/TAO_IDL/be/be_enum_val.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_enum_val.cpp -// -// = DESCRIPTION -// Extension of class AST_EnumVal that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_enum_val, "$Id$") - -be_enum_val::be_enum_val (void) -{ -} - -be_enum_val::be_enum_val (unsigned long v, UTL_ScopedName *n, UTL_StrList *p) - : AST_Constant (AST_Expression::EV_ulong, - AST_Decl::NT_enum_val, - new AST_Expression(v), - n, - p), - AST_Decl (AST_Decl::NT_enum_val, n, p) -{ -} - -int -be_enum_val::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - ACE_UINT32 *arr; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << "\n"; - return 0; -} - -long -be_enum_val::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - this->encap_len_ = this->name_encap_len (); // for name - } - - return this->encap_len_; -} - -int -be_enum_val::accept (be_visitor *visitor) -{ - return visitor->visit_enum_val (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_enum_val, AST_EnumVal, be_decl) -IMPL_NARROW_FROM_DECL (be_enum_val) diff --git a/TAO/TAO_IDL/be/be_exception.cpp b/TAO/TAO_IDL/be/be_exception.cpp deleted file mode 100644 index 9c788ce25b6..00000000000 --- a/TAO/TAO_IDL/be/be_exception.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_exception.cpp -// -// = DESCRIPTION -// Extension of class AST_Exception that provides additional means for C++ -// mapping of an interface. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_exception, "$Id$") - -/* - * BE_Exception - */ -be_exception::be_exception (void) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -be_exception::be_exception (UTL_ScopedName *n, UTL_StrList *p) - : AST_Decl (AST_Decl::NT_except, n, p), - AST_Structure (AST_Decl::NT_except, n, p), - UTL_Scope (AST_Decl::NT_except), - member_count_ (-1) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -// compute total number of members -int -be_exception::compute_member_count (void) -{ - UTL_ScopeActiveIterator *si; // iterator - - this->member_count_ = 0; - - // if there are elements in this scope - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - // get the next AST decl node - this->member_count_++; - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -// return the member count -int -be_exception::member_count (void) -{ - if (this->member_count_ == -1) - this->compute_member_count (); - - return this->member_count_; -} - -// generate typecode. -// Typecode for exceptions comprises the enumerated value followed by the -// encapsulation of the parameters - -int -be_exception::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "CORBA::tk_except, // typecode kind" << nl; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - cs->incr_indent (0); - if (this->gen_encapsulation () == -1) - { - return -1; - } - cs->decr_indent (); - return 0; -} - -// generate encapsulation -// An encapsulation for ourselves will be necessary when we are part of some -// other IDL type and a typecode for that other type is being generated. This -// will comprise our typecode kind. IDL types with parameters will additionally -// have the encapsulation length and the entire typecode description -int -be_exception::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - ACE_UINT32 *arr; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - // XXXASG - byte order must be based on what m/c we are generating code - - // TODO - *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; - // generate repoID - *cs << (ACE_OS::strlen (this->repoID ())+1) << ", "; - (void)this->tc_name2long (this->repoID (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // repository ID = " << this->repoID () << nl; - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << nl; - // generate the member count - *cs << this->member_count () << ", // member count\n"; - cs->incr_indent (0); - // hand over to the scope to generate the typecode for elements - if (be_scope::gen_encapsulation () == -1) - { - ACE_ERROR ((LM_ERROR, "be_exception: cannot generate typecode for members\n")); - return -1; - } - cs->decr_indent (0); - return 0; -} - -// compute typecode size -long -be_exception::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the - // actual encapsulation length - return 4 + 4 + this->tc_encap_len (); -} - -// compute encapsulation length -long -be_exception::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - this->encap_len_ = 4; // holds the byte order flag - - this->encap_len_ += this->repoID_encap_len (); // repoID - - // do the same thing for the local name - this->encap_len_ += this->name_encap_len (); - - this->encap_len_ += 4; // to hold the member count - - // compute encap length for members - this->encap_len_ += be_scope::tc_encap_len (); - } - return this->encap_len_; -} - -int -be_exception::accept (be_visitor *visitor) -{ - return visitor->visit_exception (this); -} - -// Narrowing -IMPL_NARROW_METHODS3 (be_exception, AST_Exception, be_scope, be_type) -IMPL_NARROW_FROM_DECL (be_exception) -IMPL_NARROW_FROM_SCOPE (be_exception) diff --git a/TAO/TAO_IDL/be/be_expression.cpp b/TAO/TAO_IDL/be/be_expression.cpp deleted file mode 100644 index 9a0dd75c4bf..00000000000 --- a/TAO/TAO_IDL/be/be_expression.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_expression.cpp -// -// = DESCRIPTION -// Extension of class AST_Expression that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_expression, "$Id$") - -/* - * BE_Expression - */ - -// the constructors -be_expression::be_expression (UTL_ScopedName *n) - : AST_Expression (n) -{ -} - -be_expression::be_expression (AST_Expression *b, AST_Expression::ExprType t) - : AST_Expression (b, t) -{ -} - -be_expression::be_expression (AST_Expression::ExprComb c, - AST_Expression *v1, - AST_Expression *v2) - : AST_Expression (c, v1, v2) -{ -} - -be_expression::be_expression (long l) - : AST_Expression (l) -{ -} - -be_expression::be_expression (long l, AST_Expression::ExprType t) - : AST_Expression (l, t) -{ -} - -be_expression::be_expression (unsigned long l) - : AST_Expression (l) -{ -} - -be_expression::be_expression (String *s) - : AST_Expression (s) -{ -} - -be_expression::be_expression (char c) - : AST_Expression (c) -{ -} - -be_expression::be_expression (double d) - : AST_Expression (d) -{ -} - -int -be_expression::accept (be_visitor *visitor) -{ - return visitor->visit_expression (this); -} diff --git a/TAO/TAO_IDL/be/be_field.cpp b/TAO/TAO_IDL/be/be_field.cpp deleted file mode 100644 index 60844f6898a..00000000000 --- a/TAO/TAO_IDL/be/be_field.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_field.cpp -// -// = DESCRIPTION -// Extension of class AST_Field that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_field, "$Id$") - -/* - * BE_Field - */ -be_field::be_field (void) -{ -} -be_field::be_field (AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p) - : AST_Field (ft, n, p), - AST_Decl (AST_Decl::NT_field, n, p) -{ -} - -int -be_field::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - be_type *bt; // our type node - long i, arrlen; - ACE_UINT32 *arr; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << "\n"; - - // hand over code generation to our type node - bt = be_type::narrow_from_decl (this->field_type ()); - return bt->gen_typecode (); -} - -long -be_field::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - be_type *bt; - - // struct member is represented as the "name" followed by the typecode - - this->encap_len_ = this->name_encap_len (); // for name - - // add to this, the size of our typecode - bt = be_type::narrow_from_decl (this->field_type ()); - this->encap_len_ += bt->tc_size (); // note that we must add typecode - // size of the type - } - return this->encap_len_; -} - -// 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) - { - 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 - return 0; -} - -int -be_field::accept (be_visitor *visitor) -{ - return visitor->visit_field (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_field, AST_Field, be_decl) -IMPL_NARROW_FROM_DECL (be_field) diff --git a/TAO/TAO_IDL/be/be_generator.cpp b/TAO/TAO_IDL/be/be_generator.cpp deleted file mode 100644 index 60d53081ba6..00000000000 --- a/TAO/TAO_IDL/be/be_generator.cpp +++ /dev/null @@ -1,415 +0,0 @@ -// $Id$ - -/* - -COPYRIGHT - -Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United -States of America. All Rights Reserved. - -This product is protected by copyright and distributed under the following -license restricting its use. - -The Interface Definition Language Compiler Front End (CFE) is made -available for your use provided that you include this license and copyright -notice on all media and documentation and the software program in which -this product is incorporated in whole or part. You may copy and extend -functionality (but may not remove functionality) of the Interface -Definition Language CFE without charge, but you are not authorized to -license or distribute it to anyone else except as part of a product or -program developed by you or with the express written consent of Sun -Microsystems, Inc. ("Sun"). - -The names of Sun Microsystems, Inc. and any of its subsidiaries or -affiliates may not be used in advertising or publicity pertaining to -distribution of Interface Definition Language CFE as permitted herein. - -This license is effective until terminated by Sun for failure to comply -with this license. Upon termination, you shall destroy or return all code -and documentation for the Interface Definition Language CFE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF -ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS -FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF -DEALING, USAGE OR TRADE PRACTICE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT -ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES -TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT. - -SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH -RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY -INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF. - -IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR -ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL -DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -Use, duplication, or disclosure by the government is subject to -restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in -Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR -52.227-19. - -Sun, Sun Microsystems and the Sun logo are trademarks or registered -trademarks of Sun Microsystems, Inc. - -SunSoft, Inc. -2550 Garcia Avenue -Mountain View, California 94043 - -NOTE: - -SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are -trademarks or registered trademarks of Sun Microsystems, Inc. - - */ - -// be_generator.cc -// -// Implementation of BE generator class -// -// 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 "ace/inc_user_config.h" - -ACE_RCSID(be, be_generator, "$Id$") - -/* - * Constructor - */ - -/* - * Private operations - */ - -/* - * Public operations - */ - -/* - * Inherited operations redefined here - */ - -/* - * Construct a be_root node (a node representing the root of an AST of BE nodes) - */ -AST_Root * -be_generator::create_root(UTL_ScopedName *n, - UTL_StrList *p) -{ - return new be_root(n, p); -} - -/* - * Create a BE_PredefinedType node - */ -AST_PredefinedType * -be_generator::create_predefined_type(AST_PredefinedType::PredefinedType t, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_PredefinedType *) new be_predefined_type(t, n, p); -} - -/* - * Create a BE_Module node - */ -AST_Module * -be_generator::create_module(UTL_ScopedName *n, UTL_StrList *p) -{ - return (AST_Module *) new be_module(n, p); -} - -/* - * Create a BE_Interface node - */ -AST_Interface * -be_generator::create_interface(UTL_ScopedName *n, - AST_Interface **ih, - long nih, - UTL_StrList *p) -{ - return (AST_Interface *) new be_interface(n, ih, nih, p); -} - -/* - * Create a BE_InterfaceFwd node - */ -AST_InterfaceFwd * -be_generator::create_interface_fwd(UTL_ScopedName *n, UTL_StrList *p) -{ - return (AST_InterfaceFwd *) new be_interface_fwd(n, p); -} - -/* - * Create a BE_Exception node - */ -AST_Exception * -be_generator::create_exception(UTL_ScopedName *n, UTL_StrList *p) -{ - return (AST_Exception *) new be_exception(n, p); -} - -/* - * Create a BE_Structure node - */ -AST_Structure * -be_generator::create_structure(UTL_ScopedName *n, UTL_StrList *p) -{ - return (AST_Structure *) new be_structure(n, p); -} - -/* - * Create a BE_Enum node - */ -AST_Enum * -be_generator::create_enum(UTL_ScopedName *n, UTL_StrList *p) -{ - return (AST_Enum *) new be_enum(n, p); -} - -/* - * Create a BE_Operation node - */ -AST_Operation * -be_generator::create_operation(AST_Type *rt, - AST_Operation::Flags fl, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_Operation *) new be_operation(rt, fl, n, p); -} - -/* - * Create a BE_Field node - */ -AST_Field * -be_generator::create_field(AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p) -{ - return (AST_Field *) new be_field(ft, n, p); -} - -/* - * Create a BE_Argument node - */ -AST_Argument * -be_generator::create_argument(AST_Argument::Direction d, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_Argument *) new be_argument(d, ft, n, p); -} - -/* - * Create a BE_Attribute node - */ -AST_Attribute * -be_generator::create_attribute(idl_bool ro, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_Attribute *) new be_attribute(ro, ft, n, p); -} - -/* - * Create a BE_Union node - */ -AST_Union * -be_generator::create_union(AST_ConcreteType *dt, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_Union *) new be_union(dt, n, p); -} - -/* - * Create a BE_UnionBranch node - */ -AST_UnionBranch * -be_generator::create_union_branch(AST_UnionLabel *lab, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_UnionBranch *) new be_union_branch(lab, ft, n, p); -} - -/* - * Create a BE_UnionLabel node - */ -AST_UnionLabel * -be_generator::create_union_label(AST_UnionLabel::UnionLabel ul, - AST_Expression *lv) -{ - return (AST_UnionLabel *) new be_union_label(ul, lv); -} - -/* - * Create a BE_Constant node - */ -AST_Constant * -be_generator::create_constant(AST_Expression::ExprType et, - AST_Expression *ev, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_Constant *) new be_constant (et, ev, n, p); -} - -/* - * Create a symbolic BE_Expression node - */ -AST_Expression * -be_generator::create_expr(UTL_ScopedName *n) -{ - return (AST_Expression *) new be_expression (n); -} - -/* - * Create a BE_Expression node denoting a coercion - */ -AST_Expression * -be_generator::create_expr(AST_Expression *b, AST_Expression::ExprType t) -{ - return (AST_Expression *) new be_expression (b, t); -} - -/* - * Create a BE_Expression node combining two other AST_Expression nodes - */ -AST_Expression * -be_generator::create_expr(AST_Expression::ExprComb c, - AST_Expression *v1, - AST_Expression *v2) -{ - return (AST_Expression *) new be_expression (c, v1, v2); -} - -/* - * Create a BE_Expression node denoting a long integer - */ -AST_Expression * -be_generator::create_expr(long l) -{ - return (AST_Expression *) new be_expression (l); -} - -/* - * Create a BE_Expression node denoting a long integer being used as a boolean - */ -AST_Expression * -be_generator::create_expr(long l, AST_Expression::ExprType t) -{ - return (AST_Expression *) new be_expression (l, t); -} - -/* - * Create a BE_Expression node denoting an unsigned long integer - */ -AST_Expression * -be_generator::create_expr(unsigned long l) -{ - return (AST_Expression *) new be_expression(l); -} - -/* - * Create a BE_Expression node denoting a char * (encapsulated as a String) - */ -AST_Expression * -be_generator::create_expr (String *s) -{ - return (AST_Expression *) new be_expression (s); -} - -/* - * Create a BE_Expression node denoting a character - */ -AST_Expression * -be_generator::create_expr(char c) -{ - return (AST_Expression *) new be_expression (c); -} - -/* - * Create a BE_Expression node denoting a 64-bit floating point number - */ -AST_Expression * -be_generator::create_expr (double d) -{ - return (AST_Expression *) new be_expression (d); -} - -/* - * Create a BE_EnumVal node - */ -AST_EnumVal * -be_generator::create_enum_val(unsigned long v, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_EnumVal *) new be_enum_val(v, n, p); -} - -/* - * Create a BE_Array node - */ -AST_Array * -be_generator::create_array(UTL_ScopedName *n, - unsigned long ndims, - UTL_ExprList *dims) -{ - return (AST_Array *) new be_array(n, ndims, dims); -} - -/* - * Create a BE_Sequence node - */ -AST_Sequence * -be_generator::create_sequence(AST_Expression *v, AST_Type *bt) -{ - return (AST_Sequence *) new be_sequence(v, bt); -} - -/* - * Create a BE_String node - */ -AST_String * -be_generator::create_string(AST_Expression *v) -{ - return (AST_String *) new be_string(v); -} - -/* - * Create a BE_string node for a wide string - */ -AST_String * -be_generator::create_wstring(AST_Expression *v) -{ - return (AST_String *) new be_string(v, sizeof(ACE_OS::WChar)); -} - -/* - * Create a BE_Typedef node - */ -AST_Typedef * -be_generator::create_typedef(AST_Type *bt, UTL_ScopedName *n, UTL_StrList *p) -{ - return (AST_Typedef *) new be_typedef(bt, n, p); -} - -/* - * Construct an AST_Native node - */ -AST_Native * -be_generator::create_native (UTL_ScopedName *n, - UTL_StrList *p) -{ - return (AST_Native *) new be_native (n, p); -} diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp deleted file mode 100644 index 0618cf5aed4..00000000000 --- a/TAO/TAO_IDL/be/be_helper.cpp +++ /dev/null @@ -1,336 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_helper.cpp -// -// = DESCRIPTION -// Provides helper classes to print generated code to the output -// -// = AUTHOR -// Aniruddha Gokhale -// -// Improvements by Carlos O'Ryan -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_helper, "$Id$") - -static const char copyright [] = -"/* -*- C++ -*- */\n\n\ -// ****** Code generated by the The ACE ORB (TAO) IDL Compiler *******\n\ -// TAO ORB and the TAO IDL Compiler have been developed by Washington \n\ -// University Computer Science's Distributed Object Computing Group.\n\ -//\n\ -// Information on TAO is available at\n\ -// http://www.cs.wustl.edu/~schmidt/TAO.html\n"; - -TAO_NL::TAO_NL (void) -{ -} - -TAO_INDENT::TAO_INDENT (int do_now) - : do_now_ (do_now) -{ -} - -TAO_UNINDENT::TAO_UNINDENT (int do_now) - : do_now_ (do_now) -{ -} - -const TAO_NL be_nl; -const TAO_INDENT be_idt; -const TAO_INDENT be_idt_nl (1); -const TAO_UNINDENT be_uidt; -const TAO_UNINDENT be_uidt_nl (1); - -// methods of the TAO_OutStream class - -TAO_OutStream::TAO_OutStream (void) - : fp_ (NULL), - indent_level_ (0) -{ -} - -TAO_OutStream::~TAO_OutStream (void) -{ - // close the underlying I/O handle only if it exists - if (fp_) - { - ACE_OS::fclose (fp_); - fp_ = NULL; - } - indent_level_ = 0; -} - -int -TAO_OutStream::open (const char *fname, - TAO_OutStream::STREAM_TYPE st) -{ - if (fname) - { - // file name exists, open an I/O file handle - fp_ = ACE_OS::fopen (fname, "w"); - if (fp_) - { - this->st_ = st; - // put the copyright notice. Not for the gperf's temp input - // file. - if (st != TAO_OutStream::TAO_GPERF_INPUT) - { - ACE_OS::fprintf (fp_, "%s\n", copyright); - ACE_OS::fflush (fp_); - } - return 0; - } - else - return -1; - } - else - { - return -1; - } -} - -// set and get the stream type -void -TAO_OutStream::stream_type (TAO_OutStream::STREAM_TYPE st) -{ - this->st_ = st; -} - -TAO_OutStream::STREAM_TYPE -TAO_OutStream::stream_type (void) -{ - return this->st_; -} - -// Return the underlying lowlevel file pointer. -// indentation. -FILE * -TAO_OutStream::file (void) -{ - return this->fp_; -} - -int -TAO_OutStream::incr_indent (unsigned short flag) -{ - indent_level_++; - if (flag) - return this->indent (); - else - return 0; // do not indent output -} - -// indentation -int -TAO_OutStream::decr_indent (unsigned short flag) -{ - indent_level_--; - // Just in case somebody gets "unindent happy". - if (this->indent_level_ < 0) - { - // ACE_DEBUG ((LM_DEBUG, "negative indentation?\n")); - this->indent_level_ = 0; - } - if (flag) - return this->indent (); - else - return 0; // do not indent output -} - -int -TAO_OutStream::reset (void) -{ - indent_level_ = 0; - return 0; -} - -// indented print -int -TAO_OutStream::indent (void) -{ - int i; - // based on the current indentation level, leave appropriate number of blank - // spaces in the output - if (this->indent_level_ > 0) - { - for (i=0; i < this->indent_level_; i++) - { - ACE_OS::fprintf (this->fp_, " "); - ACE_OS::fflush (this->fp_); - } - } - return 0; -} - -int -TAO_OutStream::nl (void) -{ - ACE_OS::fprintf (this->fp_, "\n"); - this->indent (); - return 0; -} - -// macro generation -int -TAO_OutStream::gen_ifdef_macro (const char *flatname, const char *suffix) -{ - static char macro [NAMEBUFSIZE]; - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ACE_OS::memset (macro, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (macro, "_%s_", cg->upcase (flatname)); - if (suffix) - { - ACE_OS::sprintf (macro, "%s_%s_", macro, cg->upcase (suffix)); - } - - // append a suffix representing the stream type - switch (this->st_) - { - case TAO_OutStream::TAO_CLI_HDR: - ACE_OS::strcat (macro, "CH_"); - break; - case TAO_OutStream::TAO_CLI_INL: - ACE_OS::strcat (macro, "CI_"); - break; - case TAO_OutStream::TAO_CLI_IMPL: - ACE_OS::strcat (macro, "CS_"); - break; - case TAO_OutStream::TAO_SVR_HDR: - ACE_OS::strcat (macro, "SH_"); - break; - case TAO_OutStream::TAO_IMPL_HDR: - ACE_OS::strcat (macro, "IH_"); - break; - case TAO_OutStream::TAO_IMPL_SKEL: - ACE_OS::strcat (macro, "IS_"); - break; - case TAO_OutStream::TAO_SVR_INL: - ACE_OS::strcat (macro, "SI_"); - break; - case TAO_OutStream::TAO_SVR_IMPL: - ACE_OS::strcat (macro, "SS_"); - break; - } - *this << "\n#if !defined (" << macro << ")\n"; - *this << "#define " << macro << "\n\n"; - return 0; -} - -int -TAO_OutStream::gen_endif (void) -{ - *this << "\n#endif /* end #if !defined */\n\n"; - return 0; -} - - -// ifdef generation -int -TAO_OutStream::gen_ifdef_AHETI (void) -{ - *this << be_nl << "#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) \\" << be_nl; - *this << " || !defined (ACE_HAS_TEMPLATE_SPECIALIZATION)" << be_idt_nl; - return 0; -} - -int -TAO_OutStream::gen_else_AHETI (void) -{ - *this << be_uidt_nl << "#else /* AHETI */" << be_idt_nl; - return 0; -} - -int -TAO_OutStream::gen_endif_AHETI (void) -{ - *this << be_uidt_nl << "#endif /* AHETI */ " << be_nl; - return 0; -} - - -// printf style variable argument print -int -TAO_OutStream::print (const char *format, ...) -{ - int result = 0; - va_list ap; - va_start (ap, format); - ACE_OSCALL (::vfprintf (this->fp_, format, ap), int, -1, result); - ACE_OS::fflush (fp_); - va_end (ap); - return result; -} - -TAO_OutStream & -TAO_OutStream::operator<< (const char *str) -{ - ACE_OS::fprintf (this->fp_, "%s", str); - ACE_OS::fflush (fp_); - return *this; -} - -TAO_OutStream & -TAO_OutStream::operator<< (const long num) -{ - ACE_OS::fprintf (this->fp_, "%ld", num); - ACE_OS::fflush (fp_); - return *this; -} - -TAO_OutStream & -TAO_OutStream::operator<< (const TAO_NL&) -{ - ACE_OS::fprintf (this->fp_ , "\n"); - this->indent (); - return *this; -} - -TAO_OutStream & -TAO_OutStream::operator<< (const TAO_INDENT& i) -{ - this->incr_indent (0); - if (i.do_now_) - this->nl (); - return *this; -} - -TAO_OutStream & -TAO_OutStream::operator<< (const TAO_UNINDENT& i) -{ - this->decr_indent (0); - if (i.do_now_) - this->nl (); - return *this; -} - -TAO_OutStream & -TAO_OutStream::operator<< (Identifier *id) -{ - return this->print (id); -} - -TAO_OutStream & -TAO_OutStream::operator<< (UTL_IdList *id) -{ - return this->print (id); -} - -TAO_OutStream & -TAO_OutStream::operator<< (AST_Expression *expr) -{ - return this->print (expr); -} diff --git a/TAO/TAO_IDL/be/be_init.cpp b/TAO/TAO_IDL/be/be_init.cpp deleted file mode 100644 index 4558a32dbb3..00000000000 --- a/TAO/TAO_IDL/be/be_init.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// $Id$ - -/* - -COPYRIGHT - -Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United -States of America. All Rights Reserved. - -This product is protected by copyright and distributed under the following -license restricting its use. - -The Interface Definition Language Compiler Front End (CFE) is made -available for your use provided that you include this license and copyright -notice on all media and documentation and the software program in which -this product is incorporated in whole or part. You may copy and extend -functionality (but may not remove functionality) of the Interface -Definition Language CFE without charge, but you are not authorized to -license or distribute it to anyone else except as part of a product or -program developed by you or with the express written consent of Sun -Microsystems, Inc. ("Sun"). - -The names of Sun Microsystems, Inc. and any of its subsidiaries or -affiliates may not be used in advertising or publicity pertaining to -distribution of Interface Definition Language CFE as permitted herein. - -This license is effective until terminated by Sun for failure to comply -with this license. Upon termination, you shall destroy or return all code -and documentation for the Interface Definition Language CFE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF -ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS -FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF -DEALING, USAGE OR TRADE PRACTICE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT -ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES -TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT. - -SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH -RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY -INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF. - -IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR -ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL -DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -Use, duplication, or disclosure by the government is subject to -restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in -Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR -52.227-19. - -Sun, Sun Microsystems and the Sun logo are trademarks or registered -trademarks of Sun Microsystems, Inc. - -SunSoft, Inc. -2550 Garcia Avenue -Mountain View, California 94043 - -NOTE: - -SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are -trademarks or registered trademarks of Sun Microsystems, Inc. - - */ - -// BE_init.cc - Initialization for dummy BE - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_init, "$Id$") - -/* - * Initialize the BE. The protocol requires only that this routine - * return an instance of AST_Generator (or a subclass thereof). - * - * Remember that none of the FE initialization has been done, when you - * add stuff here. - */ -AST_Generator * -BE_init() -{ - tao_cg = TAO_CODEGEN::instance (); - AST_Generator *g = new be_generator(); - - if (g == NULL) { - cerr << GTDEVEL("IDL: BE init failed to create generator, exiting\n"); - exit(99); - } - return g; -} - -/* - * Print out a version string for the BE - */ -void -BE_version() -{ - cerr << GTDEVEL("TAO C++ BE, version 0.1.0\n"); -} diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp deleted file mode 100644 index 6d90df87100..00000000000 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ /dev/null @@ -1,2110 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_interface.cpp -// -// = DESCRIPTION -// Extension of class AST_Interface that provides additional means for C++ -// mapping of an interface. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be_visitor_interface.h" -#include "be.h" - -ACE_RCSID(be, be_interface, "$Id$") - -/* - * BE_Interface - */ - -// default constructor -be_interface::be_interface (void) - : full_skel_name_ (0), - skel_count_ (0), - full_coll_name_ (0), - local_coll_name_ (0), - in_mult_inheritance_ (-1) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -// constructor used to build the AST -be_interface::be_interface (UTL_ScopedName *n, AST_Interface **ih, long nih, - UTL_StrList *p) - : AST_Interface (n, ih, nih, p), - AST_Decl (AST_Decl::NT_interface, n, p), - UTL_Scope (AST_Decl::NT_interface), - full_skel_name_ (0), - skel_count_ (0), - full_coll_name_ (0), - local_coll_name_ (0), - in_mult_inheritance_ (-1) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -be_interface::~be_interface (void) -{ - if (this->full_skel_name_ != 0) - { - delete[] this->full_skel_name_; - this->full_skel_name_ = 0; - } - if (this->full_coll_name_ != 0) - { - delete[] this->full_coll_name_; - this->full_coll_name_ = 0; - } - if (this->local_coll_name_ != 0) - { - delete[] this->local_coll_name_; - this->local_coll_name_ = 0; - } -} - -// compute stringified fully qualified collocated class name. -void -be_interface::compute_coll_name (void) -{ - if (this->full_coll_name_ != 0) - return; - - const char collocated[] = "_tao_collocated_"; - const char poa[] = "POA_"; - // Reserve enough room for the "POA_" prefix, the "_tao_collocated_" - // prefix and the local name and the (optional) "::" - int namelen = sizeof (collocated) + sizeof (poa); - - UTL_IdListActiveIterator *i; - ACE_NEW (i, UTL_IdListActiveIterator (this->name ())); - while (!i->is_done ()) - { - // reserve 2 characters for "::". - namelen += ACE_OS::strlen (i->item ()->get_string ()) + 2; - i->next (); - } - delete i; - - ACE_NEW (this->full_coll_name_, - char[namelen+1]); - this->full_coll_name_[0] = 0; // null terminate the string... - - // Iterate again.... - ACE_NEW (i, UTL_IdListActiveIterator (this->name ())); - - // Only the first component get the "POA_" preffix. - int poa_added = 0; - while (!i->is_done ()) - { - const char* item = i->item ()->get_string (); - - // Increase right away, so we can test for the final component - // in the loop. - i->next (); - - // We add the POA_ preffix only if the first component is not - // the global scope... - if (ACE_OS::strcmp (item, "") != 0) - { - if (!i->is_done ()) - { - // We only add the POA_ preffix if there are more than - // two components in the name, in other words, if the - // class is inside some scope. - if (!poa_added) - { - ACE_OS::strcat (this->full_coll_name_, poa); - poa_added = 1; - } - ACE_OS::strcat (this->full_coll_name_, item); - ACE_OS::strcat (this->full_coll_name_, "::"); - } - else - { - ACE_OS::strcat (this->full_coll_name_, collocated); - ACE_OS::strcat (this->full_coll_name_, item); - } - } - } - delete i; - - // Compute the local name for the collocated class. - int localen = sizeof (collocated); - localen += ACE_OS::strlen (this->local_name ()->get_string ()); - ACE_NEW (this->local_coll_name_, char[localen]); - ACE_OS::strcpy(this->local_coll_name_, collocated); - ACE_OS::strcat(this->local_coll_name_, - this->local_name ()->get_string ()); -} - -const char * -be_interface::full_coll_name (void) -{ - if (this->full_coll_name_ == 0) - this->compute_coll_name (); - - return this->full_coll_name_; -} - -const char* -be_interface::local_coll_name (void) const -{ - if (this->local_coll_name_ == 0) - ACE_const_cast (be_interface*, this)->compute_coll_name (); - - return this->local_coll_name_; -} - -// compute stringified fully scoped skel name -void -be_interface::compute_fullskelname (void) -{ - if (full_skel_name_) - return; - else - { - long namelen; - UTL_IdListActiveIterator *i; - long first = I_TRUE; - long second = I_FALSE; - - // in the first loop compute the total length - namelen = 4; - i = new UTL_IdListActiveIterator (this->name ()); - while (!(i->is_done ())) - { - if (!first) - namelen += 2; // for "::" - else if (second) - first = second = I_FALSE; - // print the identifier - namelen += ACE_OS::strlen (i->item ()->get_string ()); // - // additional 4 for the POA_ characters - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - - this->full_skel_name_ = new char [namelen+1]; - this->full_skel_name_[0] = '\0'; - first = I_TRUE; - second = I_FALSE; - ACE_OS::strcat (this->full_skel_name_, "POA_"); - i = new UTL_IdListActiveIterator (this->name ()); - while (!(i->is_done ())) - { - if (!first) - ACE_OS::strcat (this->full_skel_name_, "::"); - else if (second) - first = second = I_FALSE; - // print the identifier - ACE_OS::strcat (this->full_skel_name_, i->item ()->get_string ()); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - delete i; - } - return; -} - -// retrieve the fully scoped skeleton name -const char* -be_interface::full_skel_name (void) -{ - if (!this->full_skel_name_) - compute_fullskelname (); - - return this->full_skel_name_; -} - -// Am I in some kind of a multiple inheritance -int be_interface::in_mult_inheritance (void) -{ - if (this->in_mult_inheritance_ == -1) - { - // compute once for all - // determine if we are in some form of a multiple inheritance - if (this->traverse_inheritance_graph - (be_interface::in_mult_inheritance_helper, 0) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_interface::in_mult_inheritance " - "error determining mult inheritance\n"), - -1); - } - } - - return this->in_mult_inheritance_; -} - -void be_interface::in_mult_inheritance (int mi) -{ - if (this->in_mult_inheritance_ == -1) - this->in_mult_inheritance_ = mi; -} - -//gen copy constructors -void -be_interface::gen_copy_ctors (TAO_OutStream* os) -{ - this->traverse_inheritance_graph(be_interface::gen_copy_ctors_helper,os); - return; -} - -int -be_interface::gen_copy_ctors_helper (be_interface* node, be_interface* base, TAO_OutStream *os) -{ - static int first = 0; - if(node != base) - { - if(first) - { - *os << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " (t)" - << ", " << base->full_skel_name () << " (t)"; - first = 0; - } - else - { - *os << ", " << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " (t)" - << ", " << base->full_skel_name () << " (t)"; ; - - } - } - else - { - *os << ":"; - first = 1; - } - - return 1; - -} - -//generate default constructors -void -be_interface::gen_def_ctors (TAO_OutStream* os) -{ - this->traverse_inheritance_graph(be_interface::gen_def_ctors_helper,os); - return; -} - - -int -be_interface::gen_def_ctors_helper (be_interface* node, be_interface* base, TAO_OutStream *os) -{ - - static int first = 0; - if(node != base) - { - if(first) - { - *os << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " ()"; - first = 0; - } - else - { - *os << ", " << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " ()"; - - } - } - else - { - *os << ":"; - first = 1; - } - - return 1; - -} - - -// generate the var definition -int -be_interface::gen_var_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_var", this->local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - ch->indent (); // start with whatever was our current indent level - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - - // default constr - *ch << namebuf << " (void); // default constructor" << nl; - *ch << namebuf << " (" << local_name () << "_ptr);" << nl; - - // copy constructor - *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << nl; - - // destructor - *ch << "~" << namebuf << " (void); // destructor" << nl; - *ch << nl; - - // assignment operator from a pointer - *ch << namebuf << " &operator= (" << local_name () << "_ptr);" << nl; - - // assignment from _var - *ch << namebuf << " &operator= (const " << namebuf << - " &);" << nl; - - // arrow operator - *ch << local_name () << "_ptr operator-> (void) const;" << nl; - - *ch << nl; - - // other extra types (cast operators, [] operator, and others) - *ch << "operator const " << local_name () << "_ptr &() const;" << nl; - *ch << "operator " << local_name () << "_ptr &();" << nl; - - *ch << "// in, inout, out, _retn " << nl; - // the return types of in, out, inout, and _retn are based on the parameter - // passing rules and the base type - *ch << local_name () << "_ptr in (void) const;" << nl; - *ch << local_name () << "_ptr &inout (void);" << nl; - *ch << local_name () << "_ptr &out (void);" << nl; - *ch << local_name () << "_ptr _retn (void);" << nl; - - // generate an additional member function that returns the underlying pointer - *ch << local_name () << "_ptr ptr (void) const;\n"; - - *ch << "\n"; - ch->decr_indent (); - - // private - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << "_ptr ptr_;\n"; - - ch->decr_indent (); - *ch << "};\n\n"; - - return 0; -} - -// implementation of the _var class. All of these get generated in the inline -// file -int -be_interface::gen_var_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local _var names - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - // generate the var implementation in the inline file - // Depending upon the data type, there are some differences which we account - // for over here. - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // default constr - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << - " (void) // default constructor" << nl; - *ci << " " << ": ptr_ (" << this->name () << "::_nil ())" << nl; - *ci << "{}\n\n"; - - // constr from a _ptr - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << "_ptr p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{}\n\n"; - - // 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. - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr " << nl; - *ci << fname << "::ptr (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << " : ptr_ (" << name () << "::_duplicate (p.ptr ()))" << nl; - *ci << "{}\n\n"; - - // destructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::~" << lname << " (void) // destructor" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << name () << - "_ptr p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _var - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "if (this != &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = " << name () << "::_duplicate (p.ptr ());\n"; - ci->decr_indent (); - *ci << "}" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator const " << name () << - "_ptr &() const // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << name () << "_ptr &() // cast " << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // operator-> - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr " << nl; - *ci << fname << "::operator-> (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // in, inout, out, and _retn - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr" << nl; - *ci << fname << "::in (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr &" << nl; - *ci << fname << "::inout (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr &" << nl; - *ci << fname << "::out (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = " << this->name () << "::_nil ();" << nl; - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr " << nl; - *ci << fname << "::_retn (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "// yield ownership of managed obj reference" << nl; - *ci << this->name () << "_ptr val = this->ptr_;" << nl; - *ci << "this->ptr_ = " << this->name () << "::_nil ();" << nl; - *ci << "return val;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - return 0; -} - -// generate the _out definition -int -be_interface::gen_out_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // to hold the _out name - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the out definition (always in the client header) - ch->indent (); // start with whatever was our current indent level - - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - - // No default constructor - - // constructor from a pointer - *ch << namebuf << " (" << local_name () << "_ptr &);" << nl; - // constructor from a _var & - *ch << namebuf << " (" << local_name () << "_var &);" << nl; - // constructor from a _out & - *ch << namebuf << " (const " << namebuf << " &);" << nl; - // assignment operator from a _out & - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; - // assignment operator from a pointer &, cast operator, ptr fn, operator - // -> and any other extra operators - // only interface allows assignment from var & - *ch << namebuf << " &operator= (const " << local_name () << "_var &);" << nl; - *ch << namebuf << " &operator= (" << local_name () << "_ptr);" << nl; - // cast - *ch << "operator " << local_name () << "_ptr &();" << nl; - // ptr fn - *ch << local_name () << "_ptr &ptr (void);" << nl; - // operator -> - *ch << local_name () << "_ptr operator-> (void);" << nl; - - *ch << "\n"; - ch->decr_indent (); - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << "_ptr &ptr_;\n"; - - ch->decr_indent (); - *ch << "};\n\n"; - return 0; -} - -int -be_interface::gen_out_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - 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_out", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - // generate the var implementation in the inline file - // Depending upon the data type, there are some differences which we account - // for over here. - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // constr from a _ptr - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << "_ptr &p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = " << this->name () << "::_nil ();\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // constructor from _var & - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << this->name () << - "_var &p) // constructor from _var" << nl; - *ci << " : ptr_ (p.out ())" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = " << this->name () << "::_nil ();\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << " : ptr_ (ACE_const_cast (" << fname << "&,p).ptr_)" << nl; - *ci << "{}\n\n"; - - // assignment operator from _out & - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = ACE_const_cast (" << fname << "&,p).ptr_;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _var - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << this->name () << - "_var &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = " << this->name () << "::_duplicate (p.ptr ());" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _ptr - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << this->name () << - "_ptr p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << this->name () << - "_ptr &() // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // ptr function - ci->indent (); - *ci << "ACE_INLINE " << this->name () << "_ptr &" << nl; - *ci << fname << "::ptr (void) // ptr" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // operator-> - ci->indent (); - *ci << "ACE_INLINE " << this->name () << "_ptr " << nl; - *ci << fname << "::operator-> (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - return 0; -} - -// generate typecode. -// Typecode for interface comprises the enumerated value followed by the -// encapsulation of the parameters - -int -be_interface::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "CORBA::tk_objref, // typecode kind" << nl; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - return this->gen_encapsulation (); -} - -// generate encapsulation -// An encapsulation for ourselves will be necessary when we are part of some -// other IDL type and a typecode for that other type is being generated. This -// will comprise our typecode kind. IDL types with parameters will additionally -// have the encapsulation length and the entire typecode description -int -be_interface::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - ACE_UINT32 *arr; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - // XXXASG - byte order must be based on what m/c we are generating code - - // TODO - *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; - // generate repoID - *cs << (ACE_OS::strlen (this->repoID ())+1) << ", "; - (void)this->tc_name2long (this->repoID (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // repository ID = " << this->repoID () << nl; - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << ",\n"; - - return 0; -} - -// compute size of typecode -long -be_interface::tc_size (void) -{ - return 4 + 4 + this->tc_encap_len (); -} - -// compute the encapsulation length -long -be_interface::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - long slen; - - // Macro to avoid "warning: unused parameter" type warning. - ACE_UNUSED_ARG (slen); - - this->encap_len_ = 4; // holds the byte order flag - - this->encap_len_ += this->repoID_encap_len (); // for repoID - - // do the same thing for the local name - this->encap_len_ += this->name_encap_len (); - - } - return this->encap_len_; -} - -// helper. -int -be_interface::gen_operation_table (void) -{ - TAO_OutStream *ss; // output stream. - TAO_NL nl; // end line. - - // Retrieve the singleton instance of the CodeGen. - TAO_CodeGen *cg = 0; - cg = TAO_CODEGEN::instance (); - - // Check out the op_lookup_strategy. - switch (cg->lookup_strategy ()) - { - case TAO_CodeGen::TAO_DYNAMIC_HASH: - // Init the outstream appropriately. - ss = cg->server_skeletons (); - - // start from current indentation level. - ss->indent (); - - // Start the table generation. - *ss << "static const TAO_operation_db_entry " << this->flatname () << - "_operations [] = {\n"; - ss->incr_indent (0); - - // Traverse the graph. - if (this->traverse_inheritance_graph (be_interface::gen_optable_helper, ss) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::gen_operation_table - " - "inheritance graph traversal failed\n"), -1); - } - - // generate the skeleton for the is_a method. - ss->indent (); - *ss << "{\"_is_a\", &" << this->full_skel_name () << "::_is_a_skel},\n"; - this->skel_count_++; - - ss->indent (); - *ss << "{\"_non_existent\", &" << this->full_skel_name () << "::_non_existent_skel}\n"; - this->skel_count_++; - - ss->decr_indent (); - *ss << "};" << nl << nl; - - // XXXASG - this code should be based on using different strategies for - // demux - for next release - *ss << "static const CORBA::Long _tao_" << this->flatname () - << "_optable_size = sizeof (ACE_Hash_Map_Entry<const char *," - << " TAO_Skeleton>) * (" << (3*this->skel_count_) - << ");" << be_nl; - *ss << "static char _tao_" << this->flatname () << "_optable_pool " - << "[_tao_" << this->flatname () << "_optable_size];" << be_nl; - *ss << "static ACE_Static_Allocator_Base _tao_" << this->flatname () - << "_allocator (_tao_" << this->flatname () << "_optable_pool, " - << "_tao_" << this->flatname () << "_optable_size);" << be_nl; - *ss << "TAO_Dynamic_Hash_OpTable tao_" << this->flatname () << "_optable " - << "(" << this->flatname () << "_operations, " << this->skel_count_ - << ", " << 2*this->skel_count_ << ", &_tao_" << this->flatname () - << "_allocator);" << be_nl; - - break; - - case TAO_CodeGen::TAO_LINEAR_SEARCH: - // For generating linear search also, we are calling GPERF - // only. - case TAO_CodeGen::TAO_BINARY_SEARCH: - // For generating binary search also, we are calling GPERF - // only. - case TAO_CodeGen::TAO_PERFECT_HASH: - // For each interface in the IDL, have a new temp file to - // collect the input for the gperf program. - { - // Temp file name. - char *temp_file = 0; - ACE_NEW_RETURN (temp_file, - char [ACE_OS::strlen (ACE_DEFAULT_TEMP_FILE) + - ACE_OS::strlen (this->flatname ()) + - ACE_OS::strlen (".gperf") + 2], - -1); - ACE_OS::sprintf (temp_file, - "%s_%s.gperf", - ACE_DEFAULT_TEMP_FILE, - this->flatname ()); - - // Save this file name with the codegen singleton. - cg->gperf_input_filename (temp_file); - - // Make a new outstream to hold the gperf_temp_file for this - // interface. - - // Retrieve the singleton instance to the outstream factory. - TAO_OutStream_Factory *factory = - TAO_OUTSTREAM_FACTORY::instance (); - - // Get a new instance for the temp file. - ss = factory->make_outstream (); - if (ss == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss", - "::", - "visit_interface-", - "make_outstream failed"), - -1); - - // Store the outstream with the codegen singleton. - cg->gperf_input_stream (ss); - - // Open the temp file. - if (ss->open (temp_file, - TAO_OutStream::TAO_GPERF_INPUT) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss", - "::", - "visit_interface-", - "gperf_input.tmp file open failed"), - -1); - - // Add the gperf input header. - gen_gperf_input_header (ss); - - // Traverse the graph. - if (this->traverse_inheritance_graph (be_interface::gen_optable_helper, ss) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::gen_operation_table - " - "inheritance graph traversal failed\n"), - -1); - - // Generate the skeleton for the is_a method. - ss->indent (); - *ss << "_is_a" << ", &" - << this->full_skel_name () - << "::_is_a_skel\n"; - this->skel_count_++; - - ss->indent (); - *ss << "_non_existent, &" - << this->full_skel_name () - << "::_non_existent_skel\n"; - this->skel_count_++; - - // Input to the gperf is ready. Run gperf and get things - // done. This method also unlinks the temp file that we used - // for the gperf. - gen_gperf_things (); - } - break; - - default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_interface", - "::", - "gen_operation_table", - "unknown op_lookup_strategy"), - -1); - } - return 0; -} - -// Output the header (type declaration and %%) to the gperf's input -// file. -void -be_interface::gen_gperf_input_header (TAO_OutStream *ss) -{ - *ss << "class TAO_operation_db_entry {\n" - << "public:\n" - << "\tchar *opname_;" << "\n" - << "\tTAO_Skeleton skel_ptr_;" << "\n" - << "};" << "\n" - << "%%" - << "\n"; -} - -// we separate the generation of operation table entries from the -// "gen_operation_table" method. This enables us to invoke generation of -// entries for interfaces from which we inherit without any additional -// code. The parameter "derived" is the one for which the entire operation -// table is being built. -int -be_interface::gen_optable_entries (be_interface *derived) -{ - UTL_ScopeActiveIterator *si; - AST_Decl *d; - TAO_OutStream *ss; // output stream - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - switch (cg->lookup_strategy ()) - { - case TAO_CodeGen::TAO_DYNAMIC_HASH: - // Init the outstream. - ss = cg->server_skeletons (); - - // The major stuff. - if (this->nmembers () > 0) - { - // if there are elements in this scope i.e., any operations and - // attributes defined by "this" which happens to be the same as "derived" - // or one of its ancestors. - - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - // instantiate a scope iterator. - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - if (d->node_type () == AST_Decl::NT_op) - { - ss->indent (); // start from current indentation level - // we are an operation node - *ss << "{\"" << d->local_name () << "\", &" - << derived->full_skel_name () << "::" - << d->local_name () << "_skel},\n"; - derived->skel_count_++; - } - else if (d->node_type () == AST_Decl::NT_attr) - { - AST_Attribute *attr; - - ss->indent (); // start from current indentation level - // generate only the "get" entry if we are readonly - *ss << "{\"_get_" << d->local_name () << "\", &" << - derived->full_skel_name () << "::_get_" << d->local_name () << - "_skel},\n"; - derived->skel_count_++; - - attr = AST_Attribute::narrow_from_decl (d); - if (!attr) - return -1; - - if (!attr->readonly ()) - { - // the set method - ss->indent (); // start from current indentation level - *ss << "{\"_set_" << d->local_name () << "\", &" << - derived->full_skel_name () << "::_set_" << d->local_name - () << "_skel},\n"; - derived->skel_count_++; - } - } - si->next (); - } // end of while - delete si; // free the iterator object - } - break; - - case TAO_CodeGen::TAO_LINEAR_SEARCH: - case TAO_CodeGen::TAO_BINARY_SEARCH: - case TAO_CodeGen::TAO_PERFECT_HASH: - // We call GPERF for all these three strategies. - // Init the outstream. - ss = cg->gperf_input_stream (); - - if (this->nmembers () > 0) - { - // if there are elements in this scope i.e., any operations and - // attributes defined by "this" which happens to be the same as "derived" - // or one of its ancestors. - - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - // instantiate a scope iterator. - - while (!(si->is_done ())) - { - // Get the next AST decl node. - d = si->item (); - if (d->node_type () == AST_Decl::NT_op) - { - ss->indent (); // start from current indentation level - // we are an operation node - *ss << d->local_name () << ",\t&" - << derived->full_skel_name () << "::" - << d->local_name () << "_skel" << "\n"; - derived->skel_count_++; - } - else if (d->node_type () == AST_Decl::NT_attr) - { - AST_Attribute *attr; - - ss->indent (); // start from current indentation level - // generate only the "get" entry if we are readonly - *ss << "_get_" << d->local_name () << ",\t&" - << derived->full_skel_name () << "::_get_" - << d->local_name () << "_skel\n"; - derived->skel_count_++; - - attr = AST_Attribute::narrow_from_decl (d); - if (!attr) - return -1; - - if (!attr->readonly ()) - { - // the set method - ss->indent (); // start from current indentation level - *ss << "_set_" << d->local_name () << ",\t&" - << derived->full_skel_name () << "::_set_" - << d->local_name () << "_skel\n"; - derived->skel_count_++; - } - } - si->next (); - } // end of while - delete si; // free the iterator object - } - break; - - default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_interface", - "::", - "gen_optable_entries", - "unknown op_lookup_strategy"), - -1); - } - return 0; -} - -// 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_interface::traverse_inheritance_graph (be_interface::tao_code_emitter gen, - TAO_OutStream *os) -{ - long i; // loop index - ACE_Unbounded_Queue <be_interface*> queue; // Queue data structure needed for - // breadth-first traversal of - // inheritance tree - - // 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 . - - ACE_Unbounded_Queue <be_interface*> del_queue; // queue of dequeued nodes to - // be searched for the above case - - // insert ourselves in the Queue - if (queue.enqueue_tail (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::gen_operation_table - " - "error generating entries\n"), -1); - } - - // do until queue is empty - while (!queue.is_empty ()) - { - be_interface *bi; // 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. - - // dequeue the element at the head of the queue - if (queue.dequeue_head (bi)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::traverse_graph - " - "dequeue_head failed\n"), -1); - } - - // insert the dequeued element in the del_queue - if (del_queue.enqueue_tail (bi) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::traverse_graph - " - "enqueue_head failed\n"), -1); - } - - // 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 - if (gen (this, bi, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::traverse_graph - " - "helper code gen failed\n"), -1); - } - - // now check if the dequeued element has any ancestors. If yes, insert - // them inside the queue making sure that there are no duplicates - for (i=0; i < bi->n_inherits (); i++) - { - be_interface *parent; // parent of the dequeued element - - // initialize an iterator to search the queue for duplicates - ACE_Unbounded_Queue_Iterator<be_interface*> q_iter (queue); - - // retrieve the next parent from which the dequeued element inherits - parent = be_interface::narrow_from_decl (bi->inherits ()[i]); - if (!parent) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::gen_server_skeletons - " - "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; - while (!q_iter.done ()) - { - be_interface **temp; // queue element - - (void) q_iter.next (temp); - if (!ACE_OS::strcmp (parent->fullname (), (*temp)->fullname ())) - { - // we exist in this queue and cannot be inserted - found = 1; - } - if (found) - break; - (void) q_iter.advance (); - } // end of while - - // initialize an iterator to search the del_queue for duplicates - ACE_Unbounded_Queue_Iterator<be_interface*> del_q_iter (del_queue); - - while (!found && !del_q_iter.done ()) - { - be_interface **temp; // queue element - - (void) del_q_iter.next (temp); - if (!ACE_OS::strcmp (parent->fullname (), (*temp)->fullname ())) - { - // we exist in this del_queue and cannot be inserted - found = 1; - } - if (found) - break; - (void) del_q_iter.advance (); - } // end of while - - 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); - } - } - } // end of for loop - } // end of while queue not empty - return 0; -} - -// helpers passed to the template method - -int -be_interface::gen_optable_helper (be_interface *derived, - be_interface *ancestor, - TAO_OutStream * /*os*/) -{ - // generate entries for the derived class using the properties of its - // ancestors - if (ancestor->gen_optable_entries (derived) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interface::gen_operation_table - " - "error generating entries for inherited" - "interfaces\n"), -1); - } - return 0; -} - -// Run GPERF and get the correct lookup and other operations -// depending on which strategy we are using. Returns 0 on sucess, -1 -// on error. -int -be_interface::gen_gperf_things (void) -{ - // GPERF can give Binary search, Linear search and Perfect Hash - // methods. Generate the class defintion according to that. - - // Codegen singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // 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 - // we are following. - switch (cg->lookup_strategy ()) - { - case TAO_CodeGen::TAO_PERFECT_HASH: - // Output a class definition deriving from - // TAO_Perfect_Hash_OpTable. - gen_perfect_hash_class_definition (); - - // Call GPERF and get the methods defined. - if (gen_gperf_lookup_methods () == -1) - return -1; - - // Create an instance of the correct class corresponding the - // operation lookup strategy we are following. - gen_perfect_hash_instance (); - - break; - - case TAO_CodeGen::TAO_BINARY_SEARCH: - // Output a class definition deriving from - // TAO_Binary_Search_OpTable. - this->gen_binary_search_class_definition (); - - // Call GPERF and get the methods defined. - if (gen_gperf_lookup_methods () == -1) - return -1; - - // Create an instance of the correct class corresponding the - // operation lookup strategy we are following. - gen_binary_search_instance (); - - break; - - case TAO_CodeGen::TAO_LINEAR_SEARCH: - // Output a class definition deriving from - // TAO_Linear_Search_OpTable. - gen_linear_search_class_definition (); - - // Call GPERF and get the methods defined. - if (gen_gperf_lookup_methods () == -1) - return -1; - - // Create an instance of the correct class corresponding the - // operation lookup strategy we are following. - gen_linear_search_instance (); - - break; - - default: - ACE_ERROR_RETURN ((LM_ERROR, - "tao_idl:ERROR:%N:%l:Unknown Operation Lookup Strategy\n"), - -1); - } - - return 0; -} - - -// Outputs the class definition for the perfect hashing. This class -// will inherit from the TAO_Perfect_Hash_OpTable. -void -be_interface::gen_perfect_hash_class_definition (void) -{ - // Codegen singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); - - *ss << "class " << "TAO_" << this->flatname () << "_Perfect_Hash_OpTable" - << " : public TAO_Perfect_Hash_OpTable" - << be_nl - << "{" - << be_nl - << "private:" - << be_nl - << " unsigned int hash (const char *str, unsigned int len);" - << be_nl - << "public:" - << be_nl - << " const TAO_operation_db_entry * lookup (const char *str, unsigned int len);" - << be_nl - << "};" - << "\n"; -} - -// Outputs the class definition for the binary searching. This class -// will inherit from the TAO_Binary_Seach_OpTable. -void -be_interface::gen_binary_search_class_definition (void) -{ - // Codegen singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); - - *ss << "class " << "TAO_" << this->flatname () << "_Binary_Search_OpTable" - << " : public TAO_Binary_Search_OpTable" - << be_nl - << "{" - << be_nl - << "public:" - << be_nl - << " const TAO_operation_db_entry * lookup (const char *str);" - << be_nl - << "};" - << "\n"; -} - -// Outputs the class definition for the linear search. This class -// will inherit from the TAO_Linear_Search_OpTable. -void -be_interface::gen_linear_search_class_definition (void) -{ - // Codegen singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); - - *ss << "class " << "TAO_" << this->flatname () << "_Linear_Search_OpTable" - << " : public TAO_Linear_Search_OpTable" - << be_nl - << "{" - << be_nl - << "public:" - << be_nl - << " const TAO_operation_db_entry * lookup (const char *str);" - << be_nl - << "};" - << "\n"; -} - -// We have collected the input (Operations and the corresponding -// skeleton pointers) for the gperf program. Now let us execute gperf -// and get things done. -// GPERF reads from our temp file and write to the Server Skeleton -// file. -int -be_interface::gen_gperf_lookup_methods (void) -{ - // Using ACE_Process. - ACE_Process process_manager; - ACE_Process_Options process_options; - - // Codegen's singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Adjust the offset of the underlying file pointer. - ACE_OS::rewind (cg->gperf_input_stream ()->file ()); - - // Set the stdin and stdout appropriately for the gperf program. - - // Stdin is our temp file. Close the temp file and open. We will use - // <open_temp_file> to open the file now, so that the file will get - // deleted once when we close the file. - - // Close the file. - if (ACE_OS::fclose (cg->gperf_input_stream ()->file ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p:File close failed on temp gperf's input file\n"), - -1); - - // Open the temp file. - ACE_HANDLE input = ACE::open_temp_file (cg->gperf_input_filename (), - O_RDONLY); - - if (input == ACE_INVALID_HANDLE) - ACE_ERROR_RETURN ((LM_ERROR, - "%p:File open failed on gperf's temp input file\n"), - -1); - - // Stdout is server skeleton. Do *not* close the file, just open - // again with ACE_OS::open with WRITE + APPEND option.. After this, - // remember to update the file offset to the correct location. - - ACE_HANDLE output = ACE_OS::open (idl_global->be_get_server_skeleton_fname (), - O_WRONLY | O_APPEND); - if (output == ACE_INVALID_HANDLE) - ACE_ERROR_RETURN ((LM_ERROR, - "%p:File open failed on server skeleton file\n"), - -1); - - // Set the handles now in the process options. - process_options.set_handles (input, output); - - // Set the command line for the gperf program. Give the right - // arguments for the operation lookup strategy that we are using. - switch (cg->lookup_strategy ()) - { - // Perfect Hashing. - case TAO_CodeGen::TAO_PERFECT_HASH: - process_options.command_line ("%s" - " " - "-m -M -J -c -C" - " " - "-D -E -T -f 0" - " " - "-a -o -t -p -K" - " " - "opname_ -L C++" - " " - "-Z TAO_%s_Perfect_Hash_OpTable" - " " - "-N lookup", - idl_global->gperf_path (), - this->flatname ()); - break; - - // Binary search methods from GPERF. Everythis and the -B flag. - case TAO_CodeGen::TAO_BINARY_SEARCH: - process_options.command_line ("%s" - " " - "-B" - " " - "-m -M -J -c -C" - " " - "-D -E -T -f 0" - " " - "-a -o -t -p -K" - " " - "opname_ -L C++" - " " - "-Z TAO_%s_Binary_Search_OpTable" - " " - "-N lookup", - idl_global->gperf_path (), - this->flatname ()); - break; - - // Linear search methods from GPERF. Everything and the -z flag. - case TAO_CodeGen::TAO_LINEAR_SEARCH: - process_options.command_line ("%s" - " " - "-b" - " " - "-m -M -J -c -C" - " " - "-D -E -T -f 0" - " " - "-a -o -t -p -K" - " " - "opname_ -L C++" - " " - "-Z TAO_%s_Linear_Search_OpTable" - " " - "-N lookup", - idl_global->gperf_path (), - this->flatname ()); - break; - - default: - ACE_ERROR_RETURN ((LM_ERROR, - "tao_idl:ERROR:%N:%l:Unknown Operation Lookup Strategy\n"), - -1); - } - - - // Spawn a process for gperf. - if (process_manager.spawn (process_options) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "Error:%p:Couldnt spawn a process for gperf program\n"), - -1); - - // Wait for gperf to complete. - if (process_manager.wait () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "Error:%p:Error on wait'ing for completion of gperf program.\n"), - -1); - - // Adjust the file offset to the EOF for the server skeleton file. - ACE_OS::fseek (cg->server_skeletons ()->file (), 0, SEEK_END); - - return 0; -} - -// Create an instance of this perfect hash table. -void -be_interface::gen_perfect_hash_instance () -{ - // Codegen singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); - - *ss << "TAO_" << this->flatname () << "_Perfect_Hash_OpTable" - << " " - << "tao_" << this->flatname () << "_optable" - << ";" - << be_nl; -} - -// Create an instance of the binary search optable. -void -be_interface::gen_binary_search_instance () -{ - // Codegen singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); - - *ss << "TAO_" << this->flatname () << "_Binary_Search_OpTable" - << " " - << "tao_" << this->flatname () << "_optable" - << ";" - << be_nl; -} - -// Create an instance of this perfect hash table. -void -be_interface::gen_linear_search_instance () -{ - // Codegen singleton. - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); - - *ss << "TAO_" << this->flatname () << "_Linear_Search_OpTable" - << " " - << "tao_" << this->flatname () << "_optable" - << ";" - << 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"; - - return 0; -} - -int -be_interface::downcast_helper (be_interface * /* derived */, - be_interface *base, - TAO_OutStream *os) -{ - *os << "if (ACE_OS::strcmp (logical_type_id, \"" - << base->repoID () << "\") == 0)" << be_idt_nl - << "return ACE_static_cast (" - << base->full_skel_name () << "_ptr, this);" << be_uidt_nl; - return 0; -} - -int -be_interface::gen_skel_helper (be_interface *derived, - be_interface *ancestor, - TAO_OutStream *os) -{ - UTL_ScopeActiveIterator *si; - AST_Decl *d; - TAO_NL nl; // end line - - // if derived and ancestor are same, skip it - if (derived == ancestor) - 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 - - si = new UTL_ScopeActiveIterator (ancestor, UTL_Scope::IK_decls); - // instantiate a scope iterator. - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - if (d->node_type () == AST_Decl::NT_op) - { - os->indent (); // start from current indentation level - 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 - << "CORBA::ServerRequest &req, " << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &env =" << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << 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 " - << derived->full_skel_name () << "::" - << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &env" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - *os << ancestor->full_skel_name () - << "_ptr impl = (" - << derived->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 - << " env" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl - << "}\n"; - } - } - else if (d->node_type () == AST_Decl::NT_attr) - { - AST_Attribute *attr; - - attr = AST_Attribute::narrow_from_decl (d); - if (!attr) - return -1; - - os->indent (); // start from current indentation level - if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) - { - // generate the static method corresponding to this method - *os << "static void _get_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &env =" << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << 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 " - << derived->full_skel_name () << "::_get_" - << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &env" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << ancestor->full_skel_name () - << "_ptr impl = (" - << derived->full_skel_name () - << "_ptr) obj;" << nl; - *os << ancestor->full_skel_name () - << "::_get_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "req," << be_nl - << "(" << ancestor->full_skel_name () - << "_ptr) impl," << be_nl - << "context," << be_nl - << "env" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl - << "}\n"; - } - - if (!attr->readonly ()) - { - // the set method - os->indent (); // start from current indentation level - if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) - { - // generate the static method corresponding to - // this method - *os << "static void _set_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &env = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << 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 " - << derived->full_skel_name () - << "::_set_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &env" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << ancestor->full_skel_name () - << "_ptr impl = (" - << derived->full_skel_name () - << "_ptr) obj;" << be_nl; - *os << ancestor->full_skel_name () - << "::_get_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "req," << be_nl - << "(" << ancestor->full_skel_name () - << "_ptr) impl," << be_nl - << "context," << be_nl - << "env" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl - << "}\n"; - } - - } - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -int -be_interface::collocated_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; - - if (base->is_nested ()) - { - be_decl *scope; - scope = be_scope::narrow_from_scope (base->defined_in ())->decl (); - *os << " ACE_NESTED_CLASS (POA_" << scope->name () << "," - << base->local_coll_name () << ") (servant, stub)," << be_nl; - } - else - { - *os << " " << base->full_coll_name () << " (servant, stub)," << be_nl; - } - - return 0; -} - -int -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; - - if (base->is_nested ()) - { - be_decl *scope; - scope = be_scope::narrow_from_scope (base->defined_in ())->decl (); - *os << " ACE_NESTED_CLASS (POA_" << scope->name () << "," - << base->local_name () << ") (rhs)," << be_nl; - } - else - { - *os << " " << base->full_skel_name () << " (rhs)," << be_nl; - } - - return 0; -} - -int -be_interface::in_mult_inheritance_helper (be_interface *derived, - be_interface *base, - TAO_OutStream *) -{ - switch (derived->n_inherits ()) - { - case 0: - // no parent - derived->in_mult_inheritance (0); - break; - case 1: - if (derived == base) - // prevent indefinite recursion - derived->in_mult_inheritance (-1); - else - // one parent. We have the same characteristics as our base - derived->in_mult_inheritance (base->in_mult_inheritance ()); - break; - default: - // direct multiple inheritance - derived->in_mult_inheritance (1); - } - return 0; -} - -const char* -be_interface::relative_coll_name (const char *collname) -{ - return be_interface::relative_name (this->full_coll_name (), - collname); -} - -// return the relative skeleton name (needed due to NT compiler insanity) -const char * -be_interface::relative_skel_name (const char *skelname) -{ - return be_interface::relative_name (this->full_skel_name (), - skelname); -} - -const char* -be_interface::relative_name (const char *localname, - const char *othername) -{ - // 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. We have to emit just the partial name, relative to our - // "localname" - - // 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 - - static char macro [NAMEBUFSIZE]; - // UNUSED: be_decl *def_scope = 0; // our defining scope - char // hold the fully scoped name - def_name [NAMEBUFSIZE], - use_name [NAMEBUFSIZE]; - char // these point to the curr and next component in the scope - *def_curr = def_name, - *def_next, - *use_curr = use_name, - *use_next; - - ACE_OS::memset (macro, '\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 - - ACE_OS::strcpy (def_name, localname); - ACE_OS::strcpy (use_name, othername); - - 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) - *def_next = 0; - - if (use_next) - *use_next = 0; - - if (!ACE_OS::strcmp (def_curr, use_curr)) - { - // they have same prefix, append to arg1 - def_curr = (def_next ? (def_next+2) : 0); // skip the :: - use_curr = (use_next ? (use_next+2) : 0); // skip the :: - } - else - { - // we had overwritten a ':' by a '\0' for string comparison. We - // revert back because we want the rest of the relative name to be - // used - if (def_next) - *def_next = ':'; - - if (use_next) - *use_next = ':'; - - // 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 - - // copy the remaining def_name (if any left) - if (def_curr) - ACE_OS::strcat (macro, def_curr); - - return macro; -} - -int -be_interface::accept (be_visitor *visitor) -{ - return visitor->visit_interface (this); -} - -// Narrowing -IMPL_NARROW_METHODS3 (be_interface, AST_Interface, be_scope, be_type) -IMPL_NARROW_FROM_DECL (be_interface) -IMPL_NARROW_FROM_SCOPE (be_interface) - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Node <be_interface*>; -template class ACE_Unbounded_Queue <be_interface*>; -template class ACE_Unbounded_Queue_Iterator <be_interface*>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Node<be_interface*> -#pragma instantiate ACE_Unbounded_Queue<be_interface*> -#pragma instantiate ACE_Unbounded_Queue_Iterator<be_interface*> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/TAO_IDL/be/be_interface_fwd.cpp b/TAO/TAO_IDL/be/be_interface_fwd.cpp deleted file mode 100644 index 75bc5b02e0e..00000000000 --- a/TAO/TAO_IDL/be/be_interface_fwd.cpp +++ /dev/null @@ -1,518 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_interface.h -// -// = DESCRIPTION -// Extension of class AST_Interface_Fwd that provides additional means for C++ -// mapping of an interface. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_interface_fwd, "$Id$") - -/* - * BE_InterfaceFwd - */ - -be_interface_fwd::be_interface_fwd (void) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -be_interface_fwd::be_interface_fwd (UTL_ScopedName *n, UTL_StrList *p) - : AST_InterfaceFwd (n, p), - AST_Decl (AST_Decl::NT_interface_fwd, n, p) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -// generate the var definition -int -be_interface_fwd::gen_var_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_var", this->local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - ch->indent (); // start with whatever was our current indent level - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - - // default constr - *ch << namebuf << " (void); // default constructor" << nl; - *ch << namebuf << " (" << local_name () << "_ptr);" << nl; - - // copy constructor - *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << nl; - - // destructor - *ch << "~" << namebuf << " (void); // destructor" << nl; - *ch << nl; - - // assignment operator from a pointer - *ch << namebuf << " &operator= (" << local_name () << "_ptr);" << nl; - - // assignment from _var - *ch << namebuf << " &operator= (const " << namebuf << - " &);" << nl; - - // arrow operator - *ch << local_name () << "_ptr operator-> (void) const;" << nl; - - *ch << nl; - - // other extra types (cast operators, [] operator, and others) - *ch << "operator const " << local_name () << "_ptr &() const;" << nl; - *ch << "operator " << local_name () << "_ptr &();" << nl; - - *ch << "// in, inout, out, _retn " << nl; - // the return types of in, out, inout, and _retn are based on the parameter - // passing rules and the base type - *ch << local_name () << "_ptr in (void) const;" << nl; - *ch << local_name () << "_ptr &inout (void);" << nl; - *ch << local_name () << "_ptr &out (void);" << nl; - *ch << local_name () << "_ptr _retn (void);" << nl; - - // generate an additional member function that returns the underlying pointer - *ch << local_name () << "_ptr ptr (void) const;\n"; - - *ch << "\n"; - ch->decr_indent (); - - // private - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << "_ptr ptr_;\n"; - - ch->decr_indent (); - *ch << "};\n\n"; - - return 0; -} - -// implementation of the _var class. All of these get generated in the inline -// file -int -be_interface_fwd::gen_var_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local _var names - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - // generate the var implementation in the inline file - // Depending upon the data type, there are some differences which we account - // for over here. - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // default constr - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << - " (void) // default constructor" << nl; - *ci << " " << ": ptr_ (" << this->name () << "::_nil ())" << nl; - *ci << "{}\n\n"; - - // constr from a _ptr - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << "_ptr p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{}\n\n"; - - // 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. - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr " << nl; - *ci << fname << "::ptr (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << " : ptr_ (" << name () << "::_duplicate (p.ptr ()))" << nl; - *ci << "{}\n\n"; - - // destructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::~" << lname << " (void) // destructor" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << name () << - "_ptr p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _var - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "if (this != &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = " << name () << "::_duplicate (p.ptr ());\n"; - ci->decr_indent (); - *ci << "}" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator const " << name () << - "_ptr &() const // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << name () << "_ptr &() // cast " << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // operator-> - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr " << nl; - *ci << fname << "::operator-> (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // in, inout, out, and _retn - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr" << nl; - *ci << fname << "::in (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr &" << nl; - *ci << fname << "::inout (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr &" << nl; - *ci << fname << "::out (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = " << this->name () << "::_nil ();" << nl; - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << "_ptr " << nl; - *ci << fname << "::_retn (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "// yield ownership of managed obj reference" << nl; - *ci << this->name () << "_ptr val = this->ptr_;" << nl; - *ci << "this->ptr_ = " << this->name () << "::_nil ();" << nl; - *ci << "return val;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - return 0; -} - -// generate the _out definition -int -be_interface_fwd::gen_out_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // to hold the _out name - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the out definition (always in the client header) - ch->indent (); // start with whatever was our current indent level - - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - - // No default constructor - - // constructor from a pointer - *ch << namebuf << " (" << local_name () << "_ptr &);" << nl; - // constructor from a _var & - *ch << namebuf << " (" << local_name () << "_var &);" << nl; - // constructor from a _out & - *ch << namebuf << " (const " << namebuf << " &);" << nl; - // assignment operator from a _out & - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; - // assignment operator from a pointer &, cast operator, ptr fn, operator - // -> and any other extra operators - // only interface allows assignment from var & - *ch << namebuf << " &operator= (const " << local_name () << "_var &);" << nl; - *ch << namebuf << " &operator= (" << local_name () << "_ptr);" << nl; - // cast - *ch << "operator " << local_name () << "_ptr &();" << nl; - // ptr fn - *ch << local_name () << "_ptr &ptr (void);" << nl; - // operator -> - *ch << local_name () << "_ptr operator-> (void);" << nl; - - *ch << "\n"; - ch->decr_indent (); - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << "_ptr &ptr_;\n"; - - ch->decr_indent (); - *ch << "};\n\n"; - - return 0; -} - -int -be_interface_fwd::gen_out_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - 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_out", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - // generate the var implementation in the inline file - // Depending upon the data type, there are some differences which we account - // for over here. - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // constr from a _ptr - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << "_ptr &p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = " << this->name () << "::_nil ();\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // constructor from _var & - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << this->name () << - "_var &p) // constructor from _var" << nl; - *ci << " : ptr_ (p.out ())" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "CORBA::release (this->ptr_);" << nl; - *ci << "this->ptr_ = " << this->name () << "::_nil ();\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << " : ptr_ (ACE_const_cast (" << fname - << "&,p).ptr_)" << nl; - *ci << "{}\n\n"; - - // assignment operator from _out & - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = ACE_const_cast (" << fname << "&,p).ptr_;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _var - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << this->name () << - "_var &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = " << this->name () << "::_duplicate (p.ptr ());" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _ptr - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << this->name () << - "_ptr p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << this->name () << - "_ptr &() // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // ptr function - ci->indent (); - *ci << "ACE_INLINE " << this->name () << "_ptr &" << nl; - *ci << fname << "::ptr (void) // ptr" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // operator-> - ci->indent (); - *ci << "ACE_INLINE " << this->name () << "_ptr " << nl; - *ci << fname << "::operator-> (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - return 0; -} -int -be_interface_fwd::gen_typecode (void) -{ - return 0; -} - -long -be_interface_fwd::tc_size (void) -{ - return 0; -} - -int -be_interface_fwd::accept (be_visitor *visitor) -{ - return visitor->visit_interface_fwd (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_interface_fwd, AST_InterfaceFwd, be_type) -IMPL_NARROW_FROM_DECL (be_interface_fwd) diff --git a/TAO/TAO_IDL/be/be_module.cpp b/TAO/TAO_IDL/be/be_module.cpp deleted file mode 100644 index 1d2138b0264..00000000000 --- a/TAO/TAO_IDL/be/be_module.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_module.cpp -// -// = DESCRIPTION -// Extension of class AST_Module that provides additional means for C++ -// mapping of a module -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_module, "$Id$") - -/* - * BE_Module - */ -be_module::be_module (void) -{ -} - -be_module::be_module (UTL_ScopedName *n, UTL_StrList *p) - : AST_Decl (AST_Decl::NT_module, n, p), - UTL_Scope (AST_Decl::NT_module) -{ -} - -// compute the size type of the node in question -int -be_module::compute_size_type (void) -{ - // our size does not matter - return 0; -} - -int -be_module::accept (be_visitor *visitor) -{ - return visitor->visit_module (this); -} - -// Narrowing -IMPL_NARROW_METHODS3 (be_module, AST_Module, be_scope, be_decl) -IMPL_NARROW_FROM_DECL (be_module) -IMPL_NARROW_FROM_SCOPE (be_module) diff --git a/TAO/TAO_IDL/be/be_native.cpp b/TAO/TAO_IDL/be/be_native.cpp deleted file mode 100644 index 149d5956dee..00000000000 --- a/TAO/TAO_IDL/be/be_native.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_native.cpp -// -// = DESCRIPTION -// The native IDL type -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_native, "$Id$") - - -// be_native: New IDL type added by the POA spec -/* - * Constructor(s) - */ -be_native::be_native (void) -{ -} - -be_native::be_native (UTL_ScopedName *n, - UTL_StrList *p) - : AST_Native (n, p), - AST_Decl (AST_Decl::NT_native, n, p) -{ -} - -int -be_native::gen_typecode (void) -{ - return 0; -} - -long -be_native::tc_size (void) -{ - return 0; -} - -int -be_native::accept (be_visitor *visitor) -{ - return visitor->visit_native (this); -} - -// Narrowing -IMPL_NARROW_METHODS2(be_native, AST_Native, be_type) -IMPL_NARROW_FROM_DECL(be_native) diff --git a/TAO/TAO_IDL/be/be_operation.cpp b/TAO/TAO_IDL/be/be_operation.cpp deleted file mode 100644 index 76f834dd1ab..00000000000 --- a/TAO/TAO_IDL/be/be_operation.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_operation.cpp -// -// = DESCRIPTION -// Extension of class AST_Operation that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_operation, "$Id$") - -/* - * BE_Operation - */ -be_operation::be_operation (void) - : argument_count_ (-1), - has_native_ (0) -{ -} - -be_operation::be_operation (AST_Type *rt, AST_Operation::Flags fl, - UTL_ScopedName *n, UTL_StrList *p) - : AST_Operation (rt, fl, n, p), - AST_Decl (AST_Decl::NT_op, n, p), - UTL_Scope (AST_Decl::NT_op), - argument_count_ (-1), - has_native_ (0) -{ -} - -// compute total number of members -int -be_operation::compute_argument_attr (void) -{ - if (this->argument_count_ != -1) - return 0; - - this->argument_count_ = 0; - - // if there are elements in this scope - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - UTL_ScopeActiveIterator *si = - new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - // get the next AST decl node - AST_Decl *d = si->item (); - - if (d->node_type () == AST_Decl::NT_argument) - { - this->argument_count_++; - be_argument *arg = be_argument::narrow_from_decl (d); - be_type* type = - be_type::narrow_from_decl (arg->field_type ()); - - if (type->base_node_type () == AST_Decl::NT_native) - this->has_native_ = 1; - } - si->next (); - } // end of while - delete si; // free the iterator object - } - - be_type* type = be_type::narrow_from_decl (this->return_type ()); - if (type->base_node_type () == AST_Decl::NT_native) - this->has_native_ = 1; - - return 0; -} - -// return the member count -int -be_operation::argument_count (void) -{ - this->compute_argument_attr (); - - return this->argument_count_; -} - -// return if any argument or the return type is a <native> type. -int -be_operation::has_native (void) -{ - this->compute_argument_attr (); - - return this->has_native_; -} - -be_argument * -be_operation::add_argument_to_scope (be_argument *arg) -{ - this->add_to_scope (arg); - this->add_to_referenced (arg, 0); - return arg; -} - -// compute the size type of the node in question -int -be_operation::compute_size_type (void) -{ - UTL_ScopeActiveIterator *si; - AST_Decl *d; - be_decl *bd; - - if (this->nmembers () > 0) - { - // if there are elements in this scope - - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - // instantiate a scope iterator. - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - 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")); - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -int -be_operation::accept (be_visitor *visitor) -{ - return visitor->visit_operation (this); -} - -// Narrowing -IMPL_NARROW_METHODS3 (be_operation, AST_Operation, be_scope, be_decl) -IMPL_NARROW_FROM_DECL (be_operation) -IMPL_NARROW_FROM_SCOPE (be_operation) diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp deleted file mode 100644 index 4ca417ca519..00000000000 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ /dev/null @@ -1,470 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_predefined_type.cpp -// -// = DESCRIPTION -// Extension of class AST_PredefinedType that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_predefined_type, "$Id$") - -/* - * BE_PredefinedType - */ -be_predefined_type::be_predefined_type (void) -{ -} - -be_predefined_type::be_predefined_type (AST_PredefinedType::PredefinedType t, - UTL_ScopedName *n, UTL_StrList *p) - : AST_PredefinedType (t, n, p), - AST_Decl (AST_Decl::NT_pre_defined, n, p) -{ - // generate a new Scoped Name for us such that we belong to the CORBA - // namespace - if (this->pt () != AST_PredefinedType::PT_void) - { - - UTL_ScopedName *new_name = new UTL_ScopedName (new Identifier ("CORBA", 1, 0, - I_FALSE), - NULL); - switch (this->pt ()) - { - case AST_PredefinedType::PT_long: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Long", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_ulong: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("ULong", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_short: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Short", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_ushort: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("UShort", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_float: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Float", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_double: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Double", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_char: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Char", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_octet: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Octet", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_wchar: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("WChar", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_boolean: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Boolean", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_longlong: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("LongLong", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_ulonglong: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("ULongLong", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_longdouble: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("LongDouble", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_any: - { - new_name->nconc (new UTL_ScopedName (new Identifier ("Any", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_pseudo: - { - new_name->nconc (new UTL_ScopedName (new Identifier - (n->last_component - ()->get_string (), 1, 0, - I_FALSE), NULL)); - } - break; - default: - { - new_name->nconc (new UTL_ScopedName (this->local_name (), NULL)); - } - } - this->set_name (new_name); - } - - // computes the repoID - compute_repoID (); - - // computes the fully scoped name - compute_fullname (); - - // computes the fully scoped typecode name - compute_tc_name (); - - // compute the flattened fully scoped name - compute_flatname (); - - -} - -// overriden method -void -be_predefined_type::compute_tc_name (void) -{ - // start with the head as the CORBA namespace - this->tc_name_ = new UTL_ScopedName (new Identifier ("CORBA", 1, 0, I_FALSE), - NULL); - - switch (this->pt ()) - { - case AST_PredefinedType::PT_void: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_void", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_long: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_long", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_longlong: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_longlong", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_ulong: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_ulong", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_ulonglong: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_ulonglong", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_short: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_short", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_ushort: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_ushort", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_float: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_float", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_double: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_double", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_longdouble: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_longdouble", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_char: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_char", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_wchar: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_wchar", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_octet: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_octet", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_boolean: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_boolean", 1, 0, - I_FALSE), NULL)); - } - break; - case AST_PredefinedType::PT_any: - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier - ("_tc_any", - 1, 0, - I_FALSE), - NULL)); - } - break; - case AST_PredefinedType::PT_pseudo: - { - char tcname [100]; - ACE_OS::sprintf (tcname, "_tc_%s", - this->name ()->last_component ()->get_string ()); - this->tc_name_->nconc (new UTL_ScopedName (new Identifier - (ACE_OS::strdup (tcname), - 1, 0, - I_FALSE), NULL)); - } - break; - default: - ACE_ERROR ((LM_WARNING, "Unknown or invalid predefined type")); - break; - } -} - -int -be_predefined_type::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - // Macro to avoid "warning: unused parameter" type warning. - ACE_UNUSED_ARG (nl); - - cs = cg->client_stubs (); - cs->indent (); // start from the current indentation level - - switch (this->pt ()) - { - case AST_PredefinedType::PT_void: - *cs << "CORBA::tk_void,\n\n"; - break; - case AST_PredefinedType::PT_short: - *cs << "CORBA::tk_short,\n\n"; - break; - case AST_PredefinedType::PT_ushort: - *cs << "CORBA::tk_ushort,\n\n"; - break; - case AST_PredefinedType::PT_long: - *cs << "CORBA::tk_long,\n\n"; - break; - case AST_PredefinedType::PT_ulong: - *cs << "CORBA::tk_ulong,\n\n"; - break; - case AST_PredefinedType::PT_longlong: - *cs << "CORBA::tk_longlong,\n\n"; - break; - case AST_PredefinedType::PT_ulonglong: - *cs << "CORBA::tk_ulonglong,\n\n"; - break; - case AST_PredefinedType::PT_float: - *cs << "CORBA::tk_float,\n\n"; - break; - case AST_PredefinedType::PT_double: - *cs << "CORBA::tk_double,\n\n"; - break; - case AST_PredefinedType::PT_longdouble: - *cs << "CORBA::tk_longdouble,\n\n"; - break; - case AST_PredefinedType::PT_boolean: - *cs << "CORBA::tk_boolean,\n\n"; - break; - case AST_PredefinedType::PT_char: - *cs << "CORBA::tk_char,\n\n"; - break; - case AST_PredefinedType::PT_octet: - *cs << "CORBA::tk_octet,\n\n"; - break; - case AST_PredefinedType::PT_any: - *cs << "CORBA::tk_any,\n\n"; - break; - case AST_PredefinedType::PT_wchar: - *cs << "CORBA::tk_wchar,\n\n"; - break; - case AST_PredefinedType::PT_pseudo: - { - if (!ACE_OS::strcmp (this->local_name ()->get_string (), "TypeCode")) - *cs << "CORBA::tk_TypeCode,\n\n"; - else - if (!ACE_OS::strcmp (this->local_name ()->get_string (), "Object")) - { - *cs << "CORBA::tk_objref,\n"; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - this->gen_encapsulation (); - } - } - break; - } - return 0; -} - -long -be_predefined_type::tc_size (void) -{ - if (ACE_OS::strcmp (this->local_name ()->get_string (), "Object")) // not same - return 4; // for the enum value - else - return 4 + 4 + this->tc_encap_len (); -} - -long -be_predefined_type::tc_encap_len (void) -{ - if ((this->encap_len_ == -1) // not computed yet - && (!ACE_OS::strcmp (this->local_name ()->get_string (), "Object"))) - // is a CORBA::Object - { - this->encap_len_ = 4; // holds the byte order flag - - this->encap_len_ += this->repoID_encap_len (); // for repoID - - // do the same thing for the local name - this->encap_len_ += this->name_encap_len (); - } - - return this->encap_len_; -} - -int -be_predefined_type::gen_encapsulation (void) -{ - if ((this->pt () == AST_PredefinedType::PT_any) - || (this->pt () == AST_PredefinedType::PT_pseudo)) - { - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - ACE_UINT32 *arr; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - // XXXASG - byte order must be based on what m/c we are generating code - - // TODO - *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; - // generate repoID - *cs << (ACE_OS::strlen (this->repoID ())+1) << ", "; - (void)this->tc_name2long (this->repoID (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // repository ID = " << this->repoID () << nl; - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << ",\n"; - } - return 0; -} - -// compute the size type of the node in question -int -be_predefined_type::compute_size_type (void) -{ - switch (this->pt ()) - { - case AST_PredefinedType::PT_any: - case AST_PredefinedType::PT_pseudo: - // we are variable length type - this->size_type (be_decl::VARIABLE); - break; - default: - this->size_type (be_decl::FIXED); - } - return 0; -} - -void -be_predefined_type::compute_repoID (void) -{ - switch (this->pt ()) - { - case AST_PredefinedType::PT_pseudo: - if (!ACE_OS::strcmp (this->local_name ()->get_string (), "Object")) - this->repoID_ = ACE::strnew ("IDL:omg.org/CORBA/Object:1.0"); - else - be_decl::compute_repoID (); - break; - default: - be_decl::compute_repoID (); - break; - } -} - -int -be_predefined_type::accept (be_visitor *visitor) -{ - return visitor->visit_predefined_type (this); -} - -// 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 deleted file mode 100644 index 018984e65d7..00000000000 --- a/TAO/TAO_IDL/be/be_produce.cpp +++ /dev/null @@ -1,255 +0,0 @@ -// $Id$ - -/* - -COPYRIGHT - -Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United -States of America. All Rights Reserved. - -This product is protected by copyright and distributed under the following -license restricting its use. - -The Interface Definition Language Compiler Front End (CFE) is made -available for your use provided that you include this license and copyright -notice on all media and documentation and the software program in which -this product is incorporated in whole or part. You may copy and extend -functionality (but may not remove functionality) of the Interface -Definition Language CFE without charge, but you are not authorized to -license or distribute it to anyone else except as part of a product or -program developed by you or with the express written consent of Sun -Microsystems, Inc. ("Sun"). - -The names of Sun Microsystems, Inc. and any of its subsidiaries or -affiliates may not be used in advertising or publicity pertaining to -distribution of Interface Definition Language CFE as permitted herein. - -This license is effective until terminated by Sun for failure to comply -with this license. Upon termination, you shall destroy or return all code -and documentation for the Interface Definition Language CFE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF -ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS -FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF -DEALING, USAGE OR TRADE PRACTICE. - -INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT -ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES -TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT. - -SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH -RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY -INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF. - -IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR -ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL -DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -Use, duplication, or disclosure by the government is subject to -restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in -Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR -52.227-19. - -Sun, Sun Microsystems and the Sun logo are trademarks or registered -trademarks of Sun Microsystems, Inc. - -SunSoft, Inc. -2550 Garcia Avenue -Mountain View, California 94043 - -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" - -ACE_RCSID(be, be_produce, "$Id$") - -/* - * Do the work of this BE. This is the starting point for code generation. - */ - -void -BE_produce (void) -{ - be_root *root; // root of the AST made up of BE nodes - be_visitor *visitor; // visitor for root - be_visitor_context ctx; // context information for the visitor root - - // configure the CodeGen object with the strategy to generate the visitors - // that can produce interpretive or compiled marshaling stubs and skeletons - tao_cg->config_visitor_factory (); - - // get the root node and narrow it down to be the back-end root node - AST_Decl *d = idl_global->root (); - root = be_root::narrow_from_decl (d); - if (!root) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "No Root\n")); - BE_abort (); - } - - // Code generation involves six steps because of the six files that we - // generate. - - // (1) generate client header - // instantiate a visitor context - ctx.state (TAO_CodeGen::TAO_ROOT_CH); // set the codegen state - // 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 (); - } - // it is our responsibility to free up the visitor - delete visitor; - - // (2) generate client inline - // 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 (); - } - // it is our responsibility to free up the visitor - 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 (); - } - // it is our responsibility to free up the visitor - 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 (); - } - // it is our responsibility to free up the visitor - 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 (); - } - // it is our responsibility to free up the visitor - 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 (); - } - // it is our responsibility to free up the visitor - delete visitor; - - //check if the flags are set for generating the - //the implementation header and skeleton files - if(idl_global->gen_impl_files()) - { - // (7) generate implementation skeleton header - - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_IH); - // create a visitor - visitor = tao_cg->make_visitor (&ctx); - // generate code for the implementation skeleton header - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "implementation skeletons for Root failed\n")); - BE_abort (); - } - - // it is our responsibility to free up the visitor - delete visitor; - - // (8) generate implementation skeleton header - - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_IS); - // create a visitor - visitor = tao_cg->make_visitor (&ctx); - - // generate code for the implementation skeleton header - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "implementation skeletons for Root failed\n")); - BE_abort (); - } - - // it is our responsibility to free up the visitor - delete visitor; - } -} - -/* - * Abort this run of the BE - */ -void -BE_abort (void) -{ - ACE_ERROR ((LM_ERROR, - "Fatal Error - Aborting\n")); - ACE_OS::exit (1); -} diff --git a/TAO/TAO_IDL/be/be_root.cpp b/TAO/TAO_IDL/be/be_root.cpp deleted file mode 100644 index 43aa5ffa9ca..00000000000 --- a/TAO/TAO_IDL/be/be_root.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_root.cpp -// -// = DESCRIPTION -// Extension of class AST_Root that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_root, "$Id$") - -// Default Constructor -be_root::be_root (void) -{ -} - -// Constructor used to build the root of the abstract syntax tree (AST) -be_root::be_root (UTL_ScopedName *n, UTL_StrList *p) - : AST_Root (n, p), - AST_Decl (AST_Decl::NT_root, n, p), - UTL_Scope (AST_Decl::NT_root) - -{ -} - -// We had to provide these since the AST_Root::fe_* method was setting the -// names of these three to "local type" - -/* - * Add this AST_Sequence to the locally defined types in this scope - */ -AST_Sequence * -be_root::fe_add_sequence (AST_Sequence *t) -{ - if (t == NULL) - return NULL; - - add_to_local_types(t); - return t; -} - -/* - * Add this AST_String to the locally defined types in this scope - */ -AST_String * -be_root::fe_add_string (AST_String *t) -{ - if (t == NULL) - return NULL; - - add_to_local_types (t); - - return t; -} - -/* - * Add this AST_Array to the locally defined types in this scope - */ -AST_Array * -be_root::fe_add_array (AST_Array *t) -{ - if (t == NULL) - return NULL; - - add_to_local_types (t); - - return t; -} - -int -be_root::accept (be_visitor *visitor) -{ - return visitor->visit_root (this); -} - -/* - * Narrowing methods - */ -IMPL_NARROW_METHODS3 (be_root, AST_Root, be_scope, be_decl) -IMPL_NARROW_FROM_DECL (be_root) -IMPL_NARROW_FROM_SCOPE (be_root) diff --git a/TAO/TAO_IDL/be/be_scope.cpp b/TAO/TAO_IDL/be/be_scope.cpp deleted file mode 100644 index 24d3eb1daf4..00000000000 --- a/TAO/TAO_IDL/be/be_scope.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// -// $Id$ -// -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_scope, "$Id$") - - -// Default Constructor -be_scope::be_scope (void) - : comma_ (0) -{ -} - -// Constructor -be_scope::be_scope (AST_Decl::NodeType type) - : UTL_Scope (type), - comma_ (0) -{ -} - -be_scope::~be_scope (void) -{ -} - -// Code generation methods -void -be_scope::comma (unsigned short comma) -{ - this->comma_ = comma; -} - -int -be_scope::comma (void) const -{ - return this->comma_; -} - -int -be_scope::gen_encapsulation (void) -{ - UTL_ScopeActiveIterator *si; - AST_Decl *d; - be_decl *bd; - - // if there are elements in this scope - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - bd = be_decl::narrow_from_decl (d); - if (bd->gen_encapsulation () == -1) - { - // failure - return -1; - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -long -be_scope::tc_encap_len (void) -{ - UTL_ScopeActiveIterator *si; - AST_Decl *d; - be_decl *bd; - long encap_len = 0; - - if (this->nmembers () > 0) - { - // if there are elements in this scope - - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - // instantiate a scope iterator. - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - - // NOTE: Our assumptin here is that whatever scope we are in, the - // node type that shows up here *MUST* be valid according to the - // IDL grammar. We do not check for this since the front end must - // have taken care of weeding out such errors - - bd = be_decl::narrow_from_decl (d); - if (bd != 0) - { - encap_len += bd->tc_encap_len (); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l): be_scope::tc_encap_len - " - "narrow_from_decl returned 0\n")); - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return encap_len; -} - -// return the scope created by this node (if one exists, else NULL) -be_decl * -be_scope::decl (void) -{ - switch (this->scope_node_type()) - { - case AST_Decl::NT_interface: - return be_interface::narrow_from_scope (this); - case AST_Decl::NT_module: - return be_module::narrow_from_scope (this); - case AST_Decl::NT_root: - return be_root::narrow_from_scope (this); - case AST_Decl::NT_except: - return be_exception::narrow_from_scope (this); - case AST_Decl::NT_union: - return be_union::narrow_from_scope (this); - case AST_Decl::NT_struct: - return be_structure::narrow_from_scope (this); - case AST_Decl::NT_enum: - return be_enum::narrow_from_scope (this); - case AST_Decl::NT_op: - return be_operation::narrow_from_scope (this); - default: - return (be_decl *)0; - } -} - -int -be_scope::accept (be_visitor *visitor) -{ - return visitor->visit_scope (this); -} - -// narrowing methods -IMPL_NARROW_METHODS1 (be_scope, UTL_Scope) -IMPL_NARROW_FROM_SCOPE (be_scope) diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp deleted file mode 100644 index 2fca004ea58..00000000000 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ /dev/null @@ -1,451 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_sequence.cpp -// -// = DESCRIPTION -// Extension of class AST_Sequence that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_sequence.h" - -ACE_RCSID(be, be_sequence, "$Id$") - - -/* - * BE_Sequence - */ -be_sequence::be_sequence (void) - : mt_ (be_sequence::MNG_UNKNOWN) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -be_sequence::be_sequence (AST_Expression *v, AST_Type *t) - : AST_Sequence (v, t), - AST_Decl (AST_Decl::NT_sequence, - NULL, - NULL), - mt_ (be_sequence::MNG_UNKNOWN) -{ - // check if we are bounded or unbounded. An expression value of 0 means - // unbounded - if (v->ev ()->u.ulval == 0) - { - this->unbounded_ = I_TRUE; - } - else - { - this->unbounded_ = I_FALSE; - } - - this->size_type (be_decl::VARIABLE); // a sequence data type is always - // VARIABLE -} - -idl_bool -be_sequence::unbounded (void) const -{ - return this->unbounded_; -} - -// helper to create_name -char * -be_sequence::gen_name (void) -{ - char namebuf [NAMEBUFSIZE]; - be_type *bt; // base type; - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); // reset the buffer - // retrieve the base type - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_sequence::" - "gen_name - " - "bad base type\n"), - 0); - } - if (bt->node_type () == AST_Decl::NT_sequence) - { - // our base type is an anonymous sequence - be_sequence *seq; - seq = be_sequence::narrow_from_decl (bt); - if (!seq) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_sequence::" - "gen_name - " - "error converting base type to sequence\n"), - 0); - } - seq->set_defined_in (this); // set ourselves as its parent - this->fe_add_sequence (seq); // add the child to our scope - ACE_OS::sprintf (namebuf, "_tao_seq_%s", seq->gen_name ()); - } - else - { - ACE_OS::sprintf (namebuf, "_tao_seq_%s", bt->local_name ()->get_string ()); - } - // append the size (if any) - if (!this->unbounded_) - { - ACE_OS::sprintf (namebuf, "%s_%d", namebuf, this->max_size ()->ev - ()->u.ulval); - } - return ACE_OS::strdup (namebuf); -} - -// create a name for ourselves -int -be_sequence::create_name (be_typedef *node) -{ - static char namebuf [NAMEBUFSIZE]; - UTL_ScopedName *n = NULL; - be_decl *scope; // scope in which we are defined - - // if there is a typedef node, we use its name as our name - if (node) - { - n = (UTL_ScopedName *)node->name ()->copy (); - this->set_name (n); // set our name - } - else - { - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); // reset the buffer - ACE_OS::strcpy (namebuf, this->gen_name ()); // generate a local name - - // 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 () ; - - // add our local name as the last component - n->nconc (new UTL_ScopedName (new Identifier (ACE_OS::strdup - (namebuf), 1, - 0, I_FALSE), - NULL)); - // 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. - return -1; - } - } - return 0; -} - -// Does this sequence have a managed type sequence element? -be_sequence::MANAGED_TYPE -be_sequence::managed_type (void) -{ - if (this->mt_ == be_sequence::MNG_UNKNOWN) // not calculated yet - { - be_type *bt, *prim_type; // base types - - bt = be_type::narrow_from_decl (this->base_type ()); - - 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); - prim_type = t->primitive_base_type (); - } - else - prim_type = bt; - - // determine if we need a managed type and which one - switch (prim_type->node_type ()) - { - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - this->mt_ = be_sequence::MNG_OBJREF; - break; - case AST_Decl::NT_string: - this->mt_ = be_sequence::MNG_STRING; - break; - case AST_Decl::NT_pre_defined: - { - be_predefined_type *bpd = be_predefined_type::narrow_from_decl - (prim_type); - if (bpd->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; - } - else - { - this->mt_ = be_sequence::MNG_NONE; - } - } - break; - default: - this->mt_ = be_sequence::MNG_NONE; - } // end of switch - } - return this->mt_; -} - -// generate typecode. -// Typecode for sequences comprises the enumerated value followed by the -// encapsulation of the parameters - -int -be_sequence::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "CORBA::tk_sequence, // typecode kind" << nl; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - return this->gen_encapsulation (); -} - -// generate encapsulation -// An encapsulation for ourselves will be necessary when we are part of some -// other IDL type and a typecode for that other type is being generated. This -// will comprise our typecode kind. IDL types with parameters will additionally -// have the encapsulation length and the entire typecode description - -int -be_sequence::gen_encapsulation (void) -{ - TAO_OutStream *os; // output stream - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - be_type *bt; // base type - - os = cg->client_stubs (); - os->incr_indent (); - - *os << "TAO_ENCAP_BYTE_ORDER, // byte order\n"; - - // emit typecode of element type - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt || (bt->gen_typecode () == -1)) - { - ACE_ERROR ((LM_ERROR, "be_sequence::gen_typecode - bad base type\n")); - return -1; - } - - // emit the length - os->decr_indent (); - *os << this->max_size () << ",\n"; - return 0; -} - -// compute typecode size -long -be_sequence::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the - // actual encapsulation length - return 4 + 4 + this->tc_encap_len (); -} - -long -be_sequence::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - be_type *bt; // base type - - this->encap_len_ = 4; // holds the byte order flag - // add the encapsulation length of our base type - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_ERROR ((LM_ERROR, - "be_sequence::tc_encap_len - bad base type\n")); - return 0; - } - this->encap_len_ += bt->tc_size (); - this->encap_len_ += 4; // to hold the max size - - } - return this->encap_len_; -} - -/* - * Add this be_sequence to the locally defined types in this scope - */ -AST_Sequence * -be_sequence::fe_add_sequence (AST_Sequence *t) -{ - if (t == NULL) - return NULL; - - this->add_to_local_types(t); - return t; -} - -// overridden method -be_decl * -be_sequence::decl (void) -{ - return this; -} - -int -be_sequence::accept (be_visitor *visitor) -{ - return visitor->visit_sequence (this); -} - - -const char * -be_sequence::instance_name () -{ - static char namebuf[NAMEBUFSIZE]; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - - be_type *bt; - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_DEBUG ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_instantiate_name - " - "Bad element type\n")); - return namebuf; - } - - // generate the class name - - // the base type after removing all the aliases - be_type *prim_type = bt; - 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); - prim_type = t->primitive_base_type (); - } - - // generate the appropriate sequence type - switch (this->managed_type ()) - { - case be_sequence::MNG_PSEUDO: - case be_sequence::MNG_OBJREF: - if (this->unbounded ()) - ACE_OS::sprintf (namebuf, - "_TAO_Unbounded_Object_Sequence_%s", - this->flatname()); - else - ACE_OS::sprintf (namebuf, - "_TAO_Bounded_Object_Sequence_%s_%d", - this->flatname(), - this->max_size ()->ev()->u.ulval); - break; - case be_sequence::MNG_STRING: // sequence of strings - if (this->unbounded ()) - ACE_OS::sprintf (namebuf, - "TAO_Unbounded_String_Sequence"); - else - ACE_OS::sprintf (namebuf, - "_TAO_Bounded_String_Sequence_%s", - this->flatname()); - break; - default: // not a managed type - if (this->unbounded ()) - { - // TAO provides extensions for octet sequences, first find out - // if the base type is an octet (or an alias for octet) - be_predefined_type *predef = - be_predefined_type::narrow_from_decl (prim_type); - if (predef != 0 && - predef->pt() == AST_PredefinedType::PT_octet) - ACE_OS::sprintf (namebuf, - "TAO_Unbounded_Sequence<CORBA::Octet>"); - else - ACE_OS::sprintf (namebuf, - "_TAO_Unbounded_Sequence_%s", - this->flatname()); - // or prim_type->flatname ()); - // ACE_DEBUG ((LM_DEBUG, "testing.... %d, %d = <%s>\n", - // predef, predef->pt (), namebuf)); - } - else - ACE_OS::sprintf (namebuf, - "_TAO_Bounded_Sequence_%s_%d", - this->flatname(), - //prim_type->flatname (), - this->max_size()->ev()->u.ulval); - break; - } - - return namebuf; -} - - -const char * -be_sequence::object_manager_name () -{ - static char namebuf[NAMEBUFSIZE]; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - - be_type *bt; - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_DEBUG ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_instantiate_name - " - "Bad element type\n")); - return namebuf; - } - - be_scope * bs = be_scope::narrow_from_scope (this->defined_in()); - - if (!bs) - { - ACE_DEBUG ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_instantiate_name - " - "Bad element type\n")); - return namebuf; - } - - ACE_OS::sprintf (namebuf, - "_TAO_Object_Manager_%s_%s", - bs->decl()->flatname(), - bt->flatname()); - - - return namebuf; -} - - -// Narrowing -IMPL_NARROW_METHODS3 (be_sequence, AST_Sequence, be_scope, be_type) -IMPL_NARROW_FROM_DECL (be_sequence) diff --git a/TAO/TAO_IDL/be/be_stream_factory.cpp b/TAO/TAO_IDL/be/be_stream_factory.cpp deleted file mode 100644 index bb662d03c5b..00000000000 --- a/TAO/TAO_IDL/be/be_stream_factory.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// $Id$ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_sunsoft.h" - -ACE_RCSID(be, be_factory, "$Id$") - -// constructor -TAO_OutStream_Factory::TAO_OutStream_Factory (void) - : strm_type_ (TAO_OutStream_Factory::TAO_SUNSOFT) -{ -} - -// destructor -TAO_OutStream_Factory::~TAO_OutStream_Factory (void) -{ -} - -// set the type of specialized o/p stream we want -int -TAO_OutStream_Factory::set_stream_type -(TAO_OutStream_Factory::TAO_OutStream_Type t) -{ - this->strm_type_ = t; - return 0; -} - -// factory method -TAO_OutStream * -TAO_OutStream_Factory::make_outstream (void) -{ - switch (this->strm_type_) - { - case TAO_OutStream_Factory::TAO_SUNSOFT: - return new TAO_SunSoft_OutStream (); - case TAO_OutStream_Factory::TAO_FLICK: - return (TAO_OutStream *)0; // not implemented as yet - default: - return (TAO_OutStream *)0; - } -} diff --git a/TAO/TAO_IDL/be/be_string.cpp b/TAO/TAO_IDL/be/be_string.cpp deleted file mode 100644 index ba4a3c87277..00000000000 --- a/TAO/TAO_IDL/be/be_string.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_string.cpp -// -// = DESCRIPTION -// Extension of class AST_Array that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_string, "$Id$") - - -/* - * BE_String - */ -be_string::be_string (void) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -be_string::be_string (AST_Expression *v) - : AST_String (v), - AST_Decl (AST_Decl::NT_string, - new UTL_ScopedName(new Identifier("string", 1, 0, I_FALSE), - NULL), - NULL) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -be_string::be_string (AST_Expression *v, long wide) - : AST_String (v, wide), - AST_Decl (AST_Decl::NT_string, - wide == 1 - ? new UTL_ScopedName(new Identifier("string",1,0,I_FALSE), - NULL) - : new UTL_ScopedName(new Identifier("wstring_t", - 1, - 0, - I_FALSE), - NULL), - NULL) -{ - this->size_type (be_decl::VARIABLE); // always the case -} - -// overriden method -void -be_string::compute_tc_name (void) -{ - // start with the head as the CORBA namespace - this->tc_name_ = new UTL_ScopedName (new Identifier ("CORBA", 1, 0, I_FALSE), - NULL); - - this->tc_name_->nconc (new UTL_ScopedName (new Identifier ("_tc_string", 1, 0, - I_FALSE), NULL)); -} - -int -be_string::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from the current indentation level - // emit the enumeration - *cs << "CORBA::tk_string, " << nl; - *cs << this->max_size () << ", // string length\n"; - return 0; -} - -// compute typecode size -long -be_string::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing string length - return 4 + 4; -} - -int -be_string::gen_encapsulation (void) -{ - return 0; -} - -long -be_string::tc_encap_len (void) -{ - if (this->encap_len_ == -1) - { - this->encap_len_ = 0; // no encapsulation - } - return this->encap_len_; -} - -int -be_string::accept (be_visitor *visitor) -{ - return visitor->visit_string (this); -} - -// 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 deleted file mode 100644 index 3073c59e1f3..00000000000 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ /dev/null @@ -1,720 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_structure.cpp -// -// = DESCRIPTION -// Extension of class AST_Structure that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_structure, "$Id$") - - -/* - * BE_Structure - */ -be_structure::be_structure (void) -{ -} - -be_structure::be_structure (UTL_ScopedName *n, UTL_StrList *p) - : AST_Decl (AST_Decl::NT_struct, n, p), - UTL_Scope (AST_Decl::NT_struct), - member_count_ (-1) -{ -} - -// compute total number of members -int -be_structure::compute_member_count (void) -{ - UTL_ScopeActiveIterator *si; // iterator - - this->member_count_ = 0; - - // if there are elements in this scope - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - this->member_count_++; - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -// return the member count -int -be_structure::member_count (void) -{ - if (this->member_count_ == -1) - this->compute_member_count (); - - return this->member_count_; -} - -// generate the _var definition for ourself -int -be_structure::gen_var_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_var", this->local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - ch->indent (); // start with whatever was our current indent level - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - // default constr - *ch << namebuf << " (void); // default constructor" << nl; - // constr - *ch << namebuf << " (" << local_name () << " *);" << nl; - // copy constructor - *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << nl; - // destructor - *ch << "~" << namebuf << " (void); // destructor" << nl; - *ch << nl; - // assignment operator from a pointer - *ch << namebuf << " &operator= (" << local_name () << " *);" << nl; - // assignment from _var - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; - - // arrow operator - *ch << local_name () << " *operator-> (void);" << nl; - *ch << "const " << local_name () << " *operator-> (void) const;" << nl; - *ch << nl; - - // other extra types (cast operators, [] operator, and others) - *ch << "operator const " << local_name () << " &() const;" << nl; - *ch << "operator " << local_name () << " &();" << nl; - *ch << "operator " << local_name () << " &() const;" << nl; - *ch << "// in, inout, out, _retn " << nl; - // 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) - { - *ch << "const " << local_name () << " &in (void) const;" << nl; - *ch << local_name () << " &inout (void);" << nl; - *ch << local_name () << " &out (void);" << nl; - *ch << local_name () << " _retn (void);" << nl; - } - else - { - *ch << "const " << local_name () << " &in (void) const;" << nl; - *ch << local_name () << " &inout (void);" << nl; - *ch << local_name () << " *&out (void);" << nl; - *ch << local_name () << " *_retn (void);" << nl; - } - - // generate an additional member function that returns the underlying pointer - *ch << local_name () << " *ptr (void) const;\n"; - - *ch << "\n"; - ch->decr_indent (); - - // generate the private section - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << " *ptr_;\n"; - ch->decr_indent (); - *ch << "};\n\n"; - - return 0; -} - -// implementation of the _var class. All of these get generated in the inline -// file -int -be_structure::gen_var_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local _var names - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // default constr - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << - " (void) // default constructor" << nl; - *ci << " " << ": ptr_ (0)" << nl; - *ci << "{}\n\n"; - - // constr from a pointer - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << " *p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "if (p.ptr_)" << nl; - *ci << " this->ptr_ = new " << this->name () << "(*p.ptr_);" << nl; - *ci << "else" << nl; - *ci << " this->ptr_ = 0;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // destructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::~" << lname << " (void) // destructor" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from a pointer - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << name () << - " *p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _var - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "if (this != &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = new " << this->name () << " (*p.ptr_);\n"; - ci->decr_indent (); - *ci << "}" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // two arrow operators - ci->indent (); - *ci << "ACE_INLINE const " << this->name () << " *" << nl; - *ci << fname << "::operator-> (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - 3 cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator const " << name () << - " &() const // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << name () << " &() // cast " << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << name () << " &() const// cast " << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // in, inout, out, and _retn - ci->indent (); - *ci << "ACE_INLINE const " << name () << " &" << nl; - *ci << fname << "::in (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << " &" << nl; - *ci << fname << "::inout (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // the out is handled differently based on our size type - ci->indent (); - if (this->size_type () == be_decl::VARIABLE) - { - *ci << "// mapping for variable size " << nl; - *ci << "ACE_INLINE " << name () << " *&" << nl; - *ci << fname << "::out (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << " *" << nl; - *ci << fname << "::_retn (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << this->name () << " *tmp = this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; - *ci << "return tmp;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - } - else - { - *ci << "// mapping for fixed size " << nl; - *ci << "ACE_INLINE " << name () << " &" << nl; - *ci << fname << "::out (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << nl; - *ci << fname << "::_retn (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - } - - // the additional ptr () member function - ci->indent (); - *ci << "ACE_INLINE " << name () << " *" << nl; - *ci << fname << "::ptr (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - return 0; -} - -// generate the _out definition -int -be_structure::gen_out_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // to hold the _out name - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the out definition (always in the client header) - ch->indent (); // start with whatever was our current indent level - - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - - // No default constructor - - // constructor from a pointer - *ch << namebuf << " (" << local_name () << " *&);" << nl; - // constructor from a _var & - *ch << namebuf << " (" << local_name () << "_var &);" << nl; - // constructor from a _out & - *ch << namebuf << " (const " << namebuf << " &);" << nl; - // assignment operator from a _out & - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; - // assignment operator from a pointer &, cast operator, ptr fn, operator - // -> and any other extra operators - // assignment - *ch << namebuf << " &operator= (" << local_name () << " *);" << nl; - // operator () - *ch << "operator " << local_name () << " *&();" << nl; - // ptr fn - *ch << local_name () << " *&ptr (void);" << nl; - // operator -> - *ch << local_name () << " *operator-> (void);" << nl; - - *ch << "\n"; - ch->decr_indent (); - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << " *&ptr_;" << nl; - *ch << "// assignment from T_var not allowed" << nl; - *ch << "void operator= (const " << local_name () << "_var &);\n"; - - ch->decr_indent (); - *ch << "};\n\n"; - return 0; -} - -int -be_structure::gen_out_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - 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_out", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - // generate the var implementation in the inline file - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // constr from a pointer - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << " *&p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = 0;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // constructor from _var & - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << this->name () << - "_var &p) // constructor from _var" << nl; - *ci << " : ptr_ (p.out ())" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = 0;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << " : ptr_ (ACE_const_cast (" << fname << "&,p).ptr_)" << nl; - *ci << "{}\n\n"; - - // assignment operator from _out & - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = ACE_const_cast (" << fname << "&,p).ptr_;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment from _var is not allowed by a private declaration - - // assignment operator from pointer - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << this->name () << - " *p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << this->name () << - " *&() // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // ptr function - ci->indent (); - *ci << "ACE_INLINE " << this->name () << " *&" << nl; - *ci << fname << "::ptr (void) // ptr" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // operator -> - ci->indent (); - *ci << "ACE_INLINE " << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - - return 0; -} - -// generate typecode. -// Typecode for structures comprises the enumerated value followed by the -// encapsulation of the parameters - -int -be_structure::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "CORBA::tk_struct, // typecode kind" << nl; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - cs->incr_indent (0); - if (this->gen_encapsulation () == -1) - { - return -1; - } - cs->decr_indent (); - return 0; -} - -// generate encapsulation -// An encapsulation for ourselves will be necessary when we are part of some -// other IDL type and a typecode for that other type is being generated. This -// will comprise our typecode kind. IDL types with parameters will additionally -// have the encapsulation length and the entire typecode description -int -be_structure::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - ACE_UINT32 *arr; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; - // generate repoID - *cs << (ACE_OS::strlen (this->repoID ())+1) << ", "; - (void)this->tc_name2long (this->repoID (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // repository ID = " << this->repoID () << nl; - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << nl; - // generate the member count - *cs << this->member_count () << ", // member count\n"; - cs->incr_indent (0); - // hand over to the scope to generate the typecode for elements - if (be_scope::gen_encapsulation () == -1) - { - ACE_ERROR ((LM_ERROR, "be_structure: cannot generate typecode for members\n")); - return -1; - } - cs->decr_indent (0); - return 0; -} - -// compute typecode size -long -be_structure::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the - // actual encapsulation length - return 4 + 4 + this->tc_encap_len (); -} - -// compute encapsulation length -long -be_structure::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - this->encap_len_ = 4; // holds the byte order flag - - this->encap_len_ += this->repoID_encap_len (); // repoID - - // do the same thing for the local name - this->encap_len_ += this->name_encap_len (); - - this->encap_len_ += 4; // to hold the member count - - // compute encap length for members - this->encap_len_ += be_scope::tc_encap_len (); - } - return this->encap_len_; -} - -// compute the size type of the node in question -int -be_structure::compute_size_type (void) -{ - UTL_ScopeActiveIterator *si; - AST_Decl *d; - be_decl *bd; - - if (this->nmembers () > 0) - { - // if there are elements in this scope - - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - // instantiate a scope iterator. - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - 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_structure::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -int -be_structure::accept (be_visitor *visitor) -{ - return visitor->visit_structure (this); -} - -// Narrowing -IMPL_NARROW_METHODS3 (be_structure, AST_Structure, be_scope, be_type) -IMPL_NARROW_FROM_DECL (be_structure) -IMPL_NARROW_FROM_SCOPE (be_structure) diff --git a/TAO/TAO_IDL/be/be_sunsoft.cpp b/TAO/TAO_IDL/be/be_sunsoft.cpp deleted file mode 100644 index 442d693007e..00000000000 --- a/TAO/TAO_IDL/be/be_sunsoft.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// $Id$ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_sunsoft.h" - -ACE_RCSID(be, be_sunsoft, "$Id$") - - -TAO_SunSoft_OutStream::TAO_SunSoft_OutStream (void) - : TAO_OutStream () -{ -} - -TAO_SunSoft_OutStream::~TAO_SunSoft_OutStream (void) -{ -} - -TAO_OutStream & -TAO_SunSoft_OutStream::print (Identifier *id) -{ - ACE_OS::fprintf (this->fp_, id->get_string ()); - return *this; -} - -TAO_OutStream & -TAO_SunSoft_OutStream::print (UTL_IdList *idl) -{ - UTL_IdListActiveIterator *i = new UTL_IdListActiveIterator (idl); - long first = I_TRUE; - long second = I_FALSE; - - while (!(i->is_done ())) - { - if (!first) - *this << "::"; - else if (second) - first = second = I_FALSE; - // print the identifier - *this << i->item (); - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - // does not start with a "" - first = I_FALSE; - else - second = I_TRUE; - } - i->next (); - } - return *this; -} - -TAO_OutStream& -TAO_SunSoft_OutStream::print (AST_Expression *expr) -{ - AST_Expression::AST_ExprValue *ev = expr->ev (); - - if (ev) - { - switch (ev->et) - { - case AST_Expression::EV_short: - this->TAO_OutStream::print ("%hd", ev->u.sval); - break; - case AST_Expression::EV_ushort: - this->TAO_OutStream::print ("%hu", ev->u.usval); - break; - case AST_Expression::EV_long: - this->TAO_OutStream::print ("%ld", ev->u.lval); - break; - case AST_Expression::EV_ulong: - this->TAO_OutStream::print ("%ld", ev->u.ulval); - break; - case AST_Expression::EV_longlong: - break; - case AST_Expression::EV_ulonglong: - break; - case AST_Expression::EV_float: - this->TAO_OutStream::print ("%f", ev->u.fval); - break; - case AST_Expression::EV_double: - this->TAO_OutStream::print ("%f", ev->u.dval); - break; - case AST_Expression::EV_longdouble: - break; - case AST_Expression::EV_char: - if (isprint (ev->u.cval)) - this->TAO_OutStream::print ("'%c'", ev->u.cval); - else if (iscntrl (ev->u.cval)) - switch (ev->u.cval) - { - case '\n': - this->TAO_OutStream::print ("'\\n'"); - break; - case '\t': - this->TAO_OutStream::print ("'\\t'"); - break; - case '\r': - this->TAO_OutStream::print ("'\\r'"); - break; - case '\v': - this->TAO_OutStream::print ("'\\v'"); - break; - case '\f': - this->TAO_OutStream::print ("'\\f'"); - break; - case '\b': - this->TAO_OutStream::print ("'\\b'"); - break; - case '\a': - this->TAO_OutStream::print ("'\\a'"); - break; - default: - this->TAO_OutStream::print ("'\\x%x'", ev->u.cval); - } - else - this->TAO_OutStream::print ("'\\x%x'", ev->u.cval); - break; - case AST_Expression::EV_wchar: - break; - case AST_Expression::EV_octet: - this->TAO_OutStream::print ("%d", ev->u.oval); - break; - case AST_Expression::EV_bool: - this->TAO_OutStream::print ("%ld", ev->u.bval); - break; - case AST_Expression::EV_string: - this->TAO_OutStream::print ("\"%s\"", ev->u.strval->get_string ()); - break; - case AST_Expression::EV_wstring: - break; - default: - break; - } - } - else // - { - // XXXASG: need to add code here - } - return *this; -} diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp deleted file mode 100644 index 19c96513ca8..00000000000 --- a/TAO/TAO_IDL/be/be_type.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_type.cpp -// -// = DESCRIPTION -// Extension of class AST_Type that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_type, "$Id$") - - -/* - * BE_Type - */ - -be_type::be_type (void) - : tc_name_ (0), - type_name_ (0), - nested_type_name_ (0) -{ -} - -be_type::be_type (AST_Decl::NodeType nt, UTL_ScopedName *n, UTL_StrList *p) - : AST_Decl (nt, n, p), - tc_name_ (0), - type_name_ (0), - nested_type_name_ (0) -{ -} - -be_type::~be_type (void) -{ - if (this->nested_type_name_ != 0) - { - delete[] this->nested_type_name_; - this->nested_type_name_ = 0; - } -} - -// compute the typecode name. The idea is to use the fully scoped name, -// however, prepend a _tc_ to the last component. A slightly different approach -// is required of the predefined types. Hence this method is overridden for -// predefined types. - -void -be_type::compute_tc_name (void) -{ - static char namebuf [NAMEBUFSIZE]; - UTL_ScopedName *n; - - this->tc_name_ = NULL; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - n = this->name (); - while (n->tail () != NULL) - { - if (!this->tc_name_) - { - // does not exist - this->tc_name_ = new UTL_ScopedName (n->head (), NULL); - } - else - { - this->tc_name_->nconc (new UTL_ScopedName (n->head (), NULL)); - } - n = (UTL_ScopedName *)n->tail (); - } - ACE_OS::sprintf (namebuf, "_tc_%s", n->last_component ()->get_string ()); - if (!this->tc_name_) - { - // does not exist - this->tc_name_ = new UTL_ScopedName (new Identifier (ACE_OS::strdup - (namebuf), 1, 0, I_FALSE), NULL); - } - else - { - this->tc_name_->nconc (new UTL_ScopedName (new Identifier (ACE_OS::strdup - (namebuf), 1, - 0, I_FALSE), NULL)); - } - return; -} - -// retrieve typecode name -UTL_ScopedName * -be_type::tc_name (void) -{ - if (!this->tc_name_) - compute_tc_name (); - - return this->tc_name_; -} - -// XXXASG - This code works. However, whether we should generate the -// ACE_NESTED_CLASS macro or not should be based on an option to the -// compiler. In this version, we choose to generate a relative path. - -// 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) -{ - // 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); - - be_decl *def_scope = 0; // our defining scope - char // hold the fully scoped name - def_name [NAMEBUFSIZE], - use_name [NAMEBUFSIZE]; - char // these point to the curr and next component in the scope - *def_curr = def_name, - *def_next, - *use_curr = use_name, - *use_next; - - 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->fullname ()); - ACE_OS::strcpy (use_name, use_scope->fullname ()); - - // 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) - *def_next = 0; - - if (use_next) - *use_next = 0; - - if (!ACE_OS::strcmp (def_curr, use_curr)) - { - // 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 ("); - //@@ ACE_OS::strcat (this->nested_type_name_, def_curr); // initialize the first argument - - 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) - *def_next = 0; - - if (use_next) - *use_next = 0; - - if (!ACE_OS::strcmp (def_curr, use_curr)) - { - // they have same prefix, append to arg1 - //@@ ACE_OS::strcat (this->nested_type_name_, "::"); - //@@ ACE_OS::strcat (this->nested_type_name_, def_curr); - 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 left) - if (def_curr) - { - ACE_OS::strcat (this->nested_type_name_, def_curr); - ACE_OS::strcat (this->nested_type_name_, "::"); - } - - // append our local name - if (prefix) - ACE_OS::strcat (this->nested_type_name_, prefix); - ACE_OS::strcat (this->nested_type_name_, this->local_name ()->get_string ()); - if (suffix) - 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 fullname - if (prefix) - ACE_OS::strcat (this->nested_type_name_, prefix); - ACE_OS::strcat (this->nested_type_name_, this->fullname ()); - if (suffix) - ACE_OS::strcat (this->nested_type_name_, suffix); - - return this->nested_type_name_; -} - -// ***************************** -// CODE GENERATION -// ***************************** - -// generate the _var definition for ourself -int -be_type::gen_var_defn (void) -{ - return 0; -} - -// implementation of the _var class. All of these get generated in the inline -// file -int -be_type::gen_var_impl (void) -{ - return 0; -} - -// generate the _out definition -int -be_type::gen_out_defn (void) -{ - return 0; -} - -int -be_type::gen_out_impl (void) -{ - return 0; -} - -AST_Decl::NodeType be_type::base_node_type (void) const -{ - return ACE_const_cast(be_type*, this)->node_type (); -} - -int -be_type::accept (be_visitor *visitor) -{ - return visitor->visit_type (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_type, AST_Type, be_decl) -IMPL_NARROW_FROM_DECL (be_type) diff --git a/TAO/TAO_IDL/be/be_typedef.cpp b/TAO/TAO_IDL/be/be_typedef.cpp deleted file mode 100644 index f07db98f150..00000000000 --- a/TAO/TAO_IDL/be/be_typedef.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_typedef.cpp -// -// = DESCRIPTION -// Extension of class AST_Typedef that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_typedef, "$Id$") - - -be_typedef::be_typedef (void) -{ -} - -be_typedef::be_typedef (AST_Type *bt, UTL_ScopedName *n, UTL_StrList *p) - : AST_Typedef (bt, n, p), - AST_Decl (AST_Decl::NT_typedef, n, p) -{ -} - -// given a typedef node, traverse the chain of base types until they are no -// more typedefs, and return that most primitive base type -be_type * -be_typedef::primitive_base_type (void) -{ - be_type *d; - - d = this; - while (d && d->node_type () == AST_Decl::NT_typedef) - { - be_typedef *temp; // temporary - - temp = be_typedef::narrow_from_decl (d); - d = be_type::narrow_from_decl (temp->base_type ()); - } - return d; -} - -int -be_typedef::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "CORBA::tk_alias, // typecode kind for typedefs" << nl; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - cs->incr_indent (0); - if (this->gen_encapsulation () == -1) - { - return -1; - } - - cs->decr_indent (0); - return 0; -} - -// generate encapsulation. A typedef is an alias to its base type -int -be_typedef::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - ACE_UINT32 *arr; - be_type *bt; // base type - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; - // generate repoID - *cs << (ACE_OS::strlen (this->repoID ())+1) << ", "; - (void)this->tc_name2long (this->repoID (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // repository ID = " << this->repoID () << nl; - - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << "\n"; - - // generate typecode for the base type - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt || (bt->gen_typecode () == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_typedef::gen_encapsulation failed for base type\n"), - -1); - } - return 0; -} - -long -be_typedef::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the - // actual encapsulation length - return 4 + 4 + this->tc_encap_len (); -} - -long -be_typedef::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - be_type *bt; // base type - this->encap_len_ = 4; // holds the byte order flag - - this->encap_len_ += this->repoID_encap_len (); // repoID - - // do the same thing for the local name - this->encap_len_ += this->name_encap_len (); - - // add the encapsulation length of our base type - bt = be_type::narrow_from_decl (this->base_type ()); - if (!bt) - { - ACE_ERROR ((LM_ERROR, - "be_typedef::tc_encap_len - bad base type\n")); - return 0; - } - this->encap_len_ += bt->tc_size (); - - } - return this->encap_len_; -} - -// 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) - { - 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 ()); - return 0; -} - -AST_Decl::NodeType be_typedef::base_node_type (void) const -{ - be_type *base = be_type::narrow_from_decl (ACE_const_cast(be_typedef*, this)->base_type ()); - return base->base_node_type (); -} - -int -be_typedef::accept (be_visitor *visitor) -{ - return visitor->visit_typedef (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_typedef, AST_Typedef, be_type) -IMPL_NARROW_FROM_DECL (be_typedef) diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp deleted file mode 100644 index 6a07d15fd6a..00000000000 --- a/TAO/TAO_IDL/be/be_union.cpp +++ /dev/null @@ -1,788 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_union.cpp -// -// = DESCRIPTION -// Extension of class AST_Union that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_union, "$Id$") - - -/* - * BE_Union - */ - -be_union::be_union (void) -{ -} - -be_union::be_union (AST_ConcreteType *dt, UTL_ScopedName *n, UTL_StrList *p) - : AST_Union (dt, n, p), - AST_Structure (AST_Decl::NT_union, n, p), - AST_Decl (AST_Decl::NT_union, n, p), - UTL_Scope (AST_Decl::NT_union), - member_count_ (-1), - default_index_ (-2) -{ -} - -// compute total number of members -int -be_union::compute_member_count (void) -{ - UTL_ScopeActiveIterator *si; // iterator - - this->member_count_ = 0; - - // if there are elements in this scope - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - this->member_count_++; - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -// compute total number of members -int -be_union::compute_default_index (void) -{ - UTL_ScopeActiveIterator *si; // iterator - AST_Decl *d; // temp node - be_union_branch *bub; // union branch node - int i = 0; // counter - - this->default_index_ = -1; // if not used at all, this is the value it will - // take - - // if there are elements in this scope - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - if (!d->imported ()) - { - bub = be_union_branch::narrow_from_decl (d); - if (bub->label ()->label_kind () == AST_UnionLabel::UL_default) - this->default_index_ = i; // zero based indexing - i++; - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -// return the member count -int -be_union::member_count (void) -{ - if (this->member_count_ == -1) - this->compute_member_count (); - - return this->member_count_; -} - -// return the default_index -int -be_union::default_index (void) -{ - if (this->default_index_ == -2) - this->compute_default_index (); - - return this->default_index_; -} - -// generate typecode. -// Typecode for union comprises the enumerated value followed by the -// encapsulation of the parameters - -// generate the _var definition for ourself -int -be_union::gen_var_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_var", this->local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - ch->indent (); // start with whatever was our current indent level - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - // default constr - *ch << namebuf << " (void); // default constructor" << nl; - // constr - *ch << namebuf << " (" << local_name () << " *);" << nl; - // copy constructor - *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << nl; - // destructor - *ch << "~" << namebuf << " (void); // destructor" << nl; - *ch << nl; - // assignment operator from a pointer - *ch << namebuf << " &operator= (" << local_name () << " *);" << nl; - // assignment from _var - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; - - // arrow operator - *ch << local_name () << " *operator-> (void);" << nl; - *ch << "const " << local_name () << " *operator-> (void) const;" << nl; - *ch << nl; - - // other extra types (cast operators, [] operator, and others) - *ch << "operator const " << local_name () << " &() const;" << nl; - *ch << "operator " << local_name () << " &();" << nl; - *ch << "operator " << local_name () << " &() const;" << nl; - *ch << "// in, inout, out, _retn " << nl; - // 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) - { - *ch << "const " << local_name () << " &in (void) const;" << nl; - *ch << local_name () << " &inout (void);" << nl; - *ch << local_name () << " &out (void);" << nl; - *ch << local_name () << " _retn (void);" << nl; - } - else - { - *ch << "const " << local_name () << " &in (void) const;" << nl; - *ch << local_name () << " &inout (void);" << nl; - *ch << local_name () << " *&out (void);" << nl; - *ch << local_name () << " *_retn (void);" << nl; - } - - // generate an additional member function that returns the underlying pointer - *ch << local_name () << " *ptr(void) const;\n"; - - *ch << "\n"; - ch->decr_indent (); - - // generate the private section - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << " *ptr_;\n"; - ch->decr_indent (); - *ch << "};\n\n"; - - return 0; -} - -// implementation of the _var class. All of these get generated in the inline -// file -int -be_union::gen_var_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local _var names - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // default constr - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << - " (void) // default constructor" << nl; - *ci << " " << ": ptr_ (0)" << nl; - *ci << "{}\n\n"; - - // constr from a pointer - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << " *p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "if (p.ptr_)" << nl; - *ci << " this->ptr_ = new " << this->name () << "(*p.ptr_);" << nl; - *ci << "else" << nl; - *ci << " this->ptr_ = 0;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // destructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::~" << lname << " (void) // destructor" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from a pointer - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << name () << - " *p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment operator from _var - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "if (this != &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = new " << this->name () << " (*p.ptr_);\n"; - ci->decr_indent (); - *ci << "}" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // two arrow operators - ci->indent (); - *ci << "ACE_INLINE const " << this->name () << " *" << nl; - *ci << fname << "::operator-> (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - 3 cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator const " << name () << - " &() const // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << name () << " &() // cast " << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << name () << " &() const// cast " << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // in, inout, out, and _retn - ci->indent (); - *ci << "ACE_INLINE const " << name () << " &" << nl; - *ci << fname << "::in (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << " &" << nl; - *ci << fname << "::inout (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // the out is handled differently based on our size type - ci->indent (); - if (this->size_type () == be_decl::VARIABLE) - { - *ci << "// mapping for variable size " << nl; - *ci << "ACE_INLINE " << name () << " *&" << nl; - *ci << fname << "::out (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << " *" << nl; - *ci << fname << "::_retn (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << this->name () << " *tmp = this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; - *ci << "return tmp;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - } - else - { - *ci << "// mapping for fixed size " << nl; - *ci << "ACE_INLINE " << name () << " &" << nl; - *ci << fname << "::out (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - ci->indent (); - *ci << "ACE_INLINE " << name () << nl; - *ci << fname << "::_retn (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return *this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // the additional ptr () member function - ci->indent (); - *ci << "ACE_INLINE " << name () << " *" << nl; - *ci << fname << "::ptr (void) const" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - } - - return 0; -} - -// generate the _out definition -int -be_union::gen_out_defn (void) -{ - TAO_OutStream *ch; // output stream - TAO_NL nl; // end line - char namebuf [NAMEBUFSIZE]; // to hold the _out name - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ch = cg->client_header (); - - // generate the out definition (always in the client header) - ch->indent (); // start with whatever was our current indent level - - *ch << "class " << idl_global->export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); - - // No default constructor - - // constructor from a pointer - *ch << namebuf << " (" << local_name () << " *&);" << nl; - // constructor from a _var & - *ch << namebuf << " (" << local_name () << "_var &);" << nl; - // constructor from a _out & - *ch << namebuf << " (const " << namebuf << " &);" << nl; - // assignment operator from a _out & - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; - // assignment operator from a pointer &, cast operator, ptr fn, operator - // -> and any other extra operators - // assignment - *ch << namebuf << " &operator= (" << local_name () << " *);" << nl; - // operator () - *ch << "operator " << local_name () << " *&();" << nl; - // ptr fn - *ch << local_name () << " *&ptr (void);" << nl; - // operator -> - *ch << local_name () << " *operator-> (void);" << nl; - - *ch << "\n"; - ch->decr_indent (); - *ch << "private:\n"; - ch->incr_indent (); - *ch << local_name () << " *&ptr_;" << nl; - *ch << "// assignment from T_var not allowed" << nl; - *ch << "void operator= (const " << local_name () << "_var &);\n"; - - ch->decr_indent (); - *ch << "};\n\n"; - return 0; -} - -int -be_union::gen_out_impl (void) -{ - TAO_OutStream *ci; // output stream - TAO_NL nl; // end line - 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_out", this->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); - - // retrieve a singleton instance of the code generator - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - ci = cg->client_inline (); - - // generate the var implementation in the inline file - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; - *ci << "// *************************************************************\n\n"; - - // constr from a pointer - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << name () << " *&p)" << nl; - *ci << " : ptr_ (p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = 0;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // constructor from _var & - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (" << this->name () << - "_var &p) // constructor from _var" << nl; - *ci << " : ptr_ (p.out ())" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = 0;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // copy constructor - ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << nl; - *ci << " : ptr_ (ACE_const_cast (" << fname << "&,p).ptr_)" << nl; - *ci << "{}\n\n"; - - // assignment operator from _out & - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (const " << fname << - " &p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = ACE_const_cast (" << fname << "&,p).ptr_;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // assignment from _var is not allowed by a private declaration - - // assignment operator from pointer - ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << this->name () << - " *p)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "this->ptr_ = p;" << nl; - *ci << "return *this;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // other extra methods - cast operator () - ci->indent (); - *ci << "ACE_INLINE " << nl; - *ci << fname << "::operator " << this->name () << - " *&() // cast" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // ptr function - ci->indent (); - *ci << "ACE_INLINE " << this->name () << " *&" << nl; - *ci << fname << "::ptr (void) // ptr" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - // operator -> - ci->indent (); - *ci << "ACE_INLINE " << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; - *ci << "{\n"; - ci->incr_indent (); - *ci << "return this->ptr_;\n"; - ci->decr_indent (); - *ci << "}\n\n"; - - - return 0; -} - -int -be_union::gen_typecode (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "CORBA::tk_union, // typecode kind" << nl; - *cs << this->tc_encap_len () << ", // encapsulation length\n"; - // now emit the encapsulation - return this->gen_encapsulation (); -} - -// generate encapsulation. -// An encapsulation for ourselves will be necessary when we are part of some -// other IDL type and a typecode for that other type is being generated. This -// will comprise our typecode kind. IDL types with parameters will additionally -// have the encapsulation length and the entire typecode description - -int -be_union::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - long i, arrlen; - ACE_UINT32 *arr; - be_type *discrim; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - *cs << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; - // generate repoID - *cs << (ACE_OS::strlen (this->repoID ())+1) << ", "; - (void)this->tc_name2long (this->repoID (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // repository ID = " << this->repoID () << nl; - // generate name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << ",\n"; - - // generate typecode for discriminant - discrim = be_type::narrow_from_decl (this->disc_type ()); - if (discrim->gen_typecode () == -1) - { - ACE_ERROR ((LM_ERROR, "be_union: cannot generate typecode for discriminant\n")); - return -1; - } - - // generate the default used flag - cs->indent (); - *cs << this->default_index () << ", // default used index" << nl; - // generate the member count - *cs << this->member_count () << ", // member count\n"; - cs->incr_indent (0); - // hand over to the scope to generate the typecode for elements - if (be_scope::gen_encapsulation () == -1) - { - ACE_ERROR ((LM_ERROR, "be_union: cannot generate code for members\n")); - return -1; - } - cs->decr_indent (0); - return 0; -} - -// compute typecode size -long -be_union::tc_size (void) -{ - // 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the - // actual encapsulation length - return 4 + 4 + this->tc_encap_len (); -} - -long -be_union::tc_encap_len (void) -{ - if (this->encap_len_ == -1) // not computed yet - { - long slen; - be_type *discrim; - - // Macro to avoid "warning: unused parameter" type warning. - ACE_UNUSED_ARG (slen); - - this->encap_len_ = 4; // holds the byte order flag - - this->encap_len_ += this->repoID_encap_len (); // for repoID - - // do the same thing for the local name - this->encap_len_ += this->name_encap_len (); // for name - - // add encapsulation size of discriminant typecode - discrim = be_type::narrow_from_decl (this->disc_type ()); - this->encap_len_ += discrim->tc_size (); - - this->encap_len_ += 4; // to hold the "default used" flag - this->encap_len_ += 4; // to hold the member count - - // compute encap length for members - this->encap_len_ += be_scope::tc_encap_len (); - } - return this->encap_len_; -} - -// compute the size type of the node in question -int -be_union::compute_size_type (void) -{ - UTL_ScopeActiveIterator *si; - AST_Decl *d; - be_decl *bd; - - if (this->nmembers () > 0) - { - // if there are elements in this scope - - si = new UTL_ScopeActiveIterator (this, UTL_Scope::IK_decls); - // instantiate a scope iterator. - - while (!(si->is_done ())) - { - // get the next AST decl node - d = si->item (); - 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_structure::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - si->next (); - } // end of while - delete si; // free the iterator object - } - return 0; -} - -int -be_union::accept (be_visitor *visitor) -{ - return visitor->visit_union (this); -} - -// Narrowing -IMPL_NARROW_METHODS3 (be_union, AST_Union, be_scope, be_type) -IMPL_NARROW_FROM_DECL (be_union) -IMPL_NARROW_FROM_SCOPE (be_union) diff --git a/TAO/TAO_IDL/be/be_union_branch.cpp b/TAO/TAO_IDL/be/be_union_branch.cpp deleted file mode 100644 index e1ea7eabf91..00000000000 --- a/TAO/TAO_IDL/be/be_union_branch.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_union_branch.cpp -// -// = DESCRIPTION -// Extension of class AST_UnionBranch that provides additional means for C++ -// mapping. -// -// = AUTHOR -// Copyright 1994-1995 by Sun Microsystems, Inc. -// and -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_union_branch, "$Id$") - - -/* - * BE_UnionBranch - */ -be_union_branch::be_union_branch (void) -{ -} - -be_union_branch::be_union_branch (AST_UnionLabel *lab, AST_Type *ft, - UTL_ScopedName *n, UTL_StrList *p) - : AST_UnionBranch (lab, ft, n, p), - AST_Field (AST_Decl::NT_union_branch, ft, n, p), - AST_Decl (AST_Decl::NT_union_branch, n, p) -{ -} - -int -be_union_branch::gen_encapsulation (void) -{ - TAO_OutStream *cs; // output stream - TAO_NL nl; // end line - TAO_CodeGen *cg = TAO_CODEGEN::instance (); - be_type *bt; // our type node - long i, arrlen; - ACE_UINT32 *arr; - - cs = cg->client_stubs (); - cs->indent (); // start from whatever indentation level we were at - - // emit the case label value - *cs << this->label ()->label_val (); - *cs << ", // union case label (evaluated)" << nl; - // emit name - *cs << (ACE_OS::strlen (this->local_name ()->get_string ())+1) << ", "; - (void)this->tc_name2long(this->local_name ()->get_string (), arr, arrlen); - for (i=0; i < arrlen; i++) - { - cs->print ("ACE_NTOHL (0x%x), ", arr[i]); - } - *cs << " // name = " << this->local_name () << "\n"; - - // hand over code generation to our type node - bt = be_type::narrow_from_decl (this->field_type ()); - if (!bt) - return -1; - return bt->gen_typecode (); -} - -long -be_union_branch::tc_encap_len (void) -{ - if (this->encap_len_ == -1) - { - be_type *bt; - - this->encap_len_ = 4; // case label; - this->encap_len_ += this->name_encap_len (); // for name - bt = be_type::narrow_from_decl (this->field_type ()); - if (!bt) - { - ACE_ERROR ((LM_ERROR, "be_union_branch: bad field type\n")); - return -1; - } - this->encap_len_ += bt->tc_size (); // note that we add the typecode size - // of the type - } - return this->encap_len_; -} - -// 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) - { - 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 - return 0; -} - -int -be_union_branch::accept (be_visitor *visitor) -{ - return visitor->visit_union_branch (this); -} - -// Narrowing -IMPL_NARROW_METHODS2 (be_union_branch, AST_UnionBranch, be_decl) -IMPL_NARROW_FROM_DECL (be_union_branch) diff --git a/TAO/TAO_IDL/be/be_union_label.cpp b/TAO/TAO_IDL/be/be_union_label.cpp deleted file mode 100644 index 16b8a09bb41..00000000000 --- a/TAO/TAO_IDL/be/be_union_label.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// -// $Id$ -// -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_union_label, "$Id$") - - -/* - * BE_UnionLabel - */ -be_union_label::be_union_label() -{ -} -be_union_label::be_union_label(AST_UnionLabel::UnionLabel ul, - AST_Expression *v) - : AST_UnionLabel(ul, v) -{ -} - -int -be_union_label::accept (be_visitor *visitor) -{ - return visitor->visit_union_label (this); -} - diff --git a/TAO/TAO_IDL/be/be_visitor.cpp b/TAO/TAO_IDL/be/be_visitor.cpp deleted file mode 100644 index a04b1c4c33f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// -// $Id$ -// -/* -*- c++ -*- */ -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor.h -// -// = DESCRIPTION -// Abstract class for back end visitors. -// -// = NOTES -// This is not a pure abstract class -// -// = AUTHOR -// Aniruddha Gokhale and Carlos O'Ryan -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor.h" - -ACE_RCSID(be, be_visitor, "$Id$") - - -be_visitor::be_visitor (void) -{ -} - -be_visitor::~be_visitor (void) -{ -} - -// all the visit methods. Concrete visitors will selectively override each one -int be_visitor::visit_decl (be_decl *) -{ - return 0; -} - -int be_visitor::visit_scope (be_scope *) -{ - return 0; -} - -int be_visitor::visit_type (be_type *) -{ - return 0; -} - -int be_visitor::visit_predefined_type (be_predefined_type *) -{ - return 0; -} - -int be_visitor::visit_module (be_module *) -{ - return 0; -} - -int be_visitor::visit_interface (be_interface *) -{ - return 0; -} - -int be_visitor::visit_interface_fwd (be_interface_fwd *) -{ - return 0; -} - -int be_visitor::visit_structure (be_structure *) -{ - return 0; -} - -int be_visitor::visit_exception (be_exception *) -{ - return 0; -} - -int be_visitor::visit_expression (be_expression *) -{ - return 0; -} - -int be_visitor::visit_enum (be_enum *) -{ - return 0; -} - -int be_visitor::visit_operation (be_operation *) -{ - return 0; -} - -int be_visitor::visit_field (be_field *) -{ - return 0; -} - -int be_visitor::visit_argument (be_argument *) -{ - return 0; -} - -int be_visitor::visit_attribute (be_attribute *) -{ - return 0; -} - -int be_visitor::visit_union (be_union *) -{ - return 0; -} - -int be_visitor::visit_union_branch (be_union_branch *) -{ - return 0; -} - -int be_visitor::visit_union_label (be_union_label *) -{ - return 0; -} - -int be_visitor::visit_constant (be_constant *) -{ - return 0; -} - -int be_visitor::visit_enum_val (be_enum_val *) -{ - return 0; -} - -int be_visitor::visit_array (be_array *) -{ - return 0; -} - -int be_visitor::visit_sequence (be_sequence *) -{ - return 0; -} - -int be_visitor::visit_string (be_string *) -{ - return 0; -} - -int be_visitor::visit_typedef (be_typedef *) -{ - return 0; -} - -int be_visitor::visit_root (be_root *) -{ - return 0; -} - -int be_visitor::visit_native (be_native *) -{ - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument.cpp deleted file mode 100644 index 82984108372..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_args.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Argument -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -// include all the individual files -#include "be_visitor_argument/arglist.cpp" -#include "be_visitor_argument/argument.cpp" -#include "be_visitor_argument/docall_cs.cpp" -#include "be_visitor_argument/marshal_ss.cpp" -#include "be_visitor_argument/post_docall_cs.cpp" -#include "be_visitor_argument/post_docall_compiled_cs.cpp" -#include "be_visitor_argument/post_marshal_ss.cpp" -#include "be_visitor_argument/post_upcall_ss.cpp" -#include "be_visitor_argument/pre_docall_cs.cpp" -#include "be_visitor_argument/pre_upcall_ss.cpp" -#include "be_visitor_argument/upcall_ss.cpp" -#include "be_visitor_argument/vardecl_ss.cpp" -#include "be_visitor_argument/compiled_marshal_cs.cpp" -#include "be_visitor_argument/compiled_marshal_ss.cpp" -#include "be_visitor_argument/pre_invoke_cs.cpp" - -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 deleted file mode 100644 index dadb0375cb8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp +++ /dev/null @@ -1,314 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// arglist.cpp -// -// = DESCRIPTION -// Visitor that generates the parameters in an Operation signature -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, arglist, "$Id$") - - -// ************************************************************ -// be_visitor_args_arglist for parameter list in method declarations and -// definitions -// ************************************************************ - -be_visitor_args_arglist::be_visitor_args_arglist (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -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 - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_arglist::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - os->indent (); // start with current indentation level - - // Different types have different mappings when used as in/out or - // inout parameters. Let this visitor deal with the type - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_arglist::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - *os << " " << node->local_name () << ",\n"; - return 0; -} - -int be_visitor_args_arglist::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << "const " << this->type_name (node); - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node); - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_enum (be_enum *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << this->type_name (node); - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node) << " &"; - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << this->type_name (node, "_ptr"); - break; - case AST_Argument::dir_INOUT: // inout - *os << this->type_name (node, "_ptr") << " &"; - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << this->type_name (node, "_ptr"); - break; - case AST_Argument::dir_INOUT: // inout - *os << this->type_name (node, "_ptr") << " &"; - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_native (be_native *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << this->type_name (node); - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node) << " &"; - break; - case AST_Argument::dir_OUT: - *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 - - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << "const " << this->type_name (node) << " &"; - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node) << " &"; - break; - 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 - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << this->type_name (node, "_ptr"); - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node, "_ptr") << " &"; - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } // end switch direction - } // end else if - else // simple predefined types - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << this->type_name (node); - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node) << " &"; - break; - 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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << "const " << this->type_name (node) << " &"; - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node) << " &"; - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get the stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << "const char *"; - break; - case AST_Argument::dir_INOUT: - *os << "char *&"; - break; - case AST_Argument::dir_OUT: - *os << "CORBA::String_out"; - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_structure (be_structure *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get the stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << "const " << this->type_name (node) << " &"; - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node) << " &"; - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_union (be_union *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get the stream - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << "const " << this->type_name (node) << " &"; - break; - case AST_Argument::dir_INOUT: - *os << this->type_name (node) << " &"; - break; - case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); - break; - } - return 0; -} - -int be_visitor_args_arglist::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_arglist::" - "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/argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp deleted file mode 100644 index 22e77c1924a..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// argument.cpp -// -// = DESCRIPTION -// generic visitor for Argument node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, argument, "$Id$") - -be_visitor_args::be_visitor_args (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_args::~be_visitor_args (void) -{ -} - -int be_visitor_args::visit_argument (be_argument *) -{ - return -1; -} - -// helper that returns the type name either as a nested type name (for header -// files) or as a fully scoped name. In addition, we make sure that if the type -// is an alias, we use that name -const char * -be_visitor_args::type_name (be_type *node, const char *suffix) -{ - static char namebuf [NAMEBUFSIZE]; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - - be_type *bt; // type to use - - // use the typedefed name if that is the one used in the IDL defn - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // generate the NESTED_CLASS macro i.e., a relative path name to satisfy the - // MSVC++ compiler - switch (this->ctx_->stream ()->stream_type ()) - { - case TAO_OutStream::TAO_CLI_HDR: - ACE_OS::sprintf (namebuf, "%s", bt->nested_type_name - (this->ctx_->scope (), suffix)); - break; - default: // fullname for all other cases - ACE_OS::sprintf (namebuf, "%s", bt->fullname ()); - if (suffix) - ACE_OS::strcat (namebuf, suffix); - } - - return namebuf; -} - -// helper that returns the direction type of the argument -AST_Argument::Direction -be_visitor_args::direction (void) -{ - // grab the argument node. We know that our context has stored the right - // argument node - be_argument *arg = this->ctx_->be_node_as_argument (); - - ACE_ASSERT (arg != 0); - return arg->direction (); -} diff --git a/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_cs.cpp deleted file mode 100644 index 17444de85af..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_cs.cpp +++ /dev/null @@ -1,656 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// compiled_marshal_cs.cpp -// -// = DESCRIPTION -// Visitor generating the code that passes arguments to the CDR operators -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, compiled_marshal_cs, "$Id$") - - -// **************************************************************************** -// visitor for arguments passing to the CDR operators. -// **************************************************************************** - -be_visitor_args_compiled_marshal_cs:: -be_visitor_args_compiled_marshal_cs (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_compiled_marshal_cs:: -~be_visitor_args_compiled_marshal_cs (void) -{ -} - -int be_visitor_args_compiled_marshal_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, - "be_visitor_args_compiled_marshal_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // Different types have different mappings when used as in/out or - // inout parameters. Let this visitor deal with the type - - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "(_tao_out << "; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - os->indent (); - *os << "(_tao_in >> "; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_argument - " - "Bad substate\n"), - -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << ")"; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << ")"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_argument - " - "Bad substate\n"), - -1); - } - - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << node->name () << "_forany (" - << "(" << node->name () << "_slice *)" - << arg->local_name () << ")"; - break; - case AST_Argument::dir_INOUT: - *os << node->name () << "_forany (" - << arg->local_name () << ")"; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << node->name () << "_forany (" - << arg->local_name () << ")"; - break; - case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - { - *os << node->name () << "_forany (" - << arg->local_name () << ".ptr ())"; - } - else - { - *os << node->name () << "_forany (" - << arg->local_name () << ")"; - } - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_array - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << arg->local_name (); - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_enum - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - *os << arg->local_name () << ".ptr ()"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - *os << arg->local_name () << ".ptr ()"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - case AST_PredefinedType::PT_any: - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_float: - case AST_PredefinedType::PT_double: - case AST_PredefinedType::PT_longdouble: - *os << arg->local_name (); - break; - case AST_PredefinedType::PT_char: - *os << "CORBA::Any::from_char (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_wchar: - *os << "CORBA::Any::from_wchar (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_boolean: - *os << "CORBA::Any::from_boolean (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_octet: - *os << "CORBA::Any::from_octet (" << arg->local_name () << ")"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_predefined_type - " - "Bad predefined type\n"), - -1); - } - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << arg->local_name () << ".ptr ()"; - break; - case AST_PredefinedType::PT_any: - *os << "*" << arg->local_name () << ".ptr ()"; - break; - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_float: - case AST_PredefinedType::PT_double: - case AST_PredefinedType::PT_longdouble: - *os << arg->local_name (); - break; - case AST_PredefinedType::PT_char: - *os << "CORBA::Any::to_char (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_wchar: - *os << "CORBA::Any::to_wchar (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_boolean: - *os << "CORBA::Any::to_boolean (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_octet: - *os << "CORBA::Any::to_octet (" << arg->local_name () << ")"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal_cs::" - "visit_array - " - "Bad predefined type\n"), - -1); - } - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_array - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - *os << "*" << arg->local_name () << ".ptr ()"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - // we need to make a distinction between bounded and unbounded strings - if (node->max_size ()->ev ()->u.ulval == 0) - { - // unbounded - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - *os << arg->local_name () << ".ptr ()"; - break; - } - } - else - { - // bounded - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << "CORBA::Any::to_string (" - << arg->local_name () << ", " - << node->max_size ()->ev ()->u.ulval << ")"; - break; - case AST_Argument::dir_OUT: - *os << "CORBA::Any::to_string (" - << arg->local_name () << ".ptr (), " - << node->max_size ()->ev ()->u.ulval << ")"; - break; - } - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - *os << "*" << arg->local_name () << ".ptr ()"; - else - *os << arg->local_name (); - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_marshal_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - *os << "*" << arg->local_name () << ".ptr ()"; - else - *os << arg->local_name (); - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "visit_interface - " - "Bad substate\n"), - -1); - } - - return 0; -} - -int be_visitor_args_compiled_marshal_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_cs::" - "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/compiled_marshal_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_ss.cpp deleted file mode 100644 index 0b49ff7edd2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_ss.cpp +++ /dev/null @@ -1,697 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// compiled_marshal_ss.cpp -// -// = DESCRIPTION -// Visitor generating the code that passes arguments to the CDR operators -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, compiled_marshal_ss, "$Id$") - - -// **************************************************************************** -// visitor for arguments passing to the CDR operators. -// **************************************************************************** - -be_visitor_args_compiled_marshal_ss:: -be_visitor_args_compiled_marshal_ss (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_compiled_marshal_ss:: -~be_visitor_args_compiled_marshal_ss (void) -{ -} - -int be_visitor_args_compiled_marshal_ss::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, - "be_visitor_args_compiled_marshal_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // Different types have different mappings when used as in/out or - // inout parameters. Let this visitor deal with the type - - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "(_tao_in >> "; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - os->indent (); - *os << "(_tao_out << "; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_argument - " - "Bad substate\n"), - -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << ")"; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << ")"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_argument - " - "Bad substate\n"), - -1); - } - - return 0; -} - -int be_visitor_args_compiled_marshal_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 (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - *os << node->name () << "_forany (" - << "(" << node->name () << "_slice *)" - << arg->local_name () << ")"; - break; - case AST_Argument::dir_INOUT: - *os << node->name () << "_forany (" - << arg->local_name () << ")"; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << node->name () << "_forany (" - << arg->local_name () << ")"; - break; - case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - { - *os << node->name () << "_forany (" - << "(" << node->name () << "_slice *)" - << arg->local_name () << ".in ())"; - } - else - { - *os << node->name () << "_forany (" - << arg->local_name () << ")"; - } - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_array - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << arg->local_name (); - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_enum - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name () << ".out ()"; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << arg->local_name () << ".in ()"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name () << "out ()"; - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << arg->local_name () << ".in ()"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << arg->local_name () << ".out ()"; - break; - case AST_PredefinedType::PT_any: - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_float: - case AST_PredefinedType::PT_double: - case AST_PredefinedType::PT_longdouble: - *os << arg->local_name (); - break; - case AST_PredefinedType::PT_char: - *os << "CORBA::Any::to_char (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_wchar: - *os << "CORBA::Any::to_wchar (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_boolean: - *os << "CORBA::Any::to_boolean (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_octet: - *os << "CORBA::Any::to_octet (" << arg->local_name () << ")"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_predefined_type - " - "Bad predefined type\n"), - -1); - } - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << arg->local_name () << ".in ()"; - break; - case AST_PredefinedType::PT_any: - *os << arg->local_name (); - break; - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_float: - case AST_PredefinedType::PT_double: - case AST_PredefinedType::PT_longdouble: - *os << arg->local_name (); - break; - case AST_PredefinedType::PT_char: - *os << "CORBA::Any::from_char (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_wchar: - *os << "CORBA::Any::from_wchar (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_boolean: - *os << "CORBA::Any::from_boolean (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_octet: - *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); - } - break; - case AST_Argument::dir_OUT: - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << arg->local_name () << ".in ()"; - break; - case AST_PredefinedType::PT_any: - *os << arg->local_name () << ".in ()"; - break; - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_float: - case AST_PredefinedType::PT_double: - case AST_PredefinedType::PT_longdouble: - *os << arg->local_name (); - break; - case AST_PredefinedType::PT_char: - *os << "CORBA::Any::from_char (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_wchar: - *os << "CORBA::Any::from_wchar (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_boolean: - *os << "CORBA::Any::from_boolean (" << arg->local_name () << ")"; - break; - case AST_PredefinedType::PT_octet: - *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); - } - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_array - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - *os << arg->local_name () << ".in ()"; - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - // we need to make a distinction between bounded and unbounded strings - if (node->max_size ()->ev ()->u.ulval == 0) - { - *os << arg->local_name () << ".out ()"; - } - else - { - *os << "CORBA::Any::to_string (" - << arg->local_name () << ".out (), " - << node->max_size ()->ev ()->u.ulval - << ")"; - } - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - // we need to make a distinction between bounded and unbounded strings - if (node->max_size ()->ev ()->u.ulval == 0) - { - // unbounded - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << arg->local_name () << ".in ()"; - break; - } - } - else - { - // bounded - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << "CORBA::Any::from_string ((char *)" - << arg->local_name () << ".in (), " - << node->max_size ()->ev ()->u.ulval << ")"; - break; - } - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - *os << arg->local_name () << ".in ()"; - else - *os << arg->local_name (); - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_args_compiled_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 - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - break; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - *os << arg->local_name () << ".in ()"; - else - *os << arg->local_name (); - break; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_compiled_marshal_ss::" - "visit_interface - " - "Bad substate\n"), - -1); - } - - return 0; -} - -int be_visitor_args_compiled_marshal_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_args_compiled_marshal_ss::" - "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/docall_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/docall_cs.cpp deleted file mode 100644 index 2c8fdc8592b..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/docall_cs.cpp +++ /dev/null @@ -1,325 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// docall_cs.cpp -// -// = DESCRIPTION -// Visitor generating the code that passes arguments to the do_static_call -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, docall_cs, "$Id$") - - -// **************************************************************************** -// visitor for argument passing to do_static_call. The do_static_call -// method takes an array with pointers to each argument (the type is -// actually void*). The total number of parameters is determined by the -// "calldata" parameter that must be passed before the variable list -// starts. -// Hence we pass the address of each argument. The case for _out is a bit -// tricky where we must first retrieve the pointer, allocate memory -// and pass it to do_static_call. This is done in the -// "pre_do_static_call" processing. -// **************************************************************************** - -be_visitor_args_docall_cs::be_visitor_args_docall_cs (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_docall_cs::~be_visitor_args_docall_cs (void) -{ -} - -int be_visitor_args_docall_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, - "be_visitor_args_docall_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // Different types have different mappings when used as in/out or - // inout parameters. Let this visitor deal with the type - - TAO_OutStream *os = this->ctx_->stream (); // get output stream - os->indent (); - *os << "*_tao_arg = "; - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_docall_cs::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - *os << "; _tao_arg++;\n"; - - return 0; -} - -int be_visitor_args_docall_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 - - 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_type::VARIABLE) - // pass reference to the pointer to slice - // *os << "_tao_base_" << arg->local_name (); - *os << arg->local_name () << ".ptr ()"; - else - *os << arg->local_name (); - break; - } - return 0; -} - -int be_visitor_args_docall_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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - // pass the address. Storage is already allocated - *os << "&" << arg->local_name (); - break; - } - return 0; -} - -int be_visitor_args_docall_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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << "&_tao_base_" << arg->local_name (); - break; - } - return 0; -} - -int be_visitor_args_docall_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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << "&_tao_base_" << arg->local_name (); - break; - } - return 0; -} - -int be_visitor_args_docall_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 - - os->indent (); - // check if the type is an any - if (node->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: - //*os << "_tao_base_" << arg->local_name (); - *os << arg->local_name () << ".ptr ()"; - break; - } // end switch direction - } // end of if any - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., - // CORBA::Object, - // CORBA::TypeCode - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - //*os << "&_tao_base_" << arg->local_name (); - *os << "&" << arg->local_name () << ".ptr ()"; - break; - } // end switch direction - } // end else if pseudo - else // simple predefined types - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << "&" << arg->local_name (); - break; - } // end switch direction - } // end of else - - return 0; -} - -int be_visitor_args_docall_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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - // *os << "_tao_base_" << arg->local_name (); - *os << arg->local_name () << ".ptr ()"; - break; - } - return 0; -} - -int be_visitor_args_docall_cs::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - //*os << "&_tao_base_" << arg->local_name (); - *os << "&" << arg->local_name () << ".ptr ()"; - break; - } - return 0; -} - -int be_visitor_args_docall_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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - { - // check if the size type is VARIABLE - if (node->size_type () == be_type::VARIABLE) - // *os << "_tao_base_" << arg->local_name (); - *os << arg->local_name () << ".ptr ()"; - else - *os << "&" << arg->local_name (); - } - break; - } - return 0; -} - -int be_visitor_args_docall_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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - { - // check if the size type is VARIABLE - if (node->size_type () == be_type::VARIABLE) - //*os << "_tao_base_" << arg->local_name (); - *os << arg->local_name () << ".ptr ()"; - else - *os << "&" << arg->local_name (); - } - break; - } - return 0; -} - -int be_visitor_args_docall_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_docall_cs::" - "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/marshal_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/marshal_ss.cpp deleted file mode 100644 index 3d76e31f5ec..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/marshal_ss.cpp +++ /dev/null @@ -1,311 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// marshal_ss.cpp -// -// = DESCRIPTION -// Visitor that generates code that passes the argument variable to the -// marshal operations. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, marshal_ss, "$Id$") - - -// ************************************************************************ -// Visitor to generate code for passing argument to the marshal/demarshal -// routines -// ************************************************************************ - -be_visitor_args_marshal_ss::be_visitor_args_marshal_ss (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_marshal_ss::~be_visitor_args_marshal_ss (void) -{ -} - -int be_visitor_args_marshal_ss::visit_argument (be_argument *node) -{ - this->ctx_->node (node); // save the argument node - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_marshal_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_marshal_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -int be_visitor_args_marshal_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 - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << arg->local_name (); - break; - case AST_Argument::dir_OUT: - os->indent (); - if (node->size_type () == be_type::VARIABLE) - { - // *os << "_tao_ptr_" << arg->local_name (); - *os << arg->local_name () << ".inout ()"; - } - else - { - *os << arg->local_name (); - } - break; - } - 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 - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - os->indent (); - *os << "&" << arg->local_name (); - break; - } - 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 - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - os->indent (); - *os << "&_tao_base_var_" << arg->local_name () << ".inout ()"; - break; - } - 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 - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - os->indent (); - *os << "&_tao_base_var_" << arg->local_name () << ".inout ()"; - break; - } - return 0; -} - -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 the argument - // node - - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - os->indent (); - // *os << "_tao_ptr_" << arg->local_name (); - *os << "&" << arg->local_name () << ".inout ()"; - 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: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - os->indent (); - // *os << "&_tao_ptr_" << arg->local_name (); - *os << "&" << arg->local_name () << ".inout ()"; - break; - } // end switch direction - } // end else if - else // simple predefined types - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - os->indent (); - *os << "&" << arg->local_name (); - break; - } // end switch direction - } // end of else - - return 0; -} - -int be_visitor_args_marshal_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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - os->indent (); - // *os << "_tao_ptr_" << arg->local_name (); - *os << "&" << arg->local_name () << ".inout ()"; - break; - } - return 0; -} - -int be_visitor_args_marshal_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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - os->indent (); - // *os << "&_tao_ptr_" << arg->local_name (); - *os << "&" << arg->local_name () << ".inout ()"; - break; - } - return 0; -} - -int be_visitor_args_marshal_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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - os->indent (); - if (node->size_type () == be_type::VARIABLE) - // *os << "_tao_ptr_" << arg->local_name (); - *os << "&" << arg->local_name () << ".inout ()"; - else - *os << "&" << arg->local_name (); - break; - } - return 0; -} - -int be_visitor_args_marshal_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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "&" << arg->local_name (); - break; - case AST_Argument::dir_OUT: - os->indent (); - if (node->size_type () == be_type::VARIABLE) - // *os << "_tao_ptr_" << arg->local_name (); - *os << "&" << arg->local_name () << ".inout ()"; - else - *os << "&" << arg->local_name (); - break; - } - return 0; -} - -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, - "be_visitor_args_marshal_ss::" - "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/post_docall_compiled_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_docall_compiled_cs.cpp deleted file mode 100644 index e3deb5a070e..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_docall_compiled_cs.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// post_docall_compiled_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for post-processing of arguments following a -// do_static_call, when compiled marshaling (default) is enabled. -// -// = AUTHOR -// Jeff Parsons -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - - -// ************************************************************************* -// visitor for argument to do any post docall processing. Not all types need -// this. Only those that have an _out type need this. In addition, interfaces -// need it because we need to convert from the interface type to the base Object -// type and vice versa. -// ************************************************************************* - -be_visitor_args_post_docall_compiled_cs::be_visitor_args_post_docall_compiled_cs -(be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_post_docall_compiled_cs::~be_visitor_args_post_docall_compiled_cs (void) -{ -} - -int -be_visitor_args_post_docall_compiled_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, - "be_visitor_args_pre_docall_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_post_docall_compiled_cs::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -int -be_visitor_args_post_docall_compiled_cs::visit_interface (be_interface *) -{ - // 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 - - switch (this->direction ()) - { - case AST_Argument::dir_INOUT: - { - os->indent (); - // assign the narrowed obj reference - *os << "CORBA::release (" << arg->local_name () - << ");\n"; - } - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_post_docall_compiled_cs::visit_interface_fwd (be_interface_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 - - switch (this->direction ()) - { - case AST_Argument::dir_INOUT: - { - os->indent (); - // assign the narrowed obj reference - *os << "CORBA::release (" << arg->local_name () - << ");\n"; - } - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_post_docall_compiled_cs::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - os->indent (); - *os << "CORBA::string_free (" << arg->local_name () << ");" << be_nl; - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int -be_visitor_args_post_docall_compiled_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_post_docall_compiled_cs::" - "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/post_docall_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_docall_cs.cpp deleted file mode 100644 index 759051aa376..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_docall_cs.cpp +++ /dev/null @@ -1,164 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// post_docall_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for post-processing of arguments following a -// do_static_call -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, post_docall_cs, "$Id$") - - -// ************************************************************************* -// visitor for argument to do any post docall processing. Not all types need -// this. Only those that have an _out type need this. In addition, interfaces -// need it because we need to convert from the interface type to the base Object -// type and vice versa. -// ************************************************************************* - -be_visitor_args_post_docall_cs::be_visitor_args_post_docall_cs -(be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_post_docall_cs::~be_visitor_args_post_docall_cs (void) -{ -} - -int -be_visitor_args_post_docall_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, - "be_visitor_args_pre_docall_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_pre_docall_cs::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -int -be_visitor_args_post_docall_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 - - switch (this->direction ()) - { - case AST_Argument::dir_INOUT: - { - os->indent (); - // assign the narrowed obj reference - *os << arg->local_name () << " = " << node->name () - << "::_narrow (_tao_base_" << arg->local_name () - << ", _tao_environment);" << be_nl; - *os << "CORBA::release (_tao_base_" << arg->local_name () - << ");\n"; - } - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_post_docall_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 - - switch (this->direction ()) - { - case AST_Argument::dir_INOUT: - { - os->indent (); - // assign the narrowed obj reference - *os << arg->local_name () << " = " << node->name () - << "::_narrow (_tao_base_" << arg->local_name () - << ", _tao_environment);" << be_nl; - *os << "CORBA::release (_tao_base_" << arg->local_name () - << ");\n"; - } - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_post_docall_cs::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: - *os << "CORBA::string_free (" << arg->local_name () << ");" << be_nl; - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int -be_visitor_args_post_docall_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_post_docall_cs::" - "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/post_marshal_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_marshal_ss.cpp deleted file mode 100644 index a532881930a..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_marshal_ss.cpp +++ /dev/null @@ -1,236 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// post_marshal_ss.cpp -// -// = DESCRIPTION -// Visitor generating code that does post-processing of arguments following -// any marshaling. This involves any cleanup. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, post_marshal_ss, "$Id$") - - -// ************************************************************************ -// visitor for doing any post-processing after the marshaling is done -// ************************************************************************ - -be_visitor_args_post_marshal_ss::be_visitor_args_post_marshal_ss (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_post_marshal_ss::~be_visitor_args_post_marshal_ss (void) -{ -} - -int be_visitor_args_post_marshal_ss::visit_argument (be_argument *node) -{ - this->ctx_->node (node); // save the argument node - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_post_marshal_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_post_marshal_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - 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, - "be_visitor_args_post_marshal_ss::" - "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/post_upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp deleted file mode 100644 index 9d684bda8e3..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp +++ /dev/null @@ -1,252 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// post_upcall_ss.cpp -// -// = DESCRIPTION -// Visitor generating code to do post-processing of arguments following an -// upcall. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -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 (ctx) -{ -} - -be_visitor_args_post_upcall_ss::~be_visitor_args_post_upcall_ss (void) -{ -} - -int be_visitor_args_post_upcall_ss::visit_argument (be_argument *node) -{ - this->ctx_->node (node); // save the argument node - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_post_upcall_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_post_upcall_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -int be_visitor_args_post_upcall_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_upcall_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_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 - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: // inout - case AST_Argument::dir_OUT: - os->indent (); - *os << "_tao_base_var_" << arg->local_name () - << " = CORBA::Object::_duplicate (" - << arg->local_name () << ".in ());\n"; - break; - } - return 0; -} - -int be_visitor_args_post_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 - switch (this->direction ()) - { - case AST_Argument::dir_IN: - break; - case AST_Argument::dir_INOUT: // inout - case AST_Argument::dir_OUT: - os->indent (); - *os << "_tao_base_var_" << arg->local_name () - << " = CORBA::Object::_duplicate (" - << arg->local_name () << ".in ());\n"; - break; - } - return 0; -} - -int be_visitor_args_post_upcall_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_upcall_ss::visit_sequence (be_sequence *node) -{ - 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_upcall_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_upcall_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_upcall_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_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_args_post_upcall_ss::" - "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_docall_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/pre_docall_cs.cpp deleted file mode 100644 index 27f367ab145..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/pre_docall_cs.cpp +++ /dev/null @@ -1,445 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// pre_docall_cs.cpp -// -// = DESCRIPTION -// Visitor that generates code (if any) for pre-processing prior to call to -// do_static_call in the client stub -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, pre_docall_cs, "$Id$") - - -// ************************************************************************* -// visitor for argument to do any pre docall processing. Not all types need -// this. Only those that have an _out type need this. In addition, interfaces -// need it because we ned to convert from the interface type to the base Object -// type and vice versa. -// ************************************************************************* - -be_visitor_args_pre_docall_cs::be_visitor_args_pre_docall_cs -(be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_pre_docall_cs::~be_visitor_args_pre_docall_cs (void) -{ -} - -int -be_visitor_args_pre_docall_cs::void_return_type (void) -{ - // is the operation return type void? - be_argument *arg = this->ctx_->be_node_as_argument (); - ACE_ASSERT (arg != 0); - be_operation *op = be_operation::narrow_from_scope (arg->defined_in ()); - ACE_ASSERT (arg != 0); - - be_type *bt = be_type::narrow_from_decl (op->return_type ()); - 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; -} - -int be_visitor_args_pre_docall_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, - "be_visitor_args_pre_docall_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_pre_docall_cs::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -int -be_visitor_args_pre_docall_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 - // if the current type is an alias, use that - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - switch (this->direction ()) - { - case AST_Argument::dir_OUT: - if (node->size_type () == be_decl::VARIABLE) - { - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_slice *&_tao_base_" << arg->local_name () - << " = " << arg->local_name () << ".ptr ();" << be_nl; - if (!this->void_return_type ()) - { - *os << "ACE_ALLOCATOR_RETURN (_tao_base_" << arg->local_name () - << ", " << bt->name () << "_alloc (), _tao_retval);\n"; - } - else - { - *os << "ACE_ALLOCATOR (_tao_base_" << arg->local_name () - << ", " << bt->name () << "_alloc ());\n"; - } -#endif - if (!this->void_return_type ()) - { - *os << "ACE_ALLOCATOR_RETURN (" << arg->local_name () - << ".ptr (), " << bt->name () << "_alloc (), _tao_retval);\n"; - } - else - { - *os << "ACE_ALLOCATOR (" << arg->local_name () - << ".ptr (), " << bt->name () << "_alloc ());\n"; - } - } - break; - default: - break; - } - return 0; - -} - -int -be_visitor_args_pre_docall_cs::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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "CORBA::Object_ptr _tao_base_" << arg->local_name () - << " = " << arg->local_name () << ";\n"; - break; - case AST_Argument::dir_OUT: - os->indent (); - *os << "CORBA::Object_ptr _tao_base_" << arg->local_name () << ";\n"; - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_pre_docall_cs::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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); - *os << "CORBA::Object_ptr _tao_base_" << arg->local_name () - << " = " << arg->local_name () << ";\n"; - break; - case AST_Argument::dir_OUT: - os->indent (); - *os << "CORBA::Object_ptr _tao_base_" << arg->local_name () << ";\n"; - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_pre_docall_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - // get the argument node - be_argument *arg = this->ctx_->be_node_as_argument (); - -#if 0 - // if the current type is an alias, use that - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; -#endif - - // pre do_static_call processing is valid only for pseudo objects and for Any - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - { - switch (this->direction ()) - { - case AST_Argument::dir_OUT: -#if 0 - os->indent (); - *os << bt->name () << "_ptr &_tao_base_" << arg->local_name () - << " = " << arg->local_name () << ".ptr ();\n"; -#endif - break; - default: - break; - } - } - break; - case AST_PredefinedType::PT_any: - { - switch (this->direction ()) - { - case AST_Argument::dir_OUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << " *&_tao_base_" << arg->local_name () - << " = " << arg->local_name () << ".ptr ();" << be_nl; - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (_tao_base_" << arg->local_name () - << ", CORBA::Any, _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (_tao_base_" << arg->local_name () - << ", CORBA::Any);\n"; - } -#endif - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (" << arg->local_name () - << ".ptr (), CORBA::Any, _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (" << arg->local_name () - << ".ptr (), CORBA::Any);\n"; - } - break; - default: - break; - } - } - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_pre_docall_cs::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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - switch (this->direction ()) - { - case AST_Argument::dir_OUT: - // caller must have allocated the pointer - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << " *&_tao_base_" << arg->local_name () - << " = " << arg->local_name () << ".ptr ();" << be_nl; - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (_tao_base_" << arg->local_name () - << ", " << bt->name () << ", _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (_tao_base_" << arg->local_name () - << ", " << bt->name () << ");\n"; - } -#endif - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (" << arg->local_name () - << ".ptr (), " << bt->name () << ", _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (" << arg->local_name () - << ".ptr (), " << bt->name () << ");\n"; - } - break; - default: - break; - } - return 0; -} - -int -be_visitor_args_pre_docall_cs::visit_string (be_string *) -{ - return 0; -} - -int -be_visitor_args_pre_docall_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 - // if the current type is an alias, use that - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (node->size_type () == be_type::VARIABLE) - { - switch (this->direction ()) - { - case AST_Argument::dir_OUT: - // caller must have allocated the pointer - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << " *&_tao_base_" << arg->local_name () - << " = " << arg->local_name () << ".ptr ();" << be_nl; - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (_tao_base_" << arg->local_name () - << ", " << bt->name () << ", _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (_tao_base_" << arg->local_name () - << ", " << bt->name () << ");\n"; - } -#endif - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (" << arg->local_name () - << ".ptr (), " << bt->name () << ", _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (" << arg->local_name () - << ".ptr (), " << bt->name () << ");\n"; - } - break; - default: - break; - } - } - return 0; -} - -int -be_visitor_args_pre_docall_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 - // if the current type is an alias, use that - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (node->size_type () == be_type::VARIABLE) - { - switch (this->direction ()) - { - case AST_Argument::dir_OUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << " *&_tao_base_" << arg->local_name () - << " = " << arg->local_name () << ".ptr ();" << be_nl; - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (_tao_base_" << arg->local_name () - << ", " << bt->name () << ", _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (_tao_base_" << arg->local_name () - << ", " << bt->name () << ");\n"; - } -#endif - if (!this->void_return_type ()) - { - *os << "ACE_NEW_RETURN (" << arg->local_name () - << ".ptr (), " << bt->name () << ", _tao_retval);\n"; - } - else - { - *os << "ACE_NEW (" << arg->local_name () - << ".ptr (), " << bt->name () << ");\n"; - } - break; - default: - break; - } - } - return 0; -} - -int -be_visitor_args_pre_docall_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_pre_docall_cs::" - "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 deleted file mode 100644 index ed862708579..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// pre_invoke_cs.cpp -// -// = DESCRIPTION -// Visitor that generates code (if any) for pre-processing prior to call to -// do_static_call in the client stub -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, pre_invoke_cs, "$Id$") - - -// ************************************************************************* -// visitor for argument to do any pre invoke processing. Not all types need -// this. Only those that have an _out type need this. This ne is for compiled -// marshaling and overrides osme methods of the base class (which does the job -// for interpretive marshaling) -// ************************************************************************* - -be_visitor_args_pre_invoke_cs::be_visitor_args_pre_invoke_cs -(be_visitor_context *ctx) - : be_visitor_args_pre_docall_cs (ctx) -{ -} - -be_visitor_args_pre_invoke_cs::~be_visitor_args_pre_invoke_cs (void) -{ -} - -int -be_visitor_args_pre_invoke_cs::visit_interface (be_interface *) -{ - // overriding action - return 0; -} - -int -be_visitor_args_pre_invoke_cs::visit_interface_fwd (be_interface_fwd *) -{ - return 0; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_argument/pre_upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/pre_upcall_ss.cpp deleted file mode 100644 index 7a1c822681f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/pre_upcall_ss.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// pre_upcall_ss.cpp -// -// = DESCRIPTION -// Visitor that generates any pre-processing of arguments prior to making -// the upcall (in the skeleton). -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, pre_upcall_ss, "$Id$") - - -// ************************************************************************ -// visitor for passing arguments to the upcall -// ************************************************************************ - -be_visitor_args_pre_upcall_ss::be_visitor_args_pre_upcall_ss (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -be_visitor_args_pre_upcall_ss::~be_visitor_args_pre_upcall_ss (void) -{ -} - -int be_visitor_args_pre_upcall_ss::visit_argument (be_argument *node) -{ - this->ctx_->node (node); // save the argument node - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_pre_upcall_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_pre_upcall_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -int be_visitor_args_pre_upcall_ss::visit_array (be_array *) -{ - return 0; -} - -int be_visitor_args_pre_upcall_ss::visit_enum (be_enum *) -{ - return 0; -} - -int be_visitor_args_pre_upcall_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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: // inout - os->indent (); - *os << arg->local_name () << " = " << node->name () - << "::_narrow (_tao_base_var_" << arg->local_name () - << ".in (), _tao_environment);\n"; - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_pre_upcall_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 - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: // inout - os->indent (); - *os << arg->local_name () << " = " << node->name () - << "::_narrow (_tao_base_var_" << arg->local_name () - << ".in (), _tao_environment);\n"; - break; - case AST_Argument::dir_OUT: - break; - } - return 0; -} - -int be_visitor_args_pre_upcall_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_pre_upcall_ss::visit_sequence (be_sequence *) -{ - return 0; -} - -int be_visitor_args_pre_upcall_ss::visit_string (be_string *) -{ - return 0; -} - -int be_visitor_args_pre_upcall_ss::visit_structure (be_structure *) -{ - return 0; -} - -int be_visitor_args_pre_upcall_ss::visit_union (be_union *) -{ - return 0; -} - -int be_visitor_args_pre_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_args_pre_upcall_ss::" - "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/upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp deleted file mode 100644 index 5d3ef6b1286..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp +++ /dev/null @@ -1,378 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// upcall_ss.cpp -// -// = DESCRIPTION -// Visitor that generates code that passes argument variables to the -// upcall. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -ACE_RCSID(be_visitor_argument, upcall_ss, "$Id$") - - -// ************************************************************************ -// visitor for passing arguments to the upcall -// ************************************************************************ - -be_visitor_args_upcall_ss::be_visitor_args_upcall_ss (be_visitor_context *ctx) - : be_visitor_args (ctx) -{ -} - -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 - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_upcall_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_upcall_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -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 - - os->indent (); - 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 ()"; - else - *os << arg->local_name (); - break; - } - return 0; -} - -int be_visitor_args_upcall_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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - 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 *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *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 (); - else - *os << arg->local_name () << ".inout ()"; - break; - case AST_Argument::dir_OUT: - // *os << arg->local_name (); - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *os << arg->local_name () << ".out ()"; - break; - } - return 0; -} - -int be_visitor_args_upcall_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 - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *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 (); - else - *os << arg->local_name () << ".inout ()"; - break; - case AST_Argument::dir_OUT: - // *os << arg->local_name (); - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *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 - - os->indent (); - // check if the type is an any - if (node->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 (); - else - *os << arg->local_name () << ".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: - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *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 (); - else - *os << arg->local_name () << ".inout ()"; - break; - case AST_Argument::dir_OUT: - // *os << arg->local_name (); - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *os << arg->local_name () << ".out ()"; - break; - } // end switch direction - } // end else if - else // simple predefined types - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - case AST_Argument::dir_OUT: - *os << arg->local_name (); - break; - } // end switch direction - } // end of else - - return 0; -} - -int be_visitor_args_upcall_ss::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get the stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - - os->indent (); - 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 (); - else - *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 - - os->indent (); - switch (this->direction ()) - { - case AST_Argument::dir_IN: - if (this->ctx_->state () - == TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS) - *os << arg->local_name (); - else - *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 (); - 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 (); - else - *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 - - os->indent (); - 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 ()"; - else - *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 - - os->indent (); - 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 ()"; - else - *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, - "be_visitor_args_upcall_ss::" - "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/vardecl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp deleted file mode 100644 index 91c67e64215..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp +++ /dev/null @@ -1,560 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// vardecl_ss.cpp -// -// = DESCRIPTION -// Visitor that generates the variable declaration in the skeleton -// corresponding to the Argument node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_argument.h" - -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 (ctx) -{ -} - -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 - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_args_vardecl_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // 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, - "be_visitor_args_vardecl_ss::" - "visit_argument - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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 (); - if (node->size_type () == be_type::VARIABLE) - { -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << "_slice *&_tao_ptr_" << arg->local_name () - << " = _tao_var_" << arg->local_name () << ".out ();" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_ptr_" << arg->local_name () << ");\n"; -#endif - *os << bt->name () << "_var " - << arg->local_name () << ";\n"; - } - else - *os << bt->name () << " " << arg->local_name () << ";\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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - 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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var " << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_var _tao_base_var_" << arg->local_name () - << ";" << be_nl; - *os << "CORBA::Object_ptr &_tao_base_ptr_" << arg->local_name () - << " = _tao_base_var_" << arg->local_name () << ".out ();\n"; -#endif - *os << bt->name () << "_var " << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_var _tao_base_var_" << arg->local_name () - << ";\n"; - break; - case AST_Argument::dir_OUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_ptr _tao_base_ptr_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_var_" << arg->local_name () << ".out ());\n"; -#endif - *os << bt->name () << "_var " - << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_var _tao_base_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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var " << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_var _tao_base_var_" << arg->local_name () - << ";" << be_nl; - *os << "CORBA::Object_ptr &_tao_base_ptr_" << arg->local_name () - << " = _tao_base_var_" << arg->local_name () << ".out ();\n"; -#endif - *os << bt->name () << "_var " << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_var _tao_base_var_" << arg->local_name () - << ";\n"; - break; - case AST_Argument::dir_OUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_ptr _tao_base_ptr_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_var_" << arg->local_name () << ".out ());\n"; -#endif - *os << bt->name () << "_var " - << arg->local_name () << ";" << be_nl; - *os << "CORBA::Object_var _tao_base_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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // check if the type is an any - if (node->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 (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << "_ptr &_tao_ptr_" << arg->local_name () - << " = _tao_var_" << arg->local_name () << ".out ();" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_ptr_" << arg->local_name () << ");\n"; -#endif - *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 - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var " << arg->local_name () - << ";" << be_nl; - *os << bt->name () << "_ptr &_tao_ptr_" << arg->local_name () - << " = " << arg->local_name () << ".out ();\n"; -#endif - *os << bt->name () << "_var " << arg->local_name () - << ";\n"; - break; - case AST_Argument::dir_OUT: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << "_ptr &_tao_ptr_" << arg->local_name () - << " = _tao_var_" << arg->local_name () << ".out ();" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_ptr_" << arg->local_name () << ");" << be_nl; -#endif - *os << bt->name () << "_var " - << arg->local_name () << ";\n"; - break; - } // end switch direction - } // end else if - else // simple predefined types - { - switch (this->direction ()) - { - case AST_Argument::dir_IN: - 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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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 (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << " *&_tao_ptr_" << arg->local_name () - << " = _tao_var_" << arg->local_name () << ".out ();" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_ptr_" << arg->local_name () << ");\n"; -#endif - *os << bt->name () << "_var " - << arg->local_name () << ";" << be_nl; - break; - } - return 0; -} - -int be_visitor_args_vardecl_ss::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument - // node - - switch (this->direction ()) - { - case AST_Argument::dir_IN: - case AST_Argument::dir_INOUT: - os->indent (); -#if 0 /* ASG */ - *os << "CORBA::String_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << "char *&" << arg->local_name () << " = _tao_var_" - << arg->local_name () << ".out ();" << be_nl; -#endif - *os << "CORBA::String_var " - << arg->local_name () << ";\n"; - break; - case AST_Argument::dir_OUT: - os->indent (); -#if 0 /* ASG */ - *os << "CORBA::String_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << "char *&_tao_ptr_" << arg->local_name () << " = _tao_var_" - << arg->local_name () << ".out ();" << be_nl; - *os << "CORBA::String_out " << arg->local_name () - << " (_tao_ptr_" << arg->local_name () << ");\n"; -#endif - *os << "CORBA::String_var " - << arg->local_name () << ";\n"; - 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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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) - { -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << " *&_tao_ptr_" << arg->local_name () - << " = _tao_var_" << arg->local_name () << ".out ();" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_ptr_" << arg->local_name () << ");\n"; -#endif - *os << bt->name () << "_var " - << arg->local_name () << ";\n"; - } - else - *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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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) - { -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_var_" - << arg->local_name () << ";" << be_nl; - *os << bt->name () << " *&_tao_ptr_" << arg->local_name () - << " = _tao_var_" << arg->local_name () << ".out ();" << be_nl; - *os << bt->name () << "_out " << arg->local_name () - << " (_tao_ptr_" << arg->local_name () << ");\n"; -#endif - *os << bt->name () << "_var " - << arg->local_name () << ";\n"; - - } - else - *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, - "be_visitor_args_vardecl_ss::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - - -// ************************************************************************ -// Visitor to generate code for argument variable declaration for compiled -// marshaling. This provides only the overriden methods. The rest is handled by -// the base class that works for interpretiveskeletons. -// ************************************************************************ - -be_compiled_visitor_args_vardecl_ss:: -be_compiled_visitor_args_vardecl_ss (be_visitor_context *ctx) - : be_visitor_args_vardecl_ss (ctx) -{ -} - -be_compiled_visitor_args_vardecl_ss::~be_compiled_visitor_args_vardecl_ss (void) -{ -} - -int be_compiled_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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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_compiled_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 - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_array.cpp b/TAO/TAO_IDL/be/be_visitor_array.cpp deleted file mode 100644 index d3b5a590e05..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_array.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Array -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.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" -#include "be_visitor_array/array_cs.cpp" -#include "be_visitor_array/any_op_ch.cpp" -#include "be_visitor_array/any_op_cs.cpp" -#include "be_visitor_array/cdr_op_ch.cpp" -#include "be_visitor_array/cdr_op_cs.cpp" - -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 deleted file mode 100644 index 15237b1baf9..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/any_op_ch.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the Any operators in the client -// header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, any_op_ch, "$Id$") - - -// *************************************************************************** -// Array visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_array_any_op_ch::be_visitor_array_any_op_ch -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_any_op_ch::~be_visitor_array_any_op_ch (void) -{ -} - -int -be_visitor_array_any_op_ch::visit_array (be_array *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - os->indent (); - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, const " << node->name () - << "_forany &);" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << node->name () << "_forany &);\n"; - - node->cli_hdr_any_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp deleted file mode 100644 index 4384d1d2471..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/any_op_cs.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the Any operators in the client -// stubs. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, any_op_cs, "$Id$") - - -// *************************************************************************** -// Array visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_array_any_op_cs::be_visitor_array_any_op_cs -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_any_op_cs::~be_visitor_array_any_op_cs (void) -{ -} - -int -be_visitor_array_any_op_cs::visit_array (be_array *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - *os << "void operator<<= (CORBA::Any &_tao_any, const " - << node->name () << "_forany &_tao_elem)" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "if (_tao_elem.nocopy ()) // no copy" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " - << "_tao_elem.in (), 1, TAO_TRY_ENV); // consume it" << be_uidt_nl - << "else // copy" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " << node->name () - << "_dup (_tao_elem.in ()), 1, TAO_TRY_ENV);" << be_uidt_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY {}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n\n"; - - os->indent (); - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << "_forany &_tao_elem)" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", TAO_TRY_ENV)) return 0; // not equal" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "if (_tao_any.any_owns_data ())" << be_nl - << "{" << be_idt_nl - << "_tao_elem = (" << node->name () << "_slice *)_tao_any.value ();" - << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // else Any does not own the data - << "{" << be_idt_nl - << "_tao_elem.out () = " << node->name () << "_alloc ();" << be_nl - << "if (!_tao_elem.in ()) return 0;" << be_nl - << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any._tao_get_cdr ());" - << be_nl - << "if (stream.decode (" << node->tc_name () - << ", _tao_elem.inout (), 0, TAO_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->replace (" - << node->tc_name () << ", _tao_elem.inout (), 1, TAO_TRY_ENV);" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << node->name () << "_free (_tao_elem._retn ());" << be_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\n"; - - node->cli_stub_any_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/array.cpp b/TAO/TAO_IDL/be/be_visitor_array/array.cpp deleted file mode 100644 index a19959e36a1..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array.cpp -// -// = DESCRIPTION -// Generic visitor for code generation for Arrays -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array, "$Id$") - - -// ************************************************************************ -// generic visitor for array declaration -// ************************************************************************ - -be_visitor_array::be_visitor_array (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array::~be_visitor_array (void) -{ -} - -int be_visitor_array::visit_array (be_array *) -{ - // must be overloaded by derived visitors - return -1; -} - -int -be_visitor_array::visit_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); - else - *os << bt->name () << "_var"; - return 0; -} - -int -be_visitor_array::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); - else - *os << bt->name () << "_var"; - return 0; -} - -int -be_visitor_array::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << node->name () << "_var"; - else - *os << node->name (); - return 0; -} - -int -be_visitor_array::visit_sequence (be_sequence *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); - // *os << "CORBA::String_var"; - *os << "TAO_String_Manager"; - return 0; -} - -int -be_visitor_array::visit_structure (be_structure *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_union (be_union *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array::visit_typedef (be_typedef *node) -{ - return this->visit_node (node); -} - -// helper -int -be_visitor_array::visit_node (be_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *os << bt->name (); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp deleted file mode 100644 index 754d5106682..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp +++ /dev/null @@ -1,510 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array_ch.cpp -// -// = DESCRIPTION -// Visitor for Array code generation in client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_ch, "$Id$") - - -// ************************************************************************ -// visitor for array declaration in client header -// ************************************************************************ - -be_visitor_array_ch::be_visitor_array_ch (be_visitor_context *ctx) - : be_visitor_array (ctx) -{ -} - -be_visitor_array_ch::~be_visitor_array_ch (void) -{ -} - -int be_visitor_array_ch::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_type *bt; // base type - be_decl *scope = this->ctx_->scope (); // scope in which it is used - - // nothing to do if we are imported or code is already generated - if (node->imported () || (node->cli_hdr_gen ())) - return 0; - - this->ctx_->node (node); // save the array node - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "Bad base type\n"), - -1); - } - - // generate the ifdefined macro - os->gen_ifdef_macro (node->flatname ()); - - os->indent (); - *os << "typedef "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "base type decl failed\n"), - -1); - } - *os << " "; - if (!this->ctx_->tdef ()) - { - // we are dealing with an anonymous array case. Generate a typedef with - // an _ prepended to the name - *os << "_"; - } - *os << node->local_name (); - - if (node->gen_dimensions (os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "gen dimensions failed\n"), - -1); - } - *os << ";" << be_nl; - - // now define the slice type and other required operations - *os << "typedef "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "base type decl failed\n"), - -1); - } - *os << " "; - if (!this->ctx_->tdef ()) - { - // we are dealing with an anonymous array case. Generate a typedef with - // an _ prepended to the name - *os << "_"; - } - *os << node->local_name () << "_slice"; - if (node->gen_dimensions (os, 1) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "gen slice dimensions failed\n"), - -1); - } - *os << ";\n"; - - // typedef the _var, _out, and _forany types - if (this->gen_var_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "var_defn failed\n"), - -1); - } - // a class is generated for an out defn only for a variable length struct - if (node->size_type () == be_decl::VARIABLE) - { - if (this->gen_out_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "out_defn failed\n"), - -1); - } - } - else - { - // fixed size - os->indent (); - // if we are a typedefed array, we can use the TYPE name to define an - // _out type. However, for anonymous arrays that do not give rise to a - // new type, we use the base type for defining an out type - if (this->ctx_->tdef ()) - { - *os << "typedef " << node->local_name () << " " - << node->local_name () << "_out;\n"; - } - else - { - *os << "typedef "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "base type decl failed\n"), - -1); - } - *os << " _" << node->local_name () << "_out"; - if (node->gen_dimensions (os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_array - " - "gen dimensions failed\n"), - -1); - } - *os << ";\n"; - } - } - - if (this->gen_forany_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "forany_defn failed\n"), - -1); - } - // the _alloc, _dup, copy, and free methods. If the node is nested, the - // methods become static - os->indent (); - char *storage_class = 0; - - if (node->is_nested ()) - { - if (scope->node_type () != AST_Decl::NT_module) - storage_class = "static "; - else - storage_class = "TAO_NAMESPACE_STORAGE_CLASS "; - } - else - storage_class = ""; - - if (this->ctx_->tdef ()) - { - // typedefed array - if (!node->is_nested ()) - *os << "ACE_INLINE "; - *os << storage_class << node->nested_type_name (scope, "_slice") << " *"; - *os << node->nested_type_name (scope, "_alloc") << " (void);" << be_nl; - if (!node->is_nested ()) - *os << "ACE_INLINE "; - *os << storage_class << "void " << node->nested_type_name (scope, "_free") << " ("; - *os << node->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl; - *os << storage_class << node->nested_type_name (scope, "_slice") << " *"; - *os << node->nested_type_name (scope, "_dup") << " (const "; - *os << node->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl; - *os << storage_class << "void " << node->nested_type_name (scope, "_copy") << " ("; - *os << node->nested_type_name (scope, "_slice") << " *_tao_to, const "; - *os << node->nested_type_name (scope, "_slice") << " *_tao_from);" << be_nl; - } - else - { - // anonymous array - if (!node->is_nested ()) - *os << "ACE_INLINE "; - *os << storage_class << node->nested_type_name (scope, "_slice", "_") << " *"; - *os << node->nested_type_name (scope, "_alloc", "_") << " (void);" << be_nl; - if (!node->is_nested ()) - *os << "ACE_INLINE "; - *os << storage_class << "void " - << node->nested_type_name (scope, "_free", "_") << " ("; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice);" << be_nl; - *os << storage_class << node->nested_type_name (scope, "_slice", "_") << " *"; - *os << node->nested_type_name (scope, "_dup", "_") << " (const "; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice);" << be_nl; - *os << storage_class << "void " - << node->nested_type_name (scope, "_copy", "_") << " ("; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_to, const "; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_from);" << be_nl; - } - - *os << "\n"; - -#if 0 - // Typecode for an anonymous array will not be required anywhere since we do - // not generate the Any operators for anonymous types - - // is this a typedefined array? if so, then let the typedef deal with - // generation of the typecode - if (!this->ctx_->tdef ()) - { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_ch::" - "visit_array - " - "TypeCode declaration failed\n" - ), -1); - } - delete visitor; - } -#endif /* 0 */ - - // generate the endif macro - os->gen_endif (); - - node->cli_hdr_gen (1); - return 0; -} - -// generate the var defn -int -be_visitor_array_ch::gen_var_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - char namebuf [NAMEBUFSIZE]; // names - char varnamebuf [NAMEBUFSIZE]; // var names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (varnamebuf, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed array - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (varnamebuf, "%s_var", node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (namebuf, "_%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (varnamebuf, "_%s_var", node->local_name ()->get_string ()); - } - - // generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - os->indent (); // start with whatever was our current indent level - *os << "class " << idl_global->export_macro () - << " " << varnamebuf << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - // default constr - *os << varnamebuf << " (void); // default constructor" << be_nl; - // constr from pointer to slice - *os << varnamebuf << " (" << namebuf << "_slice *);" << be_nl; - // copy constructor - *os << varnamebuf << " (const " << varnamebuf << - " &); // copy constructor" << be_nl; - // destructor - *os << "~" << varnamebuf << " (void); // destructor" << be_nl; - *os << be_nl; - // assignment operator from a pointer to slice - *os << varnamebuf << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // assignment from _var - *os << varnamebuf << " &operator= (const " << varnamebuf << " &);" << be_nl; - - // arrow operator - // nothing here - *os << be_nl; - - // other extra types (cast operators, [] operator, and others) - // overloaded [] operator - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" - << be_nl; - *os << "const " << namebuf - << "_slice &operator[] (CORBA::ULong index) const;" << be_nl; - - // cast operators - *os << "operator " << namebuf << "_slice * const &() const;" - << be_nl; - *os << "operator " << namebuf << "_slice *&();" << be_nl; - - // in, inout, out and _retn - *os << "// in, inout, out, _retn " << be_nl; - *os << "const " << namebuf << "_slice *in (void) const;" << be_nl; - *os << namebuf << "_slice *inout (void);" << be_nl; - *os << namebuf << "_slice *&out (void);" << be_nl; - *os << namebuf << "_slice *_retn (void);" << be_nl; - - // generate an additional member function that returns the underlying pointer - *os << namebuf << "_slice *ptr (void) const;" << be_uidt_nl; - - // generate the private section - *os << "private:" << be_idt_nl; - *os << namebuf << "_slice *ptr_;" << be_uidt_nl; - *os << "};\n\n"; - - return 0; -} - -// generate the _out definition -int -be_visitor_array_ch::gen_out_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - char namebuf [NAMEBUFSIZE]; // to hold the name - char outnamebuf [NAMEBUFSIZE]; // to hold the _out name - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (outnamebuf, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (outnamebuf, "%s_out", node->local_name ()->get_string ()); - } - else - { - // anonymous array - ACE_OS::sprintf (namebuf, "_%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (outnamebuf, "_%s_out", node->local_name ()->get_string ()); - } - - // generate the out definition (always in the client header) - os->indent (); // start with whatever was our current indent level - - *os << "class " << idl_global->export_macro () - << " " << outnamebuf << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - - // No default constructor - - // constructor from a pointer to slice - *os << outnamebuf << " (" << namebuf << "_slice *&);" << be_nl; - // constructor from a _var & - *os << outnamebuf << " (" << namebuf << "_var &);" << be_nl; - // constructor from a _out & - *os << outnamebuf << " (const " << outnamebuf << " &);" << be_nl; - // assignment operator from a _out & - *os << outnamebuf << " &operator= (const " << outnamebuf << " &);" << be_nl; - // assignment from slice * - *os << outnamebuf << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // cast - *os << "operator " << namebuf << "_slice *&();" << be_nl; - // ptr fn - *os << namebuf << "_slice *&ptr (void);" << be_nl; - // operator [] instead of -> - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" << be_nl; - *os << "const " << namebuf << "_slice &operator[] " - << "(CORBA::ULong index) const;" << be_uidt_nl; - - *os << "private:" << be_idt_nl; - *os << namebuf << "_slice *&ptr_;" << be_nl; - *os << "// assignment from T_var not allowed" << be_nl; - *os << "void operator= (const " << namebuf << "_var &);" << be_uidt_nl; - *os << "};\n\n"; - return 0; -} - -// generate the _var definition for ourself -int -be_visitor_array_ch::gen_forany_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - char namebuf [NAMEBUFSIZE]; // names - char foranyname [NAMEBUFSIZE]; // forany class names - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (foranyname, '\0', NAMEBUFSIZE); - - if (this->ctx_->tdef ()) - { - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (foranyname, "%s_forany", node->local_name ()->get_string ()); - } - else - { - // anonymous array case - ACE_OS::sprintf (namebuf, "_%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (foranyname, "_%s_forany", - node->local_name ()->get_string ()); - } - - // generate the forany definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - os->indent (); // start with whatever was our current indent level - *os << "class " << idl_global->export_macro () - << " " << foranyname << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - - // default constr - *os << foranyname << " (void); // default constructor" << be_nl; - // constr from pointer to slice - *os << foranyname << " (" << namebuf << "_slice *, " - << "CORBA::Boolean nocopy=0);" << be_nl; - // copy constructor - *os << foranyname << " (const " << foranyname - << " &); // copy constructor" << be_nl; - // destructor - *os << "~" << foranyname << " (void); // destructor" << be_nl; - *os << be_nl; - // assignment operator from a pointer to slice - *os << foranyname << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // assignment from _var - *os << foranyname << " &operator= (const " << foranyname << " &);" << be_nl; - - // arrow operator - // nothing here - *os << be_nl; - - // other extra types (cast operators, [] operator, and others) - // overloaded [] operator - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" - << be_nl; - *os << "const " << namebuf - << "_slice &operator[] (CORBA::ULong index) const;" << be_nl; - - // cast operators - *os << "operator " << namebuf << "_slice * const &() const;" - << be_nl; - *os << "operator " << namebuf << "_slice *&();" << be_nl; - - // in, inout, out and _retn - *os << "// in, inout, out, _retn " << be_nl; - *os << "const " << namebuf << "_slice *in (void) const;" << be_nl; - *os << namebuf << "_slice *inout (void);" << be_nl; - *os << namebuf << "_slice *&out (void);" << be_nl; - *os << namebuf << "_slice *_retn (void);" << be_nl; - - // generate an additional member function that returns the underlying pointer - *os << namebuf << "_slice *ptr (void) const;" << be_nl; - - // additional member function that returns the NOCOPY flag - *os << "CORBA::Boolean nocopy (void) const;" << be_uidt_nl; - - // generate the private section - *os << "private:" << be_idt_nl; - *os << "/* friend class CORBA_Any; */" << be_nl; - *os << namebuf << "_slice *ptr_;" << be_nl; - *os << "CORBA::Boolean nocopy_;" << be_uidt_nl; - *os << "};\n\n"; - - return 0; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp deleted file mode 100644 index af6b5a497a8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp +++ /dev/null @@ -1,701 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Arrays in the client inline. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_ci, "$Id$") - - -// ************************************************************************ -// visitor for array declaration in client inline -// ************************************************************************ - -be_visitor_array_ci::be_visitor_array_ci (be_visitor_context *ctx) - : be_visitor_array (ctx) -{ -} - -be_visitor_array_ci::~be_visitor_array_ci (void) -{ -} - -int be_visitor_array_ci::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_type *bt; // base type - - // nothing to do if we are imported or code is already generated - if (node->imported () || (node->cli_inline_gen ())) - return 0; - - this->ctx_->node (node); // save the array node - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "Bad base type\n"), - -1); - } - - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - ACE_OS::sprintf (lname, "%s", - node->local_name ()->get_string ()); - } - else - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - ACE_OS::sprintf (lname, "_%s", - node->local_name ()->get_string ()); - } - } - - // alloc method - os->indent (); // start from current indentation - *os << "ACE_INLINE " << fname << "_slice *" << be_nl; - *os << fname << "_alloc (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return new "; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "base type decl failed\n"), - -1); - } - - if (node->gen_dimensions (os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_array::" - "gen_client_inline - " - "dimensions codegen failed\n"), - -1); - } - - *os << ";" << be_uidt_nl; - *os << "}\n\n"; - - // free method - os->indent (); - *os << "ACE_INLINE void" << be_nl - << fname << "_free (" << fname - << "_slice *_tao_slice)" << be_nl; - *os << "{" << be_idt_nl; - *os << "delete [] _tao_slice;" << be_uidt_nl; - *os << "}\n\n"; - - // generate code for the _var, _out, and _forany types - if (this->gen_var_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "var_defn failed\n"), - -1); - } - if (node->size_type () == be_decl::VARIABLE) - { - if (this->gen_out_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "out_defn failed\n"), - -1); - } - } - - if (this->gen_forany_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "forany_defn failed\n"), - -1); - } - - node->cli_inline_gen (1); - return 0; -} - -// implementation of the _var class. All of these get generated in the inline -// file -int -be_visitor_array_ci::gen_var_impl (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - - char nodename [NAMEBUFSIZE]; // node name - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the var - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (nodename, '\0', NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_var", node->fullname ()); - ACE_OS::sprintf (lname, "%s_var", - node->local_name ()->get_string ()); - } - else - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (nodename, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_var", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_var", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_var", node->fullname ()); - ACE_OS::sprintf (lname, "_%s_var", - node->local_name ()->get_string ()); - } - } - - // generate the var implementation in the inline file - - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // default constr - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << - " (void) // default constructor" << be_nl; - *os << " " << ": ptr_ (0)" << be_nl; - *os << "{}\n\n"; - - // constr from a _slice * - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename << "_slice *p)" << be_nl; - *os << " : ptr_ (p)" << be_nl; - *os << "{}\n\n"; - - // copy constructor (deep copy) - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname - << " &p) // copy constructor" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = " << nodename << "_dup (p.ptr_);" << be_uidt_nl; - *os << "}\n\n"; - - // destructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_free (this->ptr_);" << be_uidt_nl; - *os << "}\n\n"; - - // assignment operator - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << nodename - << "_slice *p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// is what we own the same that is being assigned to us?" - << be_nl; - *os << "if (this->ptr_ != p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// delete our stuff and assume ownership of p" << be_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = p;" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // assignment operator from _var - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname - << " &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "if (this != &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// not assigning to ourselves" << be_nl; - *os << nodename << "_free (this->ptr_); // free old stuff" << be_nl; - *os << "this->ptr_ = " << nodename - << "_dup (p.ptr_);// deep copy" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // other extra methods - cast operators () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice * const &() const // cast" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename << "_slice *&() // cast " << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // two operator []s instead of -> - os->indent (); - *os << "ACE_INLINE const " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - // in, inout, out, and _retn - os->indent (); - *os << "ACE_INLINE const " << nodename << "_slice *" << be_nl; - *os << fname << "::in (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::inout (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice * &" << be_nl; - *os << fname << "::out (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = (" << nodename << "_slice *)0;" << be_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::_retn (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_slice *tmp = this->ptr_;" << be_nl; - *os << "this->ptr_ = (" << nodename << "_slice *)0;" << be_nl; - *os << "return tmp;" << be_uidt_nl; - *os << "}\n\n"; - - // the additional ptr () member function - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::ptr (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_array_ci::gen_out_impl (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - - char nodename [NAMEBUFSIZE]; // node name - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the out class - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (nodename, '\0', NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_out", node->fullname ()); - ACE_OS::sprintf (lname, "%s_out", - node->local_name ()->get_string ()); - } - else - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (nodename, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_out", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_out", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_out", node->fullname ()); - ACE_OS::sprintf (lname, "_%s_out", - node->local_name ()->get_string ()); - } - } - - // generate the out implementation in the inline file - - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // constr from a pointer to slice - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename << "_slice *&p)" << be_nl; - *os << " : ptr_ (p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = 0;" << be_uidt_nl; - *os << "}\n\n"; - - // constructor from _var & - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename - << "_var &p) // constructor from _var" << be_nl; - *os << " : ptr_ (p.out ())" << be_nl; - *os << "{" << be_idt_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = 0;" << be_uidt_nl; - *os << "}\n\n"; - - // copy constructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname - << " &p) // copy constructor" << be_nl; - *os << " : ptr_ (ACE_const_cast (" - << fname << "&,p).ptr_)" << be_nl; - *os << "{}\n\n"; - - // assignment operator from _out & - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname - << " &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = ACE_const_cast (" - << fname << "&,p).ptr_;" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // assignment from _var is not allowed - - // assignment operator from _ptr - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << nodename - << "_slice *p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = p;" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // other extra methods - cast operator () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice *&() // cast" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // ptr function - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *&" << be_nl; - *os << fname << "::ptr (void) // ptr" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // operator [] instead of -> - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_array_ci::gen_forany_impl (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - - char nodename [NAMEBUFSIZE]; // node name - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the var - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (nodename, '\0', NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_forany", node->fullname ()); - ACE_OS::sprintf (lname, "%s_forany", - node->local_name ()->get_string ()); - } - else - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (nodename, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_forany", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s_forany", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_forany", node->fullname ()); - ACE_OS::sprintf (lname, "_%s_forany", - node->local_name ()->get_string ()); - } - } - - // generate the var implementation in the inline file - - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // default constr - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << - " (void) // default constructor" << be_nl; - *os << " " << ": ptr_ (0)," << be_nl; - *os << " nocopy_ (0)" << be_nl; - *os << "{}\n\n"; - - // constr from a _slice * - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << nodename << "_slice *p, " - << "CORBA::Boolean nocopy)" << be_nl; - *os << " : ptr_ (p)," << be_nl; - *os << " nocopy_ (nocopy)" << be_nl; - *os << "{}\n\n"; - - // copy constructor (deep copy) - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname - << " &p) // copy constructor" << be_nl; - *os << "{" << be_idt_nl; - *os << "this->ptr_ = " << nodename << "_dup (p.ptr_);" << be_nl; - *os << "this->nocopy_ = p.nocopy_;" << be_uidt_nl; - *os << "}\n\n"; - - // destructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; - *os << "{" << be_nl; - *os << " // don't do anything" << be_nl; - *os << "}\n\n"; - - // assignment operator - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << nodename - << "_slice *p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// is what we own the same that is being assigned to us?" << - be_nl; - *os << "if (this->ptr_ != p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// delete our stuff and assume ownership of p" << be_nl; - *os << nodename << "_free (this->ptr_);" << be_nl; - *os << "this->ptr_ = p;" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // assignment operator from _forany - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname - << " &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "if (this != &p)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// not assigning to ourselves" << be_nl; - *os << nodename << "_free (this->ptr_); // free old stuff" << be_nl; - *os << "this->ptr_ = " << nodename - << "_dup (p.ptr_);// deep copy" << be_nl; - *os << "this->nocopy_ = p.nocopy_;" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return *this;" << be_uidt_nl; - *os << "}\n\n"; - - // other extra methods - cast operators () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice * const &() const // cast" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << nodename - << "_slice *&() // cast " << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // two operator []s instead of -> - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice const &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice &" << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_[index];" << be_uidt_nl; - *os << "}\n\n"; - - // in, inout, out, and _retn - os->indent (); - *os << "ACE_INLINE const " << nodename << "_slice *" << be_nl; - *os << fname << "::in (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::inout (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice * &" << be_nl; - *os << fname << "::out (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::_retn (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // the additional ptr () member function - os->indent (); - *os << "ACE_INLINE " << nodename << "_slice *" << be_nl; - *os << fname << "::ptr (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->ptr_;" << be_uidt_nl; - *os << "}\n\n"; - - // the additional nocopy member function - os->indent (); - *os << "ACE_INLINE CORBA::Boolean" << be_nl; - *os << fname << "::nocopy (void) const" << be_nl; - *os << "{" << be_idt_nl; - *os << "return this->nocopy_;" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp deleted file mode 100644 index 9e71a704bd0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp +++ /dev/null @@ -1,247 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// array_cs.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays in the client stubs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, array_cs, "$Id$") - - -// ************************************************************************ -// visitor for array declaration in client stubs -// ************************************************************************ - -be_visitor_array_cs::be_visitor_array_cs (be_visitor_context *ctx) - : be_visitor_array (ctx) -{ -} - -be_visitor_array_cs::~be_visitor_array_cs (void) -{ -} - -int be_visitor_array_cs::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_type *bt; // base type - unsigned long i; - - // nothing to do if we are imported or code is already generated - if (node->imported () || (node->cli_stub_gen ())) - return 0; - - this->ctx_->node (node); // save the array node - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ci::" - "visit_array - " - "Bad base type\n"), - -1); - } - - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local names of the var - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - ACE_OS::sprintf (lname, "%s", - node->local_name ()->get_string ()); - } - else - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - ACE_OS::sprintf (lname, "_%s", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - ACE_OS::sprintf (lname, "_%s", - node->local_name ()->get_string ()); - } - } - - // dup method - os->indent (); - *os << fname << "_slice *" << be_nl - << fname << "_dup (const " << fname - << "_slice *_tao_src_array)" << be_nl; - *os << "{" << be_idt_nl; - *os << fname << "_slice *_tao_dup_array = " << fname - << "_alloc ();" << be_nl; - *os << "if (!_tao_dup_array) return (" << fname - << "_slice *)0;" << be_nl; - *os << fname << "_copy (_tao_dup_array, _tao_src_array);" << be_nl; - *os << "return _tao_dup_array;" << be_uidt_nl; - *os << "}\n\n"; - - // copy method - os->indent (); - *os << "void " << be_nl; - *os << fname << "_copy (" << fname << "_slice * _tao_to, " - << "const " << fname << "_slice *_tao_from)" << be_nl; - *os << "{" << be_idt_nl; - *os << "// copy each individual elements" << be_nl; - - // generate nested loops for as many dimensions as there are - for (i = 0; i < node->n_dims (); i++) - { - // retrieve the ith dimension value - AST_Expression *expr = node->dims ()[i]; - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cs::" - "visit_array - " - "bad array dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - // generate a loop for each dimension - *os << "for (CORBA::ULong i" << i << " = 0; i" << i << " < " - << expr->ev ()->u.ulval << "; i" << i << "++)" << be_idt_nl; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cs::" - "visit_array - " - "bad array dimension value\n"), - -1); - } - } - - // now generate code such that every element of the array gets assigned - // inside the innermost level of the nested loops generated above - be_array *primitive_type = 0; - if (bt->node_type () == AST_Decl::NT_typedef) - { - // base type of the array node is a typedef. We need to make sure that - // this typedef is not to another array type. If it is, then we cannot - // assign an array to another. We will have to invoke the underlying - // array type's copy method for every array dimension. - be_typedef *tdef = be_typedef::narrow_from_decl (bt); - // check if the base type of the typedef node is an Array node - primitive_type = be_array::narrow_from_decl (tdef->base_type ()); - } - if (primitive_type) - { - // the base type is not a typedef to a possibly another array type. In - // such a case, assign each element. - - *os << "// call the underlying _copy" << be_nl; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cs::" - "visit_array - " - "base type decl failed\n"), - -1); - } - - *os << "_copy (_tao_to"; - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << ", "; - *os << "_tao_from"; // generate the rvalue - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << ");"; - } - else - { - // the base type is not a typedef to a possibly another array type. In - // such a case, assign each element. - - *os << "_tao_to"; // generate the lvalue - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << " = "; - *os << "_tao_from"; // generate the rvalue - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - *os << ";"; - } - for (i = 0; i < node->n_dims (); i++) - { - // decrement indentation as many times as the number of dimensions - *os << be_uidt; - } - *os << be_uidt_nl << "}\n\n"; - -#if 0 - // typecode for anonymous arrays is not required since we do not generate the - // Any operators for it and it cannot be used as a type - - // is this a typedefined array? if so, then let the typedef deal with - // generation of the typecode - if (!this->ctx_->tdef ()) - { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cs::" - "visit_array - " - "TypeCode definition failed\n" - ), -1); - } - delete visitor; - } -#endif /* 0 */ - - node->cli_stub_gen (1); - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp deleted file mode 100644 index 776217da5d5..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the Cdr operators in the client -// header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, cdr_op_ch, "$Id$") - - -// *************************************************************************** -// Array visitor for generating CDR operator declarations in the client header -// *************************************************************************** - -be_visitor_array_cdr_op_ch::be_visitor_array_cdr_op_ch -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_cdr_op_ch::~be_visitor_array_cdr_op_ch (void) -{ -} - -int -be_visitor_array_cdr_op_ch::visit_array (be_array *node) -{ - if (node->cli_hdr_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const "; - // @@ TODO: this should be done in the node, it is absurd to repeat - // this code all over the visitors!!!! - if (!this->ctx_->tdef ()) - { - be_scope* scope = be_scope::narrow_from_scope (node->defined_in ()); - be_decl* parent = scope->decl (); - *os << parent->fullname () - << "::_" << node->local_name () - << "_forany &);" << be_nl; - } - else - { - *os << node->name () << "_forany &);" << be_nl; - } - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, "; - if (!this->ctx_->tdef ()) - { - be_scope* scope = be_scope::narrow_from_scope (node->defined_in ()); - be_decl* parent = scope->decl (); - *os << parent->fullname () - << "::_" << node->local_name () - << "_forany &);" << be_nl; - } - else - { - *os << node->name () << "_forany &);" << be_nl; - } - - node->cli_hdr_cdr_op_gen (1); - return 0; -} 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 deleted file mode 100644 index ee2d0ac34f7..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp +++ /dev/null @@ -1,562 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor for code generation of Arrays for the CDR operators in the client -// stubs. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_array.h" - -ACE_RCSID(be_visitor_array, cdr_op_cs, "$Id$") - - -// *************************************************************************** -// Array visitor for generating CDR operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_array_cdr_op_cs::be_visitor_array_cdr_op_cs -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_array_cdr_op_cs::~be_visitor_array_cdr_op_cs (void) -{ -} - -int -be_visitor_array_cdr_op_cs::visit_array (be_array *node) -{ - if (this->ctx_->alias ()) - { - // we are here because the base type of the array node is itself an array - // i.e., this is a case of array of array - return this->visit_node (node); - } - else - { - TAO_OutStream *os = this->ctx_->stream (); - - be_type *bt; // base type of the array - - if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cdr_op_cs::" - "visit_array - " - "Bad base type\n"), - -1); - } - - // for anonymous arrays, the type name has a _ prepended. We compute the - // fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (this->ctx_->tdef ()) - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - } - else - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - } - } - - // generate the CDR << and >> operator defns - - // save the array node for further use - this->ctx_->node (node); - - // set the sub state as generating code for the output operator - this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - *os << "ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &strm, " - << "const " << fname << "_forany &_tao_array)" << be_nl - << "{" << be_idt_nl; - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cdr_op_cs::" - "visit_array - " - "Base type codegen failed\n"), - -1); - } - *os << "}\n\n"; - - // set the sub state as generating code for the input operator - os->indent (); - this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_INPUT); - *os << "ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, " - << fname << "_forany &_tao_array)" << be_nl - << "{" << be_idt_nl; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_cdr_op_cs::" - "visit_array - " - "Base type codegen failed\n"), - -1); - } - *os << "}\n\n"; - - node->cli_stub_cdr_op_gen (1); - } - return 0; -} - -// handle all the base types - -int -be_visitor_array_cdr_op_cs::visit_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_cs::visit_interface (be_interface *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_cs::visit_interface_fwd (be_interface_fwd *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - case AST_PredefinedType::PT_any: - // let the helper handle this - return this->visit_node (node); - case AST_PredefinedType::PT_void: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_predefined_type - " - "Bad primitive type\n" - ), -1); - default: - // all other primitive types. Handle them as shown below - break; - }; - - // we get here if the "type" of individual elements of the array is a - // primitive type. In this case, we treat the array as a single dimensional - // array (even though it was multi-dimensional), and pass the total length of - // the array as a cross product of the dimensions - - // index - unsigned long i; - - // grab the array node - be_array *array = this->ctx_->be_node_as_array (); - - if (!node) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_predefined_type - " - "bad array node\n"), - -1); - } - - // we generate optimized code based on an optimized interface available from - // the CDR class. These optimizations are applicable only to primitive - // types. - *os << " return strm."; - - // based on our substate, we may be reading from a stream or writing into a - // stream - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "read_"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "write_"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_predefined_type - " - "bad sub state\n"), - -1); - } - - // determine what kind of array are we reading/writing - switch (node->pt ()) - { - case AST_PredefinedType::PT_long: - *os << "long_array"; - break; - case AST_PredefinedType::PT_ulong: - *os << "ulong_array"; - break; - case AST_PredefinedType::PT_short: - *os << "short_array"; - break; - case AST_PredefinedType::PT_ushort: - *os << "ushort_array"; - break; - case AST_PredefinedType::PT_octet: - *os << "octet_array"; - break; - case AST_PredefinedType::PT_char: - *os << "char_array"; - break; - case AST_PredefinedType::PT_wchar: - *os << "wchar_array"; - break; - case AST_PredefinedType::PT_float: - *os << "float_array"; - break; - case AST_PredefinedType::PT_double: - *os << "double_array"; - break; - case AST_PredefinedType::PT_longlong: - *os << "longlong_array"; - break; - case AST_PredefinedType::PT_ulonglong: - *os << "ulonglong_array"; - break; - case AST_PredefinedType::PT_longdouble: - *os << "longdouble_array"; - break; - case AST_PredefinedType::PT_boolean: - *os << "boolean_array"; - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_predefined_type - " - "bad primitive type for optimized code gen\n"), - -1); - } - - // handle special case to avoid compiler errors - switch (node->pt ()) - { - case AST_PredefinedType::PT_char: - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " ((char *)_tao_array.inout (), "; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << " ((const char *)_tao_array.in (), "; - break; - } - break; - default: - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " (_tao_array.inout (), "; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << " (_tao_array.in (), "; - break; - } - break; - } - // generate a product of all the dimensions. This will be the total length of - // the "unfolded" single dimensional array. - for (i = 0; i < array->n_dims (); i++) - { - // retrieve the ith dimension value - AST_Expression *expr = array->dims ()[i]; - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_predefined_type - " - "bad array dimension\n"), - -1); - } - if (i != 0) - // do not generate the multiplication operator the first time in - *os << "*"; - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - // generate a loop for each dimension - *os << expr->ev ()->u.ulval; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_predefined_type - " - "bad array dimension value\n"), - -1); - } - } - *os << ");" << be_uidt_nl; - - return 0; -} - -int -be_visitor_array_cdr_op_cs::visit_sequence (be_sequence *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_cs::visit_string (be_string *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_cs::visit_structure (be_structure *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_cdr_op_cs::visit_union (be_union *node) -{ - return this->visit_node (node); -} - -int -be_visitor_array_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 - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -// helper -int -be_visitor_array_cdr_op_cs::visit_node (be_type *bt) -{ - TAO_OutStream *os = this->ctx_->stream (); - unsigned long i; - be_array *node = this->ctx_->be_node_as_array (); - - if (!node) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_node - " - "bad array node\n"), - -1); - } - - // initialize a boolean variable - *os << "CORBA::Boolean _tao_marshal_flag = 1;" << be_nl; - - // we get here if the "type" of individual elements of the array is not a - // primitive type. In this case, we are left with no other alternative but to - // encode/decode element by element - - // generate nested loops for as many dimensions as there are - for (i = 0; i < node->n_dims (); i++) - { - // retrieve the ith dimension value - AST_Expression *expr = node->dims ()[i]; - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_node - " - "bad array dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - // generate a loop for each dimension - *os << "for (CORBA::ULong i" << i << " = 0; i" << i << " < " - << expr->ev ()->u.ulval << " && _tao_marshal_flag; i" << i - << "++)" << be_idt_nl; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_node - " - "bad array dimension value\n"), - -1); - } - } - - // if the type was a string, an obj ref, or a pseudo-obj, we are dealing with - // the _var type and hence we must use the appropriate in () and out () methods - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "_tao_marshal_flag = (strm >> "; - // handle the array of array case in which case, we need to pass the - // forany type - if (bt->node_type () == AST_Decl::NT_array) - { - *os << bt->name () << "_forany ((" << bt->name () - << "_slice *) "; - } - *os << "_tao_array "; - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - switch (bt->node_type ()) - { - // the following have a _var type and must be handled in a special way - case AST_Decl::NT_string: - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - *os << ".out ()"; - break; - case AST_Decl::NT_pre_defined: - { - // we need to separately handle this case of pseudo objects because - // they have a _var type - be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); - if (!pt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_node - " - "bad predefined type node\n"), - -1); - } - if (pt->pt () == AST_PredefinedType::PT_pseudo) - { - *os << ".out ()"; - } - } - } - if (bt->node_type () == AST_Decl::NT_array) - { - *os << ")"; - } - *os << ");"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "_tao_marshal_flag = (strm << "; - // handle the array of array case in which case, we need to pass the - // forany type - if (bt->node_type () == AST_Decl::NT_array) - { - *os << bt->name () << "_forany ((" << bt->name () - << "_slice *) "; - } - *os << "_tao_array "; - for (i = 0; i < node->n_dims (); i++) - { - *os << "[i" << i << "]"; - } - switch (bt->node_type ()) - { - // the follwoing three have a _var type and must be handled in a - // special way - case AST_Decl::NT_string: - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - *os << ".in ()"; - break; - case AST_Decl::NT_pre_defined: - { - be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); - if (!pt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_node - " - "bad predefined type node\n"), - -1); - } - if (pt->pt () == AST_PredefinedType::PT_pseudo) - { - *os << ".in ()"; - } - } - } - if (bt->node_type () == AST_Decl::NT_array) - { - // array of array case - *os << ")"; - } - *os << ");"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_array_cdr_op_cs::" - "visit_node - " - "bad sub state\n"), - -1); - } - - for (i = 0; i < node->n_dims (); i++) - { - // decrement indentation as many times as the number of dimensions - *os << be_uidt; - } - *os << be_nl; - *os << "return _tao_marshal_flag;" << be_uidt_nl; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_attribute.cpp b/TAO/TAO_IDL/be/be_visitor_attribute.cpp deleted file mode 100644 index 7b11a6294c2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_attribute.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_attribute.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Attribute -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_attribute.h" - -// include all the individual files -#include "be_visitor_attribute/attribute.cpp" - -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 deleted file mode 100644 index 19c2f374eea..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// attribute.cpp -// -// = DESCRIPTION -// Visitor for generation of code for Attribute -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_attribute.h" - -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 -// attribute. -// -// code generation for attributes is achieved by mapping an attribute node to -// a corresponding operation node. The reason is that we do not want to -// duplicate the code. However, an attribute node and an operation node have -// different interfaces. Hence we need some form of an adapter that can take us -// from an attribute node to an operation node. The following paragraph -// describes how this is accomplished. -// -// For a "get" operation on the attribute, we create an operation node with the -// same name as the attribute and a return type which is the same as the type -// of the attribute. This operation has no arguments. -// -// For a "set" operation on the attribute (if it is not readonly), we create an -// operation node with a "void" return type and an "in" parameter of the same -// type as the attribute. - -// In both cases the context will hold sufficient information to indicate that -// the operation node is really an attribute node. - -// ************************************************************************* -// primary visitor for "attribute". The context state decides the next state -// ************************************************************************* - -be_visitor_attribute::be_visitor_attribute (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -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 - - be_operation *op; - - // first the "get" operation - op = new be_operation (node->field_type (), AST_Operation::OP_noflags, - node->name (), 0); - op->set_name (node->name ()); - be_visitor_context ctx (*this->ctx_); - - // this switch statement eliminates the need for different classes that have - // exactly the same code except different states. - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_ATTRIBUTE_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_CH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_CS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_IH: - ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_IS: - ctx.state (TAO_CodeGen::TAO_OPERATION_IS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_COLLOCATED_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_SH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_COLLOCATED_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_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; - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -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 op; - delete visitor; - if (node->readonly ()) - return 0; // nothing else to do - - // the set method. - // the return type is "void" - be_predefined_type *rt = new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName - (new Identifier - ("void", 1, 0, I_FALSE), 0), - 0); - // argument type is the same as the attribute type - be_argument *arg = new be_argument (AST_Argument::dir_IN, - node->field_type (), - node->name (), - 0); - arg->set_name (node->name ()); - // create the operation - op = new be_operation (rt, AST_Operation::OP_noflags, - node->name (), 0); - op->set_name (node->name ()); - op->add_argument_to_scope (arg); - - ctx = *this->ctx_; - // this switch statement eliminates the need for different classes that have - // exactly the same code except different states. - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_ATTRIBUTE_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_CH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_CS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_IH: - ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_IS: - ctx.state (TAO_CodeGen::TAO_OPERATION_IS); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_COLLOCATED_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_SH); - break; - case TAO_CodeGen::TAO_ATTRIBUTE_COLLOCATED_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_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; - } - - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (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 op; - delete visitor; - delete rt; - delete arg; - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_constant.cpp b/TAO/TAO_IDL/be/be_visitor_constant.cpp deleted file mode 100644 index 0281cbccf4d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_constant.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_constant.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Constant -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_constant.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$") - diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp deleted file mode 100644 index 5f38c6e62fc..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// constant_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for the Constant node in the client header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_constant.h" - -ACE_RCSID(be_visitor_constant, constant_ch, "$Id$") - - -// ******************************************************************** -// Visitor implementation for the Constant type -// This one for the client header file -// ******************************************************************** - -be_visitor_constant_ch::be_visitor_constant_ch (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_constant_ch::~be_visitor_constant_ch (void) -{ -} - -// visit the Constant_Ch node and its scope -int -be_visitor_constant_ch::visit_constant (be_constant *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (!node->cli_hdr_gen () && !node->imported ()) - { - // 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 - - os->indent (); // start from whatever indentation level we were at - // 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)) - *os << "TAO_NAMESPACE_STORAGE_CLASS "; - else - *os << "static "; - *os << "const " << node->exprtype_to_string () - << " " << node->local_name (); - 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 << ";\n\n"; - 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 deleted file mode 100644 index 2f40e9fbbf9..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// constant_cs.cpp -// -// = DESCRIPTION -// Visitor for code generation of Constant code in the client stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_constant.h" - -ACE_RCSID(be_visitor_constant, constant_cs, "$Id$") - - -// ******************************************************************** -// Visitor implementation for the Constant type -// This one for the client stubs file -// ******************************************************************** - -be_visitor_constant_cs::be_visitor_constant_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_constant_cs::~be_visitor_constant_cs (void) -{ -} - -// visit the Constant_cs node and its scope -int -be_visitor_constant_cs::visit_constant (be_constant *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (!node->cli_stub_gen () && !node->imported ()) - { - if (node->is_nested ()) - { - if (node->defined_in ()->scope_node_type () == AST_Decl::NT_module) - { - *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)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_constant_cs::visit_constant - " - "Error parsing nested name\n"), - -1); - } - *os << "TAO_NAMESPACE_DEFINE (const " - << node->exprtype_to_string () << ", " - << 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 - " - "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 () << " " - << node->name () << " = " << node->constant_value () - << ";\n\n"; - } - } - node->cli_stub_gen (I_TRUE); - } - return 0; -} - -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler -int -be_visitor_constant_cs::gen_nested_namespace_begin (be_module *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; - - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // leave the outermost root scope - *os << "TAO_NAMESPACE_BEGIN (" << i->item ()->get_string () - << ")" << be_nl; - } - i->next (); - } - delete i; - return 0; -} - -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler -int -be_visitor_constant_cs::gen_nested_namespace_end (be_module *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; - - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // leave the outermost root scope - *os << "TAO_NAMESPACE_END" << be_nl; - } - i->next (); - } - delete i; - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_context.cpp b/TAO/TAO_IDL/be/be_visitor_context.cpp deleted file mode 100644 index 8102f332f78..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_context.cpp +++ /dev/null @@ -1,514 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_context.cpp -// -// = DESCRIPTION -// Maintains the context information for visitors -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -ACE_RCSID(be, be_visitor_context, "$Id$") - - -// constructor -be_visitor_context::be_visitor_context (void) - : state_ (TAO_CodeGen::TAO_UNKNOWN), - sub_state_ (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN), - os_ (0), - scope_ (0), - node_ (0), - alias_ (0), - tdef_ (0), - attr_ (0), - exception_ (0), - comma_ (0), - interface_ (0) -{ -} - -be_visitor_context::be_visitor_context (const be_visitor_context &ctx) - : state_ (ctx.state_), - sub_state_ (ctx.sub_state_), - os_ (ctx.os_), - scope_ (ctx.scope_), - node_ (ctx.node_), - alias_ (ctx.alias_), - tdef_ (ctx.tdef_), - attr_ (ctx.attr_), - exception_ (ctx.exception_), - comma_ (ctx.comma_), - interface_ (ctx.interface_) -{ -} - -be_visitor_context & -be_visitor_context::operator= (const be_visitor_context &ctx) -{ - this->state_ = ctx.state_; - this->sub_state_ = ctx.sub_state_; - this->os_ = ctx.os_; - this->scope_ = ctx.scope_; - this->node_ = ctx.node_; - this->alias_ = ctx.alias_; - this->tdef_ = ctx.tdef_; - this->attr_ = ctx.attr_; - this->exception_ = ctx.exception_; - this->comma_ = ctx.comma_; - this->interface_ = ctx.interface_; - - return *this; -} - -be_visitor_context::~be_visitor_context (void) -{ - // we do not own anything -} - -//= helpers - -void -be_visitor_context::reset (void) -{ - this->state_ = TAO_CodeGen::TAO_INITIAL; - this->sub_state_ = TAO_CodeGen::TAO_SUB_STATE_UNKNOWN; - this->os_ = 0; - this->scope_ = 0; - this->node_ = 0; - this->alias_ = 0; - this->tdef_ = 0; - this->attr_ = 0; - this->exception_ = 0; - this->comma_ = 0; - -} - -void -be_visitor_context::stream (TAO_OutStream *os) -{ - this->os_ = os; -} - -TAO_OutStream * -be_visitor_context::stream (void) -{ - return this->os_; -} - -void -be_visitor_context::scope (be_decl *s) -{ - this->scope_ = s; -} - -be_decl * -be_visitor_context::scope (void) -{ - return this->scope_; -} - -void -be_visitor_context::node (be_decl *n) -{ - this->node_ = n; -} - -be_decl * -be_visitor_context::node (void) -{ - return this->node_; -} - -void -be_visitor_context::state (TAO_CodeGen::CG_STATE st) -{ - this->state_ = st; -} - -TAO_CodeGen::CG_STATE -be_visitor_context::state (void) -{ - return this->state_; -} - -void -be_visitor_context::sub_state (TAO_CodeGen::CG_SUB_STATE st) -{ - this->sub_state_ = st; -} - -TAO_CodeGen::CG_SUB_STATE -be_visitor_context::sub_state (void) -{ - return this->sub_state_; -} - -void -be_visitor_context::tdef (be_typedef *node) -{ - this->tdef_ = node; -} - -be_typedef * -be_visitor_context::tdef (void) -{ - return this->tdef_; -} - -void -be_visitor_context::alias (be_typedef *node) -{ - this->alias_ = node; -} - -be_typedef * -be_visitor_context::alias (void) -{ - return this->alias_; -} - -void -be_visitor_context::attribute (be_attribute *node) -{ - this->attr_ = node; -} - -be_attribute * -be_visitor_context::attribute (void) -{ - return this->attr_; -} - -void -be_visitor_context::exception (idl_bool ib) -{ - this->exception_ = ib; -} - -idl_bool -be_visitor_context::exception (void) -{ - return this->exception_; -} - -void -be_visitor_context::comma (idl_bool ib) -{ - this->comma_ = ib; -} - -idl_bool -be_visitor_context::comma (void) -{ - return this->comma_; -} - -void -be_visitor_context::interface (be_interface *interface) -{ - this->interface_ = interface; -} - -be_interface * -be_visitor_context::interface (void) const -{ - return this->interface_; -} - -// **************************************************************** - -// 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_); - else - return (be_argument *)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_); - else - return (be_array *)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_); - else - return (be_attribute *)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_); - else - return (be_constant *)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_); - else - return (be_enum *)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_); - else - 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_); - else - return (be_exception *)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_); - else - return (be_field *)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_); - else - return (be_interface *)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_); - else - return (be_interface_fwd *)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_); - else - return (be_module *)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_); - else - return (be_operation *)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_); - else - return (be_predefined_type *)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_); - else - return (be_root *)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_); - else - return (be_sequence *)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_); - else - return (be_string *)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_); - else - return (be_structure *)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_); - else - return (be_typedef *)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_); - else - return (be_union *)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_); - else - return (be_union_branch *)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_); - else - return (be_enum *)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_); - else - return (be_exception *)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_); - else - 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_); - else - return (be_module *)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_); - else - return (be_operation *)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_); - else - return (be_root *)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_); - else - return (be_structure *)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_); - else - return (be_union *)0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_decl.cpp b/TAO/TAO_IDL/be/be_visitor_decl.cpp deleted file mode 100644 index 7658f3e181f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_decl.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_decl.cpp -// -// = DESCRIPTION -// Visitor for the base be_decl node. This serves to maintain the current -// state (context) of code generation for the derived visitor. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_decl.h" - -ACE_RCSID(be, be_visitor_decl, "$Id$") - - -// Root visitor for client header -be_visitor_decl::be_visitor_decl (be_visitor_context *ctx) - : ctx_ (ctx) -{ -} - -be_visitor_decl::~be_visitor_decl (void) -{ - delete this->ctx_; -} diff --git a/TAO/TAO_IDL/be/be_visitor_enum.cpp b/TAO/TAO_IDL/be/be_visitor_enum.cpp deleted file mode 100644 index 3be324fbc36..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_enum.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_enum.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Enum -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.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" -#include "be_visitor_enum/any_op_cs.cpp" -#include "be_visitor_enum/cdr_op_ch.cpp" -#include "be_visitor_enum/cdr_op_cs.cpp" - -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 deleted file mode 100644 index 46b3c3013ed..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_enum/any_op_ch.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Enums for the Any operators -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, any_op_ch, "$Id$") - - -// *************************************************************************** -// Enum visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_enum_any_op_ch::be_visitor_enum_any_op_ch -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_enum_any_op_ch::~be_visitor_enum_any_op_ch (void) -{ -} - -int -be_visitor_enum_any_op_ch::visit_enum (be_enum *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operators - os->indent (); - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, " << node->name () - << ");" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << node->name () << " &);\n"; - - 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 deleted file mode 100644 index 0614d2cc1da..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_enum/any_op_cs.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Enum for the Any operators -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, any_op_cs, "$Id$") - - -// *************************************************************************** -// Enum visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_enum_any_op_cs::be_visitor_enum_any_op_cs -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_enum_any_op_cs::~be_visitor_enum_any_op_cs (void) -{ -} - -int -be_visitor_enum_any_op_cs::visit_enum (be_enum *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->name () << " _tao_elem)" << be_nl - << "{" << be_idt_nl - << node->name () << " *_any_val;" << be_nl - << "ACE_NEW (_any_val, " << node->name () - << " (_tao_elem));" << be_nl - << "if (!_any_val) return;" << be_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () - << ", _any_val, 1, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "// free allocated storage" << be_nl - << "delete _any_val;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << " &_tao_elem)" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", TAO_TRY_ENV)) return 0; // not equal" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any._tao_get_cdr ());" - << be_nl - << "if (stream.decode (" << node->tc_name () - << ", &_tao_elem, 0, TAO_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << " return 1;" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\n"; - - node->cli_stub_any_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ch.cpp deleted file mode 100644 index 7c35d00c706..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_ch.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Enums for the CDR operators -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.h" - -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 (void) -{ -} - -int -be_visitor_enum_cdr_op_ch::visit_enum (be_enum *node) -{ - if (node->cli_hdr_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - - // generate the CDR << and >> operators - os->indent (); - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const " << node->name () - << " &); // " << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, " - << node->name () << " &);\n"; - - node->cli_hdr_cdr_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_cs.cpp deleted file mode 100644 index 882f9b3019b..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_enum/cdr_op_cs.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Enum for the CDR operators -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, cdr_op_cs, "$Id$") - - -// *************************************************************************** -// Enum visitor for generating CDR operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_enum_cdr_op_cs::be_visitor_enum_cdr_op_cs -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_enum_cdr_op_cs::~be_visitor_enum_cdr_op_cs (void) -{ -} - -int -be_visitor_enum_cdr_op_cs::visit_enum (be_enum *node) -{ - if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - - // generate CDR << and >> operators - os->indent (); - *os << "ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &strm, " - << "const " << node->name () << " &_tao_enumval)" << be_nl - << "{" << be_idt_nl - << "return strm.write_ulong ((CORBA::ULong) _tao_enumval);" << be_uidt_nl - << "}\n\n"; - - *os << "ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, " - << node->name () << " &_tao_enumval)" << be_nl - << "{" << be_idt_nl - << "CORBA::ULong _tao_temp;" << be_nl - << "if (strm.read_ulong (_tao_temp))" << be_nl - << "{" << be_idt_nl - << "ACE_OS::memcpy (&_tao_enumval, &_tao_temp, sizeof (CORBA::ULong));" - << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl - << "}\n\n"; - - node->cli_stub_cdr_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp b/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp deleted file mode 100644 index 3ca5ff12115..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// enum_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Enums in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, enum_ch, "$Id$") - - -// ******************************************************************** -// Visitor implementation for the Enum type -// This one for the client header file -// ******************************************************************** - -be_visitor_enum_ch::be_visitor_enum_ch (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_enum_ch::~be_visitor_enum_ch (void) -{ -} - -// visit the Enum_Ch node and its scope -int -be_visitor_enum_ch::visit_enum (be_enum *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - this->ctx_->comma (1); // comma to be generated by the scope visitor - - if (!node->cli_hdr_gen () && !node->imported ()) - { - os->indent (); // start from whatever indentation level we were at - *os << "enum " << node->local_name () << be_nl; - *os << "{\n"; - os->incr_indent (); - 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->decr_indent (); - *os << "};" << be_nl; - // As per the ORBOS spec, we need the following typedef - *os << "typedef " << node->local_name () << " &" << node->local_name () - << "_out;\n"; - - // 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_DECL); - 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); - } - - node->cli_hdr_gen (I_TRUE); - } - return 0; -} - -int -be_visitor_enum_ch::post_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - // Am I the last one? - if (!this->last_node (bd)) - *os << "," << be_nl; - return 0; -} - -int -be_visitor_enum_ch::visit_enum_val (be_enum_val *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); - *os << node->local_name (); - - 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 deleted file mode 100644 index 254939b0378..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// enum_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Enums in the client stubs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_enum.h" - -ACE_RCSID(be_visitor_enum, enum_cs, "$Id$") - - -// ******************************************************************** -// Visitor implementation for the Enum type -// This one for the client stubs file -// ******************************************************************** - -be_visitor_enum_cs::be_visitor_enum_cs (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_enum_cs::~be_visitor_enum_cs (void) -{ -} - -// visit the Enum_cs node and its scope -int -be_visitor_enum_cs::visit_enum (be_enum *node) -{ - if (!node->cli_stub_gen () && !node->imported ()) - { - // 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); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_enum_cs::" - "visit_enum - " - "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 deleted file mode 100644 index 5121050e009..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_exception.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Exception -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.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" -#include "be_visitor_exception/exception_cs.cpp" -#include "be_visitor_exception/exception_ctor.cpp" -#include "be_visitor_exception/ctor_assign.cpp" -#include "be_visitor_exception/any_op_ch.cpp" -#include "be_visitor_exception/any_op_cs.cpp" -#include "be_visitor_exception/cdr_op_ch.cpp" -#include "be_visitor_exception/cdr_op_cs.cpp" - -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 deleted file mode 100644 index d0c16445b30..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/any_op_ch.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for the Any operators for Exceptions -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, any_op_ch, "$Id$") - - -// *************************************************************************** -// Exception visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_exception_any_op_ch::be_visitor_exception_any_op_ch -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_exception_any_op_ch::~be_visitor_exception_any_op_ch (void) -{ -} - -int -be_visitor_exception_any_op_ch::visit_exception (be_exception *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - os->indent (); - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, const " << node->name () - << " &); // copying version" << be_nl; - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, " << node->name () - << "*); // noncopying version" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << 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, - "(%N:%l) be_visitor_exception::visit_exception - " - "codegen for scope failed\n"), -1); - } - - node->cli_hdr_any_op_gen (1); - return 0; -} - -int -be_visitor_exception_any_op_ch::visit_field (be_field *node) -{ - be_type *bt; // field's type - - // 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_exception_any_op_ch::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_any_op_ch::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} 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 deleted file mode 100644 index 2170bdca554..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for the Any operators for Exceptions. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, any_op_cs, "$Id$") - - -// *************************************************************************** -// Exception visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_exception_any_op_cs::be_visitor_exception_any_op_cs -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_exception_any_op_cs::~be_visitor_exception_any_op_cs (void) -{ -} - -int -be_visitor_exception_any_op_cs::visit_exception (be_exception *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - *os << "void operator<<= (CORBA::Any &_tao_any, const " - << node->name () << " &_tao_elem) // copying" << be_nl - << "{" << be_idt_nl - << node->name () << " *_tao_any_val = new " << node->name () - << " (_tao_elem);" << be_nl - << "if (!_tao_any_val) return;" << be_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", _tao_any_val, " - << "1, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY " << be_nl - << "{" << be_idt_nl - << "delete _tao_any_val;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->name () << " *_tao_elem) // non copying" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " - << "_tao_elem, 1, TAO_TRY_ENV); // consume it" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY {}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << " *&_tao_elem)" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", TAO_TRY_ENV)) return 0; // not equal" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "if (_tao_any.any_owns_data ())" << be_nl - << "{" << be_idt_nl - << "_tao_elem = (" << node->name () << " *)_tao_any.value ();" - << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // else any does not own the data - << "{" << be_idt_nl - << "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);" - << be_nl - << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any._tao_get_cdr ());" - << be_nl - << "if (stream.decode (" << node->tc_name () - << ", _tao_elem, 0, TAO_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->replace (" - << node->tc_name () << ", _tao_elem, 1, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // decode failed - << "{" << be_idt_nl - << "delete _tao_elem;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _tao_elem;" << be_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\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, - "(%N:%l) be_visitor_exception::visit_exception - " - "codegen for scope failed\n"), -1); - } - - node->cli_stub_any_op_gen (1); - return 0; -} - -int -be_visitor_exception_any_op_cs::visit_field (be_field *node) -{ - be_type *bt; // field's type - - // 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_exception_any_op_cs::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_any_op_cs::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} 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 deleted file mode 100644 index 1910de4e68e..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ch.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for exceptions. This uses -// compiled marshaling. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -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 (ctx) -{ -} - -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 ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Cdr <<= and >>= operator declarations - os->indent (); - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const " << node->name () - << " &); // " << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, " - << node->name () << " &);\n"; - - - // set the substate as generating code for the types defined in our scope - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cdr_op_ch::" - "visit_exception - " - "codegen for scope failed\n"), -1); - } - - - node->cli_hdr_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 deleted file mode 100644 index f327831fdce..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_cs.cpp +++ /dev/null @@ -1,186 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for exceptions -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#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_cs, "$Id$") - -// *************************************************************************** -// Exception visitor for generating CDR operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_exception_cdr_op_cs::be_visitor_exception_cdr_op_cs -(be_visitor_context *ctx) - : be_visitor_exception (ctx) -{ -} - -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) -{ - // already generated and/or we are imported. Don't do anything. - if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // First generate code for our children. The reason we do this first is - // because the inlined code for our children must be available before we use - // it in our parent - - // set the substate as generating code for the types defined in our scope - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cdr_op_cs" - "::visit_exception - " - "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 - << "{" << 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); - field_decl.visit_scope (node); - - // some members - *os << "// first marshal the repository ID" << be_nl - << "if (strm << _tao_aggregate._id ())" << be_nl - << "{" << be_idt_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_cs::" - "visit_exception - " - "codegen for scope failed\n"), -1); - } - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl; - } - else - { - // no members - *os << "// first marshal the repository ID" << be_nl - << "if (strm << _tao_aggregate._id ())" << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl; - } - *os << "}\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; - // retrieve the repository ID and compare with what we have - *os << "// retrieve RepoID and verify if we are of that type" << be_nl; - *os << "char *_tao_repoID;" << be_nl; - *os << "if ((strm >> _tao_repoID) &&" << be_nl - << " (_tao_aggregate._is_a (_tao_repoID)))" << be_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); - field_decl.visit_scope (node); - - // some members - *os << "// now marshal 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, - "(%N:%l) be_visitor_exception_cdr_op_cs::" - "visit_exception - " - "codegen for scope failed\n"), -1); - } - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl; - } - else - { - *os << "return 1;" << be_uidt_nl; - } - *os << "}" << be_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt_nl - << "}\n\n"; - - node->cli_stub_cdr_op_gen (1); - return 0; -} - -int -be_visitor_exception_cdr_op_cs::post_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (!this->last_node (bd)) - { - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_OUTPUT: - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " &&" << be_nl; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - default: - break; - }; - } - 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 deleted file mode 100644 index 72b5f13525f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// ctor_assign.cpp -// -// = DESCRIPTION -// Visitor generating code for the special CTOR and assignment operator for -// Exceptions. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, ctor_assign, "$Id$") - - -// ************************************************************************ -// used for the body of the assignment operator and the copy constructor -// ************************************************************************ - -be_visitor_exception_ctor_assign::be_visitor_exception_ctor_assign (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_exception_ctor_assign::~be_visitor_exception_ctor_assign (void) -{ -} - -int be_visitor_exception_ctor_assign::visit_exception (be_exception *node) -{ - this->ctx_->node (node); // save the argument node - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_exception_ctor_assign::" - "visit_exception - " - "codegen for scope failed\n"), - -1); - } - - return 0; -} - -int be_visitor_exception_ctor_assign::visit_field (be_field *node) -{ - this->ctx_->node (node); // save the argument node - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_exception_ctor_assign::" - "visit_field - " - "Bad field type\n"), - -1); - } - - // 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, - "be_visitor_exception_ctor_assign::" - "visit_field - " - "cannot accept visitor\n"), - -1); - } - - return 0; -} - -int be_visitor_exception_ctor_assign::visit_array (be_array *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; - } - else - { - *os << "this->" << bd->local_name () << " = _tao_excp." << bd->local_name () - << ";\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_enum (be_enum *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; - } - else - { - *os << "this->" << bd->local_name () << " = _tao_excp." << bd->local_name () - << ";\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_" << bd->local_name () << ");\n"; - } - else - { - *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_excp." << bd->local_name () << ".in ());\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_" << bd->local_name () << ");\n"; - } - else - { - *os << "this->" << bd->local_name () << " = " << node->name () - << "::_duplicate (_tao_excp." << bd->local_name () << ".in ());\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) - { - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = _tao_" - << bd->local_name () << ";\n"; - } - else - { - *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; - } - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object - { - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = " - << node->name () << "::_duplicate (_tao_" - << bd->local_name () << ");\n"; - } - else - { - *os << "this->" << bd->local_name () << " = " - << node->name () << "::_duplicate (_tao_excp." - << bd->local_name () << ".in ());\n"; - } - } // end else if - else // simple predefined types - { - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = _tao_" - << bd->local_name () << ";\n"; - } - else - { - *os << "this->" << bd->local_name () << " = _tao_excp." - << bd->local_name () << ";\n"; - } - } // end of else - - return 0; -} - -int be_visitor_exception_ctor_assign::visit_sequence (be_sequence *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; - } - else - { - *os << "this->" << bd->local_name () << " = _tao_excp." << bd->local_name () - << ";\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = CORBA::string_dup (_tao_" - << bd->local_name () << ");\n"; - } - else - { - *os << "this->" << bd->local_name () - << " = CORBA::string_dup (_tao_excp." << bd->local_name () - << ".in ());\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_structure (be_structure *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; - } - else - { - *os << "this->" << bd->local_name () << " = _tao_excp." << bd->local_name () - << ";\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_union (be_union *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - be_decl *bd = this->ctx_->node (); - - os->indent (); - if (this->ctx_->exception ()) // special ctor - { - *os << "this->" << bd->local_name () << " = _tao_" << bd->local_name () - << ";\n"; - } - else - { - *os << "this->" << bd->local_name () << " = _tao_excp." << bd->local_name () - << ";\n"; - } - return 0; -} - -int be_visitor_exception_ctor_assign::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_exception_ctor_assign::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp deleted file mode 100644 index 7d3e67eb403..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// .cpp -// -// = DESCRIPTION -// Generic visitor generating code for Exceptions. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, exception, "$Id$") - - -// generic struct visitor -be_visitor_exception::be_visitor_exception (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_exception::~be_visitor_exception (void) -{ -} - -// visit the Exception node and its scope -int -be_visitor_exception::visit_exception (be_exception *) -{ - return -1; // must be overriden -} - -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 - 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_EXCEPTION_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - break; - case TAO_CodeGen::TAO_EXCEPTION_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CI); - break; - case TAO_CodeGen::TAO_EXCEPTION_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CS); - break; - case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_field - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_field - " - "NUL 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 deleted file mode 100644 index 855abbc721d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// exception_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Exception in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, exception_ch, "$Id$") - - -// ****************************************************** -// for client header -// ****************************************************** - -be_visitor_exception_ch::be_visitor_exception_ch (be_visitor_context *ctx) - : be_visitor_exception (ctx) -{ -} - -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; // output stream - - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported - { - os = this->ctx_->stream (); - - os->gen_ifdef_macro (node->flatname (), "_ptr"); - - os->indent (); - *os << "class " << node->local_name () << ";" << be_nl; - // generate the _ptr declaration - *os << "typedef " << node->local_name () << " *" - << node->local_name () << "_ptr;" << be_nl; - os->gen_endif (); - - os->gen_ifdef_macro (node->flatname ()); - - os->indent (); - *os << "class " << idl_global->export_macro () - << " " << node->local_name () - << " : public CORBA::UserException" << be_nl; - *os << "{" << be_nl - << "public:\n"; - os->incr_indent (); - // constructors and destructor - *os << node->local_name () << " (void); // default ctor" << be_nl; - *os << node->local_name () << " (const " << node->local_name () - << " &); // copy ctor" << be_nl; - *os << "~" << node->local_name () << " (void); // dtor" << be_nl; - - os->indent (); - // assignment operator - *os << node->local_name () << " &operator= (const " - << node->local_name () << " &);\n\n"; - - *os << be_nl - << "virtual void _raise (void);\n" << be_nl - << "static " << node->local_name () - << " *_narrow (CORBA::Exception *);\n\n"; - - // 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 *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_exception - " - "codegen for ctor failed\n"), -1); - } - delete visitor; - } - - // 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 extension" << be_nl - << "static CORBA::Exception *_alloc (void);\n" << be_uidt_nl - << "}; // exception " << node->name () - << "\n" << be_nl; - - // 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_DECL); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -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); - - } - 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 deleted file mode 100644 index 7f7a34758b1..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ci.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// exception_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Exception in the inline file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -ACE_RCSID(be_visitor_exception, exception_ci, "$Id$") - - -// ****************************************************** -// for client inline -// ****************************************************** - -be_visitor_exception_ci::be_visitor_exception_ci (be_visitor_context *ctx) - : be_visitor_exception (ctx) -{ -} - -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 - - 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 - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_exception -" - "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 deleted file mode 100644 index 17aa786ba9f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// exception_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Exception in the stubs file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -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) -{ -} - -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; // output stream - - if (!node->cli_stub_gen () && !node->imported ()) - { - os = this->ctx_->stream (); - - // default constructor - os->indent (); - *os << "// default constructor" << be_nl; - *os << node->name () << "::" << node->local_name () << " (void)" << be_nl; - *os << " : CORBA_UserException (" - << node->tc_name () << ")\n"; - *os << "{" << be_nl; - *os << "}\n\n"; - - // destructor - os->indent (); - *os << "// destructor - all members are of self managing types" << be_nl; - *os << node->name () << "::~" << node->local_name () << " (void)" << be_nl; - *os << "{" << be_nl; - *os << "}\n\n"; - - // copy constructor - os->indent (); - *os << "// copy constructor" << be_nl; - *os << node->name () << "::" << node->local_name () << " (const " << - node->name () << " &_tao_excp)" << be_nl; - *os << " : CORBA_UserException (" << - "_tao_excp._type ())" << be_nl; - *os << "{\n"; - os->incr_indent (); - // assign each individual member - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception -" - "codegen for scope failed\n"), -1); - } - delete visitor; - os->decr_indent (); - *os << "}\n\n"; - - // assignment operator - os->indent (); - *os << "// assignment operator" << be_nl; - *os << node->name () << "&" << be_nl; - *os << node->name () << "::operator= (const " - << node->name () << " &_tao_excp)" << be_nl - << "{\n" << 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); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception -" - "codegen for scope failed\n"), -1); - } - delete visitor; - os->indent (); - *os << "return *this;" << be_uidt_nl - << "}\n\n"; - - // narrow method - os->indent (); - *os << "// narrow" << be_nl; - *os << node->name () << "_ptr " << be_nl; - *os << node->name () << "::_narrow (CORBA::Exception *exc)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "if (!ACE_OS::strcmp (\"" << node->repoID () << - "\", exc->_id ())) // same type" << be_nl; - *os << " return ACE_dynamic_cast (" << node->name () << "_ptr, exc);" << - be_nl; - *os << "else" << be_nl; - *os << " return 0;\n"; - os->decr_indent (); - *os << "}\n\n"; - - *os << be_nl - << "void " << node->name () << "::_raise ()" << be_nl - << "{" << be_idt_nl - << "TAO_RAISE(*this);" << be_uidt_nl - << "}\n\n"; - - // generate the _alloc method - os->indent (); - *os << "// TAO extension - the _alloc method" << be_nl; - *os << "CORBA::Exception *" << node->name () - << "::_alloc (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return new " << node->name () << ";" << be_uidt_nl; - *os << "}\n\n"; - - // 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); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_exception - " - "codegen for ctor failed\n"), -1); - } - delete visitor; - - *os << " : CORBA_UserException " - << " (CORBA::TypeCode::_duplicate (" << node->tc_name () - << "))" << be_nl; - *os << "{\n"; - os->incr_indent (); - // assign each individual member. We need yet another state - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); - ctx.exception (1); // indicate that the special ctor is being - // generated - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception -" - "codegen for scope failed\n"), -1); - } - delete visitor; - os->decr_indent (); - *os << "}\n\n"; - } - - // 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 - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception_cs::" - "visit_exception - " - "TypeCode definition failed\n" - ), -1); - } - - 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 deleted file mode 100644 index e264ed29f93..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp +++ /dev/null @@ -1,303 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// exception_ctor.cpp -// -// = DESCRIPTION -// Visitor generating code for the special constructor for Exceptions -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_exception.h" - -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_scope (ctx) -{ -} - -be_visitor_exception_ctor::~be_visitor_exception_ctor (void) -{ -} - -int -be_visitor_exception_ctor::post_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (!this->last_node (bd)) - *os << ",\n"; - return 0; -} - -int be_visitor_exception_ctor::visit_exception (be_exception *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - this->ctx_->node (node); // save the argument node - - if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << node->local_name (); - else - *os << node->name () << "::" << node->local_name (); - *os << "(" << be_idt << "\n"; - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_exception_ctor_assign::" - "visit_exception - " - "codegen for scope failed\n"), - -1); - } - - if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << be_uidt << ");\n\n"; - else - *os << be_uidt << ")\n\n"; - - return 0; -} - -int be_visitor_exception_ctor::visit_field (be_field *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // retrieve the type - be_type *bt = be_type::narrow_from_decl (node->field_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_exception_ctor::" - "visit_exception - " - "Bad field type\n"), - -1); - } - - os->indent (); - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_exception_ctor::" - "visit_field - " - "cannot accept visitor\n"), - -1); - } - - *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; - 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 ()); - else - *os << "const " << bt->name (); - return 0; -} - -int be_visitor_exception_ctor::visit_enum (be_enum *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; - 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 << bt->nested_type_name (this->ctx_->scope ()); - else - *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; - 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 ()); - else - *os << "const " << bt->name (); - *os << "_ptr "; - return 0; -} - -int be_visitor_exception_ctor::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; - 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 ()); - else - *os << "const " << bt->name (); - *os << "_ptr "; - return 0; -} - -int be_visitor_exception_ctor::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; - be_type *bt; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // check if the type is an any - if (node->pt () == AST_PredefinedType::PT_any) - { - if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); - else - *os << "const " << bt->name (); - *os << " &"; - return 0; - } // end of if - else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object - { - if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); - else - *os << "const " << bt->name (); - *os << "_ptr "; - } // end else if - else // simple predefined types - { - if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *os << bt->name (); - } // end of else - - 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; - 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 ()); - else - *os << "const " << bt->name (); - *os << " &"; - return 0; -} - -int be_visitor_exception_ctor::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - *os << "const char *"; - return 0; -} - -int be_visitor_exception_ctor::visit_structure (be_structure *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - // set the right type; - 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 ()); - else - *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; - 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 ()); - else - *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, - "be_visitor_exception_ctor::" - "visit_typedef - " - "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 deleted file mode 100644 index 51ed3ffd836..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_factory.cpp +++ /dev/null @@ -1,627 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL Backend -// -// = FILENAME -// be_visitor_factory.cpp -// -// = 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. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.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_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) -{ -} - -// 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_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 (idl_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: - // this is the starting point for generation of all CDR operators. If we - // do not use compiled marshaling, we do not need these operators - if (idl_global->compiled_marshaling ()) - return new be_visitor_root_cdr_op (new_ctx); - else - // return a NO_OP visitor - return new be_visitor_decl (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_CS: - return new be_visitor_module_any_op (new_ctx); - - - 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_COLLOCATED_SH: - return new be_visitor_interface_collocated_sh (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - return new be_visitor_interface_collocated_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_CS: - return new be_visitor_interface_cdr_op_cs (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_CI: - return new be_visitor_interface_fwd_cdr_op_ci (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_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_CS: - return new be_visitor_enum_cdr_op_cs (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_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: - return new be_visitor_union_any_op_cs (new_ctx); - 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_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_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_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_CS: - return new be_visitor_typedef_cdr_op_cs (new_ctx); - - case TAO_CodeGen::TAO_TYPECODE_DECL: - // Do we need TypeCode Support? - if (idl_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 (idl_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_COLLOCATED_SH: - case TAO_CodeGen::TAO_ATTRIBUTE_COLLOCATED_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_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_CS: - return new be_visitor_array_cdr_op_cs (new_ctx); - - default: - // an error - delete new_ctx; - return 0; - } -} - -// The concrete visitor factory for operation visitors generating interpretive -// stubs and skeletons - -TAO_Interpretive_Visitor_Factory::TAO_Interpretive_Visitor_Factory (void) -{ -} - -// destructor -TAO_Interpretive_Visitor_Factory::~TAO_Interpretive_Visitor_Factory (void) -{ -} - -be_visitor * -TAO_Interpretive_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_OPERATION_CH: - return new be_visitor_operation_ch (new_ctx); - case TAO_CodeGen::TAO_OPERATION_CS: - return new be_interpretive_visitor_operation_cs (new_ctx); - case TAO_CodeGen::TAO_OPERATION_SH: - return new be_visitor_operation_sh (new_ctx); - case TAO_CodeGen::TAO_OPERATION_IH: - return new be_visitor_operation_ih (new_ctx); - case TAO_CodeGen::TAO_OPERATION_SS: - return new be_interpretive_visitor_operation_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_IS: - return new be_visitor_operation_is (new_ctx); - case TAO_CodeGen::TAO_OPERATION_COLLOCATED_SH: - return new be_visitor_operation_collocated_sh (new_ctx); - case TAO_CodeGen::TAO_OPERATION_COLLOCATED_SS: - return new be_visitor_operation_collocated_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETTYPE_CH: - case TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS: - return new be_visitor_operation_rettype (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETTYPE_IS: - return new be_visitor_operation_rettype_is (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_docall_cs (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS: - return new be_visitor_operation_rettype_docall_cs (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETVAL_POST_INVOKE_CS: - return new be_visitor_operation_rettype_post_docall_cs (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_RETVAL_DECL_SS: - return new be_visitor_operation_rettype_vardecl_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETVAL_DEMARSHAL_SS: - 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_RETVAL_POST_UPCALL_SS: - return new be_visitor_operation_rettype_post_upcall_ss (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: - return new be_visitor_operation_arglist (new_ctx); - case TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS: - case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: - case TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS: - case TAO_CodeGen::TAO_OPERATION_ARG_PRE_UPCALL_SS: - 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: - case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: - case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - case TAO_CodeGen::TAO_OPERATION_ARG_POST_MARSHAL_SS: - return new be_visitor_operation_argument (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_ARGUMENT_ARGLIST_CH: - case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS: - return new be_visitor_args_arglist (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_PRE_INVOKE_CS: - return new be_visitor_args_pre_docall_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS: - return new be_visitor_args_docall_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS: - return new be_visitor_args_post_docall_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS: - return new be_visitor_args_vardecl_ss (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_PRE_UPCALL_SS: - return new be_visitor_args_pre_upcall_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_POST_UPCALL_SS: - return new be_visitor_args_post_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); - case TAO_CodeGen::TAO_ARGUMENT_POST_MARSHAL_SS: - return new be_visitor_args_post_marshal_ss (new_ctx); - - default: - // cannot handle it; delegate it to the common visitor factory - delete new_ctx; - return TAO_COMMON_VISITOR_FACTORY::instance ()->make_visitor (ctx); - } -} - -// 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_OPERATION_CH: - return new be_visitor_operation_ch (new_ctx); - case TAO_CodeGen::TAO_OPERATION_CS: - return new be_compiled_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_compiled_visitor_operation_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_COLLOCATED_SH: - return new be_visitor_operation_collocated_sh (new_ctx); - case TAO_CodeGen::TAO_OPERATION_COLLOCATED_SS: - return new be_visitor_operation_collocated_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETTYPE_CH: - case TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS: - return new be_visitor_operation_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_compiled_marshal (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETVAL_POST_INVOKE_CS: - // this is a NO-OP - return new be_visitor_decl (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_RETVAL_DECL_SS: - return new be_compiled_visitor_operation_rettype_vardecl_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETVAL_DEMARSHAL_SS: - // this is a NO-OP - return new be_visitor_decl (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETVAL_MARSHAL_SS: - return new be_visitor_operation_rettype_compiled_marshal (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_RETVAL_POST_UPCALL_SS: - // this is a NO-OP - return new be_visitor_decl (new_ctx); - case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS: - return new be_visitor_operation_arglist (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_PRE_UPCALL_SS: - 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: - case TAO_CodeGen::TAO_OPERATION_ARG_POST_MARSHAL_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_ARG_INVOKE_CS: - return new be_compiled_visitor_operation_argument_invoke (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_ARGUMENT_ARGLIST_CH: - case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS: - return new be_visitor_args_arglist (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_compiled_marshal_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS: - return new be_visitor_args_post_docall_compiled_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS: - return new be_compiled_visitor_args_vardecl_ss (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_PRE_UPCALL_SS: - // this is a NO-OP - return new be_visitor_decl (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_POST_UPCALL_SS: - // this is a NO-OP - return new be_visitor_decl (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS: - case TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS: - return new be_visitor_args_compiled_marshal_ss (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_POST_MARSHAL_SS: - // this is a NO-OP - return new be_visitor_decl (new_ctx); - - default: - // cannot handle it; delegate it to the common visitor factory - delete new_ctx; - return TAO_COMMON_VISITOR_FACTORY::instance ()->make_visitor (ctx); - } -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Singleton<TAO_Common_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Singleton<TAO_Interpretive_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; -template class ACE_Singleton<TAO_Compiled_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Singleton<TAO_Common_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX> -#pragma instantiate ACE_Singleton<TAO_Interpretive_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX> -#pragma instantiate ACE_Singleton<TAO_Compiled_Visitor_Factory, ACE_SYNCH_RECURSIVE_MUTEX> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/TAO_IDL/be/be_visitor_field.cpp b/TAO/TAO_IDL/be/be_visitor_field.cpp deleted file mode 100644 index 00f70870bed..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_field.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// $Id$ -// -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_field.cpp -// -// = DESCRIPTION -// Concrete visitor for the base "BE_Field" node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.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" -#include "be_visitor_field/cdr_op_ch.cpp" -#include "be_visitor_field/cdr_op_cs.cpp" - -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 deleted file mode 100644 index 93be4a933f5..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp +++ /dev/null @@ -1,294 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating CDR operator declarator for field in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, cdr_op_ch, "$Id$") - - -// ********************************************** -// visitor for field in the client header file -// ********************************************** - -// constructor -be_visitor_field_cdr_op_ch::be_visitor_field_cdr_op_ch (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -// destructor -be_visitor_field_cdr_op_ch::~be_visitor_field_cdr_op_ch (void) -{ -} - -// 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); - } - - this->ctx_->node (node); // save the 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); - } - - return 0; -} - -// =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 (!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 - 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_array - " - "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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_enum - " - "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 (!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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - return 0; -} - -// visit structure type -int -be_visitor_field_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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_struct - " - "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 - // indicate that the field of the field 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_field_cdr_op_ch::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - this->ctx_->alias (0); - return 0; -} - -// visit union type -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 (!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 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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - return 0; -} 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 deleted file mode 100644 index 2bc03cf4ca1..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp +++ /dev/null @@ -1,820 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// field_cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Field in the client stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -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_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); - } - - this->ctx_->node (node); // save the 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); - } - return 0; -} - -// visit array -int -be_visitor_field_cdr_op_cs::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "cannot retrieve field node\n" - ), -1); - } - - // for anonymous arrays, the type name has a _ prepended. We compute the - // fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (!this->ctx_->alias () // not a typedef - && node->is_child (this->ctx_->scope ())) - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - } - - // check what is the code generation substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *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 - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef - && node->is_child (this->ctx_->scope ())) - { - // this is the case for anonymous arrays. Generate the <<, >> operators - // for the type defined by the anonymous array - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the declaration - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit enum type -int -be_visitor_field_cdr_op_cs::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> _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 - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_enum - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the typcode for enums - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_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_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit interface type -int -be_visitor_field_cdr_op_cs::visit_interface (be_interface *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_interface - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> _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 - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_interface - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit interface forward type -int -be_visitor_field_cdr_op_cs::visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_interface_fwd - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> _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 - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_interface_fwd - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit predefined type -int -be_visitor_field_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_predefined_type - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - // is a psuedo obj - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm >> _tao_aggregate." << f->local_name () - << ".out ())"; - else if (node->pt () == AST_PredefinedType::PT_char) - *os << "(strm >> CORBA::Any::to_char (_tao_aggregate." - << f->local_name () << "))"; - else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "(strm >> CORBA::Any::to_wchar (_tao_aggregate." - << f->local_name () << "))"; - else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "(strm >> CORBA::Any::to_octet (_tao_aggregate." - << f->local_name () << "))"; - else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "(strm >> CORBA::Any::to_boolean (_tao_aggregate." - << f->local_name () << "))"; - else - *os << "(strm >> _tao_aggregate." << f->local_name () << ")"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - // is a psuedo obj - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm << _tao_aggregate." << f->local_name () << ".in ())"; - else if (node->pt () == AST_PredefinedType::PT_char) - *os << "(strm << CORBA::Any::from_char (_tao_aggregate." - << f->local_name () << "))"; - else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "(strm << CORBA::Any::from_wchar (_tao_aggregate." - << f->local_name () << "))"; - else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "(strm << CORBA::Any::from_octet (_tao_aggregate." - << f->local_name () << "))"; - else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "(strm << CORBA::Any::from_boolean (_tao_aggregate." - << f->local_name () << "))"; - else - *os << "(strm << _tao_aggregate." << f->local_name () << ")"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - return 0; -} - -int -be_visitor_field_cdr_op_cs::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_sequence - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> _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 - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_sequence - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef - && node->is_child (this->ctx_->scope ())) - // not a typedef AND - // node is defined inside the structure - { - // Anonymous sequence - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit string type -int -be_visitor_field_cdr_op_cs::visit_string (be_string *) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_string - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> _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 - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - return 0; -} - -// visit structure type -int -be_visitor_field_cdr_op_cs::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_structure - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> _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 - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_structure - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_struct - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit typedef type -int -be_visitor_field_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 - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_field_cdr_op_cs::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_union - " - "cannot retrieve field node\n" - ), -1); - } - - // check what is the code generations substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "(strm >> _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 - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_union - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_union - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// **************************************************************** - -be_visitor_cdr_op_field_decl:: - be_visitor_cdr_op_field_decl (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -// This is a field, but the action depends on the type of the field, -// use this visitor to detect the type of the field. -// Notice that this is why the parent visitor (who create us) cannot -// do the job, because it may have another purpose for some or all of -// the visit_* methods; in other words, while running a visitor to -// generate CDR operators for structures we cannot use that one to -// generate the code of each field, because visit_struct already has a -// meaning in that visitor. -int -be_visitor_cdr_op_field_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_cdr_op_field_decl::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - // @@ Shouldn't this be saved in the visitor and not the context?! - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_cdr_op_field_decl::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} - -// visit array -int -be_visitor_cdr_op_field_decl::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); - - // retrieve the field node - be_field *f = this->ctx_->be_node_as_field (); - if (!f) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_cdr_op_field_decl::" - "visit_array - " - "cannot retrieve field node\n" - ), -1); - } - - // for anonymous arrays, the type name has a _ prepended. We compute - // the fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (!this->ctx_->alias () // not a typedef - && node->is_child (this->ctx_->scope ())) - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope - // prepended to our local name. This needs to be inserted after - // the parents's name - - if (node->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); - } - - // check what is the code generation substate. Are we generating code for - // the in/out operators for our parent or for us? - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << fname << "_forany " - << "_tao_aggregate_" << f->local_name () << be_idt << be_idt_nl - << "(ACE_const_cast (" << be_idt << be_idt_nl - << fname << "_slice*," << be_nl - << "_tao_aggregate." << f->local_name () << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_cdr_op_field_decl::" - "visit_array - " - "bad sub state\n" - ), -1); - } - ACE_NOTREACHED (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 deleted file mode 100644 index 4698fc9c6b5..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp +++ /dev/null @@ -1,461 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// field_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Field node in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, field_ch, "$Id$") - - -// ********************************************** -// 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; // output stream - be_type *bt; // field'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_field_ch::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - // now output the field name. - *os << " " << node->local_name () << ";\n"; - return 0; -} - -// =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) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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 ())) - { - // 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.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_field_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_array - " - "codegen failed\n" - ), -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->indent (); - *os << "_" << bt->local_name (); - } - else - { - // this was a typedefed array - os->indent (); // start from current indentation level - *os << bt->nested_type_name (this->ctx_->scope ()); - } - return 0; -} - -// visit enum type -int -be_visitor_field_ch::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // now use this enum as a "type" for the subsequent declarator - os->indent (); // start from current indentation level - *os << bt->nested_type_name (this->ctx_->scope ()); - - return 0; -} - -// visit interface type -int -be_visitor_field_ch::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // if not a typedef and we are defined in the use scope, we must be defined - os->indent (); - *os << "TAO_Object_Field_T<" - << bt->nested_type_name (this->ctx_->scope (), "") - << ">"; - return 0; -} - -// visit interface forward type -int -be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // if not a typedef and we are defined in the use scope, we must be defined - os->indent (); - *os << "TAO_Object_Field_T<" - << bt->nested_type_name (this->ctx_->scope (), "") - << ">"; - return 0; -} - -// visit predefined type -int -be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // if not a typedef and we are defined in the use scope, we must be defined - os->indent (); // start from current indentation level - if (node->pt () == AST_PredefinedType::PT_pseudo) // is a psuedo obj - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); - else - *os << bt->nested_type_name (this->ctx_->scope ()); - return 0; -} - -// visit sequence type -int -be_visitor_field_ch::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - os->indent (); // start from current indentation level - *os << bt->nested_type_name (this->ctx_->scope ()); - return 0; -} - -// visit string type -int -be_visitor_field_ch::visit_string (be_string *) -{ - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - os->indent (); // start from current indentation level - // set the right type; - -#if 0 - if (this->ctx_->alias ()) - { - *os << this->ctx_->alias ()->nested_type_name (this->ctx_->scope ()) - << "_var"; - } - else - *os << "CORBA::String_var"; -#endif - *os << "TAO_String_Manager"; - return 0; -} - -// visit structure type -int -be_visitor_field_ch::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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); // set the node to be the node being visited. The scope - // is still the same - - // first generate the struct 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_field_ch::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_struct - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - os->indent (); // start from current indentation level - *os << bt->nested_type_name (this->ctx_->scope ()); - return 0; -} - -// visit typedefed type -int -be_visitor_field_ch::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // save the node for use in code generation and - // indicate that the type of the field node - // is a typedefed quantity - - // make a decision based on the primitive base type - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - // reset the alias - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_field_ch::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; - - os = this->ctx_->stream (); - // set the right type; - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - 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); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - os->indent (); // start from current indentation level - *os << bt->nested_type_name (this->ctx_->scope ()); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp deleted file mode 100644 index c97f3f071ec..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp +++ /dev/null @@ -1,255 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// field_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Field in the client inline file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -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); - } - - this->ctx_->node (node); // save the 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); - } - return 0; -} - -// =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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_array - " - "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 - { - // anonymous sequence - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_SEQUENCE_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_sequence - " - "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 - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_STRUCT_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_struct - " - "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 - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_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 - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the inline code for union - ctx.state (TAO_CodeGen::TAO_UNION_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_struct - " - "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 deleted file mode 100644 index 756c8aa123b..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp +++ /dev/null @@ -1,285 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// field_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Field in the client stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_field.h" - -ACE_RCSID(be_visitor_field, field_cs, "$Id$") - - -// ********************************************** -// 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); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} - -// visit 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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_array - " - "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 - { - // 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_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_enum - " - "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 - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_SEQUENCE_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_sequence - " - "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 - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_STRUCT_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_struct - " - "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 - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_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 - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union - ctx.state (TAO_CodeGen::TAO_UNION_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_union - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface.cpp deleted file mode 100644 index 23e9e3e3ad0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// $Id$ -// -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_interface.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Interface -// -// = AUTHOR -// Aniruddha Gokhale and Carlos O'Ryan -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.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" -#include "be_visitor_interface/interface_cs.cpp" -#include "be_visitor_interface/interface_sh.cpp" -#include "be_visitor_interface/interface_ih.cpp" -#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/collocated_sh.cpp" -#include "be_visitor_interface/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" -#include "be_visitor_interface/any_op_cs.cpp" -#include "be_visitor_interface/cdr_op_ch.cpp" -#include "be_visitor_interface/cdr_op_cs.cpp" - -ACE_RCSID(be, be_visitor_interface, "$Id$") - 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 deleted file mode 100644 index c80d1932af6..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for an Interface in the client -// header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, any_op_ch, "$Id$") - - -// *************************************************************************** -// Interface visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_interface_any_op_ch::be_visitor_interface_any_op_ch -(be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_any_op_ch::~be_visitor_interface_any_op_ch (void) -{ -} - -int -be_visitor_interface_any_op_ch::visit_interface (be_interface *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - os->indent (); - *os << "// Any operators for interface " << node->name () << be_nl; - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, " << node->name () - << "_ptr);" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << 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, - "(%N:%l) be_visitor_interface::visit_interface - " - "codegen for scope failed\n"), -1); - } - - node->cli_hdr_any_op_gen (1); - return 0; -} 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 deleted file mode 100644 index d773bde03fd..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// -// $id: any_op_cs.cpp,v 1.12 1998/10/30 19:46:55 levine Exp $ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for Interface in the stubs -// file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, any_op_cs, "$Id$") - - -// *************************************************************************** -// Interface visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_interface_any_op_cs::be_visitor_interface_any_op_cs -(be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_any_op_cs::~be_visitor_interface_any_op_cs (void) -{ -} - -int -be_visitor_interface_any_op_cs::visit_interface (be_interface *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->name () << "_ptr _tao_elem)" << be_nl - << "{" << be_idt_nl - << "CORBA::Object_ptr *_tao_obj_ptr = 0;" << be_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "ACE_NEW (_tao_obj_ptr, CORBA::Object_ptr);" << be_nl - << "*_tao_obj_ptr = " << node->name () - << "::_duplicate (_tao_elem);" << be_nl - << "_tao_any.replace (" << node->tc_name () << ", " - << "_tao_obj_ptr, 1, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _tao_obj_ptr;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << "_ptr &_tao_elem)" << be_nl - << "{" << be_idt_nl - << "CORBA::Object_ptr *tmp = 0;" << be_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_elem = " << node->name () << "::_nil ();" << be_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", TAO_TRY_ENV)) return 0; // not equal" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any._tao_get_cdr ());" - << be_nl - << "CORBA::Object_var _tao_obj_var;" << be_nl - << "ACE_NEW_RETURN (tmp, CORBA::Object_ptr, 0);" << be_nl - << "if (stream.decode (" << node->tc_name () - << ", &_tao_obj_var.out (), 0, TAO_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl - << "_tao_elem = " << node->name () - << "::_narrow (_tao_obj_var.in (), TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "*tmp = (CORBA::Object_ptr) _tao_elem; // any owns the object" - << be_nl - << "((CORBA::Any *)&_tao_any)->replace (" - << node->tc_name () << ", tmp, 1, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "// failure" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete tmp;" << be_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\n"; - - *os << "#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)" << be_idt_nl - << "template class TAO_Object_Field_T<" - << node->name () << ">;" << be_uidt_nl - << "#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)" << be_nl - << "# pragma instantiate TAO_Object_Field_T<" - << node->name () << ">" << be_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) - { - 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); - 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 deleted file mode 100644 index 0874e4517d1..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_ch.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for interfaces. This uses -// compiled marshaling. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -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 (ctx) -{ -} - -be_visitor_interface_cdr_op_ch::~be_visitor_interface_cdr_op_ch (void) -{ -} - -int -be_visitor_interface_cdr_op_ch::visit_interface (be_interface *node) -{ - if (node->cli_hdr_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - os->indent (); - *os << "CORBA::Boolean " << idl_global->export_macro () << be_nl - << "operator<< (TAO_OutputCDR &, const " << node->name () - << "_ptr );" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () << be_nl - << "operator>> (TAO_InputCDR &, " - << node->name () << "_ptr &);\n"; - - - // set the substate as generating code for the types defined in our scope - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_cdr_op_ch::" - "visit_interface - " - "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_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp deleted file mode 100644 index 9dd3b3c8e6c..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for interfaces -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, cdr_op_cs, "$Id$") - -// *************************************************************************** -// Interface visitor for generating CDR operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_interface_cdr_op_cs::be_visitor_interface_cdr_op_cs -(be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_cdr_op_cs::~be_visitor_interface_cdr_op_cs (void) -{ -} - -int -be_visitor_interface_cdr_op_cs::visit_interface (be_interface *node) -{ - // already generated and/or we are imported. Don't do anything. - if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // First generate code for our children. The reason we do this first is - // because the inlined code for our children must be available before we use - // it in our parent, but we must forward declare the parent - // operators, so code like this: - // - // // IDL - // interface Foo { - // exception Bar {Foo foo_member; }; - // }; - // - // can work properly (the Foo::Bar operators need the Foo operators - // defined). - // - - // generate the CDR << and >> operator declarations - os->indent (); - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator<< (" << be_idt << be_idt_nl - << "TAO_OutputCDR &," << be_nl - << "const " << node->name () << "_ptr" << be_uidt_nl - << ");" << be_uidt_nl; - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator>> (" << be_idt << be_idt_nl - << "TAO_InputCDR &," << be_nl - << node->name () << "_ptr &" << be_uidt_nl - << ");" << be_uidt << "\n"; - - // Now it really the type to generate the operators for the members - // of the interface... - - // 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_cs" - "::visit_interface - " - "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); - // @@ TODO don't use the IIOP interpreter here, we should use << and - // >> operators, or even the operator for the base CORBA::Object!! - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator<< (" << be_idt << be_idt_nl - << "TAO_OutputCDR &strm," << be_nl - << "const " << node->name () << "_ptr _tao_objref" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - // hand over the encoding to the TAO's internal engine - // *os << "CORBA::Environment env;" << be_nl; - *os << "TAO_TRY" << be_nl - << "{" << be_idt_nl; - // resolve the nastiness created due to casting to void* and then to - // CORBA::Object_ptr - *os << "CORBA::Object_ptr _tao_corba_obj = _tao_objref;" << be_nl; - *os << "if (TAO_MARSHAL_OBJREF::instance ()->" << be_nl - << " encode (0, &_tao_corba_obj, 0, &strm, TAO_TRY_ENV) == " - << be_nl - << " CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_idt_nl - << "return 1;" << be_uidt_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl; - *os << "}\n\n"; - - // set the substate as generating code for the input operator - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - // @@ TODO don't use the IIOP interpreter here, we should use << and - // >> operators, or even the operator for the base CORBA::Object!! - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator>> (" << be_idt << be_idt_nl - << "TAO_InputCDR &strm," << be_nl - << node->name () << "_ptr &_tao_objref" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - // hand over to the TAO's internal marshaling engine - // *os << "CORBA::Environment env;" << be_nl; - *os << "TAO_TRY" << be_nl - << "{" << be_idt_nl; - *os << "CORBA::Object_ptr obj;" << be_nl; - *os << "if (TAO_MARSHAL_OBJREF::instance ()->" << be_nl - << " decode (0, &obj, 0, &strm, TAO_TRY_ENV) == " << be_nl - << " CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl; - *os << "TAO_CHECK_ENV;" << be_nl; - *os << "// narrow to the right type" << be_nl; - *os << "_tao_objref = " << node->name () - << "::_narrow (obj, TAO_TRY_ENV);" << be_nl; - *os << "TAO_CHECK_ENV;" << be_nl; - *os << "CORBA::release (obj);" << be_nl; - *os << "return 1;" << be_uidt_nl; - *os << "}" << be_nl; - *os << "return 0; // error" << be_uidt_nl; - *os << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "ACE_NOTREACHED (return 0);" << be_uidt_nl; - *os << "}\n\n"; - - node->cli_stub_cdr_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface/collocated_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/collocated_sh.cpp deleted file mode 100644 index 46a63786e3a..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/collocated_sh.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// collocated_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for collocated classes for the Interface node -// inside the server header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, collocated_sh, "$Id$") - - -// ************************************************************ -// collocated class in header -// ************************************************************ - -be_visitor_interface_collocated_sh::be_visitor_interface_collocated_sh -(be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_collocated_sh::~be_visitor_interface_collocated_sh (void) -{ -} - -int be_visitor_interface_collocated_sh::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->gen_ifdef_macro (node->flatname (), "_collocated"); - - // output the class defn - os->indent (); - *os << "class " << idl_global->export_macro () - << " " << node->local_coll_name (); - os->incr_indent (); - *os << " : public virtual " << node->name (); - - // generate base classes if any - if (node->n_inherits () > 0) - { - for (int i = 0; i < node->n_inherits (); ++i) - { - *os << "," << be_nl; - be_interface* parent = - be_interface::narrow_from_decl (node->inherits()[i]); - *os << " public virtual " - << parent->relative_coll_name (node->full_coll_name ()); - } - } - *os << "\n"; - os->decr_indent (); - *os << "{" << be_nl; - *os << "public:\n"; - os->incr_indent (); - - *os << node->local_coll_name () << " (\n"; - - os->incr_indent (0); - os->incr_indent (); - - // XXXASG - can we make this a method to return the right name ?? - if (!node->is_nested ()) - { - // The skeleton name is the outermost, we need to printout the - // POA_ prefix that goes with it. - *os << "POA_"; - } - - *os << node->local_name () << "_ptr " - << " servant," << be_nl; - - *os << "STUB_Object *stub\n"; - os->decr_indent (); - *os << ");\n"; - os->decr_indent (0); - - os->indent (); - if (!node->is_nested ()) - { - // The skeleton name is the outermost, we need to printout the - // POA_ prefix that goes with it. - *os << "POA_"; - } - *os << node->local_name () - << "_ptr _get_servant (void) const;" << be_nl; - - *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl - << "const char *logical_type_id," << be_nl - << "CORBA::Environment &_tao_environment = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt << "\n"; - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_collocated_sh::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - - os->decr_indent (); - - *os << be_nl << "private:\n"; - os->incr_indent (); - if (!node->is_nested ()) - { - // The skeleton name is the outermost, we need to printout the - // POA_ prefix that goes with it. - *os << "POA_"; - } - *os << node->local_name () << "_ptr servant_;\n"; - os->decr_indent (); - *os << "};\n\n"; - - os->gen_endif (); - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface/collocated_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/collocated_ss.cpp deleted file mode 100644 index a89bb37be3c..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/collocated_ss.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// collocated_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for collocated classes for an Interface in the -// server skeleton file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, collocated_ss, "$Id$") - - -// ************************************************************ -// be_visitor_interface_collacted_ss -// ************************************************************ - -be_visitor_interface_collocated_ss::be_visitor_interface_collocated_ss -(be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_collocated_ss::~be_visitor_interface_collocated_ss (void) -{ -} - -int be_visitor_interface_collocated_ss::visit_interface (be_interface *node) -{ - TAO_OutStream *os = tao_cg->server_skeletons (); - - this->ctx_->node (node); - - *os << node->full_coll_name () << "::" - << node->local_coll_name () << " (\n"; - - os->incr_indent (0); - os->incr_indent (); - *os << node->full_skel_name () << "_ptr " - << " servant," << be_nl; - - *os << "STUB_Object *stub\n"; - os->decr_indent (); - *os << ")\n"; - os->decr_indent (0); - - os->incr_indent (); - - if (node->is_nested ()) - { - be_decl* scope = - be_scope::narrow_from_scope (node->defined_in ())->decl (); - - *os << ": ACE_NESTED_CLASS (" - << scope->name () << "," - << node->local_name () - << ") ()," << be_nl; - } - else - { - *os << ": " << node->name () - << " ()," << be_nl; - } - - // @@ We should call the constructor for all base classes, since we - // are using multiple inheritance. - - if (node->traverse_inheritance_graph (be_interface::collocated_ctor_helper, os) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_collocated_ss::" - "visit_interface - " - "codegen for base class ctor init failed\n"), - -1); - } - - *os << " CORBA_Object (stub, servant, 1)," << be_nl - << " servant_ (servant)"; - - *os << "\n"; - os->decr_indent (); - *os << "{\n"; - *os << "}\n\n"; - - os->indent (); - *os << node->full_skel_name () << "_ptr " - << node->full_coll_name () << "::" - << "_get_servant (void) const\n" - << "{\n"; - os->incr_indent (); - *os << "return this->servant_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "CORBA::Boolean " << node->full_coll_name () - << "::_is_a (" << be_idt << be_idt_nl - << "const char* logical_type_id," << be_nl - << "CORBA::Environment &_tao_environment" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "return this->servant_->_is_a (" << be_idt << be_idt_nl - << "logical_type_id," << be_nl - << "_tao_environment" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl - << "}\n\n"; - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_collocated_ss::" - "visit_scope - " - "codegen for scope failed\n"), - -1); - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp deleted file mode 100644 index d6e5a07c006..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp +++ /dev/null @@ -1,683 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces. This is a generic visitor. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -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_interface::~be_visitor_interface (void) -{ -} - -// this method must be overridden by the derived interface visitors -int -be_visitor_interface::visit_interface (be_interface *) -{ - return -1; -} - -// =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 - 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_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_SH: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_SH); - break; - case TAO_CodeGen::TAO_INTERFACE_IH: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_IH); - break; - case TAO_CodeGen::TAO_INTERFACE_SS: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_SS); - break; - case TAO_CodeGen::TAO_INTERFACE_IS: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_IS); - break; - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SH: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_COLLOCATED_SH); - break; - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_COLLOCATED_SS); - break; - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_TIE_SH); - break; - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI); - 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: - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - case TAO_CodeGen::TAO_INTERFACE_CI: - case TAO_CodeGen::TAO_INTERFACE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_attribute - " - "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); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_attribute - " - "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 - // 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_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - 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: - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SH: - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - case TAO_CodeGen::TAO_INTERFACE_CI: - 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_TIE_SH: - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_constant - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_constant - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 - // 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_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_CI: - 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_COLLOCATED_SH: - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_enum - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_enum - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -// visit an exception -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 - 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_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; - 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_COLLOCATED_SH: - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_exception - " - "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_exception - " - "NUL 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; -} - -// visit an operation -int -be_visitor_interface::visit_operation (be_operation *node) -{ - // 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 - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_OPERATION_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_OPERATION_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_SH); - break; - case TAO_CodeGen::TAO_INTERFACE_IH: - ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - break; - case TAO_CodeGen::TAO_INTERFACE_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_SS); - break; - case TAO_CodeGen::TAO_INTERFACE_IS: - ctx.state (TAO_CodeGen::TAO_OPERATION_IS); - break; - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_SH); - break; - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_SS); - break; - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SH); - break; - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - ctx.state (TAO_CodeGen::TAO_OPERATION_TIE_SI); - 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: - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - case TAO_CodeGen::TAO_INTERFACE_CI: - case TAO_CodeGen::TAO_INTERFACE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_operation - " - "Bad context state\n" - ), -1); - } - } - - // 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); - } - - // 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); - } - delete visitor; - 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 - 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_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; - 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_COLLOCATED_SH: - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_structure - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_structure - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_structure - " - "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 - 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_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; - 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_COLLOCATED_SH: - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_union - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_union - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_union - " - "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 - 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_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; - case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; - 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_COLLOCATED_SH: - case TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS: - case TAO_CodeGen::TAO_INTERFACE_TIE_SH: - case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_typedef - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_typedef - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 deleted file mode 100644 index d99981346b0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ /dev/null @@ -1,224 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_ch, "$Id$") - - -// ****************************************************** -// Interface visitor for client header -// ****************************************************** - -be_visitor_interface_ch::be_visitor_interface_ch (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_ch::~be_visitor_interface_ch (void) -{ -} - -int -be_visitor_interface_ch::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - long i; // loop index - - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported - { - - os = this->ctx_->stream (); - - // == STEP 1: generate the class name and class names we inherit == - - // generate the ifdefined macro for the _ptr type - os->gen_ifdef_macro (node->flatname (), "_ptr"); - - - // the following two are required to be under the ifdef macro to avoid - // multiple declarations - - os->indent (); // start with whatever indentation level we are at - // forward declaration - *os << "class " << node->local_name () << ";" << be_nl; - // generate the _ptr declaration - *os << "typedef " << node->local_name () << " *" << node->local_name () - << "_ptr;" << be_nl; - - os->gen_endif (); - - // generate the ifdefined macro for the var type - os->gen_ifdef_macro (node->flatname (), "_var"); - - // generate the _var declaration - if (node->gen_var_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ch::" - "visit_interface - " - "codegen for _var failed\n"), -1); - } - os->gen_endif (); - - // generate the ifdef macro for the _out class - os->gen_ifdef_macro (node->flatname (), "_out"); - - // generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec - if (node->gen_out_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ch::" - "visit_interface - " - "codegen for _out failed\n"), -1); - } - // generate the endif macro - os->gen_endif (); - - // now the interface definition itself - os->gen_ifdef_macro (node->flatname ()); - - // now generate the class definition - os->indent (); - *os << "class " << idl_global->export_macro () - << " " << node->local_name (); - - if (node->n_inherits () > 0) // node interface inherits from other - // interfaces - { - *os << ": "; - 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 - scope = be_scope::narrow_from_scope (node->defined_in ()) - ->decl (); - } - - *os << "public virtual "; - *os << inherited->nested_type_name (scope); // dump the scoped name - if (i < node->n_inherits () - 1) // node is the case of multiple - // inheritance, so put a comma - { - *os << ", "; - } - } // end of for loop - *os << be_nl; - } - else - { - // we do not inherit from anybody, hence we do so from the base - // CORBA::Object class - // Generate code that uses the macro. This is required to deal with - // the MSVC++ insanity - *os << " : public virtual ACE_CORBA_1 (Object)" << be_nl; - } - - // generate the body - - *os << "{" << be_nl - << "public:" << be_idt_nl - // generate the static _duplicate, _narrow, and _nil operations - << "// the static operations" << be_nl - << "static " << node->local_name () << "_ptr " << "_duplicate (" - << node->local_name () << "_ptr obj);" << be_nl - << "static " << node->local_name () << "_ptr " - << "_narrow (" << be_idt << be_idt_nl - << "CORBA::Object_ptr obj," << be_nl - << "CORBA::Environment &env = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt_nl - << "static " << node->local_name () << "_ptr " << "_nil (void);\n\n"; - - // 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); - } - // the _is_a method - os->indent (); - *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl - << "const CORBA::Char *type_id, " << be_nl - << "CORBA::Environment &env = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt_nl - << "virtual const char* " - << "_interface_repository_id (void) const;" << be_uidt_nl; - - // generate the "protected" constructor so that users cannot instantiate - // us - *os << "protected:" << be_idt_nl - << node->local_name () << " (void); // default constructor" << be_nl - << node->local_name () - << " (STUB_Object *objref, " << be_idt << be_idt_nl - << "TAO_ServantBase *_tao_servant = 0, " << be_nl - << "CORBA::Boolean _tao_collocated = 0" << be_uidt_nl - << ");" << be_uidt_nl - << "virtual ~" << node->local_name () << " (void);" << be_uidt_nl; - - // private copy constructor and assignment operator. These are not - // allowed, hence they are private. - *os << "private:\n"; - os->incr_indent (); - *os << node->local_name () << " (const " << node->local_name () << " &);" - << be_nl - << "void operator= (const " << node->local_name () << " &);\n"; - - os->decr_indent (); - *os << "};\n\n"; - os->gen_endif (); - - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - 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_interface_ch::" - "visit_interface - " - "TypeCode declaration failed\n" - ), -1); - } - - - node->cli_hdr_gen (I_TRUE); - } // if !cli_hdr_gen - 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 deleted file mode 100644 index 420bd26cc40..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the client inline file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -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) -{ -} - -be_visitor_interface_ci::~be_visitor_interface_ci (void) -{ -} - -int -be_visitor_interface_ci::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - - if (node->cli_inline_gen () || node->imported ()) - return 0; - - os = this->ctx_->stream (); - - os->indent (); // start from the current indentation level - - // generate the constructors and destructor - *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::" << node->local_name () << - " (void) // default constructor" << be_nl; - *os << "{}" << be_nl << be_nl; - - *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::" << node->local_name () << - " (STUB_Object *objref, TAO_ServantBase *_tao_servant, " - << "CORBA::Boolean _tao_collocated) // constructor" << be_nl; - *os << " : CORBA_Object (objref, _tao_servant, _tao_collocated)" << be_nl; - *os << "{}" << be_nl << be_nl; - - *os << "ACE_INLINE" << be_nl; - *os << node->name () << "::~" << node->local_name () << - " (void) // destructor" << be_nl; - *os << "{}\n\n"; - - // generate the ifdefined macro for the _var type - os->gen_ifdef_macro (node->flatname (), "_var"); - if (node->gen_var_impl () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ci::" - "visit_interface - " - "codegen for _var failed\n"), -1); - } - os->gen_endif (); - - // generate the ifdefined macro for the _out type - os->gen_ifdef_macro (node->flatname (), "_out"); - if (node->gen_out_impl () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ci::" - "visit_interface - " - "codegen for _out failed\n"), -1); - } - os->gen_endif (); - - // generate inline methods for elements of our scope - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_ci::" - "visit_interface - " - "codegen for scope failed\n"), -1); - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp deleted file mode 100644 index 624362423f8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the client stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_cs, "$Id$") - - -// ************************************************************ -// Interface visitor for client stubs -// ************************************************************ - -be_visitor_interface_cs::be_visitor_interface_cs (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_cs::~be_visitor_interface_cs (void) -{ -} - -int -be_visitor_interface_cs::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - - if (node->cli_stub_gen () || node->imported ()) - return 0; - - os = this->ctx_->stream (); - - os->indent (); // start with whatever indentation level we are at - - // first generate the code for the static methods - - // The _duplicate method - *os << node->name () << "_ptr " << node->name () << "::_duplicate (" - << node->name () << "_ptr obj)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "if (!CORBA::is_nil (obj))\n"; - os->incr_indent (); - *os << "obj->_incr_refcnt ();\n"; - os->decr_indent (); - *os << be_nl; - *os << "return obj;\n"; - os->decr_indent (); - *os << "} // end of _duplicate" << be_nl << be_nl; - - // The _narrow method - *os << node->name () << "_ptr " << node->name () - << "::_narrow (" << be_idt << be_idt_nl - << "CORBA::Object_ptr obj," << be_nl - << "CORBA::Environment &env" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "if (CORBA::is_nil (obj))" << be_idt_nl - << "return " << node->name () << "::_nil ();" << be_uidt_nl - << "if (!obj->_is_a (\"" << node->repoID () << "\", env))" - << be_idt_nl - << "return " << node->name () << "::_nil ();" << be_uidt_nl; - - *os << "STUB_Object* stub = obj->_stubobj ();" << be_nl - << "stub->_incr_refcnt ();" << be_nl; - *os << "if (!obj->_is_collocated ()" << be_idt << be_idt << be_idt_nl - << " || !obj->_servant()" << be_nl - << " || obj->_servant()->_downcast (\"" - << node->repoID () << "\") == 0" << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << "{" << be_idt_nl; - *os << "return new " - << node->name () << "(stub);" << be_uidt_nl - << "}" << be_nl; - - *os << "void* servant = obj->_servant ()->_downcast (\"" - << node->repoID () << "\");" << be_nl - << "return new "; - - // This may be necessary to work around a GCC compiler bug! - const char *skel_name = node->full_skel_name (); - const char *coll_name = node->full_coll_name (); - assert (coll_name != 0); - - *os << coll_name << "(" << be_idt << be_idt_nl - << "ACE_reinterpret_cast(" << skel_name - << "_ptr, servant)," << be_nl - << "stub" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl - << "}" << be_nl << be_nl; - - // _nil method - *os << node->name () << "_ptr " - << node->name () << "::_nil (void)" << be_nl - << "{" << be_idt_nl - << "return (" << node->name () << "_ptr)0;" << be_uidt_nl - << "}" << be_nl << be_nl; - - // generate code for the elements of the interface - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_cs::" - "visit_interface - " - "codegen for scope failed\n"), -1); - } - - // generate the is_a method - os->indent (); - *os << "CORBA::Boolean " << node->name () << "::_is_a (" << - "const CORBA::Char *value, CORBA::Environment &env)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "if (\n"; - os->incr_indent (0); - if (node->traverse_inheritance_graph (be_interface::is_a_helper, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_cs::" - "visit_interface - " - "_is_a method codegen failed\n"), -1); - } - - os->indent (); - *os << "(!ACE_OS::strcmp ((char *)value, CORBA::_tc_Object->id (env))))\n"; - *os << " return 1; // success using local knowledge\n"; - os->decr_indent (); - *os << "else" << be_nl; - *os << " return this->CORBA_Object::_is_a (value, env); // remote call\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "const char* " << node->name () - << "::_interface_repository_id (void) const" - << be_nl - << "{" << be_idt_nl - << "return \"" << node->repoID () << "\";" << be_uidt_nl - << "}\n\n"; - - // 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); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_cs::" - "visit_interface - " - "TypeCode definition failed\n" - ), -1); - } - - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp deleted file mode 100644 index c952c2fab35..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_ih.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the implementation header -// -// = AUTHOR -// Yamuna Krishnamurthy (yamuna@cs.wustl.edu) -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_ih, "$Id$") - -// ************************************************************ -// Interface visitor for implementation header -// ************************************************************ - -be_visitor_interface_ih::be_visitor_interface_ih (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_ih::~be_visitor_interface_ih (void) -{ -} - -int -be_visitor_interface_ih::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - long i; // loop index - static char namebuf [NAMEBUFSIZE]; // holds the class name - - - if (node->impl_hdr_gen () || node->imported ()) - return 0; - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - - os = this->ctx_->stream (); - - // generate the skeleton class name - - os->indent (); // start with whatever indentation level we are at - - - ACE_OS::sprintf (namebuf, "%s", node->flatname ()); - - *os << "//Class " << idl_global->impl_class_prefix ()<<namebuf << idl_global->impl_class_suffix ()<< be_nl; - // now generate the class definition - *os << "class " << idl_global->export_macro () - << " " <<idl_global->impl_class_prefix () << namebuf << idl_global->impl_class_suffix () << " : "; - - if (node->n_inherits () > 0) - { - // this interface inherits from other interfaces - be_interface *intf; // inherited interface - - - *os << "public virtual "; - - intf = be_interface::narrow_from_decl (node->inherits ()[0]); - *os << idl_global->impl_class_prefix () << intf->flatname () << idl_global->impl_class_suffix ();//intf->relative_skel_name (node->full_skel_name ()); - for (i = 1; i < node->n_inherits (); i++) - { - *os << ", public virtual "; - intf = be_interface::narrow_from_decl (node->inherits ()[i]); - *os << idl_global->impl_class_prefix () <<intf->flatname () << idl_global->impl_class_suffix ();//intf->relative_skel_name (node->full_skel_name ()); - } // end of for loop - - //inherit from the base skeleton file - *os<<", public virtual "<<node->full_skel_name (); - } - - else - { - //inherit from the base skeleton file - *os<<"public virtual "<<node->full_skel_name (); - } - - - *os << be_nl - << "{" << be_nl - << "public:" << be_idt_nl - << "//Constructor " << be_nl - << idl_global->impl_class_prefix () << namebuf << idl_global->impl_class_suffix () << " (void);" << be_nl << be_nl; - - if (idl_global->gen_copy_ctor ()) - { - *os << "//Copy Constructor"<<be_nl - << idl_global->impl_class_prefix () << namebuf << idl_global->impl_class_suffix () << " (const " - << idl_global->impl_class_prefix () << namebuf << idl_global->impl_class_suffix () << "&);" <<be_nl <<be_nl; - } - - if (idl_global->gen_assign_op ()) - { - *os << "//Copy Assignment" << be_nl - << idl_global->impl_class_prefix () << namebuf << idl_global->impl_class_suffix () << "& " - << "operator=(const " << idl_global->impl_class_prefix () << namebuf << idl_global->impl_class_suffix () << "&);"<<be_nl << be_nl; - - } - - *os << "//Destructor " << be_nl - << "virtual " << "~" << idl_global->impl_class_prefix () << namebuf << idl_global->impl_class_suffix () << " (void);" << be_nl << be_uidt_nl; - - - // generate code for elements in the scope (e.g., operations) - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ih::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - - - *os << "};" << be_nl <<be_nl; - 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 deleted file mode 100644 index 21c3ebb6245..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Id:$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_is.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the implementation skeletons file. -// -// = AUTHOR -// Yamuna Krishnamurthy (yamuna@cs.wustl.edu) -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - - -// ************************************************************ -// Interface visitor for implementation skeletons -// ************************************************************ - -ACE_RCSID(be_visitor_interface, interface_is, "$Id$") - -be_visitor_interface_is::be_visitor_interface_is (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_is::~be_visitor_interface_is (void) -{ -} - -int -be_visitor_interface_is::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - - if (node->impl_skel_gen () || node->imported ()) - return 0; - - os = this->ctx_->stream (); - - // generate the skeleton class name - - os->indent (); // start with whatever indentation level we are at - - - // constructor - *os << "// Implementation skeleton constructor" << be_nl; - // find if we are at the top scope or inside some module - *os << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () <<"::" << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () << - " (void)" << be_idt_nl; - - - if(node->n_inherits () >0) - { - //generate the default constructors of all the base classes - node->gen_def_ctors(os); - } - *os << "{" << be_nl - << "}" << be_nl << be_uidt_nl; - - // destructor - os->indent (); - *os << "// Implementation skeleton destructor" << be_nl; - - *os << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () <<"::~" << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () << - " (void)" << be_idt_nl; - - *os << "{" <<be_nl; - *os << "}" << be_nl <<be_uidt_nl; - - if (idl_global->gen_copy_ctor () ) - { - *os << "//Implementation Skeleton Copy Constructor" << be_nl; - - *os <<idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () <<"::" - << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () << " (const " - << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () << "& t)"<< be_idt_nl; - if(node->n_inherits () >0) - { - node->gen_copy_ctors(os); - *os << ", TAO_ServantBase (t)" << be_nl; - } - *os << "{" << be_nl - << "}" << be_nl << be_uidt_nl; - } - - if (idl_global->gen_assign_op ()) - { - *os << "//Implementation Skeleton Copy Assignment" << be_nl; - - *os << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () << "& " - << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () << "::operator=(const " - << idl_global->impl_class_prefix () << node->flatname () << idl_global->impl_class_suffix () << "& t)" <<be_idt_nl - << "{" << be_idt_nl - << "return *this;" << be_uidt_nl - << "}" << be_nl << be_uidt_nl; - } - - // generate code for elements in the scope (e.g., operations) - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - - - 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 deleted file mode 100644 index 7b21288dd07..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the server header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_sh, "$Id$") - - -// ************************************************************ -// Interface visitor for server header -// ************************************************************ - -be_visitor_interface_sh::be_visitor_interface_sh (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_sh::~be_visitor_interface_sh (void) -{ -} - -int -be_visitor_interface_sh::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - long i; // loop index - static char namebuf [NAMEBUFSIZE]; // holds the class name - - if (node->srv_hdr_gen () || node->imported ()) - return 0; - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - - os = this->ctx_->stream (); - - // generate the skeleton class name - - os->indent (); // start with whatever indentation level we are at - - // we shall have a POA_ prefix only if we are at the topmost level - if (!node->is_nested ()) - { - // we are outermost - ACE_OS::sprintf (namebuf, "POA_%s", node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - } - - *os << "class " << namebuf << ";" << be_nl; - - // generate the _ptr declaration - *os << "typedef " << namebuf << " *" << namebuf - << "_ptr;" << be_nl; - - // now generate the class definition - *os << "class " << idl_global->export_macro () - << " " << namebuf << " : "; - if (node->n_inherits () > 0) - { - // this interface inherits from other interfaces - be_interface *intf; // inherited interface - - *os << "public virtual "; - intf = be_interface::narrow_from_decl (node->inherits ()[0]); - *os << intf->relative_skel_name (node->full_skel_name ()); - for (i = 1; i < node->n_inherits (); i++) - { - *os << ", public virtual "; - intf = be_interface::narrow_from_decl (node->inherits ()[i]); - *os << intf->relative_skel_name (node->full_skel_name ()); - } // end of for loop - } - else - { - // We don't inherit from another user defined object, hence our - // base class is the ServantBase class. - *os << " public virtual PortableServer::ServantBase"; - } - *os << be_nl - << "{" << be_nl - << "protected:" << be_idt_nl - << namebuf << " (void);" << be_uidt_nl - << "public:" << be_idt_nl - << namebuf << " (const " << namebuf << "& rhs);" << be_nl - << "virtual ~" << namebuf << " (void);" << be_nl; - - *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl - << "const char* logical_type_id," << be_nl - << "CORBA::Environment &_tao_environment = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "virtual void* _downcast (" << be_idt << be_idt_nl - << "const char* logical_type_id" << be_uidt_nl - << ");\n" << be_uidt; - - // generate code for elements in the scope (e.g., operations) - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - // add a skeleton for our _is_a method - os->indent (); - *os << "static void _is_a_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &_tao_enviroment = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt << "\n\n"; - - // add a skeleton for our _non_existent method - os->indent (); - *os << "static void _non_existent_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *context," << be_nl - << "CORBA::Environment &_tao_enviroment = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt << "\n\n"; - - // add a method that says whether we are involved in a multiple inheritance - // or not - os->indent (); - *os << "CORBA::Boolean in_mult_inheritance (void);\n\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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "inheritance graph traversal failed\n"), - -1); - } - - // add the dispatch method - os->indent (); - *os << "virtual void _dispatch (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &_tao_req," << be_nl - << "void *_tao_context," << be_nl - << "CORBA::Environment &_tao_env = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt << "\n\n"; - - // Print out the _this() method. - os->indent (); - *os << node->name () << " *_this (" << be_idt << be_idt_nl - << "CORBA::Environment &_tao_environment = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt << "\n"; - - // the _interface_repository_id method - os->indent (); - *os << "virtual const char* _interface_repository_id (void) const;\n"; - os->decr_indent (); - - *os << "};\n\n"; - - // generate the collocated class - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for collocated class failed\n"), - -1); - } - - // generate the TIE class - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for TIE class failed\n"), - -1); - } - - *os << "\n"; - ctx.stream (tao_cg->server_template_header ()); - - 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 deleted file mode 100644 index 76768659b91..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_si.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the server inline file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_si, "$Id$") - - -// ************************************************************************ -// Interface visitor for server inline -// ************************************************************************ - -be_visitor_interface_si::be_visitor_interface_si (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -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 ()) - return 0; - - os = this->ctx_->stream (); - - // determine if we are in some form of a multiple inheritance - if (node->traverse_inheritance_graph - (be_interface::in_mult_inheritance_helper, 0) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_si::visit_interface " - "error determining mult inheritance\n"), - -1); - } - - os->indent (); // start with whatever indentation level we are at - *os << "ACE_INLINE CORBA::Boolean" << be_nl; - *os << node->full_skel_name () << "::in_mult_inheritance (void)" << be_nl - << "{" << be_idt_nl; - switch (node->in_mult_inheritance ()) - { - case 0: - *os << "return 0;"; - break; - case 1: - *os << "return 1;"; - break; - default: - // error - return -1; - } - *os << be_uidt_nl - << "}" << be_nl << be_nl; - - // 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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_si::" - "visit_interface - " - "codegen for base class skeletons failed\n"), -1); - } - - // 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); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for TIE class failed\n"), - -1); - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp deleted file mode 100644 index 2b14e10b3cf..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp +++ /dev/null @@ -1,342 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for Interfaces in the server skeletons file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface_ss, "$Id$") - - -// ************************************************************ -// Interface visitor for server skeletons -// ************************************************************ - -be_visitor_interface_ss::be_visitor_interface_ss (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_ss::~be_visitor_interface_ss (void) -{ -} - -int -be_visitor_interface_ss::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - - if (node->srv_skel_gen () || node->imported ()) - return 0; - - os = this->ctx_->stream (); - - // generate the skeleton class name - - os->indent (); // start with whatever indentation level we are at - - if (node->gen_operation_table () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::" - "visit_interface - " - "codegen for operation table failed\n"), - -1); - } - - // constructor - *os << "// skeleton constructor" << be_nl; - // find if we are at the top scope or inside some module - if (!node->is_nested ()) - { - // we are outermost. So the POA_ prefix is prepended to our name - *os << node->full_skel_name () << "::POA_" << node->local_name () << - " (void)" << be_nl; - } - else - { - // the POA_ prefix is prepended to our outermost module name - *os << node->full_skel_name () << "::" << node->local_name () << - " (void)" << be_nl; - } - - *os << "{" << be_idt_nl - << "this->optable_ = &tao_" << node->flatname () - << "_optable;" << be_uidt_nl - << "}\n\n"; - - *os << "// copy ctor" << be_nl; - // find if we are at the top scope or inside some module - if (!node->is_nested ()) - { - // we are outermost. So the POA_ prefix is prepended to our name - *os << node->full_skel_name () << "::POA_" - << node->local_name () << " (" - << "const POA_" << node->local_name () << "& rhs)"; - } - else - { - // the POA_ prefix is prepended to our outermost module name - *os << node->full_skel_name () << "::" - << node->local_name () << " (const " - << node->local_name () << "& rhs)"; - } - *os << be_idt_nl - << ": "; - if (node->traverse_inheritance_graph - (be_interface::copy_ctor_helper, os) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::visit_interface - " - " copy ctor generation failed\n"), -1); - *os << " TAO_ServantBase (rhs)" << be_uidt_nl - << "{}\n"; - - // destructor - os->indent (); - *os << "// skeleton destructor" << be_nl; - - if (!node->is_nested ()) - { - // we are outermost. So the POA_ prefix is prepended to our name - *os << node->full_skel_name () << "::~POA_" << node->local_name () << - " (void)" << be_nl; - } - else - { - // the POA_ prefix is prepended to our outermost module name - *os << node->full_skel_name () << "::~" << node->local_name () << - " (void)" << be_nl; - } - *os << "{\n"; - *os << "}\n"; - - - // generate code for elements in the scope (e.g., operations) - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - - // generate code for the _is_a skeleton - os->indent (); - *os << "void " << node->full_skel_name () - << "::_is_a_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &_tao_server_request, " << be_nl - << "void * _tao_object_reference," << be_nl - << "void * /*context*/," << be_nl - << "CORBA::Environment &_tao_environment" << be_uidt_nl - << ")" << be_uidt_nl; - *os << "{\n"; - os->incr_indent (); - *os << "static const TAO_Param_Data_Skel " << node->flatname () - << "_is_a_paramdata [] = " << be_nl; - *os << "{" << be_idt_nl; - *os << "{CORBA::_tc_boolean, 0, 0}," << be_nl; - *os << "{CORBA::_tc_string, CORBA::ARG_IN, 0}" << be_uidt_nl; - *os << "};" << be_nl; - *os << "static const TAO_Call_Data_Skel " << node->flatname () - << "_is_a_calldata = " << be_nl; - *os << "{\"_is_a\", 1, 2, " << node->flatname () << "_is_a_paramdata};" - << be_nl; - // *os << "CORBA::Environment _tao_skel_environment;" << be_nl; - *os << node->full_skel_name () << "_ptr _tao_impl = (" - << node->full_skel_name () << "_ptr) _tao_object_reference;" - << be_nl; - *os << "CORBA::Boolean _tao_retval;" << be_nl; - *os << "CORBA::String_var _tao_value;" << be_nl; - *os << "_tao_server_request.demarshal (" << be_idt_nl - << "_tao_environment, " << be_nl - << "&" << node->flatname () << "_is_a_calldata, " << be_nl - << "&_tao_retval, " << be_nl - << "&_tao_value.inout ()" << be_uidt_nl - << ");" << be_nl; - *os << "TAO_CHECK_ENV_RETURN_VOID (_tao_environment);" << be_nl; - *os << "_tao_retval = _tao_impl->_is_a (_tao_value.in (), " - << "_tao_environment);" << be_nl; - *os << "TAO_CHECK_ENV_RETURN_VOID (_tao_environment);" << be_nl; - *os << "_tao_server_request.marshal (" << be_idt_nl - << "_tao_environment, " << be_nl - // << "_tao_skel_environment," << be_nl - << "&" << node->flatname () << "_is_a_calldata, " << be_nl - << "&_tao_retval, " << be_nl - << "&_tao_value.inout ()" << be_uidt_nl - << ");" << be_uidt_nl; - // *os << "CORBA::string_free (_tao_value);" << be_uidt_nl; - *os << "}\n\n"; - - - os->indent (); - *os << "CORBA::Boolean " << node->full_skel_name () - << "::_is_a (" << be_idt << be_idt_nl - << "const char* value," << be_nl - << "CORBA::Environment &_tao_environment" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "if (\n" << be_idt; - if (node->traverse_inheritance_graph (be_interface::is_a_helper, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::" - "visit_interface - " - "traversal of inhertance graph failed\n"), - -1); - } - - os->indent (); - *os << "(!ACE_OS::strcmp ((char *)value, " - << "CORBA::_tc_Object->id (_tao_environment))))" - << be_idt_nl << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt << be_uidt << be_uidt_nl - << "}\n\n"; - - // generate code for the _non_existent skeleton - os->indent (); - *os << "void " << node->full_skel_name () - << "::_non_existent_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &_tao_server_request, " << be_nl - << "void * /* _tao_object_reference */ ," << be_nl - << "void * /*context*/," << be_nl - << "CORBA::Environment &_tao_environment" << be_uidt_nl - << ")" << be_uidt_nl; - *os << "{" << be_idt_nl; - *os << "static const TAO_Param_Data_Skel " << node->flatname () - << "_non_existent_paramdata [] = " << be_nl - << "{" << be_idt_nl - << "{CORBA::_tc_boolean, 0, 0}" << be_uidt_nl - << "};" << be_nl; - *os << "static const TAO_Call_Data_Skel " << node->flatname () - << "_non_existent_calldata = " << be_nl - << "{\"_non_existent\", 1, 1, " << node->flatname () - << "_non_existent_paramdata};" << be_nl; - // *os << "CORBA::Environment _tao_skel_environment;" << be_nl; - *os << "CORBA::Boolean _tao_retval = 0;" << be_nl; - *os << "_tao_server_request.marshal (" << be_idt_nl - << "_tao_environment, " << be_nl - // << "_tao_skel_environment," << be_nl - << "&" << node->flatname () << "_non_existent_calldata, " << be_nl - << "&_tao_retval " << be_uidt_nl - << ");" << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "void* " << node->full_skel_name () - << "::_downcast (" << be_idt << be_idt_nl - << "const char* logical_type_id" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - - if (node->traverse_inheritance_graph (be_interface::downcast_helper, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::" - "visit_interface - " - "traversal of inhertance graph failed\n"), - -1); - } - - *os << "if (ACE_OS::strcmp (logical_type_id, " - << "\"IDL:omg.org/CORBA/Object:1.0\") == 0)" << be_idt_nl - << "return ACE_static_cast(PortableServer::Servant, this);" - << be_uidt_nl; - - *os << "return 0;" << be_uidt_nl - << "}\n\n"; - - - // now the dispatch method - os->indent (); - *os << "void " << node->full_skel_name () << - "::_dispatch (CORBA::ServerRequest &req, " << - "void *context, CORBA::Environment &env)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "TAO_Skeleton skel; // pointer to skeleton for operation" << be_nl; - *os << "const char *opname = req.operation (); // retrieve operation name" - << be_nl; - *os << "// find the skeleton corresponding to this opname" << be_nl; - *os << "if (this->_find (opname, skel) == -1)" << be_nl; - *os << "{" << be_idt_nl; - *os << "ACE_ERROR ((LM_ERROR, \"Bad operation <%s>\\n\", opname));" << be_nl; - *os << "TAO_THROW_ENV (CORBA_BAD_OPERATION (CORBA::COMPLETED_NO), " - << "env);" << be_uidt_nl; - // *os << "env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO));" << be_nl; - *os << "}" << be_nl; - *os << "else" << be_idt_nl; - *os << "skel (req, this, context, env);" << be_uidt << be_uidt_nl; - *os << "}\n\n"; - - os->indent (); - *os << "const char* " << node->full_skel_name () - << "::_interface_repository_id (void) const" - << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return \"" << node->repoID () << "\";\n"; - os->decr_indent (); - *os << "}\n\n"; - - // generate the collocated class impl - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::" - "visit_interface - " - "Bad visitor for collocated class\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::" - "visit_interface - " - "codegen for collocated class failed\n"), - -1); - } - delete visitor; - - *os << "\n"; - - // the _this () operation - *os << node->name () << "*" << be_nl - << node->full_skel_name () - << "::_this (CORBA_Environment &ACE_TRY_ENV)" << be_nl - << "{" << be_idt_nl - << "STUB_Object *stub = this->_create_stub (ACE_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV_RETURN (ACE_TRY_ENV, 0);" << be_nl - // << "if (ACE_TRY_ENV.exception () != 0)" << be_idt_nl - // << "return 0;" << be_uidt_nl - << "return new " << node->full_coll_name () - << " (this, stub);" << be_uidt << be_nl; - - *os << "}\n\n"; - - 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 deleted file mode 100644 index 78d03c9a8a4..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// tie_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for TIE class for an Interface in the header -// file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, tie_sh, "$Id$") - - -// ************************************************************ -// Interface visitor for server header -// ************************************************************ - -be_visitor_interface_tie_sh::be_visitor_interface_tie_sh (be_visitor_context *ctx) - : be_visitor_interface (ctx) -{ -} - -be_visitor_interface_tie_sh::~be_visitor_interface_tie_sh (void) -{ -} - -int -be_visitor_interface_tie_sh::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - static char namebuf [NAMEBUFSIZE]; // holds the class name - static char tiename [NAMEBUFSIZE]; // holds the tie name - - if (node->srv_hdr_gen () || node->imported ()) - return 0; - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (tiename, '\0', NAMEBUFSIZE); - - os = this->ctx_->stream (); - - // generate the skeleton class name which will be used to determine the TIE - // class name - - // we shall have a POA_ prefix only if we are at the topmost level - if (!node->is_nested ()) - { - // we are outermost - ACE_OS::sprintf (namebuf, "POA_%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (tiename, "POA_%s_tie", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (namebuf, "%s", node->local_name ()->get_string ()); - ACE_OS::sprintf (tiename, "%s_tie", - node->local_name ()->get_string ()); - } - - // now generate the class definition - os->indent (); // start with whatever indentation level we are at - - // Since templates nested inside of classes are broken on most C++ compilers, - // we generate code for this inside a conditional macro. The code is - // activated only if "namespaces" are supported on the platform - if (node->is_nested ()) - { - *os << "\n#if defined (ACE_HAS_USING_KEYWORD)" << be_nl; - } - - *os << "// TIE class: Refer to CORBA v2.2, Section 20.34.4" << be_nl; - *os << "template <class T>" << be_nl; - *os << "class " << idl_global->export_macro () - << " " << tiename << " : public " << namebuf << be_nl; - *os << "{" << be_nl - << "public:" << be_idt_nl - << tiename << " (T &t);" << be_nl - << "// the T& ctor" << be_nl - << tiename << " (T &t, PortableServer::POA_ptr poa);" << be_nl - << "// ctor taking a POA" << be_nl - << tiename << " (T *tp, CORBA::Boolean release=1);" << be_nl - << "// ctor taking pointer and an ownership flag" << be_nl - << tiename << " (T *tp, PortableServer::POA_ptr poa, " - << "CORBA::Boolean release=1);" << be_nl - << "// ctor with T*, ownership flag and a POA" << be_nl - << "~" << tiename << " (void);" << be_nl - << "// dtor" << be_nl << be_nl - << "// TIE specific functions" << be_nl - << "T *_tied_object (void);" << be_nl - << "// return the underlying object" << be_nl - << "void _tied_object (T &obj);" << be_nl - << "// set the underlying object" << be_nl - << "void _tied_object (T *obj, CORBA::Boolean release=1);" << be_nl - << "// set the underlying object and the ownership flag" << be_nl - << "CORBA::Boolean _is_owner (void);" << be_nl - << "// do we own it" << be_nl - << "void _is_owner (CORBA::Boolean b);" << be_nl - << "// set the ownership" << be_nl << be_nl - << "// overridden ServantBase operations" << be_nl - << "PortableServer::POA_ptr _default_POA (" << be_idt << be_idt_nl - << "CORBA::Environment &env = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt << "\n"; - - if (node->traverse_inheritance_graph (be_visitor_interface_tie_sh::method_helper, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_tie_sh_ss::" - "visit_interface - " - "traversal of inhertance graph failed\n"), - -1); - } - - *os << be_uidt << "private:" << be_idt_nl - << "T *ptr_;" << be_nl - << "PortableServer::POA_var poa_;" << be_nl - << "CORBA::Boolean rel_;" << be_nl << be_nl - << "// copy and assignment are not allowed" << be_nl - << tiename << " (const " << tiename << " &);" << be_nl - << "void operator= (const " << tiename << " &);" << be_uidt_nl - << "};\n\n"; - - if (node->is_nested ()) - { - *os << "#endif /* ACE_HAS_USING_KEYWORD */\n"; - } - - return 0; -} - -int -be_visitor_interface_tie_sh::method_helper (be_interface *, - be_interface *node, - TAO_OutStream *os) -{ - be_visitor_context ctx; - ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SH); - ctx.stream (os); - 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); - } - 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 deleted file mode 100644 index 2d9b0aba3a1..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// tie_si.cpp -// -// = DESCRIPTION -// Visitor generating code for TIE classes for the Interface node in the -// inline file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface.h" - -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 (ctx) -{ -} - -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 - - if (node->srv_inline_gen () || node->imported ()) - return 0; - - ACE_OS::memset (fulltiename, '\0', NAMEBUFSIZE); - ACE_OS::memset (localtiename, '\0', NAMEBUFSIZE); - - os = this->ctx_->stream (); - - // 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 ()); - if (!node->is_nested ()) - { - ACE_OS::sprintf (localtiename, "POA_%s_tie", - node->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (localtiename, "%s_tie", - node->local_name ()->get_string ()); - } - - if (node->is_nested ()) - { - *os << "\n#if defined (ACE_HAS_USING_KEYWORD)\n"; - } - - os->indent (); // start with whatever indentation level we are at - - *os << "template <class T> ACE_INLINE" << be_nl - << fulltiename << "<T>::" << localtiename << " (T &t)" << be_nl - << "\t: ptr_ (&t)," << be_nl - << "\t poa_ (PortableServer::POA::_nil ())," << be_nl - << "\t rel_ (0)" << be_nl - << "{}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE" << be_nl - << fulltiename << "<T>::" << localtiename - << " (T &t, PortableServer::POA_ptr poa)" << be_nl - << "\t: ptr_ (&t)," << be_nl - << "\t poa_ (PortableServer::POA::_duplicate (poa))," << be_nl - << "\t rel_ (0)" << be_nl - << "{}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE" << be_nl - << fulltiename << "<T>::" << localtiename - << " (T *tp, CORBA::Boolean release)" << be_nl - << "\t: ptr_ (tp)," << be_nl - << "\t poa_ (PortableServer::POA::_nil ())," << be_nl - << "\t rel_ (release)" << be_nl - << "{}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE" << be_nl - << fulltiename << "<T>::" << localtiename - << " (T *tp, PortableServer::POA_ptr poa, CORBA::Boolean release)" - << be_nl - << "\t: ptr_ (tp)," << be_nl - << "\t poa_ (PortableServer::POA::_duplicate (poa))," << be_nl - << "\t rel_ (release)" << be_nl - << "{}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE" << be_nl - << fulltiename << "<T>::~" << localtiename << " (void)" << be_nl - << "{" << be_idt_nl - << "if (this->rel_) delete this->ptr_;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE T *" << be_nl - << fulltiename << "<T>::_tied_object (void)" << be_nl - << "{" << be_idt_nl - << "return this->ptr_;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE void" << be_nl - << fulltiename << "<T>::_tied_object (T &obj)" << be_nl - << "{" << be_idt_nl - << "if (this->rel_) delete this->ptr_;" << be_nl - << "this->ptr_ = &obj;" << be_nl - << "this->rel_ = 0;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE void" << be_nl - << fulltiename << "<T>::_tied_object (T *obj, " - << "CORBA::Boolean release)" << be_nl - << "{" << be_idt_nl - << "if (this->rel_) delete this->ptr_;" << be_nl - << "this->ptr_ = obj;" << be_nl - << "this->rel_ = release;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE CORBA::Boolean" << be_nl - << fulltiename << "<T>::_is_owner (void)" << be_nl - << "{" << be_idt_nl - << "return this->rel_;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE void" << be_nl - << fulltiename << "<T>::_is_owner (CORBA::Boolean b)" << be_nl - << "{" << be_idt_nl - << "this->rel_ = b;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "template <class T> ACE_INLINE " - << "PortableServer::POA_ptr" << be_nl - << fulltiename << "<T>::_default_POA (CORBA::Environment &env)" << be_nl - << "{" << be_idt_nl - << "if (!CORBA::is_nil (this->poa_.in ()))" << be_idt_nl - << "return PortableServer::POA::_duplicate (this->poa_.in ());" - << be_uidt_nl - << "else" << be_nl - << "{" << be_idt_nl - << "TAO_POA *poa = TAO_ORB_Core_instance ()->root_poa ();" << be_nl - << "PortableServer::POA_var result = poa->_this (env);" << be_nl - << "if (env.exception () != 0)" << be_idt_nl - << "return PortableServer::POA::_nil ();" << be_uidt_nl - << "else" << be_idt_nl - << "return result._retn ();" << be_uidt << be_uidt_nl - << "}" << be_uidt_nl - << "}\n\n"; - - if (node->traverse_inheritance_graph (be_visitor_interface_tie_si::method_helper, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_tie_sh_ss::" - "visit_interface - " - "traversal of inhertance graph failed\n"), - -1); - } - - if (node->is_nested ()) - { - *os << "#endif /* ACE_HAS_USING_KEYWORD */\n"; - } - - return 0; -} - -int -be_visitor_interface_tie_si::method_helper (be_interface *derived, - be_interface *node, - TAO_OutStream *os) -{ - be_visitor_context ctx; - ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SI); - ctx.interface (derived); - ctx.stream (os); - - 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); - } - 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 deleted file mode 100644 index 18b5d80cb4c..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_interface_fwd.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Interface_Fwd -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_interface_fwd.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_ci.cpp" - -ACE_RCSID(be, be_visitor_interface_fwd, "$Id$") - 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 deleted file mode 100644 index e7edc5c7ad5..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/cdr_op_ci.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// $Id$ -// - -// ================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for forward -// declarations of interfaces. This uses compiled marshaling. -// -// = AUTHOR -// Aniruddha Gokhale & Carlos O'Ryan -// -// ================================================================ - -#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$") - -// **************************************************************** -// Interface visitor for generating CDR operator declarations in the -// client header -// **************************************************************** - -be_visitor_interface_fwd_cdr_op_ci:: -be_visitor_interface_fwd_cdr_op_ci (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_interface_fwd_cdr_op_ci:: -~be_visitor_interface_fwd_cdr_op_ci (void) -{ -} - -int -be_visitor_interface_fwd_cdr_op_ci:: -visit_interface_fwd (be_interface_fwd *node) -{ - if (node->cli_inline_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - os->indent (); - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator<< (" << be_idt << be_idt_nl - << "TAO_OutputCDR &," << be_nl - << "const " << node->name () << "_ptr" << be_uidt_nl - << ");" << be_uidt_nl; - *os << "ACE_INLINE CORBA::Boolean" << be_nl - << "operator>> (" << be_idt << be_idt_nl - << "TAO_InputCDR &," << be_nl - << node->name () << "_ptr &" << be_uidt_nl - << ");" << be_uidt << "\n"; - - node->cli_inline_cdr_op_gen (1); - return 0; -} - 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 deleted file mode 100644 index 7591f4d83be..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ch.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_fwd_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Interface_Fwd node in the client header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#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$") - - -// ******************************************************************** -// 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_decl (ctx) -{ -} - -be_visitor_interface_fwd_ch::~be_visitor_interface_fwd_ch (void) -{ -} - -// visit the Interface_Fwd_Ch node and its scope -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 ()) - { - os->indent (); // start from the current - - // all we do in this is generate a forward declaration of the class - *os << "class " << node->local_name () << ";" << be_nl; - - // generate the ifdefined macro for the _ptr type - os->gen_ifdef_macro (node->flatname (), "_ptr"); - - // generate the _ptr declaration - *os << "typedef " << node->local_name () << " *" << node->local_name () - << "_ptr;\n"; - - os->gen_endif (); - - // enclose under an ifdef macro - os->gen_ifdef_macro (node->flatname (), "_var"); - - // generate the _var declaration - if (node->gen_var_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_fwd_ch::" - "visit_interface_fwd - " - "codegen for _var failed\n"), -1); - } - // gen an endif - os->gen_endif (); - - // enclose under an ifdef macro - os->gen_ifdef_macro (node->flatname (), "_out"); - - // generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec - if (node->gen_out_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_fwd_ch::" - "visit_interface_fwd - " - "codegen for _out failed\n"), -1); - } - // generate the endif macro - 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 deleted file mode 100644 index 173f0829a88..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// interface_fwd_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Interface_Fwd node in the client inline. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#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$") - - -// ******************************************************************** -// 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_decl (ctx) -{ -} - -be_visitor_interface_fwd_ci::~be_visitor_interface_fwd_ci (void) -{ -} - -// visit the Interface_Fwd_ci node and its scope -int -be_visitor_interface_fwd_ci::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (!node->cli_inline_gen () && !node->imported ()) - { - - // generate the ifdefined macro for the _var type - os->gen_ifdef_macro (node->flatname (), "_var"); - - if (node->gen_var_impl () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_fwd_ci::" - "visit_interface_fwd - " - "codegen for _var failed\n"), -1); - } - - os->gen_endif (); - - // generate the ifdefined macro for the _out type - os->gen_ifdef_macro (node->flatname (), "_out"); - - if (node->gen_out_impl () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface_fwd_ci::" - "visit_interface_fwd - " - "codegen for _out failed\n"), -1); - } - os->gen_endif (); - - node->cli_stub_gen (I_TRUE); - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_module.cpp b/TAO/TAO_IDL/be/be_visitor_module.cpp deleted file mode 100644 index 1bd1b4ffe36..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_module.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_module.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Module -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.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" -#include "be_visitor_module/module_ih.cpp" -#include "be_visitor_module/any_op.cpp" -#include "be_visitor_module/cdr_op.cpp" - -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 deleted file mode 100644 index 2d50f3b54d0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_module/any_op.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for elements in the scope of -// the Module. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, any_op, "$Id$") - - -// *************************************************************************** -// Module visitor for generating Any operator declarations in the client header -// and stub -// *************************************************************************** - -be_visitor_module_any_op::be_visitor_module_any_op (be_visitor_context *ctx) - : be_visitor_module (ctx) -{ -} - -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); - } - 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 deleted file mode 100644 index 4059e2f0f05..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_module/cdr_op.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op.cpp -// -// = DESCRIPTION -// Visitor generating code for the CDR operators for types defined in Module's -// scope. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, cdr_op, "$Id") - - -// *************************************************************************** -// Module visitor for generating CDR operator declarations in the client header -// and stub -// *************************************************************************** - -be_visitor_module_cdr_op::be_visitor_module_cdr_op (be_visitor_context *ctx) - : be_visitor_module (ctx) -{ -} - -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); - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_module/module.cpp b/TAO/TAO_IDL/be/be_visitor_module/module.cpp deleted file mode 100644 index 6021ed1c978..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_module/module.cpp +++ /dev/null @@ -1,646 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// module.cpp -// -// = DESCRIPTION -// Generic visitor generating code for Module -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module, "$Id$") - - -// ****************************************************** -// Generic Module visitor -// ****************************************************** - -be_visitor_module::be_visitor_module (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_module::~be_visitor_module (void) -{ -} - -// visit the Module node and its scope -int be_visitor_module::visit_module (be_module *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); - } - return 0; -} - -// =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 - 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_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; - case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - 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: - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - case TAO_CodeGen::TAO_MODULE_CI: - case TAO_CodeGen::TAO_MODULE_SH: - case TAO_CodeGen::TAO_MODULE_IH: - case TAO_CodeGen::TAO_MODULE_SI: - case TAO_CodeGen::TAO_MODULE_SS: - case TAO_CodeGen::TAO_MODULE_IS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_constant - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_constant - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 - 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_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; - case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - 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: - case TAO_CodeGen::TAO_MODULE_SI: - case TAO_CodeGen::TAO_MODULE_SS: - case TAO_CodeGen::TAO_MODULE_IS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_enum - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_enum - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 - 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_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; - case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; - case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_SH: - case TAO_CodeGen::TAO_MODULE_IH: - case TAO_CodeGen::TAO_MODULE_SI: - case TAO_CodeGen::TAO_MODULE_SS: - case TAO_CodeGen::TAO_MODULE_IS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_exception - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_exception - " - "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_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 - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CH); - break; - case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CI); - break; - case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CS); - break; - case TAO_CodeGen::TAO_MODULE_SH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SH); - break; - case TAO_CodeGen::TAO_MODULE_IH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); - break; - case TAO_CodeGen::TAO_MODULE_SI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SI); - break; - case TAO_CodeGen::TAO_MODULE_SS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SS); - break; - case TAO_CodeGen::TAO_MODULE_IS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_interface - " - "Bad context state\n" - ), -1); - } - } - - 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); - } - - // 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); - } - delete visitor; - 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 - 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_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); - break; - case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); - 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: - 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_interface_fwd - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_interface_fwd - " - "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_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 - 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_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; - case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; - case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_SH: - case TAO_CodeGen::TAO_MODULE_IH: - case TAO_CodeGen::TAO_MODULE_SI: - case TAO_CodeGen::TAO_MODULE_SS: - 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 - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_structure - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_structure - " - "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 - 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_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; - case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; - case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_SH: - case TAO_CodeGen::TAO_MODULE_IH: - case TAO_CodeGen::TAO_MODULE_SI: - case TAO_CodeGen::TAO_MODULE_SS: - 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 - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_union - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_union - " - "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 - 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_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; - case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; - case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; - 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_typedef - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_typedef - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 deleted file mode 100644 index f109e3cd647..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// module_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Module in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module_ch, "$Id$") - - -// ****************************************************** -// Module visitor for client header -// ****************************************************** - -be_visitor_module_ch::be_visitor_module_ch (be_visitor_context *ctx) - : be_visitor_module (ctx) -{ -} - -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 (); - - // XXXASG - Modules really map to namespace. We need to see if our target - // compiler supports namespaces or not. This visitor generates a class for a - // module. We can have the factory generate another module visitor that can - // generate namespaces - - os->indent (); // start from whatever indentation level we were at - // now generate the class definition - *os << "TAO_NAMESPACE " // << idl_global->export_macro () - << " " << node->local_name () << be_nl - << "{\n"; - os->incr_indent (0); - - // generate code for the module 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_module_ch::" - "visit_module - " - "codegen for scope failed\n"), -1); - } - - *os << be_uidt_nl - << "}; // module " << node->name () << "\n\n"; - - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_module/module_ih.cpp b/TAO/TAO_IDL/be/be_visitor_module/module_ih.cpp deleted file mode 100644 index d2c47ea3bd4..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_module/module_ih.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// module_ih.cpp -// -// = DESCRIPTION -// Visitor generating code for Module in the implementation header -// -// = AUTHOR -// Yamuna Krishnamurthy (yamuna@cs.wustl.edu) -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module_ih, "$Id$") - -// ************************************************************ -// Module visitor for server header -// ************************************************************ - -be_visitor_module_ih::be_visitor_module_ih (be_visitor_context *ctx) - : be_visitor_module (ctx) -{ -} - -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 (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module_sh::" - "visit_module - " - "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 deleted file mode 100644 index f3080384f59..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_module/module_sh.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// module_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for Module in the server header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_module.h" - -ACE_RCSID(be_visitor_module, module_sh, "$Id$") - - -// ************************************************************ -// Module visitor for server header -// ************************************************************ - -be_visitor_module_sh::be_visitor_module_sh (be_visitor_context *ctx) - : be_visitor_module (ctx) -{ -} - -be_visitor_module_sh::~be_visitor_module_sh (void) -{ -} - -int -be_visitor_module_sh::visit_module (be_module *node) -{ - TAO_OutStream *os; // output stream - - if (!node->srv_hdr_gen () && !node->imported ()) // not generated and not imported - { - os = this->ctx_->stream (); - - // generate the skeleton class name - - os->indent (); // start with whatever indentation level we are at - - // now generate the class definition. The prefix POA_ is prepended to our - // name only if we are the outermost module - *os << "TAO_NAMESPACE "; // << idl_global->export_macro () - - if (!node->is_nested ()) - // we are outermost module - *os << " POA_" << node->local_name () << be_nl; - else - // we are inside another module - *os << " " << node->local_name () << be_nl; - - *os << "{" << be_nl - << be_idt; - - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module_sh::" - "visit_module - " - "codegen for scope failed\n"), -1); - } - - os->decr_indent (); - *os << "};\n\n"; - } - return 0; - -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation.cpp deleted file mode 100644 index 6e15900c125..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_operation.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Operation -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -// include all the individual files -#include "be_visitor_operation/operation.cpp" -#include "be_visitor_operation/arglist.cpp" -#include "be_visitor_operation/argument.cpp" -#include "be_visitor_operation/argument_invoke.cpp" -#include "be_visitor_operation/argument_marshal.cpp" -#include "be_visitor_operation/collocated_sh.cpp" -#include "be_visitor_operation/collocated_ss.cpp" -#include "be_visitor_operation/exceptlist_cs.cpp" -#include "be_visitor_operation/operation_ch.cpp" -#include "be_visitor_operation/operation_cs.cpp" -#include "be_visitor_operation/operation_sh.cpp" -#include "be_visitor_operation/operation_ih.cpp" -#include "be_visitor_operation/operation_ss.cpp" -#include "be_visitor_operation/operation_is.cpp" -#include "be_visitor_operation/rettype.cpp" -#include "be_visitor_operation/rettype_is.cpp" -#include "be_visitor_operation/rettype_assign_ss.cpp" -#include "be_visitor_operation/rettype_docall_cs.cpp" -#include "be_visitor_operation/rettype_marshal_ss.cpp" -#include "be_visitor_operation/rettype_post_docall_cs.cpp" -#include "be_visitor_operation/rettype_post_upcall_ss.cpp" -#include "be_visitor_operation/rettype_pre_docall_cs.cpp" -#include "be_visitor_operation/rettype_return_cs.cpp" -#include "be_visitor_operation/rettype_vardecl_cs.cpp" -#include "be_visitor_operation/rettype_vardecl_ss.cpp" -#include "be_visitor_operation/tie_sh.cpp" -#include "be_visitor_operation/tie_si.cpp" -#include "be_visitor_operation/compiled_marshal.cpp" -#include "be_visitor_operation/rettype_pre_invoke_cs.cpp" - -ACE_RCSID(be, be_visitor_operation, "$Id$") - diff --git a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp deleted file mode 100644 index 453a90735e3..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// arglist.cpp -// -// = DESCRIPTION -// Visitor generating code for the parameter list of the Operation signature. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, arglist, "$Id$") - - -// ************************************************************ -// operation visitor to generate the argument list. -// We have separated code generation for this from the 4 main -// visitors to avoid code duplication and tight coupling -// ************************************************************ - -be_visitor_operation_arglist::be_visitor_operation_arglist (be_visitor_context - *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_operation_arglist::~be_visitor_operation_arglist (void) -{ -} - -int -be_visitor_operation_arglist::visit_operation (be_operation *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - *os << " (" << be_idt << be_idt << "\n"; - - // all we do is hand over code generation to our scope - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_arglist::" - "visit_operation - " - "codegen for scope failed\n"), - -1); - } - - - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: - // last argument - is always CORBA::Environment - os->indent (); - *os << "CORBA::Environment &_tao_environment"; - *os << " = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt; - break; - case TAO_CodeGen::TAO_OPERATION_ARGLIST_IS: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: - // last argument - is always CORBA::Environment - os->indent (); - *os << "CORBA::Environment &TAO_TRY_ENV"; - break; - default: - os->indent (); - *os << "CORBA::Environment &_tao_environment"; - break; - } - *os << be_uidt_nl << ")" << be_uidt; - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: - case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: - *os << ";\n"; - break; - case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: - // each method is pure virtual in the server header - *os << " = 0;\n"; - break; - case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: - // each method is pure virtual in the server header - //*os << "\n\n"; - break; - case TAO_CodeGen::TAO_OPERATION_ARGLIST_IS: - // each method is pure virtual in the server header - break; - default: - *os << "\n"; - } - - return 0; -} - -int -be_visitor_operation_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_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_arglist::" - "visit_argument - " - "Bad interface\n"), - -1); - } - ctx.scope (intf); // set new scope - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); - break; - case TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS: - 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: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "Bad context\n"), - -1); - } - } - - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - - "visit_argument - " - "codegen for arglist failed\n"), - -1); - } - delete visitor; - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp deleted file mode 100644 index 87f43898983..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// argument.cpp -// -// = DESCRIPTION -// Visitor that calls the visitor for arguments. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, argument, "$Id$") - - -// ************************************************************ -// 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_scope (ctx) -{ -} - -be_visitor_operation_argument::~be_visitor_operation_argument (void) -{ -} - -int -be_visitor_operation_argument::post_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (!this->last_node (bd)) - { - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: - case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: - case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: - case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - *os << ",\n"; - break; - default: - break; - } - } - return 0; -} - -int -be_visitor_operation_argument::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_argument::" - "visit_operation - " - "codegen for scope failed\n"), - -1); - } - - return 0; -} - -int -be_visitor_operation_argument::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_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_arglist::" - "visit_argument - " - "Bad interface\n"), - -1); - } - ctx.scope (intf); // set new scope - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_PRE_INVOKE_CS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_PRE_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_PRE_UPCALL_SS); - break; - case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_POST_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_UPCALL_SS); - break; - case TAO_CodeGen::TAO_OPERATION_ARG_POST_MARSHAL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_MARSHAL_SS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_argument::" - "visit_argument - " - "Bad context\n"), - -1); - } - } - - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_argument::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_argument::" - - "visit_argument - " - "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 deleted file mode 100644 index 1dc503c91e0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// argument_invoke.cpp -// -// = DESCRIPTION -// Visitor to pass arguments to the CDR operators. This one helps in -// generating the && and the , at the right place. This one is for the -// client stub side. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -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 (ctx), - last_arg_printed_ (be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) -{ -} - -be_compiled_visitor_operation_argument_invoke:: -~be_compiled_visitor_operation_argument_invoke (void) -{ -} - -int -be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - be_argument *arg = be_argument::narrow_from_decl (bd); - - if (!arg) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" - "::post_process - " - "Bad argument node\n"), - -1); - } - switch (arg->direction ()) - { - case AST_Argument::dir_IN: - 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"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - // nothing - } - break; - case AST_Argument::dir_INOUT: - 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"; - } - 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"; - } - break; - case AST_Argument::dir_OUT: - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - // nothing - } - 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"; - } - break; - } - - return 0; -} - -int -be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) -{ - be_argument *arg = be_argument::narrow_from_decl (bd); - - if (!arg) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" - "::post_process - " - "Bad argument node\n"), - -1); - } - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_OUTPUT: - switch (arg->direction ()) - { - case AST_Argument::dir_IN: - // only these arguments get printed - this->last_arg_printed_ = - be_compiled_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; - break; - case AST_Argument::dir_OUT: - // these arguments don't get printed for the << operator on the stub - break; - } - break; - case TAO_CodeGen::TAO_CDR_INPUT: - switch (arg->direction ()) - { - case AST_Argument::dir_IN: - // these arguments don't get printed for the >> on the stub - break; - case AST_Argument::dir_INOUT: - // only these arguments get printed - this->last_arg_printed_ = - be_compiled_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; - break; - } - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" - "::post_process - " - "Bad sub state\n"), - -1); - } - return 0; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp deleted file mode 100644 index 221eeb62daf..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// argument_marshal.cpp -// -// = DESCRIPTION -// Visitor to pass arguments to the CDR operators. This one helps in -// generating the && and the , at the right place. This one is for the -// skeleton side. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -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 (ctx), - last_arg_printed_ (be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) -{ -} - -be_compiled_visitor_operation_argument_marshal:: -~be_compiled_visitor_operation_argument_marshal (void) -{ -} - -int -be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - be_argument *arg = be_argument::narrow_from_decl (bd); - - if (!arg) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" - "::post_process - " - "Bad argument node\n"), - -1); - } - switch (arg->direction ()) - { - case AST_Argument::dir_IN: - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) - *os << " &&\n"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - // nothing - } - break; - case AST_Argument::dir_INOUT: - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - if (this->last_arg_printed_ != - be_compiled_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) - *os << " &&\n"; - } - break; - case AST_Argument::dir_OUT: - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - // nothing - } - 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) - *os << " &&\n"; - } - break; - } - - return 0; -} - -int -be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) -{ - be_argument *arg = be_argument::narrow_from_decl (bd); - - if (!arg) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" - "::post_process - " - "Bad argument node\n"), - -1); - } - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - switch (arg->direction ()) - { - case AST_Argument::dir_IN: - // only these arguments get printed - this->last_arg_printed_ = - be_compiled_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; - break; - case AST_Argument::dir_OUT: - // these arguments don't get printed for the << operator on the stub - break; - } - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - switch (arg->direction ()) - { - case AST_Argument::dir_IN: - // these arguments don't get printed for the >> on the stub - break; - case AST_Argument::dir_INOUT: - // only these arguments get printed - this->last_arg_printed_ = - be_compiled_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; - break; - } - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" - "::post_process - " - "Bad sub state\n"), - -1); - } - return 0; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_operation/collocated_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/collocated_sh.cpp deleted file mode 100644 index 6e24c848923..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/collocated_sh.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// collocated_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for collocated operation in the server header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, collocated_sh, "$Id$") - - -// ************************************************************************* -// be_visitor_operation_collocated_sh -- -// This visitor generates code for the collocated operation signature in a -// server header file -// ************************************************************************* - -be_visitor_operation_collocated_sh::be_visitor_operation_collocated_sh -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_operation_collocated_sh::~be_visitor_operation_collocated_sh (void) -{ -} - -int be_visitor_operation_collocated_sh::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 - - // every operation is declared virtual in the client code - *os << "virtual "; - - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_sh::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // grab the right visitor to generate the return type - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_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); - } - - 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 (); - - // 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_COLLOCATED_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); - } - - 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/collocated_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/collocated_ss.cpp deleted file mode 100644 index 2d4119b7a62..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/collocated_ss.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// collocated_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for collocated Operation in the skeleton. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, collocated_ss, "$Id$") - - -// ************************************************************************* -// be_visitor_operation_collocated_ss -- -// This visitor generates code for the collocated operation signature in a -// server skeletons file -// ************************************************************************* - -be_visitor_operation_collocated_ss::be_visitor_operation_collocated_ss -(be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_operation_collocated_ss::~be_visitor_operation_collocated_ss (void) -{ -} - -int be_visitor_operation_collocated_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 () - ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) - : be_interface::narrow_from_scope (node->defined_in ()); - - if (!intf) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_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_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); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_collocated_ss::" - "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_collocated_ss::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - - *os << " " << intf->full_coll_name () << "::" - << node->local_name () << " "; - - // STEP 4: generate the argument list with the appropriate mapping (same as - // 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 to return type\n"), - -1); - } - - if (node->accept (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"; - - os->indent (); - if (bt->node_type () != AST_Decl::NT_pre_defined - || be_predefined_type::narrow_from_decl (bt)->pt () != AST_PredefinedType::PT_void) - { - *os << "return "; - } - - *os << "this->servant_->" << node->local_name () << " (" << be_idt << "\n"; - - 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)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for making upcall failed\n"), - -1); - } - // last argument is the environment - if (node->argument_count () > 0) - *os << ",\n"; - os->indent (); - *os << "_tao_environment"; - // end the upcall - *os << be_uidt_nl; - *os << ");" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/compiled_marshal.cpp b/TAO/TAO_IDL/be/be_visitor_operation/compiled_marshal.cpp deleted file mode 100644 index 6931503b046..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/compiled_marshal.cpp +++ /dev/null @@ -1,445 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// compiled_marshal.cpp -// -// = DESCRIPTION -// Visitor generating the code that passes retval to the CDR operators. The -// "OUTPUT" substate deals with the server side skeletons whereas the -// "INPUT" substate deals with the client stubs. Also notice that the type -// of parameter passed to the operator depends on the manner in which the -// variable is declared i.e., in the skeleton, we may have _var types but -// not in the stubs. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "be.h" -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, compiled_marshal, "$Id$") - - -// **************************************************************************** -// visitor for arguments passing to the CDR operators. -// **************************************************************************** - -be_visitor_operation_rettype_compiled_marshal:: -be_visitor_operation_rettype_compiled_marshal (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_compiled_marshal:: -~be_visitor_operation_rettype_compiled_marshal (void) -{ -} - -int be_visitor_operation_rettype_compiled_marshal:: -visit_operation (be_operation *node) -{ - this->ctx_->node (node); // save the argument 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, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - // Different types have different mappings when used as in/out or - // inout parameters. Let this visitor deal with the type - - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - 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 - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_operation - " - "Bad substate\n"), - -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_operation - " - "cannot accept visitor\n"), - -1); - } - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - *os << ")"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - *os << ")"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_operation - " - "Bad substate\n"), - -1); - } - - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - *os << node->name () << "_forany ("; - if (node->size_type () == be_decl::VARIABLE) - *os << "(" << node->name () << "_slice *)" - << "_tao_retval.in ()" << ")"; - else - *os << "_tao_retval" << ")"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - *os << node->name () << "_forany (" - << "_tao_retval" << ")"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_array - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_enum (be_enum *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - *os << "_tao_retval"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - *os << "_tao_retval"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_enum - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_interface (be_interface *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - *os << "_tao_retval.in ()"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - *os << "_tao_retval"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - *os << "_tao_retval.in ()"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - *os << "_tao_retval"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "_tao_retval.in ()"; - break; - case AST_PredefinedType::PT_any: - *os << "_tao_retval.in ()"; - break; - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_float: - case AST_PredefinedType::PT_double: - case AST_PredefinedType::PT_longdouble: - *os << "_tao_retval"; - break; - case AST_PredefinedType::PT_char: - *os << "CORBA::Any::from_char (_tao_retval)"; - break; - case AST_PredefinedType::PT_wchar: - *os << "CORBA::Any::from_wchar (_tao_retval)"; - break; - case AST_PredefinedType::PT_boolean: - *os << "CORBA::Any::from_boolean (_tao_retval)"; - break; - case AST_PredefinedType::PT_octet: - *os << "CORBA::Any::from_octet (_tao_retval)"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_array - " - "Bad predefined type\n"), - -1); - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "_tao_retval"; - break; - case AST_PredefinedType::PT_any: - *os << "*_tao_retval"; - break; - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_float: - case AST_PredefinedType::PT_double: - case AST_PredefinedType::PT_longdouble: - *os << "_tao_retval"; - break; - case AST_PredefinedType::PT_char: - *os << "CORBA::Any::to_char (_tao_retval)"; - break; - case AST_PredefinedType::PT_wchar: - *os << "CORBA::Any::to_wchar (_tao_retval)"; - break; - case AST_PredefinedType::PT_boolean: - *os << "CORBA::Any::to_boolean (_tao_retval)"; - break; - case AST_PredefinedType::PT_octet: - *os << "CORBA::Any::to_octet (_tao_retval)"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_array - " - "Bad predefined type\n"), - -1); - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_array - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_sequence (be_sequence *) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - *os << "_tao_retval.in ()"; - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - *os << "*_tao_retval"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_string (be_string *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - // differentiate between bounded and unbounded - if (node->max_size ()->ev ()->u.ulval == 0) - { - *os << "_tao_retval.in ()"; - } - else - { - *os << "CORBA::Any::from_string ((char *)_tao_retval.in (), " - << node->max_size ()->ev ()->u.ulval << ")"; - } - } - else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) - { - // differentiate between bounded and unbounded - if (node->max_size ()->ev ()->u.ulval == 0) - // unbounded - *os << "_tao_retval"; - else - *os << "CORBA::Any::to_string (_tao_retval, " - << node->max_size ()->ev ()->u.ulval << ")"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_structure (be_structure *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - if (node->size_type () == be_decl::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) - *os << "*_tao_retval"; - else - *os << "_tao_retval"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_interface - " - "Bad substate\n"), - -1); - } - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_union (be_union *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // get output stream - - if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) - { - if (node->size_type () == be_decl::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) - *os << "*_tao_retval"; - else - *os << "_tao_retval"; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_interface - " - "Bad substate\n"), - -1); - } - - return 0; -} - -int be_visitor_operation_rettype_compiled_marshal::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_compiled_marshal::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - 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 deleted file mode 100644 index 771706f01af..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// exceptlist_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for the list of exceptions that an operation -// raises. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, exceptlist_cs, "$Id$") - - -// **************************************************************************** -// visitor to generate the exception list for operations -// **************************************************************************** - -be_visitor_operation_exceptlist_cs::be_visitor_operation_exceptlist_cs (be_visitor_context - *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_exceptlist_cs::~be_visitor_operation_exceptlist_cs (void) -{ -} - -int -be_visitor_operation_exceptlist_cs::visit_operation (be_operation *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - // don't do anything if the exception list is empty - if (node->exceptions ()) - { - os->indent (); - *os << "static TAO_Exception_Data " << "_tao_" << node->flatname () - << "_exceptiondata [] = " << be_nl; - *os << "{" << be_idt_nl; - // initialize an iterator to iterate thru the exception list - UTL_ExceptlistActiveIterator *ei; - ACE_NEW_RETURN (ei, - UTL_ExceptlistActiveIterator (node->exceptions ()), - -1); - // continue until each element is visited - while (!ei->is_done ()) - { - be_exception *excp = be_exception::narrow_from_decl (ei->item ()); - - if (excp == 0) - { - delete ei; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_exceptlist_cs" - "visit_operation - " - "codegen for scope failed\n"), -1); - - } - *os << "{"; - // the typecode name - *os << excp->tc_name (); - *os << ", "; - // allocator method - *os << excp->name () << "::_alloc}"; - ei->next (); - if (!ei->is_done ()) - { - *os << ",\n"; - os->indent (); - } - // except the last one is processed? - - } // end of while loop - delete ei; - *os << be_uidt_nl << "};\n\n"; - } // end of if - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp deleted file mode 100644 index fd1a8af8628..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// operation.cpp -// -// = DESCRIPTION -// Visitor generating code for Operation in the stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -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_operation::~be_visitor_operation (void) -{ -} - - -int -be_visitor_operation::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; -} - -int -be_visitor_operation::has_param_type (be_operation *node, - AST_Argument::Direction dir) -{ - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - 0); - // continue until each element is visited - while (!si->is_done ()) - { - be_argument *bd = be_argument::narrow_from_decl (si->item ()); - if (bd && (bd->direction () == dir)) - return 1; - - si->next (); - } // end of while loop - delete si; - } // end of if - - // not of the type we are looking for - return 0; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp deleted file mode 100644 index ad20f9bd7a8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// operation_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Operation node in the client header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_ch, "$Id$") - - -// ****************************************************** -// primary visitor for "operation" in client header -// ****************************************************** - -be_visitor_operation_ch::be_visitor_operation_ch (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -be_visitor_operation_ch::~be_visitor_operation_ch (void) -{ -} - -int -be_visitor_operation_ch::visit_operation (be_operation *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; // type node - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node - - os->indent (); // start with the current indentation level - - // every operation is declared virtual in the client code - *os << "virtual "; - - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ch::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // grab the right visitor to generate the return type - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ch::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - - // STEP 2: generate the operation name - *os << " " << node->local_name (); - - // STEP 3: generate the argument list with the appropriate mapping. For these - // we grab a visitor that generates the parameter listing - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - 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); - } - - 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 deleted file mode 100644 index 87d7c374976..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp +++ /dev/null @@ -1,920 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// operation_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Operation in the stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_cs, "$Id$") - - -// ************************************************************ -// Operation visitor for client stubs -// ************************************************************ - -be_visitor_operation_cs::be_visitor_operation_cs (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -be_visitor_operation_cs::~be_visitor_operation_cs (void) -{ -} - -// processing to be done after every element in the scope is processed -int -be_visitor_operation_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"; - return 0; -} - -int -be_visitor_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; // visitor - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use - - os->indent (); // start with the current indentation level - - // retrieve the operation return type - bt = be_type::narrow_from_decl (node->return_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // 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_cs::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - - // Generate the operation name - *os << " " << node->name (); - - // Generate the argument list with the appropriate mapping (same as - // in the header file) - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if ((!visitor) || (node->accept (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; - - // 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 CORBA::Environment - *os << "{\n" << be_idt; - - // 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, bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "visit_operation - " - "gen_pre_stub_info failed\n"), - -1); - } - } - - // Declare a 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)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); - } - - if (node->has_native ()) // native exists => no stub - { - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "CORBA::COMPLETED_NO") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "visit_operation - " - "codegen for return var failed\n"), - -1); - } - } - else - { - os->indent (); - // Generate code that retrieves the underlying stub object and then - // invokes do_static_call on it. - *os << "STUB_Object *istub = this->_stubobj ();" << be_nl - << "if (istub)" << be_nl - << "{\n" << be_idt; - - // 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_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_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_cs::" - "visit_operation - " - "codegen for marshal and invoke failed\n"), - -1); - - } - - // do any post processing for the retval - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_POST_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_cs::" - "visit_operation - " - "codegen for return type post do_static_call failed\n"), - -1); - } - - // This was putting post_invoke code in the wrong place (after - // demarshaling). See line 807++ for this block's replacement. -#if 0 - // do any post processing for the arguments - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_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_cs::" - "visit_operation - " - "codegen for args in post do_static_call failed\n"), - -1); - } -#endif - // now generate the normal successful return statement - os->indent (); - *os << "return "; - // return the appropriate return value - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_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_cs::" - "visit_operation - " - "codegen for return var failed\n"), - -1); - } - *os << ";" << be_uidt_nl; - - *os << "}\n"; - // if the stub object was bad, then we raise a system exception - if (this->gen_raise_exception (bt, "CORBA::INV_OBJREF", - "CORBA::COMPLETED_NO") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "visit_operation - " - "codegen for checking exception failed\n"), - -1); - - } - *os << be_uidt; - - } // end of if (!native) - - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_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 - - // 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_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - os->indent (); - *os << "{" << bt->tc_name () << ", "; - switch (node->direction ()) - { - case AST_Argument::dir_IN: - *os << "PARAM_IN, "; - break; - case AST_Argument::dir_INOUT: - *os << "PARAM_INOUT, "; - break; - case AST_Argument::dir_OUT: - *os << "PARAM_OUT, "; - break; - } - *os << "0}"; - - return 0; -} - -int -be_visitor_operation_cs::gen_raise_exception (be_type *bt, - const char *excep, - const char *completion_status) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; - be_visitor_context ctx; - - os->indent (); - if (this->void_return_type (bt)) - { - *os << "TAO_THROW_ENV (" - << excep << " (" << completion_status << "), " - << "_tao_environment);\n"; - } - else - { - *os << "TAO_THROW_ENV_RETURN (" - << excep << " (" << completion_status << "), " - << "_tao_environment, "; - - // return the appropriate return value - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_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_cs::" - "gen_raise_exception - " - "codegen for return var failed\n"), - -1); - } - *os << ");\n"; - } - return 0; -} - -int -be_visitor_operation_cs::gen_check_exception (be_type *bt) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; - be_visitor_context ctx; - - os->indent (); - // check if there is an exception - if (this->void_return_type (bt)) - { - *os << "TAO_CHECK_ENV_RETURN_VOID (" - << "_tao_environment);\n"; - } - else - { - *os << "TAO_CHECK_ENV_RETURN (" - << "_tao_environment, "; - - // return the appropriate return value - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_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_cs::" - "gen_check_exception - " - "codegen failed\n"), - -1); - } - *os << ");\n"; - } - - return 0; -} - -// ************************************************************ -// Operation visitor for interpretive client stubs -// ************************************************************ - -be_interpretive_visitor_operation_cs:: -be_interpretive_visitor_operation_cs (be_visitor_context *ctx) - : be_visitor_operation_cs (ctx) -{ -} - -be_interpretive_visitor_operation_cs::~be_interpretive_visitor_operation_cs (void) -{ -} - -// concrete implementation of the template methods - -int -be_interpretive_visitor_operation_cs::gen_pre_stub_info (be_operation *node, - be_type *bt) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; - be_visitor_context ctx; - - // Generate the TAO_Param_Data table - os->indent (); - *os << "static const TAO_Param_Data "; - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () << - "_paramdata [] = " << be_nl; - *os << "{\n"; - os->incr_indent (); - - // entry for the return type - *os << "{" << bt->tc_name () << ", PARAM_RETURN, 0}"; - if (node->nmembers () > 0) - *os << ",\n"; - - // generate entries for the param data table for arguments - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interpretive_visitor_operation_cs::" - "gen_pre_stub_info - " - "visit scope failed\n"), - -1); - } - *os << "\n"; - os->decr_indent (); - *os << "}; // " << node->flatname () << "_paramdata\n\n"; - - // 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 ()) - { - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_interpretive_visitor_operation_cs::" - "gen_pre_stub_info - " - "Exceptionlist generation error\n"), - -1); - } - } - - // now generate the calldata table - os->indent (); - *os << "static const TAO_Call_Data "; - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () - << "_calldata = " << be_nl - << "{" - << "\""; - // 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_"; - else - *os << "_get_"; - } - *os << node->local_name () << "\", "; - - // are we oneway or two operation? - if (node->flags () == AST_Operation::OP_oneway) - { - *os << "0, "; // for false - } - else - { - *os << "1, "; // for true - } - // insert the size of the paramdata table i.e., number of arguments + 1 - // for return type - *os << (node->argument_count () + 1) << ", "; - - // insert the address of the paramdata table - // first 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_"; - else - *os << "_get_"; - } - *os << node->flatname () << "_paramdata, "; - - // insert exception list (if any) - node for attributes - if (this->ctx_->attribute ()) - *os << "0, 0};\n\n"; - else - { - if (node->exceptions ()) - { - *os << node->exceptions ()->length () - << ", _tao_" << node->flatname () << "_exceptiondata};\n\n"; - } - else - *os << "0, 0};\n\n"; - } - return 0; -} - -int -be_interpretive_visitor_operation_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 (); - *os << "void* _tao_arguments[" - << node->argument_count () + 1 << "];" << be_nl - << "const void** _tao_arg = ACE_const_cast (const void**,_tao_arguments);" << be_nl - << "*_tao_arg = "; - - // pass the appropriate return value to docall - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interpretive_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), - -1); - } - *os << "; _tao_arg++;\n"; - - // pass each argument to do_static_call - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interpretive_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), - -1); - } - - // call do_static_call with appropriate number of arguments - os->indent (); - *os << "istub->do_static_call (" << be_idt_nl - << "_tao_environment, " << be_nl - << "&"; - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () << "_calldata," << be_nl - << "_tao_arguments" << be_uidt_nl - << ");\n"; - - os->indent (); - // check if there is an exception - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_interpretive_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - - } - - return 0; -} - -// ************************************************************ -// Operation visitor for compiled client stubs -// ************************************************************ - -be_compiled_visitor_operation_cs:: -be_compiled_visitor_operation_cs (be_visitor_context *ctx) - : be_visitor_operation_cs (ctx) -{ -} - -be_compiled_visitor_operation_cs::~be_compiled_visitor_operation_cs (void) -{ -} - -// concrete implementation of the template methods - -int -be_compiled_visitor_operation_cs::gen_pre_stub_info (be_operation *node, - be_type *) -{ - be_visitor *visitor; - be_visitor_context ctx; - - // 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 ()) - { - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - 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_compiled_visitor_operation_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 "; - } - *os << "(istub, "; - if (this->ctx_->attribute ()) - { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "\"_set_\""; - else - *os << "\"_get_\""; - } - *os << "\"" << node->local_name () - << "\", TAO_ORB_Core_instance ());" << be_nl; - // initialize the invocation - *os << "_tao_call.start (_tao_environment);\n"; - - // check if there is an exception - 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); - - } - - - // 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->indent (); - // grab the outgoing stream - *os << "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();" << be_nl; - - *os << "if (!(\n" << be_idt; - - // 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 << "))\n" << be_idt; - - // if marshaling fails, raise exception - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "CORBA::COMPLETED_NO") == -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 << "\n"; - - } - - // call invoke - os->indent (); - - // We should only need to capture the invocation status if we are - // actually going to use it, otherwise we get nasty warnings from - // some C++ compiler. - if (!this->void_return_type (bt) || - this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) - { - *os << "TAO_GIOP_ReplyStatusType _invoke_status = "; - } - else - { - *os << "(void) "; - } - - if (node->flags () == AST_Operation::OP_oneway) - { - // oneway operation - *os << "_tao_call.invoke (_tao_environment);" << be_nl; - } - else - { - if (node->exceptions ()) - { - *os << "_tao_call.invoke (_tao_" << node->flatname () - << "_exceptiondata, " - << node->exceptions ()->length () - << ", _tao_environment);" << be_nl; - } - else - { - *os << "_tao_call.invoke (0, 0, _tao_environment);" << be_nl; - } - - *os << "// Exceptions will be caught here\n"; - // check if there is an exception - 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 code below this is for 2way 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); - } - // 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->indent (); - *os << "if (_invoke_status == TAO_GIOP_NO_EXCEPTION)" << be_nl - << "{" << be_idt << "\n"; - - os->indent (); - // grab the incoming stream - *os << "TAO_InputCDR &_tao_in = _tao_call.inp_stream ();" << be_nl; - *os << "if (!(\n" << be_idt; - } - - - if (!this->void_return_type (bt)) - { - // demarshal the return val and each inout and out argument - 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)) - { - // there are more to follow - *os << " &&\n"; - } - } - - if (this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) - { - - // 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_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->void_return_type (bt) || - this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) - { - - *os << be_uidt_nl << "))\n" << be_idt; - // if marshaling fails, raise exception - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "CORBA::COMPLETED_NO") == -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 << be_uidt << "\n"; - os->indent (); - *os << "}" << be_nl; - // else something has terribly gone wrong - *os << "else" << be_nl - << "{" << be_idt << "\n"; - // if this operation is not supposed to raise a user defined exception, then - // flag an UNKNOWN exception error - if (this->gen_raise_exception (bt, "CORBA::UNKNOWN", - "CORBA::COMPLETED_MAYBE") == -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 << "}\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 deleted file mode 100644 index ed375de2dfe..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// operation_ih.cpp -// -// = DESCRIPTION -// Visitor generating code for Operation in the implementation header -// -// = AUTHOR -// Yamuna Krishnamurthy (yamuna@cs.wustl.edu) -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_ih, "$Id$") - -// ************************************************************ -// Operation visitor for implementation header -// ************************************************************ - -be_visitor_operation_ih::be_visitor_operation_ih (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -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 (); - this->ctx_->node (node); // save the node - - os->indent (); // start with the current indentation level - - // every operation is declared virtual in the client code - *os << "virtual "; - - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_sh::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // grab the right visitor to generate the return type - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_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); - } - - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ih::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - - // STEP 2: generate the operation name - *os << " " << node->local_name (); - - // STEP 3: generate the argument list with the appropriate mapping. For these - // we grab a visitor that generates the parameter listing - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_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); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ih::" - "visit_operation - " - "codegen for argument list failed\n"), - -1); - } - delete visitor; - - //generate the exceptions that are thrown by the operation - gen_raise_exception (node); - - *os << ";\n\n"; - - return 0; -} - - -//Method to generate the exceptions that are thrown by the operation -int -be_visitor_operation_ih::gen_raise_exception (be_operation *node) -{ - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - if (node->exceptions ()) - { - os->indent (); - - // initialize an iterator to iterate thru the exception list - UTL_ExceptlistActiveIterator *ei; - ACE_NEW_RETURN (ei, - UTL_ExceptlistActiveIterator (node->exceptions ()), - -1); - *os << be_idt_nl << "TAO_THROW_SPEC (("; - // continue until each element is visited - while (!ei->is_done ()) - { - be_exception *excp = be_exception::narrow_from_decl (ei->item ()); - - if (excp == 0) - { - delete ei; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_exceptlist_cs" - "visit_operation - " - "codegen for scope failed\n"), -1); - - } - - - // allocator method - *os << excp->name (); - ei->next (); - if (!ei->is_done ()) - { - *os << "," <<be_nl<<"\t\t"; - //os->indent (); - } - // except the last one is processed? - - } // end of while loop - delete ei; - *os << "))"<<be_uidt; - } // end of if - - 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 deleted file mode 100644 index 2bb11720418..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp +++ /dev/null @@ -1,227 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// operation_is.cpp -// -// = DESCRIPTION -// Visitor generating code for Operation in the implementation skeleton -// -// = AUTHOR -// Yamuna Krishnamurthy (yamuna@cs.wustl.edu) -// -// ============================================================================ - -#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$") - -// ************************************************************ -// Operation visitor for implementation skeleton -// ************************************************************ - -be_visitor_operation_is::be_visitor_operation_is (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -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 (); - 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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_is::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // grab the right visitor to generate the return type - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *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; - - - ACE_CString str(node->flatname ()); - - - int lnmlength = ACE_OS::strlen (node->local_name ()->get_string ()); - - int fnmlength = ACE_OS::strlen (node->flatname ()); - fnmlength--; - - char * classname = str.substr (0,(fnmlength-lnmlength) ).rep (); - - // STEP 2: generate the operation name - *os << " " << idl_global->impl_class_prefix () << classname << idl_global->impl_class_suffix () << "::" << 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_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 (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_raise_exception (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_nl << be_uidt_nl; - - - return 0; -} - - -//method to generate the exceptions throw by the operation -int -be_visitor_operation_is::gen_raise_exception (be_operation *node) -{ - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - if (node->exceptions ()) - { - os->indent (); - - // initialize an iterator to iterate thru the exception list - UTL_ExceptlistActiveIterator *ei; - ACE_NEW_RETURN (ei, - UTL_ExceptlistActiveIterator (node->exceptions ()), - -1); - *os << be_idt_nl << "TAO_THROW_SPEC (("; - // continue until each element is visited - while (!ei->is_done ()) - { - be_exception *excp = be_exception::narrow_from_decl (ei->item ()); - - if (excp == 0) - { - delete ei; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_exceptlist_cs" - "visit_operation - " - "codegen for scope failed\n"), -1); - - } - - - // allocator method - *os << excp->name (); - ei->next (); - if (!ei->is_done ()) - { - *os << "," <<be_nl<<"\t\t"; - //os->indent (); - } - // except the last one is processed? - - } // end of while loop - delete ei; - *os << "))"<<be_uidt; - } // end of if - - 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 deleted file mode 100644 index 856be64611b..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// operation_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for Operation in the server header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_sh, "$Id$") - - -// ************************************************************ -// Operation visitor for server header -// ************************************************************ - -be_visitor_operation_sh::be_visitor_operation_sh (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -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 - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node - - os->indent (); // start with the current indentation level - - // every operation is declared virtual in the client code - *os << "virtual "; - - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_sh::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // grab the right visitor to generate the return type - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_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); - } - - 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 (); - - // 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_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); - } - - 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; - - // 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 - if (this->ctx_->attribute ()) - { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; - else - *os << "_get_"; - } - *os << node->local_name () << - "_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &_tao_req, " << be_nl - << "void *_tao_obj, " << be_nl - << "void *_tao_context, " << be_nl - << "CORBA::Environment &_tao_env = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt << "\n\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 deleted file mode 100644 index 7ab0f6d3daa..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp +++ /dev/null @@ -1,792 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// operation_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for Operation in the server skeleton -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, operation_ss, "$Id$") - - -// ************************************************************ -// Operation visitor for server skeletons -// ************************************************************ - -be_visitor_operation_ss::be_visitor_operation_ss (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -be_visitor_operation_ss::~be_visitor_operation_ss (void) -{ -} - -// processing to be done after every element in the scope is processed -int -be_visitor_operation_ss::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"; - return 0; -} - -int -be_visitor_operation_ss::visit_operation (be_operation *node) -{ - TAO_OutStream *os; // output stream - be_type *bt; // type node for return type - - os = this->ctx_->stream (); // grab the o/p stream - this->ctx_->node (node); // save the node for future use - - os->indent (); // start with the current indentation level - - // if there is an argument of type "native", return immediately - if (node->has_native ()) - return 0; - - // retrieve the operation return type - bt = be_type::narrow_from_decl (node->return_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "Bad return type\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 (node->defined_in ()); - - if (!intf) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "bad interface scope\n"), - -1); - } - - // generate the signature of the static skeleton - os->indent (); - *os << "void " << intf->full_skel_name () << "::"; - // 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_"; - else - *os << "_get_"; - } - *os << node->local_name () - << "_skel (" << be_idt << be_idt_nl - << "CORBA::ServerRequest &_tao_server_request, " << be_nl - << "void *_tao_object_reference, " << be_nl - << "void * /* context */, " << be_nl - << "CORBA::Environment &_tao_environment" << be_uidt << be_uidt_nl - << ")" << be_nl; - - // 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; - - // generate all the tables and other pre-skel info - if (this->gen_pre_skel_info (node, bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "gen_pre_skel_info failed\n"), - -1); - } - - os->indent (); - // declare an environment variable for user raised exceptions - // *os << "CORBA::Environment _tao_skel_environment;" << be_nl; - // get the right object implementation. - *os << intf->full_skel_name () << " *_tao_impl = (" - << intf->full_skel_name () << " *)_tao_object_reference;\n"; - - // 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); - if (!visitor || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); - } - - // 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)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); - } - - // Demarshal parameters - if (this->gen_demarshal_params (node, bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "gen_demarshal_params failed\n"), - -1); - } - - // do pre upcall processing if any - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_PRE_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for making upcall failed\n"), - -1); - } - // 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); - if (!visitor || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for retval assignment failed\n"), - -1); - } - - // make the upcall - *os << "_tao_impl->" << node->local_name () << " (" << be_idt << "\n"; - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for making upcall failed\n"), - -1); - } - // last argument is the environment - if (node->argument_count () > 0) - *os << ",\n"; - os->indent (); - // *os << "_tao_skel_environment"; - *os << "_tao_environment"; - // end the upcall - *os << be_uidt_nl; - *os << ");\n"; - - if (node->flags () != AST_Operation::OP_oneway) - { - os->indent (); - *os << "TAO_CHECK_ENV_RETURN_VOID (_tao_environment);\n"; - } - - // do any post processing for the arguments - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for args in post upcall failed\n"), - -1); - } - - // check if we are oneway in which case, we are done - if (node->flags () == AST_Operation::OP_oneway) - { - // we are done. Nothing else to do, except closing the function body. - os->decr_indent (); - *os << "}\n\n"; - return 0; - } - - // marshal outgoing parameters - if (this->gen_marshal_params (node, bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "gen_marshal_params failed\n"), - -1); - } - - // do any post processing for the retval - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_POST_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for return type post upcall failed\n"), - -1); - } - - // do any post processing for the arguments - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_MARSHAL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for args in post marshal failed\n"), - -1); - } - - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_argument - " - "Bad argument type\n"), - -1); - } - - os->indent (); - *os << "{" << bt->tc_name () << ", "; - switch (node->direction ()) - { - case AST_Argument::dir_IN: - *os << "CORBA::ARG_IN, "; - break; - case AST_Argument::dir_INOUT: - *os << "CORBA::ARG_INOUT, "; - break; - case AST_Argument::dir_OUT: - *os << "CORBA::ARG_OUT, "; - break; - } - *os << "0}"; - - return 0; -} - -int -be_visitor_operation_ss::gen_raise_exception (be_type *, - const char *excep, - const char *completion_status, - const char *env) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); - *os << "TAO_THROW_ENV (" - << excep << " (" << completion_status << "), " - << env << ");\n"; - return 0; -} - -int -be_visitor_operation_ss::gen_check_exception (be_type *, const char *env) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); - // check if there is an exception - *os << "TAO_CHECK_ENV_RETURN_VOID (" - << env << ");\n"; - - return 0; -} - - -// ********************************************************************* -// Operation visitor for server skeletons using interpretive marshaling -// ********************************************************************* - -be_interpretive_visitor_operation_ss:: -be_interpretive_visitor_operation_ss (be_visitor_context *ctx) - : be_visitor_operation_ss (ctx) -{ -} - -be_interpretive_visitor_operation_ss:: -~be_interpretive_visitor_operation_ss (void) -{ -} - -int -be_interpretive_visitor_operation_ss::gen_pre_skel_info (be_operation *node, - be_type *bt) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_visitor_context ctx; - - os->indent (); - // generate the param_data and call_data tables. We generate these if and - // only if none of our arguments is of "native" type. Native types cannot be - // marshaled. - // native type does not exist. Generate the static tables - - // generate the TAO_Param_Data_Skel table - *os << "static const TAO_Param_Data_Skel "; - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () << - "_paramdata [] = " << be_nl; - *os << "{\n"; - os->incr_indent (); - - // entry for the return type - *os << "{" << bt->tc_name () << ", 0, 0}"; - if (node->nmembers () > 0) - *os << ",\n"; - - // generate entries for the param data table for arguments - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "visit scope failed\n"), - -1); - } - *os << "\n"; - os->decr_indent (); - *os << "}; // " << node->flatname () << "_paramdata\n\n"; - - // now generate the calldata table - os->indent (); - *os << "static const TAO_Call_Data_Skel "; - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () - << "_calldata = " << be_nl - << "{" - << "\""; - // 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_"; - else - *os << "_get_"; - } - *os << node->local_name () << "\", "; - - // are we oneway or two operation? - if (node->flags () == AST_Operation::OP_oneway) - { - *os << "0, "; // for false - } - else - { - *os << "1, "; // for true - } - // insert the size of the paramdata table i.e., number of arguments + 1 - // for return type - *os << (node->argument_count () + 1) << ", "; - - // insert the address of the paramdata table - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () << "_paramdata};\n\n"; - - return 0; -} - -int -be_interpretive_visitor_operation_ss::gen_demarshal_params (be_operation *node, - be_type *bt) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; - be_visitor_context ctx; - - // setup parameters for demarshaling and demarshal them - os->indent (); - *os << "_tao_server_request.demarshal (" << be_idt_nl - << "_tao_environment, " << be_nl - << "&"; - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () << "_calldata,\n"; - - // pass the appropriate return value to the demarshal operation - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DEMARSHAL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for return var in demarshal failed\n"), - -1); - } - // insert a comma after the return val if there are arguments - if (node->argument_count () > 0) - *os << ",\n"; - - // pass each argument to the demarshal operation - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for argument in demarshal failed\n"), - -1); - } - - // end the demarshal call - *os << be_uidt_nl; - *os << ");" << be_nl; - - *os << "TAO_CHECK_ENV_RETURN_VOID (_tao_environment);\n"; - - return 0; -} - -int -be_interpretive_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 - // outgoing stream - os->indent (); - *os << "_tao_server_request.marshal (" << be_idt_nl - << "_tao_environment, " << be_nl - // << "_tao_skel_environment, " << be_nl - << "&"; - // 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_"; - else - *os << "_get_"; - } - *os << node->flatname () << "_calldata,\n"; - - // pass the appropriate return value to the marshal operation - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_MARSHAL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for return var in marshal failed\n"), - -1); - } - // insert a comma after the return val if there are arguments - if (node->argument_count () > 0) - { - *os << ",\n"; - } - - // pass each argument to the marshal operation - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for argument in marshal failed\n"), - -1); - } - // end the marshal call - *os << be_uidt_nl; - *os << ");\n"; - - return 0; -} - -// ********************************************************************* -// Operation visitor for server skeletons using compiled marshaling -// ********************************************************************* - -be_compiled_visitor_operation_ss:: -be_compiled_visitor_operation_ss (be_visitor_context *ctx) - : be_visitor_operation_ss (ctx) -{ -} - -be_compiled_visitor_operation_ss:: -~be_compiled_visitor_operation_ss (void) -{ -} - -int -be_compiled_visitor_operation_ss::gen_pre_skel_info (be_operation *node, - be_type *) -{ - TAO_OutStream *os = this->ctx_->stream (); - - // 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)) - { - // instantiate a TAO_InputCDR variable - os->indent (); - *os << "TAO_InputCDR &_tao_in = _tao_server_request.incoming ();\n"; - } - - return 0; -} - -int -be_compiled_visitor_operation_ss::gen_demarshal_params (be_operation *node, - be_type *bt) -{ - 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 - // 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->indent (); - - // demarshal the in and inout arguments - *os << "if (!(\n" << be_idt; - - // marshal each in and inout argument - 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)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" - "gen_demarshal_params - " - "codegen for demarshal failed\n"), - -1); - } - *os << be_uidt_nl << "))\n" << be_idt; - - // if marshaling fails, raise exception - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "CORBA::COMPLETED_NO", - "_tao_environment") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - *os << be_uidt << "\n"; - - }; - - return 0; -} - -int -be_compiled_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 - // outgoing stream - // the code below this is for 2way operations only - - // We will be here only if we are 2way - // first initialize a reply message - os->indent (); - *os << "_tao_server_request.init_reply (_tao_environment);\n"; - - // 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)) - { - // grab the incoming stream - os->indent (); - *os << "TAO_CHECK_ENV_RETURN_VOID (_tao_environment);" << be_nl; - *os << "TAO_OutputCDR &_tao_out = _tao_server_request.outgoing ();" << be_nl; - *os << "if (!(\n" << be_idt; - } - - if (!this->void_return_type (bt)) - { - // demarshal the return val and each inout and out argument - 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); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_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->void_return_type (bt)) - // we have already printed the return val. SO put a && - *os << " &&\n"; - - // marshal each in and inout argument - 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); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" - "gen_marshal_params - " - "codegen for args failed\n"), - -1); - } - } - - if (!this->void_return_type (bt) || - this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) - { - - *os << be_uidt_nl << "))\n" << be_idt; - // if marshaling fails, raise exception - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "CORBA::COMPLETED_NO", - "_tao_environment") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" - "gen_marshal_params - " - "codegen for raising exception failed\n"), - -1); - } - *os << be_uidt << be_uidt << "\n"; - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp deleted file mode 100644 index b527420c335..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp +++ /dev/null @@ -1,273 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype.cpp -// -// = DESCRIPTION -// Visitor generating code for return type of the Operation node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype, "$Id$") - - -// **************************************************************************** -// Operation visitor for return types. This generates the mapping for a return -// type in an operation signature -// **************************************************************************** - -be_visitor_operation_rettype::be_visitor_operation_rettype (be_visitor_context - *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype::~be_visitor_operation_rettype (void) -{ -} - -int -be_visitor_operation_rettype::visit_array (be_array *node) -{ - - - 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 (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_slice") << " *"; - else - *os << bt->name () << "_slice *"; - return 0; -} - -int -be_visitor_operation_rettype::visit_enum (be_enum *node) -{ - - 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 (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *os << bt->name (); - return 0; -} - -int -be_visitor_operation_rettype::visit_interface (be_interface *node) -{ - - 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 (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_ptr"); - else - *os << bt->name () << "_ptr"; - return 0; -} - -int -be_visitor_operation_rettype::visit_interface_fwd (be_interface_fwd *node) -{ - - 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 (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_ptr"); - else - *os << bt->name () << "_ptr"; - return 0; -} - -int -be_visitor_operation_rettype::visit_native (be_native *node) -{ - - 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 (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()) << " *"; - else - *os << bt->name () << " *"; - return 0; -} - -int -be_visitor_operation_rettype::visit_predefined_type (be_predefined_type *node) -{ - - 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 (); - else - bt = node; - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope (), "_ptr"); - else - *os << bt->name () << "_ptr"; - break; - case AST_PredefinedType::PT_any: - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()) << " *"; - else - *os << bt->name () << " *"; - break; - default: - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *os << bt->name (); - break; - } - - return 0; -} - -int -be_visitor_operation_rettype::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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()) << " *"; - else - *os << bt->name () << " *"; - return 0; -} - -int -be_visitor_operation_rettype::visit_string (be_string * /* node*/) -{ - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - *os << "char *"; - return 0; -} - -int -be_visitor_operation_rettype::visit_structure (be_structure *node) -{ - - 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 (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *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) - *os << " *"; - return 0; -} - -int -be_visitor_operation_rettype::visit_typedef (be_typedef *node) -{ - - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype::visit_union (be_union *node) -{ - - 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 (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *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) - *os << " *"; - return 0; -} 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 deleted file mode 100644 index 18da2e48a94..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_assign_ss.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_assign_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for assigning the return value of upcall to the -// return type variable. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_assign_ss, "$Id$") - - -// **************************************************************************** -// visitor for assignment to a return value variable from the upcall -// **************************************************************************** - -be_visitor_operation_rettype_assign_ss:: -be_visitor_operation_rettype_assign_ss (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_assign_ss:: -~be_visitor_operation_rettype_assign_ss (void) -{ -} - -int -be_visitor_operation_rettype_assign_ss::visit_array (be_array *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - return 0; -} - -int -be_visitor_operation_rettype_assign_ss::visit_enum (be_enum *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - - return 0; -} - -int -be_visitor_operation_rettype_assign_ss::visit_interface (be_interface *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - - return 0; -} - -int -be_visitor_operation_rettype_assign_ss:: -visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - - return 0; -} - -int -be_visitor_operation_rettype_assign_ss:: -visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - switch (node->pt ()) - { - case AST_PredefinedType::PT_void: - break; - case AST_PredefinedType::PT_pseudo: - case AST_PredefinedType::PT_any: - default: - *os << "_tao_retval = "; - break; - } - return 0; -} - -int -be_visitor_operation_rettype_assign_ss::visit_sequence (be_sequence *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - - return 0; -} - -int -be_visitor_operation_rettype_assign_ss::visit_string (be_string * /* node*/) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - - return 0; -} - -int -be_visitor_operation_rettype_assign_ss::visit_structure (be_structure *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - - return 0; -} - -int -be_visitor_operation_rettype_assign_ss::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_assign_ss::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_assign_ss::visit_union (be_union *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval = "; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_docall_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_docall_cs.cpp deleted file mode 100644 index 1e21d6a8106..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_docall_cs.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_docall_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for passing the return type variable to the -// do_static_call method in the stub. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_docall_cs, "$Id$") - - -// ***************************************************************************** -// be_visitor_operation_rettype_docall_cs -// -// This visitor generates code that passes the return type variable to the -// do_static_call method -// ***************************************************************************** - -be_visitor_operation_rettype_docall_cs::be_visitor_operation_rettype_docall_cs -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_docall_cs:: -~be_visitor_operation_rettype_docall_cs (void) -{ -} - -int -be_visitor_operation_rettype_docall_cs::visit_array (be_array *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_enum (be_enum *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "&_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_interface (be_interface *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "&_tao_base_retval"; - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "&_tao_base_retval"; - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - switch (node->pt ()) - { - case AST_PredefinedType::PT_void: - *os << "0"; - break; - case AST_PredefinedType::PT_any: - *os << "_tao_retval"; - break; - default: - *os << "&_tao_retval"; - break; - } - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_sequence (be_sequence *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "&_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_structure (be_structure *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // check if the struct is variable - if (node->size_type () == be_type::VARIABLE) - *os << "_tao_retval"; - else - *os << "&_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_docall_cs::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_docall_cs::visit_union (be_union *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // check if the union is variable - if (node->size_type () == be_type::VARIABLE) - *os << "_tao_retval"; - else - *os << "&_tao_retval"; - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_is.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_is.cpp deleted file mode 100644 index d0a7b793551..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_is.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype.cpp -// -// = DESCRIPTION -// Visitor generating code for return type of the Operation node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -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_decl (ctx) -{ -} - -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; - return 0; -} - -int -be_visitor_operation_rettype_is::visit_enum (be_enum *) -{ - - 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 (); // 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 (); // grab the out stream - - *os << "return 0;" <<be_nl; - return 0; -} - -int -be_visitor_operation_rettype_is::visit_native (be_native *) -{ - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - *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 - - switch (node->pt ()) - { - case AST_PredefinedType::PT_void: - *os << "return;" <<be_nl; - break; - default: - *os << "return 0;" <<be_nl; - break; - } - - return 0; -} - -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 (); // grab the out stream - - *os << "return 0;" <<be_nl; - return 0; -} - -int -be_visitor_operation_rettype_is::visit_string (be_string * /* node*/) -{ - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - - *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 - - *os << "return 0;" <<be_nl; - return 0; -} - -int -be_visitor_operation_rettype_is::visit_typedef (be_typedef *node) -{ - - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_is::visit_union (be_union *) -{ - - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - *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 deleted file mode 100644 index aa75c4b0fc3..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_marshal_ss.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_marshal_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for marshaling the return type variable -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_marshal_ss, "$Id$") - - -// **************************************************************************** -// Visitor that passes the return value to the marshal/demarshal routine -// **************************************************************************** - -be_visitor_operation_rettype_marshal_ss:: -be_visitor_operation_rettype_marshal_ss (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_marshal_ss:: -~be_visitor_operation_rettype_marshal_ss (void) -{ -} - -int -be_visitor_operation_rettype_marshal_ss::visit_array (be_array *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - //*os << "_tao_ptr_retval"; - *os << "_tao_retval.inout ()"; - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss::visit_enum (be_enum *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "&_tao_retval"; - - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss::visit_interface (be_interface *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // *os << "&_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss:: -visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // *os << "&_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss:: -visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - switch (node->pt ()) - { - case AST_PredefinedType::PT_void: - os->indent (); - *os << "0"; - break; - case AST_PredefinedType::PT_pseudo: - os->indent (); - //*os << "&_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - break; - case AST_PredefinedType::PT_any: - os->indent (); - // *os << "_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - break; - default: - os->indent (); - *os << "&_tao_retval"; - break; - } - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss::visit_sequence (be_sequence *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // *os << "_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss::visit_string (be_string * /* node*/) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // *os << "&_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss::visit_structure (be_structure *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - if (node->size_type () == be_type::VARIABLE) - //*os << "_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - else - *os << "&_tao_retval"; - - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_marshal_ss::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_marshal_ss::visit_union (be_union *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - if (node->size_type () == be_type::VARIABLE) - // *os << "_tao_ptr_retval"; - *os << "&_tao_retval.inout ()"; - else - *os << "&_tao_retval"; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_docall_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_docall_cs.cpp deleted file mode 100644 index 52d013c259f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_docall_cs.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_post_docall_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for return type post processing following a -// do_static_call. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_post_docall_cs, "$Id$") - - -// ******************************************************************************* -// be_visitor_operation_rettype_post_docall_cs -// -// This visitor generates code that passes the return type variable to the -// do_static_call method -// ******************************************************************************** - -be_visitor_operation_rettype_post_docall_cs:: -be_visitor_operation_rettype_post_docall_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_post_docall_cs:: -~be_visitor_operation_rettype_post_docall_cs (void) -{ -} - -int -be_visitor_operation_rettype_post_docall_cs::visit_interface (be_interface *node) -{ - 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 (); - else - bt = node; - - os->indent (); - *os << "_tao_retval = " << bt->name () - << "::_narrow (_tao_base_retval, _tao_environment);" << be_nl; - *os << "CORBA::release (_tao_base_retval);\n"; - return 0; -} - -int -be_visitor_operation_rettype_post_docall_cs:: -visit_interface_fwd (be_interface_fwd *node) -{ - 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 (); - else - bt = node; - - os->indent (); - *os << "_tao_retval = " << bt->name () - << "::_narrow (_tao_base_retval, _tao_environment);" << be_nl; - *os << "CORBA::release (_tao_base_retval);\n"; - 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 deleted file mode 100644 index 85e9aa175c6..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_post_upcall_ss.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_post_upcall_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for post-processing of return type after an -// upcall is made -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#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$") - - -// **************************************************************************** -// 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_operation_rettype_post_upcall_ss (void) -{ -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_array (be_array *) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_enum (be_enum *) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_interface (be_interface *) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_interface_fwd (be_interface_fwd *) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_predefined_type (be_predefined_type *) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_sequence (be_sequence *) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_string (be_string * /* node*/) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_structure (be_structure *) -{ - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_post_upcall_ss::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_post_upcall_ss::visit_union (be_union *) -{ - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_docall_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_docall_cs.cpp deleted file mode 100644 index f6f656853e4..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_docall_cs.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_pre_docall_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for doing any pre-processing of return type prior -// to making the do_static_call. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_pre_docall_cs, "$Id$") - - -// ***************************************************************************** -// be_visitor_operation_rettype_pre_docall_cs -// -// This visitor generates code that passes the return type variable to the -// do_static_call method -// ***************************************************************************** - -be_visitor_operation_rettype_pre_docall_cs:: -be_visitor_operation_rettype_pre_docall_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_pre_docall_cs:: -~be_visitor_operation_rettype_pre_docall_cs (void) -{ -} - -int -be_visitor_operation_rettype_pre_docall_cs::visit_array (be_array *node) -{ - 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 (); - else - bt = node; - - os->indent (); - *os << "ACE_ALLOCATOR_RETURN (_tao_retval, " << bt->name () - << "_alloc (), _tao_retval);\n"; - return 0; -} - -int -be_visitor_operation_rettype_pre_docall_cs::visit_interface (be_interface *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "CORBA::Object_ptr _tao_base_retval = CORBA::Object::_nil ();\n"; - return 0; -} - -int -be_visitor_operation_rettype_pre_docall_cs::visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "CORBA::Object_ptr _tao_base_retval = CORBA::Object::_nil ();\n"; - return 0; -} - -int -be_visitor_operation_rettype_pre_docall_cs:: -visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - switch (node->pt ()) - { - case AST_PredefinedType::PT_any: - os->indent (); - *os << "ACE_NEW_RETURN (_tao_retval, CORBA::Any, _tao_retval);\n"; - break; - default: - break; - } - return 0; -} - -int -be_visitor_operation_rettype_pre_docall_cs::visit_sequence (be_sequence *node) -{ - 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 (); - else - bt = node; - - os->indent (); - *os << "ACE_NEW_RETURN (_tao_retval, " << bt->name () << ", _tao_retval);\n"; - return 0; -} - -int -be_visitor_operation_rettype_pre_docall_cs::visit_structure (be_structure *node) -{ - 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 (); - else - bt = node; - - // check if the union is variable - if (node->size_type () == be_type::VARIABLE) - { - os->indent (); - *os << "ACE_NEW_RETURN (_tao_retval, " << bt->name () << ", _tao_retval);\n"; - } - return 0; -} - -int -be_visitor_operation_rettype_pre_docall_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_pre_docall_cs::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_pre_docall_cs::visit_union (be_union *node) -{ - 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 (); - else - bt = node; - - // check if the union is variable - if (node->size_type () == be_type::VARIABLE) - { - os->indent (); - *os << "ACE_NEW_RETURN (_tao_retval, " << bt->name () << ", _tao_retval);\n"; - } - 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 deleted file mode 100644 index 5b0c21c3a24..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_pre_invoke_cs.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_pre_invoke_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for doing any pre-processing of return type prior -// to making the do_static_call. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#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$") - - -// ***************************************************************************** -// be_visitor_operation_rettype_pre_invoke_cs -// -// ***************************************************************************** - -be_visitor_operation_rettype_pre_invoke_cs:: -be_visitor_operation_rettype_pre_invoke_cs (be_visitor_context *ctx) - : be_visitor_operation_rettype_pre_docall_cs (ctx) -{ -} - -be_visitor_operation_rettype_pre_invoke_cs:: -~be_visitor_operation_rettype_pre_invoke_cs (void) -{ -} - -int -be_visitor_operation_rettype_pre_invoke_cs::visit_interface (be_interface *) -{ - // don't do anything. This is the overriding action - return 0; -} - -int -be_visitor_operation_rettype_pre_invoke_cs::visit_interface_fwd (be_interface_fwd *) -{ - 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 deleted file mode 100644 index 59885aa6786..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_return_cs.cpp +++ /dev/null @@ -1,167 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_return_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for returning the return type variable. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_return_cs, "$Id$") - - -// ************************************************************ -// be_visitor_operation_rettype_return_cs -// -// 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_decl (ctx) -{ -} - -be_visitor_operation_rettype_return_cs::~be_visitor_operation_rettype_return_cs (void) -{ -} - -int -be_visitor_operation_rettype_return_cs::visit_array (be_array *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - //os->indent (); - //*os << "return _tao_retval;\n"; - *os << "_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_return_cs::visit_enum (be_enum *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - //os->indent (); - //*os << "return _tao_retval;\n"; - *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 - - //os->indent (); - //*os << "return _tao_retval;\n"; - *os << "_tao_retval"; - 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 - - //os->indent (); - //*os << "return _tao_retval;\n"; - *os << "_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_return_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - //os->indent (); - switch (node->pt ()) - { - case AST_PredefinedType::PT_void: - //*os << "return;\n"; - break; - default: - //*os << "return _tao_retval;\n"; - *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 - - //os->indent (); - //*os << "return _tao_retval;\n"; - *os << "_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_return_cs::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - //os->indent (); - //*os << "return _tao_retval;\n"; - *os << "_tao_retval"; - return 0; -} - -int -be_visitor_operation_rettype_return_cs::visit_structure (be_structure *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - //os->indent (); - //*os << "return _tao_retval;\n"; - *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 - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_return_cs::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_return_cs::visit_union (be_union *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - //os->indent (); - //*os << "return _tao_retval;\n"; - *os << "_tao_retval"; - return 0; -} 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 deleted file mode 100644 index 5613cffe2db..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp +++ /dev/null @@ -1,231 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_vardecl_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for return type variable declaration in the stubs. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_vardecl_cs, "$Id$") - - -// ************************************************************ -// be_visitor_operation_rettype_vardecl_cs -// This visitor generates code for variable declaration and initialization -// of the return type. -// ************************************************************ - -be_visitor_operation_rettype_vardecl_cs:: -be_visitor_operation_rettype_vardecl_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_vardecl_cs:: -~be_visitor_operation_rettype_vardecl_cs (void) -{ -} - -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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - bt = node; - - os->indent (); - *os << bt->name () << "_slice *_tao_retval = 0;\n"; - return 0; -} - -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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - bt = node; - - os->indent (); - *os << bt->name () << " _tao_retval = (" << bt->name () << ")0;\n"; - return 0; -} - -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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - bt = node; - - os->indent (); - *os << bt->name () << "_ptr _tao_retval = " << bt->name () << "::_nil ();\n"; - return 0; -} - -int -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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - bt = node; - - os->indent (); - *os << bt->name () << "_ptr _tao_retval = " << bt->name () << "::_nil ();\n"; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_cs::visit_predefined_type (be_predefined_type *node) -{ - 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 (); - else - bt = node; - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - os->indent (); - *os << bt->name () << "_ptr _tao_retval = 0;\n"; - break; - case AST_PredefinedType::PT_any: - os->indent (); - *os << bt->name () << " *_tao_retval = 0;\n"; - break; - case AST_PredefinedType::PT_void: - break; - default: - os->indent (); - *os << bt->name () << " _tao_retval = 0;\n"; - break; - } - return 0; -} - -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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - bt = node; - - os->indent (); - *os << bt->name () << " *_tao_retval = 0;\n"; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_cs::visit_string (be_string * /* node*/) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << "char *_tao_retval = 0;\n"; - return 0; -} - -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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - 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) - *os << bt->name () << " *_tao_retval = 0;\n"; - else - { - *os << bt->name () << " _tao_retval;" << be_nl; - *os << "ACE_OS::memset (&_tao_retval, 0, sizeof (" << bt->name () << "));\n"; - } - return 0; -} - -int -be_visitor_operation_rettype_vardecl_cs::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_vardecl_cs::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - 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) - *os << bt->name () << " *_tao_retval = 0;\n"; - else - { - *os << bt->name () << " _tao_retval;\n"; - } - return 0; -} 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 deleted file mode 100644 index 3bd34ae366f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp +++ /dev/null @@ -1,306 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// rettype_vardecl_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for return type variable declaration in the -// skeleton file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, rettype_vardecl_ss, "$Id$") - - -// ******************************************************************************** -// be_visitor_operation_rettype_vardecl_ss -// This visitor generates code for variable declaration and initialization -// of the return type. -// ******************************************************************************** - -be_visitor_operation_rettype_vardecl_ss::be_visitor_operation_rettype_vardecl_ss -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_operation_rettype_vardecl_ss:: -~be_visitor_operation_rettype_vardecl_ss (void) -{ -} - -int -be_visitor_operation_rettype_vardecl_ss::visit_array (be_array *node) -{ - 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 (); - else - bt = node; - - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_retval;" << be_nl; - *os << bt->name () << "_slice *&_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << bt->name () << "_var _tao_retval;\n"; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss::visit_enum (be_enum *node) -{ - 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 (); - else - bt = node; - - os->indent (); - *os << bt->name () << " _tao_retval;\n"; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss::visit_interface (be_interface *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // due to the virtual inheritance and the fact that we will be passing the - // address of the objref to the marshaling routine, we use the base - // CORBA::Object_ptr as the type for the return value even though the actual - // return type may be some derived class - *os << "CORBA::Object_var _tao_retval = CORBA::Object::_nil ();\n"; -#if 0 /* ASG */ - *os << "CORBA::Object_var _tao_retval = CORBA::Object::_nil ();" << be_nl; - *os << "CORBA::Object_ptr &_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss:: -visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - // due to the virtual inheritance and the fact that we will be passing the - // address of the objref to the marshaling routine, we use the base - // CORBA::Object_ptr as the type for the return value even though the actual - // return type may be some derived class -#if 0 /* ASG */ - *os << "CORBA::Object_var _tao_retval = CORBA::Object::_nil ();" << be_nl; - *os << "CORBA::Object_ptr &_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << "CORBA::Object_var _tao_retval = CORBA::Object::_nil ();" << be_nl; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss:: -visit_predefined_type (be_predefined_type *node) -{ - 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 (); - else - bt = node; - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_retval;" << be_nl; - *os << bt->name () << "_ptr &_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << bt->name () << "_var _tao_retval;\n"; - break; - case AST_PredefinedType::PT_any: - os->indent (); -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_retval;" << be_nl; - *os << bt->name () << "_ptr &_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << bt->name () << "_var _tao_retval;\n"; - break; - case AST_PredefinedType::PT_void: - break; - default: - os->indent (); - *os << bt->name () << " _tao_retval = 0;\n"; - break; - } - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss::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 - - if (this->ctx_->alias ()) // a typedefed return type - bt = this->ctx_->alias (); - else - bt = node; - - os->indent (); -#if 0 /* ASg */ - *os << bt->name () << "_var _tao_retval;" << be_nl; - *os << bt->name () << " *&_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << bt->name () << "_var _tao_retval;\n"; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss::visit_string (be_string * /* node*/) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); -#if 0 /* ASG */ - *os << "CORBA::String_var _tao_retval;" << be_nl; - *os << "char *&_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << "CORBA::String_var _tao_retval;\n"; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss::visit_structure (be_structure *node) -{ - 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 (); - else - 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) - { -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_retval;" << be_nl; - *os << bt->name () << " *&_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << bt->name () << "_var _tao_retval;\n"; - } - else - *os << bt->name () << " _tao_retval;\n"; - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_rettype_vardecl_ss::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_operation_rettype_vardecl_ss::visit_union (be_union *node) -{ - 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 (); - else - 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) - { -#if 0 /* ASG */ - *os << bt->name () << "_var _tao_retval;" << be_nl; - *os << bt->name () << " *&_tao_ptr_retval = _tao_retval.out ();\n"; -#endif - *os << bt->name () << "_var _tao_retval;" << be_nl; - } - else - *os << bt->name () << " _tao_retval;\n"; - return 0; -} - - -// ******************************************************************************** -// be_visitor_operation_rettype_vardecl_ss -// This visitor generates code for variable declaration and initialization -// of the return type. -// ******************************************************************************** - -be_compiled_visitor_operation_rettype_vardecl_ss -::be_compiled_visitor_operation_rettype_vardecl_ss -(be_visitor_context *ctx) - : be_visitor_operation_rettype_vardecl_ss (ctx) -{ -} - -be_compiled_visitor_operation_rettype_vardecl_ss:: -~be_compiled_visitor_operation_rettype_vardecl_ss (void) -{ -} - -int -be_compiled_visitor_operation_rettype_vardecl_ss::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << node->name () << "_var _tao_retval;\n"; - return 0; -} - -int -be_compiled_visitor_operation_rettype_vardecl_ss:: -visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream - - os->indent (); - *os << node->name () << "_var _tao_retval;\n"; - 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 deleted file mode 100644 index 08c28a0d6ee..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// tie_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for operations of the TIE class in the header -// file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, tie_sh, "$Id$") - - -// ************************************************************ -// 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_scope (ctx) -{ -} - -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 - - os = this->ctx_->stream (); - 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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_tie_sh::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // grab the right visitor to generate the return type - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *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); - } - - 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 - *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_; - // 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); - } - - if (node->accept (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 deleted file mode 100644 index 21ed4b77977..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp +++ /dev/null @@ -1,158 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// tie_si.cpp -// -// = DESCRIPTION -// Visitor generating code for operations for the TIE class. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, tie_si, "$Id$") - - -// ************************************************************ -// 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_scope (ctx) -{ -} - -be_visitor_operation_tie_si::~be_visitor_operation_tie_si (void) -{ -} - -int be_visitor_operation_tie_si::visit_operation (be_operation *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - be_interface *intf = - this->ctx_->interface (); - - if (!intf) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_tie_si::" - "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_tie_si::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - os->indent (); - *os << "template <class T> ACE_INLINE\n"; - - // 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); - } - - if (bt->accept (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 () << " "; - - // STEP 4: generate the argument list with the appropriate mapping (same as - // 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); - } - - if (node->accept (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) - { - *os << "return "; - } - - *os << "this->ptr_->" << node->local_name () << " (" << be_idt << "\n"; - - 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)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ss::" - "visit_operation - " - "codegen for making upcall failed\n"), - -1); - } - // last argument is the environment - if (node->argument_count () > 0) - *os << ",\n"; - os->indent (); - *os << "_tao_environment" << be_uidt_nl - << ");" << be_uidt_nl - << "}\n\n"; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_root.cpp b/TAO/TAO_IDL/be/be_visitor_root.cpp deleted file mode 100644 index 5dbc6ac91f6..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_root.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Root -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_root.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" -#include "be_visitor_root/root_cs.cpp" -#include "be_visitor_root/root_sh.cpp" -#include "be_visitor_root/root_si.cpp" -#include "be_visitor_root/root_ss.cpp" -#include "be_visitor_root/root_is.cpp" -#include "be_visitor_root/root_ih.cpp" -#include "be_visitor_root/any_op.cpp" -#include "be_visitor_root/cdr_op.cpp" - -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 deleted file mode 100644 index 9d31730b5c7..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op.cpp -// -// = DESCRIPTION -// Visitor generating code for the Any operators for types defined in Root's -// scope. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, any_op, "$Id$") - - -// *************************************************************************** -// Root visitor for generating Any operator declarations in the client header -// and stub -// *************************************************************************** - -be_visitor_root_any_op::be_visitor_root_any_op (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -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); - } - 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 deleted file mode 100644 index 36f9214da42..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/cdr_op.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op.cpp -// -// = DESCRIPTION -// Visitor generating code for the CDR operators for types defined -// in Root's scope. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, cdr_op, "$Id$") - - -// *************************************************************************** -// Root visitor for generating CDR operator declarations in the client header -// and stub -// *************************************************************************** - -be_visitor_root_cdr_op::be_visitor_root_cdr_op (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_cdr_op::~be_visitor_root_cdr_op (void) -{ -} - -int -be_visitor_root_cdr_op::visit_root (be_root *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_CDR_OP_CH) - { - *os << be_nl - << "#ifndef __ACE_INLINE__\n\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, - "(%N:%l) be_visitor_root_cdr_op::visit_root - " - "codegen for scope failed\n"), -1); - } - - if (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_CDR_OP_CH) - { - *os << be_nl - << "#endif /* __ACE_INLINE__ */\n\n"; - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_root/root.cpp b/TAO/TAO_IDL/be/be_visitor_root/root.cpp deleted file mode 100644 index 3cf32b20332..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root.cpp +++ /dev/null @@ -1,865 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root.cpp -// -// = DESCRIPTION -// Visitor generating code for the Root node. This is a generic visitor. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root, "$Id$") - - -// Generic Root visitor -be_visitor_root::be_visitor_root (be_visitor_context *ctx) - : be_visitor_scope (ctx) -{ -} - -be_visitor_root::~be_visitor_root (void) -{ -} - -// 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 - // 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); - } - - // 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); - } - - // 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. - be_visitor *visitor; - be_visitor_context ctx (*this->ctx_); - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CS); - break; - - case TAO_CodeGen::TAO_ROOT_IH: - (void) tao_cg->end_implementation_header (idl_global->be_get_implementation_hdr_fname (0)); - break; - case TAO_CodeGen::TAO_ROOT_SH: - (void) tao_cg->end_server_header (); - (void) tao_cg->end_server_template_header (); - return 0; - - case TAO_CodeGen::TAO_ROOT_CI: - break; - case TAO_CodeGen::TAO_ROOT_IS: - break; - case TAO_CodeGen::TAO_ROOT_SI: - return 0; // nothing to be done - case TAO_CodeGen::TAO_ROOT_SS: - (void) tao_cg->end_server_template_skeletons (); - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_constant - " - "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) - { - 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; - } - - // 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. - ctx = *this->ctx_; - - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_IH: - case TAO_CodeGen::TAO_ROOT_CS: - case TAO_CodeGen::TAO_ROOT_SI: - case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_constant - " - "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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "failed to generate CDR operators\n" - ), -1); - } - delete visitor; - - // generate any final code such as #endifs - switch (this->ctx_->state ()) - { - case TAO_CodeGen::TAO_ROOT_CH: - (void) tao_cg->end_client_header (); - break; - default: - break; - } - return 0; -} - -// =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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - 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: - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - case TAO_CodeGen::TAO_ROOT_CI: - case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_IH: - case TAO_CodeGen::TAO_ROOT_SI: - case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_constant - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_constant - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - 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: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_enum - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_enum - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_SI: - case TAO_CodeGen::TAO_ROOT_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_exception - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_exception - " - "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_exception - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -// visit an interface -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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CI); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CS); - break; - case TAO_CodeGen::TAO_ROOT_SH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SH); - break; - case TAO_CodeGen::TAO_ROOT_IH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); - break; - case TAO_CodeGen::TAO_ROOT_SI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SI); - break; - case TAO_CodeGen::TAO_ROOT_SS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_SS); - break; - case TAO_CodeGen::TAO_ROOT_IS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_interface - " - "Bad context state\n" - ), -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); - } - - // 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); - } - delete visitor; - 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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); - 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: - case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - case TAO_CodeGen::TAO_ROOT_CS: - case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_SI: - case TAO_CodeGen::TAO_ROOT_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_interface_fwd - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_interface_fwd - " - "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_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -// visit an 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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_MODULE_CI); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_CS); - break; - case TAO_CodeGen::TAO_ROOT_SH: - ctx.state (TAO_CodeGen::TAO_MODULE_SH); - break; - case TAO_CodeGen::TAO_ROOT_SI: - ctx.state (TAO_CodeGen::TAO_MODULE_SI); - break; - case TAO_CodeGen::TAO_ROOT_SS: - ctx.state (TAO_CodeGen::TAO_MODULE_SS); - break; - case TAO_CodeGen::TAO_ROOT_IS: - ctx.state (TAO_CodeGen::TAO_MODULE_IS); - break; - case TAO_CodeGen::TAO_ROOT_IH: - ctx.state (TAO_CodeGen::TAO_MODULE_IH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_module - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_module - " - "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_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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_SI: - case TAO_CodeGen::TAO_ROOT_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_structure - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_structure - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_structure - " - "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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_SI: - case TAO_CodeGen::TAO_ROOT_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_union - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_union - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_union - " - "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 - 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_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; - case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; - case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_SH: - case TAO_CodeGen::TAO_ROOT_SI: - case TAO_CodeGen::TAO_ROOT_SS: - return 0; // nothing to be done - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_typedef - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_typedef - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 deleted file mode 100644 index 29a3dacdfb9..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Root in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ch, "$Id$") - - -// ******************************** -// Root visitor for client header -// ******************************** - -be_visitor_root_ch::be_visitor_root_ch (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_ch::~be_visitor_root_ch (void) -{ -} - -int -be_visitor_root_ch::init (void) -{ - // first open the client-side header file for writing - if (tao_cg->start_client_header (idl_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; - } - - // init the stream - this->ctx_->stream (tao_cg->client_header ()); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ci.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ci.cpp deleted file mode 100644 index d7ca5008cba..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ci.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for the Root in the client inline -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ci, "$Id$") - - -// ********************************* -// Root visitor for client inline -// ********************************* - -be_visitor_root_ci::be_visitor_root_ci (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_ci::~be_visitor_root_ci (void) -{ -} - -int -be_visitor_root_ci::init (void) -{ - // first open the client-side inline file for writing - if (tao_cg->start_client_inline (idl_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; - } - - this->ctx_->stream (tao_cg->client_inline ()); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_cs.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_cs.cpp deleted file mode 100644 index a6d0bc90b54..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_cs.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Root in the client stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_cs, "$Id$") - - -// *********************************** -// Root visitor for client stubs -// *********************************** - -be_visitor_root_cs::be_visitor_root_cs (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_cs::~be_visitor_root_cs (void) -{ -} - -int -be_visitor_root_cs::init (void) -{ - // first open the file - if (tao_cg->start_client_stubs (idl_global->be_get_client_stub_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_cs - " - "Error opening client stub file\n"), -1); - } - - // init stream - this->ctx_->stream (tao_cg->client_stubs ()); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ih.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ih.cpp deleted file mode 100644 index 98370a45a42..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ih.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_ih.cpp -// -// = DESCRIPTION -// Visitor generating code for Root in the server implementation header -// -// = AUTHOR -// Yamuna Krishnamurthy (yamuna@cs.wustl.edu) -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ih, "$Id$") - - -// *********************************** -// Root visitor for implementation header -// *********************************** - -be_visitor_root_ih::be_visitor_root_ih (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -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 (idl_global->be_get_implementation_hdr_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_ih::init - " - "Error :%p: Unable to open implementation header file : %s\n", - idl_global->be_get_implementation_hdr_fname ()), - -1); - } - - - // 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 deleted file mode 100644 index 5cf2a47ffce..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_is.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_is.cpp -// -// = DESCRIPTION -// Visitor generating code for the Root in the implementation skeletons file -// -// = AUTHOR -// Yamuna Krishnamurthy (yamuna@cs.wustl.edu) -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -//ACE_RCSID(be_visitor_root, root_ss, "$Id$") - - -// ****************************************************** -// Root visitor for implementation skeletons -// ****************************************************** - -be_visitor_root_is::be_visitor_root_is (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_is::~be_visitor_root_is (void) -{ -} - -int -be_visitor_root_is::init (void) -{ - // first open the file for writing - if (tao_cg->start_implementation_skeleton (idl_global - ->be_get_implementation_skel_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_is::init - " - "Error opening implementation skeletons file\n"), -1); - } - /* - if (tao_cg->start_server_template_skeletons - (idl_global->be_get_server_template_skeleton_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_ss::init - " - "Error opening server template skeleton 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 deleted file mode 100644 index f8c1eebbc21..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_sh.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_sh.cpp -// -// = DESCRIPTION -// Visitor generating code for Root in the server header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_sh, "$Id$") - - -// *********************************** -// Root visitor for server header -// *********************************** - -be_visitor_root_sh::be_visitor_root_sh (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_sh::~be_visitor_root_sh (void) -{ -} - -int -be_visitor_root_sh::init (void) -{ - // open the file - if (tao_cg->start_server_header (idl_global->be_get_server_hdr_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_sh::init - " - "Error :%p: Unable to open server header file : %s\n", - idl_global->be_get_server_hdr_fname ()), - -1); - } - - if (tao_cg->start_server_template_header (idl_global->be_get_server_template_hdr_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_sh::init - " - "Error:Unable to openin server template header file : %s\n", - idl_global->be_get_server_template_hdr_fname ()), - -1); - } - - // set the stream and the next state - this->ctx_->stream (tao_cg->server_header ()); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_si.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_si.cpp deleted file mode 100644 index 5a4ec77261c..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_si.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_si.cpp -// -// = DESCRIPTION -// Visitor generating code for the Root in the server inline file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_si, "$Id$") - - -// *********************************************** -// Root visitor for server inline -// *********************************************** - -be_visitor_root_si::be_visitor_root_si (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_si::~be_visitor_root_si (void) -{ -} - -int -be_visitor_root_si::init (void) -{ - // first open the file for writing - if (tao_cg->start_server_inline (idl_global->be_get_server_inline_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_si::init - " - "server inline open failed\n"), -1); - } - - if (tao_cg->start_server_template_inline - (idl_global->be_get_server_template_inline_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_si::init - " - "Error opening server template inline file\n"), - -1); - } - - // init stream - this->ctx_->stream (tao_cg->server_inline ()); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ss.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ss.cpp deleted file mode 100644 index c5557f3fa80..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ss.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// root_ss.cpp -// -// = DESCRIPTION -// Visitor generating code for the Root in the server skeletons file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root_ss, "$Id$") - - -// ****************************************************** -// Root visitor for server skeletons -// ****************************************************** - -be_visitor_root_ss::be_visitor_root_ss (be_visitor_context *ctx) - : be_visitor_root (ctx) -{ -} - -be_visitor_root_ss::~be_visitor_root_ss (void) -{ -} - -int -be_visitor_root_ss::init (void) -{ - // first open the file for writing - if (tao_cg->start_server_skeletons (idl_global - ->be_get_server_skeleton_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_ss::init - " - "Error opening server skeletons file\n"), -1); - } - - if (tao_cg->start_server_template_skeletons - (idl_global->be_get_server_template_skeleton_fname ()) - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_ss::init - " - "Error opening server template skeleton file\n"), - -1); - } - - // set stream - this->ctx_->stream (tao_cg->server_skeletons ()); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_scope.cpp b/TAO/TAO_IDL/be/be_visitor_scope.cpp deleted file mode 100644 index 8ee75eff8df..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_scope.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_scope.cpp -// -// = DESCRIPTION -// Visitor for the base be_scope node. This serves to maintain the current -// state (context) of code generation for the derived visitor. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_scope.h" - -ACE_RCSID(be, be_visitor_scope, "$Id$") - - -// ****************************************************** -// Generic visitor for a scope. -// All elements that give rise to a scope inherit from -// this class -// ****************************************************** - -be_visitor_scope::be_visitor_scope (be_visitor_context *ctx) - : be_visitor_decl (ctx), - elem_number_ (0) -{ -} - -be_visitor_scope::~be_visitor_scope (void) -{ -} - -// visit the scope and its elements -int -be_visitor_scope::visit_scope (be_scope *node) -{ - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each element is visited - while (!si->is_done ()) - { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); - - } - be_decl *bd = be_decl::narrow_from_decl (d); - // set the scope node as "node" in which the code is being - // generated so that elements in the node's scope can use it - // for code generation - - this->ctx_->scope (node->decl ()); - - // set the node to be visited - this->ctx_->node (bd); - this->elem_number_++; - - // do any pre processing using the next item info - if (this->pre_process (bd) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "pre processing failed\n"), -1); - } - if (bd == 0 || bd->accept (this) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); - - } - if (this->post_process (bd) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "post processing failed\n"), -1); - } - si->next (); - } // end of while loop - delete si; - } // end of if - - -#if 0 - // For debugging the prefix... - be_decl* decl = node->decl (); - ACE_DEBUG ((LM_DEBUG, "Enter scope <%s> : [%s]\n", - decl->fullname (), decl->prefix ())); - if (decl->pragmas () != 0) - { - for (UTL_StrlistActiveIterator i(decl->pragmas ()); - !i.is_done (); - i.next ()) - { - String* s = i.item (); - - ACE_DEBUG ((LM_DEBUG, " pragma = <%s>\n", s->get_string ())); - } - } -#endif - - return 0; -} - -int -be_visitor_scope::post_process (be_decl *) -{ - return 0; -} - -int -be_visitor_scope::pre_process (be_decl *) -{ - return 0; -} - -int -be_visitor_scope::elem_number (void) -{ - // return the current element that we are working on - return this->elem_number_; -} - -// find the element that succeeds "elem" in the list -int -be_visitor_scope::next_elem (be_decl *elem, - be_decl *&successor) -{ - be_scope *node = 0; - - if (!this->ctx_->scope () || - !(node = this->ctx_->scope ()->scope ())) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::next_elem - " - "bad scope\n"), -1); - - } - - successor = 0; - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - // continue until each element is visited - while (!si->is_done ()) - { - be_decl *bd = be_decl::narrow_from_decl (si->item ()); - if (!bd) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::next_elem - " - "bad node in this scope\n"), -1); - - } - - if (bd == elem) - { - // find who is next to me - si->next (); - if (si->is_done ()) - { - // nobody left in the list - delete si; - return 0; - } - successor = be_decl::narrow_from_decl (si->item ()); - if (!successor) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::next_elem - " - "bad node in this scope\n"), -1); - - } - // nothing else to do - delete si; - return 0; - } - else - // proceed to the next element - si->next (); - } // end of while loop - delete si; - } // end of if - return 0; -} - -idl_bool -be_visitor_scope::last_node (be_decl *bd) -{ - be_decl *next = 0; - (void) this->next_elem (bd, next); - if (next) - // not the last - return 0; - - // I am the last one - return 1; -} diff --git a/TAO/TAO_IDL/be/be_visitor_sequence.cpp b/TAO/TAO_IDL/be/be_visitor_sequence.cpp deleted file mode 100644 index 05bd6999af0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_sequence.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Sequence -// -// = AUTHOR -// Aniruddha Gokhale and Carlos O'Ryan -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "be_visitor_sequence.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" -#include "be_visitor_sequence/cdr_op_cs.cpp" -#include "be_visitor_sequence/buffer_type.cpp" -#include "be_visitor_sequence/elemtype.cpp" -#include "be_visitor_sequence/sequence_base.cpp" -#include "be_visitor_sequence/sequence_ch.cpp" -#include "be_visitor_sequence/sequence_ci.cpp" -#include "be_visitor_sequence/sequence_cs.cpp" -#include "be_visitor_sequence/gen_unbounded_sequence_ch.cpp" -#include "be_visitor_sequence/gen_bounded_sequence_ch.cpp" -#include "be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp" -#include "be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp" -#include "be_visitor_sequence/gen_bounded_str_sequence_ch.cpp" -#include "be_visitor_sequence/gen_object_manager_ch.cpp" -#include "be_visitor_sequence/gen_unbounded_sequence_ci.cpp" -#include "be_visitor_sequence/gen_bounded_sequence_ci.cpp" -#include "be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp" -#include "be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp" -#include "be_visitor_sequence/gen_bounded_str_sequence_ci.cpp" -#include "be_visitor_sequence/gen_object_manager_ci.cpp" -#include "be_visitor_sequence/gen_unbounded_sequence_cs.cpp" -#include "be_visitor_sequence/gen_bounded_sequence_cs.cpp" -#include "be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp" -#include "be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp" -#include "be_visitor_sequence/gen_bounded_str_sequence_cs.cpp" - -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 deleted file mode 100644 index f1223cd7642..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for the Sequence -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, any_op_ch, "$Id$") - - -// *************************************************************************** -// Sequence visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_sequence_any_op_ch::be_visitor_sequence_any_op_ch -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_sequence_any_op_ch::~be_visitor_sequence_any_op_ch (void) -{ -} - -int -be_visitor_sequence_any_op_ch::visit_sequence (be_sequence *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operators - os->indent (); - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, const " << node->name () - << " &); // copying version" << be_nl; - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, " << node->name () - << "*); // noncopying version" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << node->name () << " *&);\n"; - - node->cli_hdr_any_op_gen (1); - return 0; -} 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 deleted file mode 100644 index 29e8467536d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operator for the Sequence node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, any_op_cs, "$Id$") - - -// *************************************************************************** -// Sequence visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_sequence_any_op_cs::be_visitor_sequence_any_op_cs -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_sequence_any_op_cs::~be_visitor_sequence_any_op_cs (void) -{ -} - -int -be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // Any <<= and >>= operators - os->indent (); - *os << "void operator<<= (" << be_idt << be_idt_nl - << "CORBA::Any &_tao_any," << be_nl - << "const " << node->name () << " &_tao_elem" << be_uidt_nl - << ") // copying" << be_uidt_nl - << "{" << be_idt_nl - << node->name () << " *_tao_any_val;" << be_nl - << "ACE_NEW (_tao_any_val, " << node->name () - << " (_tao_elem));" << be_nl - << "if (!_tao_any_val) return;" << be_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () - << ", _tao_any_val, 1, TAO_TRY_ENV);" - << " // copy the value" << be_nl - << "TAO_CHECK_ENV; " << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _tao_any_val;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->name () << " *_tao_elem) // non copying" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " - << "_tao_elem, 0, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY {}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << " *&_tao_elem)" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", TAO_TRY_ENV)) return 0; // not equal" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "if (_tao_any.any_owns_data ())" << be_nl - << "{" << be_idt_nl - << "_tao_elem = (" << node->name () << " *)_tao_any.value ();" - << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // else any does not own the data - << "{" << be_idt_nl - << "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);" - << be_nl - << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any._tao_get_cdr ());" - << be_nl - << "if (stream.decode (" << node->tc_name () - << ", _tao_elem, 0, TAO_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->replace (" - << node->tc_name () << ", _tao_elem, 1, TAO_TRY_ENV);" - << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // decode failed - << "{" << be_idt_nl - << "delete _tao_elem;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _tao_elem;" << be_nl - << "return 0;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\n"; - - node->cli_stub_any_op_gen (1); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/buffer_type.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/buffer_type.cpp deleted file mode 100644 index 5ffe0a8aced..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/buffer_type.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// buffer_type.cpp -// -// = DESCRIPTION -// Visitor generating code for the internal buffer type of the Sequence node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -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_decl (ctx) -{ -} - -be_visitor_sequence_buffer_type::~be_visitor_sequence_buffer_type (void) -{ -} - -// helper -int -be_visitor_sequence_buffer_type::visit_node (be_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *os << bt->name (); - return 0; -} - -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"; - else - *os << node->name (); - return 0; -} - -int -be_visitor_sequence_buffer_type::visit_sequence (be_sequence *node) -{ - return this->visit_node (node); -} - -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"); - else - *os << node->name () << "_ptr"; - return 0; -} - -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"); - else - *os << node->name () << "_ptr"; - return 0; -} - -int -be_visitor_sequence_buffer_type::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); - *os << "char *"; - return 0; -} - -int -be_visitor_sequence_buffer_type::visit_structure (be_structure *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_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_buffer_type::visit_exception (be_exception *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_buffer_type::visit_array (be_array *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_buffer_type::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_sequence_buffer_type::" - "visit_typedef - " - "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 deleted file mode 100644 index e689f79f608..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for sequences. This uses -// compiled marshaling. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -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_decl (ctx) -{ -} - -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 ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - os->indent (); - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const " << node->name () - << " &); // " << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, " - << node->name () << " &);\n"; - - - node->cli_hdr_cdr_op_gen (1); - return 0; -} - 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 deleted file mode 100644 index c5c6c4250dc..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp +++ /dev/null @@ -1,584 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor for code generation of Sequences for the CDR operators -// in the client stubs. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, cdr_op_cs, "$Id$") - - -// *************************************************************************** -// Sequence visitor for generating CDR operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_sequence_cdr_op_cs::be_visitor_sequence_cdr_op_cs -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_sequence_cdr_op_cs::~be_visitor_sequence_cdr_op_cs (void) -{ -} - -int -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 itself a sequence - // i.e., this is a case of sequence of sequence - return this->visit_node (node); - } - else - { - TAO_OutStream *os = this->ctx_->stream (); - - be_type *bt; // base type of the sequence - - if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; - - // retrieve the type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_sequence_cdr_op_cs::" - "visit_sequence - " - "Bad base type\n"), - -1); - } - - // generate the CDR << and >> operator defns - - // save the sequence node for further use - this->ctx_->node (node); - - // set the sub state as generating code for the output operator - this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - *os << "ACE_INLINE CORBA::Boolean operator<< (" << be_idt << be_idt_nl - << "TAO_OutputCDR &strm," << be_nl - << "const " << node->name () - << " &_tao_sequence" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - - // first encode the sequence length - *os << "if (strm << _tao_sequence.length ())" << be_nl - << "{" << be_idt_nl; - // now encode the sequence elements - *os << "// encode all elements" << be_nl; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_sequence_cdr_op_cs::" - "visit_sequence - " - "Base type codegen failed\n"), - -1); - } - *os << "}" << be_nl - << "return 0; // error" << be_uidt_nl - << "}\n\n"; - - // set the sub state as generating code for the input operator - os->indent (); - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - *os << "ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, " - << node->name () << " &_tao_sequence)" << be_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 - << "{" << be_idt_nl; - // 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))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_sequence - " - "bad sequence dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - if (expr->ev ()->u.ulval > 0) - { - // 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; - } - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_sequence - " - "bad sequence dimension value\n"), - -1); - } - *os << "// set the length of the sequence" << be_nl - << "_tao_sequence.length (_tao_seq_len);" << be_nl; - *os << "// retrieve all the elements" << be_nl; - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_sequence_cdr_op_cs::" - "visit_sequence - " - "Base type codegen failed\n"), - -1); - } - if (expr->ev ()->u.ulval > 0) - { - // we are dealing with a bounded sequence. - *os << "}" << be_uidt_nl; - } - *os << "}" << be_nl - << "return 0; // error" << be_uidt_nl - << "}\n\n"; - - 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) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_cdr_op_cs::visit_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_cdr_op_cs::visit_interface (be_interface *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_cdr_op_cs::visit_interface_fwd (be_interface_fwd *node) -{ - return this->visit_node (node); -} - -int -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_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); - 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 - // 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 - - // grab the sequence node - be_sequence *sequence = this->ctx_->be_node_as_sequence (); - - if (!sequence) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_predefined_type - " - "bad sequence node\n"), - -1); - } - - // 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) - { - *os << "\n#if defined (TAO_NO_COPY_OCTET_SEQUENCES)" << be_nl; - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - { - *os << "if (ACE_BIT_DISABLED (strm.start ()->flags ()," - << "ACE_Message_Block::DONT_DELETE))" << be_nl - << "{" << be_idt_nl - << "TAO_Unbounded_Sequence<CORBA::Octet> *oseq = " << be_nl - << " ACE_dynamic_cast(TAO_Unbounded_Sequence<CORBA::Octet>*, " - << "&_tao_sequence);" << be_nl; - *os << "oseq->replace (_tao_seq_len, strm.start ());" - << be_nl - << "oseq->mb ()->wr_ptr (oseq->mb()->rd_ptr () + " - << "_tao_seq_len);" << be_nl - << "strm.skip_bytes (_tao_seq_len);" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "return strm.read_octet_array (" - << "_tao_sequence.get_buffer (), _tao_seq_len);" - << be_uidt_nl; - } - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - { - *os << "{" << be_idt_nl - << "TAO_Unbounded_Sequence<CORBA::Octet> *oseq = " << be_nl - << " ACE_dynamic_cast (TAO_Unbounded_Sequence<CORBA::Octet>*, " - << "(" << sequence->name () << " *)&_tao_sequence);" << be_nl; - *os << "if (oseq->mb ())" << be_idt_nl - << "return strm.write_octet_array_mb (oseq->mb ());" - << be_uidt_nl - << "else" << be_idt_nl - << "return strm.write_octet_array (" - << "_tao_sequence.get_buffer (), _tao_sequence.length ());" - << be_uidt << be_uidt_nl - << "}" << be_nl; - } - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_predefined_type - " - "bad sub state\n"), - -1); - } - *os << "\n#else /* TAO_NO_COPY_OCTET_SEQUENCES */" << be_nl; - } - - *os << "return strm."; - // based on our substate, we may be reading from a stream or writing into a - // stream - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "read_"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "write_"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_predefined_type - " - "bad sub state\n"), - -1); - } - - // determine what kind of sequence are we reading/writing - switch (node->pt ()) - { - case AST_PredefinedType::PT_long: - *os << "long_array"; - break; - case AST_PredefinedType::PT_ulong: - *os << "ulong_array"; - break; - case AST_PredefinedType::PT_short: - *os << "short_array"; - break; - case AST_PredefinedType::PT_ushort: - *os << "ushort_array"; - break; - case AST_PredefinedType::PT_octet: - *os << "octet_array"; - break; - case AST_PredefinedType::PT_char: - *os << "char_array"; - break; - case AST_PredefinedType::PT_wchar: - *os << "wchar_array"; - break; - case AST_PredefinedType::PT_float: - *os << "float_array"; - break; - case AST_PredefinedType::PT_double: - *os << "double_array"; - break; - case AST_PredefinedType::PT_longlong: - *os << "longlong_array"; - break; - case AST_PredefinedType::PT_ulonglong: - *os << "ulonglong_array"; - break; - case AST_PredefinedType::PT_longdouble: - *os << "longdouble_array"; - break; - case AST_PredefinedType::PT_boolean: - *os << "boolean_array"; - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_predefined_type - " - "bad primitive type for optimized code gen\n"), - -1); - } - - // handle special case to avoid compiler errors - switch (node->pt ()) - { - case AST_PredefinedType::PT_char: - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " ((char *)_tao_sequence.get_buffer (), "; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << " ((const char *)_tao_sequence.get_buffer (), "; - break; - } - break; - default: - *os << " (_tao_sequence.get_buffer (), "; - break; - } - - *os << "_tao_sequence.length ());" << be_uidt_nl; - - if (node->pt () == AST_PredefinedType::PT_octet) - *os << "\n#endif /* TAO_NO_COPY_OCTET_SEQUENCES */" << be_nl; - return 0; -} - -int -be_visitor_sequence_cdr_op_cs::visit_string (be_string *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_cdr_op_cs::visit_structure (be_structure *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_cdr_op_cs::visit_union (be_union *node) -{ - return this->visit_node (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 - 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); - } - - 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 (); - - if (!node) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_node - " - "bad sequence node\n"), - -1); - } - - // initialize a boolean variable - *os << "CORBA::Boolean _tao_marshal_flag = 1;" << be_nl; - - // we get here if the "type" of individual elements of the 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))) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_node - " - "bad sequence dimension\n"), - -1); - } - if (expr->ev ()->et == AST_Expression::EV_ulong) - { - *os << "for (CORBA::ULong i = 0; i < _tao_sequence.length ()" - << " && _tao_marshal_flag; " - << "i++)" << be_idt_nl; - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_node - " - "bad sequence dimension value\n"), - -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. - // - - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_INPUT: - *os << "_tao_marshal_flag = (strm >> "; - switch (bt->node_type ()) - { - case AST_Decl::NT_string: - { - be_string *str = be_string::narrow_from_decl (bt); - - if (!str) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_node - " - "bad string node\n"), - -1); - } - if (str->max_size ()->ev ()->u.ulval == 0) - { - // unbounded - *os << "_tao_sequence[i].out ()"; - } - else - { - *os << "CORBA::Any::to_string (_tao_sequence[i].out (), " - << str->max_size ()->ev ()->u.ulval << ")"; - } - } - break; - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - *os << "_tao_sequence[i].out ()"; - break; - case AST_Decl::NT_pre_defined: - { - // we need to separately handle this case of pseudo objects because - // they have a _var type - be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); - if (!pt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_node - " - "bad predefined type node\n"), - -1); - } - if (pt->pt () == AST_PredefinedType::PT_pseudo) - { - *os << "_tao_sequence[i].out ()"; - } - else - { - *os << "_tao_sequence[i]"; - } - } - break; - default: - *os << "_tao_sequence[i]"; - } - *os << ");"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "_tao_marshal_flag = (strm << _tao_sequence[i]"; - switch (bt->node_type ()) - { - case AST_Decl::NT_string: - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - *os << ".in ()"; - break; - case AST_Decl::NT_pre_defined: - { - be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); - if (!pt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_node - " - "bad predefined type node\n"), - -1); - } - if (pt->pt () == AST_PredefinedType::PT_pseudo) - { - *os << ".in ()"; - } - } - } - *os << ");"; - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cdr_op_cs::" - "visit_node - " - "bad sub state\n"), - -1); - } - - *os << be_uidt_nl; - *os << "return _tao_marshal_flag;" << be_uidt_nl; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp deleted file mode 100644 index d81d919d9d4..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// elemtype.cpp -// -// = DESCRIPTION -// Visitor generating code for the element type for the Sequence -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -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_decl (ctx) -{ -} - -be_visitor_sequence_elemtype::~be_visitor_sequence_elemtype (void) -{ -} - -// helper -int -be_visitor_sequence_elemtype::visit_node (be_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()) << " &"; - else - *os << bt->name () << " &"; - return 0; -} - -int -be_visitor_sequence_elemtype::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - if (this->ctx_->state() != TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - { - if (this->ctx_->scope()->fullname()) - *os << this->ctx_->scope()->fullname() << "::"; - } - - *os << "_TAO_Object_Manager_" - << this->ctx_->scope()->flatname() - << "_" - << bt->flatname (); - - os->gen_else_AHETI(); - - if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - { - *os << "TAO_Object_Manager<" - << bt->nested_type_name (this->ctx_->scope ()) << "> "; - } - else - *os << "TAO_Object_Manager<" << bt->name () << "> "; - - os->gen_endif_AHETI(); - break; - default: - if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()) << " &"; - else - *os << bt->name () << " &"; - } - return 0; -} - -int -be_visitor_sequence_elemtype::visit_sequence (be_sequence *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_elemtype::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - if (this->ctx_->state() != TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - { - if (this->ctx_->scope()->fullname()) - *os << this->ctx_->scope()->fullname() << "::"; - } - - *os << "_TAO_Object_Manager_" - << this->ctx_->scope()->flatname() - << "_" - << bt->flatname (); - - os->gen_else_AHETI(); - - if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - { - *os << "TAO_Object_Manager<" - << bt->nested_type_name (this->ctx_->scope ()) << "> "; - } - else - *os << "TAO_Object_Manager<" << bt->name () << "> "; - - os->gen_endif_AHETI(); - - return 0; -} - -int -be_visitor_sequence_elemtype::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - os->gen_ifdef_AHETI(); - - if (this->ctx_->state() != TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - { - if (this->ctx_->scope()->fullname()) - *os << this->ctx_->scope()->fullname() << "::"; - } - - *os << "_TAO_Object_Manager_" - << this->ctx_->scope()->flatname() - << "_" - << bt->flatname (); - - os->gen_else_AHETI(); - - if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) - { - *os << "TAO_Object_Manager<" - << bt->nested_type_name (this->ctx_->scope ()) << "> "; - } - else - *os << "TAO_Object_Manager<" << bt->name () << "> "; - - os->gen_endif_AHETI(); - - return 0; -} - -int -be_visitor_sequence_elemtype::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); - - *os << "TAO_SeqElem_String_Manager "; - return 0; -} - -int -be_visitor_sequence_elemtype::visit_structure (be_structure *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_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_elemtype::visit_exception (be_exception *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_elemtype::visit_array (be_array *node) -{ - return this->visit_node (node); -} - -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, - "be_visitor_sequence_elemtype::" - "visit_typedef - " - "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 deleted file mode 100644 index f9e2ef18168..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_obj_sequence_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client header -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -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 ()); - 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; // 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; - - - 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); - - const char * object_manager = node->object_manager_name (); - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - os->gen_ifdef_macro (class_name); - - os->indent (); - - //forward declaration of the object manager; - *os << "class " << object_manager << ";" << be_nl << be_nl; - - *os << "class " << class_name << " : public TAO_Bounded_Base_Sequence" << be_nl - << "{" << be_nl - << "public:" << be_idt_nl - << "// = Initialization and termination methods." << be_nl - << be_nl; - - // default constructor - *os << class_name << " (void);" << be_nl; - - // constructor - *os << class_name << " (CORBA::ULong length," << be_idt_nl; - // 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 <<"* *value," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; - - // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl - << "// Copy constructor." << be_nl; - - // destructor - *os << "virtual ~" << class_name << " (void);" << be_nl - << "// destructor" << be_nl; - - // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl - << "// Assignment from another Bounded sequence." << be_nl; - - // operator[] - *os << object_manager << " operator[] (CORBA::ULong index) const;" - << "// Read-write accessor." << be_nl; - - // allocbuf - *os << "static "; - pt->accept (visitor); - *os << " **allocbuf (CORBA::ULong length); " - << "// Allocate storage for a sequence.." << be_nl; - - // freebuf - *os << "static void freebuf ("; - pt->accept (visitor); - *os << " **buffer);" << be_nl; - - // allocate_buffer - *os << "// The Base_Sequence functions, please see tao/sequence.h" << be_nl - << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; - - // deallocate_buffer - *os << "virtual void _deallocate_buffer (void);" << be_nl; - - // get_buffer - pt->accept(visitor); - *os << "* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; - - // get_buffer - *os << "const "; - pt->accept (visitor); - *os << "* *get_buffer (void) const;" << be_nl; - - // _shrink_buffer - *os << "virtual void _shrink_buffer (CORBA::ULong nl, CORBA::ULong ol);" << be_nl; - - be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); - 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")))) - { - // Pseudo objects do not require this methods. - *os << "virtual void _downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src," << be_nl - << "CORBA_Environment &ACE_TRY_ENV = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "virtual CORBA_Object* _upcast (void *src) const;" << be_nl; - } - *os << be_uidt_nl << "};\n"; - - os->gen_endif (); - - // generate #endif for AHETI - os->gen_endif_AHETI (); - - // Due to a bug with g++2.7.2.3 we have to generate the object manager class - // after the sequence class and instead forward declare it above - - this->gen_object_manager (node); - // Generate the code for the object manager - - 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 deleted file mode 100644 index 83be07c508f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp +++ /dev/null @@ -1,335 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_obj_sequence_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // 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; - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - ACE_OS::sprintf (full_class_name, "%s", - class_name); - } - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - this->gen_object_manager (node); - // Generate the code for the object manager - - static char object_manager [NAMEBUFSIZE]; - ACE_OS::memset (object_manager, '\0', NAMEBUFSIZE); - - if (node->is_nested ()) - { - ACE_OS::sprintf (object_manager, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->fullname (), - node->object_manager_name ()); - } - else - { - ACE_OS::sprintf (object_manager, "%s", - node->object_manager_name ()); - } - - // !! 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. Sinc - // ethey are inlined, their definition needs to come before their use else - // some compilers give lost of warnings. - - // allocbuf - *os << "ACE_INLINE "; pt->accept (visitor); - *os << " **" << be_nl; - *os << full_class_name << "::allocbuf (CORBA::ULong length) " - << "// Allocate storage for a sequence.." << be_nl - << "{" << be_idt_nl; - // 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_ci::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } - *os <<" **buf;" << be_nl - << be_nl - << "ACE_NEW_RETURN (buf, "; - pt->accept (visitor); - *os << "*[" << node->max_size () << "], 0);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < " << node->max_size () << "; i++)" << be_idt_nl - << "buf[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << be_nl - << "return buf;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // freebuf - *os << "ACE_INLINE void" << be_nl - << full_class_name << "::freebuf ("; - pt->accept (visitor); - *os << " **buffer)" << be_nl - << "{" << be_idt_nl - << "for (CORBA::ULong i = 0; i < " << node->max_size () << "; ++i)" << be_idt_nl - << "if (buffer[i] != "; - pt->accept (visitor); - *os << "::_nil ())" << be_nl - << "{" << be_idt_nl - << "CORBA::release (buffer[i]);" << be_nl - << "buffer[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << "}" << be_uidt_nl - << be_nl - << "delete[] buffer;" << be_uidt_nl - << "} " << be_nl - << be_nl; - - // constructor - *os << "// default ctor" << be_nl; - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (void)" << be_idt_nl - << " : TAO_Bounded_Base_Sequence (" << node->max_size () - << ", " << full_class_name << "::allocbuf (" << node->max_size () << "))" << be_uidt_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name - << " (CORBA::ULong length," << be_idt_nl; - pt->accept (visitor); - *os <<"* *value," << be_nl - << "CORBA::Boolean release)" << be_uidt_nl - << "// Constructor from data." << be_nl - << " : TAO_Bounded_Base_Sequence (" << node->max_size () << ", length, value, release)" << be_nl - << "{" << be_nl - << " this->_allocate_buffer (" << node->max_size () << ");" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (const " - << full_class_name << " &rhs)" << be_nl - << "// Copy constructor." << be_idt_nl - << ": TAO_Bounded_Base_Sequence (rhs)" << be_uidt_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **tmp1 = allocbuf (" << node->max_size () << ");" << be_nl; - pt->accept(visitor); - *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "** ACE_CAST_CONST, rhs.buffer_);" << be_nl - << "for (CORBA::ULong i = 0; i < rhs.length_; i++)" << be_idt_nl - << "tmp1[i] = "; pt->accept (visitor); *os << "::_duplicate (tmp2[i]);" << be_uidt_nl - << "this->buffer_ = tmp1;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // assignment operator - *os << "ACE_INLINE " << full_class_name << " &" << be_nl - << full_class_name << "::operator= (const " - << full_class_name << " &rhs)" << be_nl - << "// Assignment from another Bounded sequence." << be_nl - << "{" << be_idt_nl - << "if (this == &rhs)" << be_idt_nl - << "return *this;" << be_uidt_nl - << be_nl - << "if (this->release_)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " **, this->buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_nl - << "{" << be_idt_nl - << "CORBA::release (tmp[i]);" << be_nl - << "tmp[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << "}" << be_nl - << "// No need to reallocate the buffer since it is always of size" << be_nl - << "// " << node->max_size () << "" << be_nl - << "#if 0" << be_idt_nl - << "if (this->maximum_ < rhs.maximum_)" << be_nl - << "{" << be_idt_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = " << full_class_name << "::allocbuf (rhs.maximum_);" << be_uidt_nl - << "}" << be_uidt_nl - << "#endif /* 0 */" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "this->buffer_ = " << full_class_name << "::allocbuf (rhs.maximum_);" << be_uidt_nl - << be_nl - << "TAO_Bounded_Base_Sequence::operator= (rhs);" << be_nl - << be_nl; - pt->accept(visitor); - *os <<" **tmp1 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " **, this->buffer_);" << be_nl; - pt->accept(visitor); - *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl - << "for (CORBA::ULong i=0; i < rhs.length_; ++i)" << be_idt_nl - << "tmp1[i] = "; - pt->accept (visitor); - *os << "::_duplicate (tmp2[i]);" << be_uidt_nl - << "return *this;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator[] - *os << "ACE_INLINE " << object_manager << be_nl - << full_class_name << "::operator[] (CORBA::ULong index) const" - << " // Read-write accessor." << be_nl - << "{" << be_idt_nl - << "ACE_ASSERT (index < this->maximum_);" << be_nl; - pt->accept(visitor); - *os <<" **const tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " ** ACE_CAST_CONST, this->buffer_);" << be_nl - << "return " << object_manager << " (tmp + index, this->release_);" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE "; - pt->accept(visitor); - *os << " **" << be_nl; - *os << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os << " **result = 0;" << be_nl - << "if (orphan == 0)" << be_nl - << "{" << be_idt_nl - << "// We retain ownership." << be_nl - << "if (this->buffer_ == 0)" << be_nl - << "{" << be_idt_nl - << "result = " << full_class_name << "::allocbuf (this->maximum_);" << be_nl - << "this->buffer_ = result;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "result = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "**, this->buffer_);" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else // if (orphan == 1)" << be_nl - << "{" << be_idt_nl - << "if (this->release_ != 0)" << be_nl - << "{" << be_idt_nl - << "// We set the state back to default and relinquish" << be_nl - << "// ownership." << be_nl - << "result = ACE_reinterpret_cast("; - pt->accept (visitor); - *os << "**,this->buffer_);" << be_nl - << "this->maximum_ = 0;" << be_nl - << "this->length_ = 0;" << be_nl - << "this->buffer_ = 0;" << be_nl - << "this->release_ = 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "return result;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE const "; - pt->accept (visitor); - *os << "* *" << be_nl - << full_class_name << "::get_buffer (void) const" << be_nl - << "{" << be_idt_nl - << "return ACE_reinterpret_cast(const "; - pt->accept (visitor); - *os << " ** ACE_CAST_CONST, this->buffer_);" << be_uidt_nl - << "}" << be_nl - << be_nl; - - os->gen_endif (); - - // 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 deleted file mode 100644 index d1f50bfd03d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp +++ /dev/null @@ -1,199 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_obj_sequence_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client impl -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // 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; - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - 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); - - static char object_manager [NAMEBUFSIZE]; - ACE_OS::memset (object_manager, '\0', NAMEBUFSIZE); - - if (node->is_nested ()) - { - ACE_OS::sprintf (object_manager, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->fullname (), - node->object_manager_name ()); - } - else - { - ACE_OS::sprintf (object_manager, "%s", - node->object_manager_name ()); - } - - // !! 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. Sinc - // ethey are inlined, their definition needs to come before their use else - // some compilers give lost of warnings. - - // allocate_buffer - *os << "// The Base_Sequence functions, please see tao/sequence.h" << be_nl - << "void " << be_nl - << full_class_name << "::_allocate_buffer (CORBA::ULong length)" << be_nl - << "{" << be_idt_nl - << "// For this class memory is never reallocated so the implementation" << be_nl - << "// is *really* simple." << be_nl - << "this->buffer_ = " << full_class_name << "::allocbuf (length);" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // deallocate_buffer - *os << "void" << be_nl - << full_class_name << "::_deallocate_buffer (void)" << be_nl - << "{" << be_idt_nl - << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl - << "return;" << be_uidt_nl; - pt->accept(visitor); - *os <<" **tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " **, this->buffer_);" << be_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = 0;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // destructor - *os << full_class_name << "::~" << class_name << " (void)" << be_nl - << "// destructor" << be_nl - << "{" << be_idt_nl - << "this->_deallocate_buffer ();" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // _shrink_buffer - *os << "void" << be_nl - << full_class_name << "::_shrink_buffer (CORBA::ULong nl, CORBA::ULong ol)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " **, this->buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = nl; i < ol; ++i)" << be_nl - << "{" << be_idt_nl - << "CORBA::release (tmp[i]);" << be_nl - << "tmp[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << "}" << be_uidt_nl - << "}\n" << be_nl; - - be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); - 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")))) - { - // Pseudo objects do not require this methods. - *os << "void" << be_nl - << full_class_name << "::_downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src," << be_nl - << "CORBA::Environment &ACE_TRY_ENV" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - pt->accept (visitor); - *os << " **tmp = ACE_static_cast ("; - pt->accept (visitor); - *os << "**, target);" << be_nl - << "*tmp = "; - pt->accept (visitor); - *os << "::_narrow (src, ACE_TRY_ENV);" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA_Object*" << be_nl - << full_class_name << "::_upcast (void *src) const" << be_nl - << "{" << be_idt_nl; - pt->accept (visitor); - *os << " **tmp = ACE_static_cast ("; - pt->accept (visitor); - *os << "**, src);" << be_nl - << "return *tmp;" << be_uidt_nl - << "}" << be_nl; - } - - os->gen_endif (); - - // 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 deleted file mode 100644 index 2b6134d63ae..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_sequence_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client header -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -//#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$") - - -int -be_visitor_sequence_ch::gen_bounded_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; // 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; - - - 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); - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - os->gen_ifdef_macro (class_name); - - os->indent (); - - *os << "class " << class_name << " : public TAO_Bounded_Base_Sequence" << be_nl - << "{" << be_nl - << "public:" << be_idt_nl - << "// = Initialization and termination methods." << be_nl - << be_nl; - - // default Constructor - *os << class_name << " (void);" << be_nl; - - // constructor - *os << class_name << " (CORBA::ULong length," << be_idt_nl; - pt->accept (visitor); - *os <<" *data," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; - - // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl - << "// Copy constructor." << be_nl; - - // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl - << "// Assignment operator. " << be_nl; - - // destructor - *os << "virtual ~" << class_name << " (void); // Dtor." << be_nl; - - // Accessors - // operator[] - *os << "// = Accessors." << be_nl; - pt->accept(visitor); - *os <<" &operator[] (CORBA::ULong i);// operator []" << be_nl; - - // operator[] - *os << "const "; - pt->accept (visitor); - *os << " &operator[] (CORBA::ULong i) const;" << be_nl; - - // Static Operations - *os << "// = Static operations." << be_nl - << "static "; - pt->accept (visitor); - *os << " *allocbuf (CORBA::ULong); // Allocate storage for the sequence." << be_nl; - - // free_buf - *os << "static void freebuf ("; - pt->accept (visitor); - *os << " *buffer); // Free the sequence." << be_nl; - - // allocate_buffer - *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; - - // deallocate_buffer - *os << "virtual void _deallocate_buffer (void);" << be_nl; - - // get_buffer - pt->accept(visitor); - *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; - - // get_buffer - *os << "const "; - pt->accept (visitor); - *os << " *get_buffer (void) const;" << be_nl; - - // replace - *os << "void replace (CORBA::ULong max," << be_idt_nl - << "CORBA::ULong length," << be_nl; - pt->accept(visitor); - *os <<" *data," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt << be_uidt_nl; - - *os << "};\n"; - - 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_bounded_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp deleted file mode 100644 index 30935cf4c19..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp +++ /dev/null @@ -1,321 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_sequence_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_bounded_sequence_ci, "$Id$") - - -int -be_visitor_sequence_ci::gen_bounded_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); - } - - // 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; - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - ACE_OS::sprintf (full_class_name, "%s", - class_name); - } - - - 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. Sinc - // ethey are inlined, their definition needs to come before their use else - // some compilers give lost of warnings. - - // Static Operations - // allocbuf - *os << "// = Static operations." << be_nl - << "ACE_INLINE "; - - // 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::" - "gen_bounded_sequence - " - "base type visit failed\n"), - -1); - } - *os << " *" << be_nl - << full_class_name << "::allocbuf (CORBA::ULong) " - << "// Allocate storage for the sequence." << be_nl - << "{" << be_idt_nl - << "return new "; - pt->accept (visitor); - *os << "[" << node->max_size () << "];" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // free_buf - *os << "ACE_INLINE void " << be_nl - << full_class_name << "::freebuf ("; - pt->accept (visitor); - *os << " *buffer) // Free the sequence." << be_nl - << "{" << be_idt_nl - << "delete [] buffer;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // Constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (void)" << be_nl - << "// Default constructor." << be_nl - << " : TAO_Bounded_Base_Sequence (" << node->max_size () - << ", 0, " << full_class_name << "::allocbuf (" << node->max_size () - << "), 0)" << be_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl; - *os << full_class_name << "::" << class_name << " (CORBA::ULong length," << be_idt_nl; - pt->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 - << "{" << be_nl - << " this->_allocate_buffer (" << node->max_size () << ");" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name - << " (const " << full_class_name << " &rhs)" << be_nl - << "// Copy constructor." << be_idt_nl - << ": TAO_Bounded_Base_Sequence (rhs)" << be_uidt_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" *tmp1 = " << full_class_name << "::allocbuf (" << node->max_size () - << ");" << be_nl - << be_nl; - pt->accept(visitor); - *os <<" * const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl - << "tmp1[i] = tmp2[i];" << be_uidt_nl - << be_nl - << "this->buffer_ = tmp1;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator= - *os << "ACE_INLINE " << full_class_name << " &" << be_nl - << full_class_name << "::operator= (const " << full_class_name << " &rhs)" << be_nl - << "// Assignment operator. " << be_nl - << "{" << be_idt_nl - << "if (this == &rhs)" << be_idt_nl - << "return *this;" << be_uidt_nl - << be_nl - << "if (this->release_)" << be_nl - << "{" << be_nl - << "}" << be_nl - << "else" << be_idt_nl - << "this->buffer_ = " << full_class_name << "::allocbuf (rhs.maximum_);" << be_nl - << be_nl - <<"TAO_Bounded_Base_Sequence::operator= (rhs);" << be_nl - << be_nl; - pt->accept(visitor); - *os <<"* tmp1 = ACE_reinterpret_cast ("; - pt->accept(visitor); - *os << " *, this->buffer_);" << be_nl; - pt->accept(visitor); - *os <<"* const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl - << "tmp1[i] = tmp2[i];" << be_uidt_nl - << be_nl - << "return *this;" << be_uidt_nl << be_uidt_nl - << "}" << be_nl - << be_nl; - - // Accessors - *os << "// = Accessors." << be_nl; - *os << "ACE_INLINE "; - pt->accept(visitor); - *os << " &" << be_nl; - *os << full_class_name << "::operator[] (CORBA::ULong i)// operator []" << be_nl - << "{" << be_idt_nl - << "ACE_ASSERT (i < this->maximum_);" << be_nl; - pt->accept(visitor); - *os <<" *tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "*,this->buffer_);" << be_nl - << "return tmp[i];" << be_uidt_nl - << "}" << be_nl; - - *os << "ACE_INLINE const "; - pt->accept (visitor); - *os << " &" << be_nl - << full_class_name << "::operator[] (CORBA::ULong i) const// operator []" << be_nl - << "{" << be_idt_nl - << "ACE_ASSERT (i < this->maximum_);" << be_nl - << "const "; - pt->accept (visitor); - *os << "* tmp = ACE_reinterpret_cast (const "; - pt->accept (visitor); - *os << "* ACE_CAST_CONST,this->buffer_);" << be_nl - << "return tmp[i];" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE "; - pt->accept(visitor); - *os << " *" << be_nl - << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os << " *result = 0;" << be_nl - << "if (orphan == 0)" << be_nl - << "{" << be_idt_nl - << "// We retain ownership." << be_nl - << "if (this->buffer_ == 0)" << be_nl - << "{" << be_idt_nl - << "result = " << full_class_name << "::allocbuf (this->maximum_);" << be_nl - << "this->buffer_ = result;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "result = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "*, this->buffer_);" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else // if (orphan == 1)" << be_nl - << "{" << be_idt_nl - << "if (this->release_ != 0)" << be_nl - << "{" << be_idt_nl - << "// We set the state back to default and relinquish" << be_nl - << "// ownership." << be_nl - << "result = ACE_reinterpret_cast("; - pt->accept (visitor); - *os << "*,this->buffer_);" << be_nl - << "this->maximum_ = 0;" << be_nl - << "this->length_ = 0;" << be_nl - << "this->buffer_ = 0;" << be_nl - << "this->release_ = 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "return result;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE const "; - pt->accept (visitor); - *os << " *" << be_nl - << full_class_name << "::get_buffer (void) const" << be_nl - << "{" << be_idt_nl - << "return ACE_reinterpret_cast(const "; - pt->accept (visitor); - *os << " * ACE_CAST_CONST, this->buffer_);" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // replace - *os << "ACE_INLINE void " << be_nl - << full_class_name << "::replace (CORBA::ULong max," << be_idt_nl - << "CORBA::ULong length," << be_nl; - pt->accept(visitor); - *os <<" *data," << be_nl - << "CORBA::Boolean release)" << be_uidt_nl - << "{" << be_idt_nl - << "this->maximum_ = max;" << be_nl - << "this->length_ = length;" << be_nl - << "if (this->buffer_ && this->release_ == 1)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<"* tmp = ACE_reinterpret_cast("; - pt->accept (visitor); - *os << "* ACE_CAST_CONST, this->buffer_);" << be_nl - << full_class_name << "::freebuf (tmp);" << be_uidt_nl - << "}" << be_nl - << "this->buffer_ = data;" << be_nl - << "this->release_ = release;" << 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_bounded_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp deleted file mode 100644 index 005b454c57f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_sequence_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -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; - - // 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); - } - - // 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; - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - 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); - - // !! 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 - *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 - << "// right type" << be_nl - << "{" << be_idt_nl - << "this->buffer_ = " << full_class_name << "::allocbuf (" - << node->max_size () << ");" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // deallocate_buffer - *os << "void " << be_nl - << full_class_name << "::_deallocate_buffer (void)" << be_nl - << "// deallocate the buffer" << be_nl - << "{" << be_idt_nl - << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl - << "return;" << be_uidt_nl; - pt->accept(visitor); - *os <<" *tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " *, this->buffer_);" << be_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = 0;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // destructor - *os << full_class_name << "::~" << class_name << " (void) // Dtor." << be_nl - << "{" << be_idt_nl - << "this->_deallocate_buffer ();" << be_uidt_nl - << "}" << be_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_bounded_str_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp deleted file mode 100644 index 9d8e5bb6251..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_str_sequence_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client header -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -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; // 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; - - - 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(); - - 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 " << class_name << " : public TAO_Bounded_Base_Sequence" << be_nl - << "{" << be_nl - << "public:" << be_idt_nl; - - // constructor - *os << class_name << " (void);" << be_nl; - - // constructor - *os << class_name << " (CORBA::ULong length," << be_idt_nl - << "char* *value," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; - - // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl; - - // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl; - - // destructor - *os << "virtual ~" << class_name << " (void);" << be_nl; - - // operator[] - *os << "TAO_SeqElem_String_Manager operator[] (CORBA::ULong index) const;" << be_nl - << "// read-write accessor" << be_nl; - - // allocbuf - *os << "static char **allocbuf (CORBA::ULong length);" << be_nl; - - // freebuf - *os << "static void freebuf (char **buffer);" << be_nl; - - // allocate_buffer - *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; - - // deallocate_buffer - *os << "virtual void _deallocate_buffer (void);" << be_nl; - - // get_buffer - *os << "char* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; - - // get_buffer - *os << "const char* *get_buffer (void) const;" << be_nl; - - // shrink_buffer - *os << "virtual void _shrink_buffer (CORBA::ULong nl,CORBA::ULong ol);" - << be_uidt_nl; - - *os << "};\n"; - - 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_bounded_str_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp deleted file mode 100644 index cbac57cb55a..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_str_sequence_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -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); - - if (node->is_nested ()) - { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->fullname (), - class_name); - } - else - { - ACE_OS::sprintf (full_class_name, "%s", - class_name); - } - - - // 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 (); - -#if 0 /* Why is this here? ASG */ - // 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; - - // 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_ci::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } -#endif /* 0 */ - - // 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. - - // allocbuf - *os << "ACE_INLINE char **" << be_nl - << full_class_name << "::allocbuf (CORBA::ULong length)" << be_nl - << "{" << be_idt_nl - << "char **buf;" << be_nl - << "ACE_NEW_RETURN (buf, char *[" << node->max_size () << "], 0);" << be_nl - << "for (CORBA::ULong i = 0; i < " << node->max_size () << "; i++)" << be_idt_nl - << "buf[i] = 0;" << be_uidt_nl - << "return buf;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // freebuf - *os << "ACE_INLINE void " << be_nl - << full_class_name << "::freebuf (char **buffer)" << be_nl - << "{" << be_idt_nl - << "for (CORBA::ULong i = 0; i < " << node->max_size () << "; ++i)" << be_nl - << "{" << be_idt_nl - << "if (buffer[i] != 0)" << be_nl - << "{" << be_idt_nl - << "CORBA::string_free (buffer[i]);" << be_nl - << "buffer[i] = 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "delete [] buffer;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (void)" << be_nl - << " : TAO_Bounded_Base_Sequence (" << node->max_size () - << ", " << full_class_name << "::allocbuf(" << node->max_size () << "))" << be_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (CORBA::ULong length," << be_idt_nl - << "char* *value," << be_nl - << "CORBA::Boolean release)" << be_uidt_nl - << " : TAO_Bounded_Base_Sequence (" << node->max_size () << ", length, value, release)" << be_nl - << "{" << be_nl - << " this->_allocate_buffer (" << node->max_size () << ");" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (const " << full_class_name << " &rhs)" << be_idt_nl - << ": TAO_Bounded_Base_Sequence (rhs)" << be_uidt_nl - << "{" << be_idt_nl - << "char **tmp1 = " << full_class_name << "::allocbuf (this->maximum_);" << be_nl - << "char ** const tmp2 = ACE_reinterpret_cast (char ** ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i=0; i < rhs.length_; i++)" << be_idt_nl - << "tmp1[i] = CORBA::string_dup (tmp2[i]);" << be_uidt_nl - << be_nl - << "this->buffer_ = tmp1;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator= - *os << "ACE_INLINE " << full_class_name << "& " << be_nl - << full_class_name << "::operator= (const " << full_class_name << " &rhs)" << be_nl - << "{" << be_idt_nl - << "if (this == &rhs)" << be_idt_nl - << "return *this;" << be_uidt_nl - << be_nl - << "if (this->release_)" << be_nl - << "{ " << be_idt_nl - << "char **tmp = ACE_reinterpret_cast (char **, this->buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_nl - << "{" << be_idt_nl - << "CORBA::string_free (tmp[i]);" << be_nl - << "tmp[i] = 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "this->buffer_ = " << full_class_name << "::allocbuf (rhs.maximum_);" << be_uidt_nl - << be_nl - << "TAO_Bounded_Base_Sequence::operator= (rhs);" << be_nl - << be_nl - << "char **tmp1 = ACE_reinterpret_cast (char **, this->buffer_);" << be_nl - << "char ** const tmp2 = ACE_reinterpret_cast (char ** ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < rhs.length_; i++)" << be_idt_nl - << "tmp1[i] = CORBA::string_dup (tmp2[i]);" << be_uidt_nl - << "return *this;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator[] - *os << "ACE_INLINE TAO_SeqElem_String_Manager " << be_nl - << full_class_name << "::operator[] (CORBA::ULong index) const" << be_nl - << "// read-write accessor" << be_nl - << "{" << be_idt_nl - << "ACE_ASSERT (index < this->maximum_);" << be_nl - << "char **const tmp = ACE_reinterpret_cast (char ** ACE_CAST_CONST, this->buffer_);" << be_nl - << "return TAO_SeqElem_String_Manager (tmp + index, this->release_);" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE char**" << be_nl - << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl - << "{" << be_idt_nl - << "char **result = 0;" << be_nl - << "if (orphan == 0)" << be_nl - << "{" << be_idt_nl - << "// We retain ownership. " << be_nl - << "if (this->buffer_ == 0)" << be_nl - << "{" << be_idt_nl - << "result = " << full_class_name << "::allocbuf (this->maximum_);" << be_nl - << "this->buffer_ = result;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "result = ACE_reinterpret_cast (char **, this->buffer_);" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else // if (orphan == 1)" << be_nl - << "{" << be_idt_nl - << "if (this->release_ != 0)" << be_nl - << "{" << be_idt_nl - << "// We set state back to default and relinquish" << be_nl - << "// ownership." << be_nl - << "result = ACE_reinterpret_cast (char **, this->buffer_);" << be_nl - << "this->maximum_ = 0;" << be_nl - << "this->length_ = 0;" << be_nl - << "this->buffer_ = 0;" << be_nl - << "this->release_ = 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "return result;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE const char**" << be_nl - << full_class_name << "::get_buffer (void) const" << be_nl - << "{" << be_idt_nl - << "return ACE_reinterpret_cast (const char ** ACE_CAST_CONST, this->buffer_);" << be_uidt_nl - << "}" << be_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_bounded_str_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp deleted file mode 100644 index 87d5e6008a9..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_bounded_str_sequence_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client impl -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -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); - - if (node->is_nested ()) - { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->fullname (), - class_name); - } - else - { - ACE_OS::sprintf (full_class_name, "%s", - class_name); - } - - - // 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 (); - -#if 0 /* Why is this here? ASG */ - // 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; - - // 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_cs::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } -#endif /* 0 */ - - // allocate_buffer - *os << "void" << be_nl - << full_class_name << "::_allocate_buffer (CORBA::ULong length)" << be_nl - << "{" << be_idt_nl - << "// For this class memory is never reallocated so the implementation" << be_nl - << "// is *really* simple." << be_nl - << "this->buffer_ = " << full_class_name << "::allocbuf (" - << node->max_size () << ");" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // deallocate_buffer - *os << "void" << be_nl - << full_class_name << "::_deallocate_buffer (void)" << be_nl - << "{" << be_idt_nl - << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl - << "return;" << be_uidt_nl - << "char **tmp = ACE_reinterpret_cast (char **, this->buffer_);" << be_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = 0;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // destructor - *os << full_class_name << "::~" << class_name << " (void)" << be_nl - << "{" << be_idt_nl - << "this->_deallocate_buffer ();" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // shrink_buffer - *os << "void" << be_nl - << full_class_name << "::_shrink_buffer (CORBA::ULong nl, CORBA::ULong ol)" << be_nl - << "{" << be_idt_nl - << "char **tmp = ACE_reinterpret_cast (char **,this->buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = nl; i < ol; ++i)" << be_nl - << "{" << be_idt_nl - << "CORBA::string_free (tmp[i]);" << be_nl - << "tmp[i] = 0;" << be_uidt_nl - << "}" << 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_object_manager_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_object_manager_ch.cpp deleted file mode 100644 index 79ebbf95882..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_object_manager_ch.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_object_manager_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client header -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_object_manager_ch, "$Id$") - - -int -be_visitor_sequence_ch::gen_object_manager (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 - // we might want to use this later - 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; - - - 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); - - const char * object_manager = node->object_manager_name (); - // create the name for the object manager - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - os->gen_ifdef_macro (object_manager); - - os->indent (); - - *os << "class " << object_manager << be_nl - << "{" << be_idt_nl - << "friend class " << class_name << ";" << be_uidt_nl - << "public:" << be_idt_nl - << be_nl; - - // constructor - *os << "// = Initialization and termination methods." << be_nl - << object_manager << " (const " << object_manager << " &rhs);" << be_nl; - - // constructor - *os << object_manager << " ("; - // 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 << "** buffer, CORBA::Boolean release);" << be_nl; - - // destructor - *os << "~" << object_manager << " (void);" << be_nl; - - // operator= - *os << object_manager << " &operator= (const " << object_manager << " &rhs);" << be_nl; - - // operator= - *os << object_manager << " &operator= ("; - pt->accept (visitor); - *os << " *p);" << be_nl; - - // cast operator - *os << "operator const "; - pt->accept (visitor); - *os << " *() const; // Cast (read-only)." << be_nl; - - // cast operator - *os << "operator "; - pt->accept (visitor); - *os << " *&(); // Cast." << be_nl; - - // in method - *os << "const "; - pt->accept (visitor); - *os << " *in (void) const; // in " << be_nl; - - // inout method - pt->accept (visitor); - *os << " *&inout (void); // inout " << be_nl; - - // out method - pt->accept (visitor); - *os << " *&out (void); // out " << be_nl; - - // retn method - pt->accept (visitor); - *os << " *_retn (void); // retn " << be_uidt_nl; - - // members - *os << "private:" << be_idt_nl; - pt->accept(visitor); - *os <<" **ptr_;" << be_nl - << "// data member, notice that it is a pointer, to implement the" << be_nl - << "// reference behavior for assignment." << be_nl - << be_nl - << "CORBA::Boolean release_;" << be_nl - << "// release flag based on parent's flag" << 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_object_manager_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_object_manager_ci.cpp deleted file mode 100644 index 394bbb01531..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_object_manager_ci.cpp +++ /dev/null @@ -1,257 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_object_manager_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_object_manager_ci, "$Id$") - - -int -be_visitor_sequence_ci::gen_object_manager (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); - } - - // generate the class name - // we might want to use this later - 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; - - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - const char * object_manager = node->object_manager_name (); - - static char full_object_manager [NAMEBUFSIZE]; - ACE_OS::memset (full_object_manager, '\0', NAMEBUFSIZE); - - if (node->is_nested ()) - { - ACE_OS::sprintf (full_object_manager, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->fullname (), - object_manager); - } - else - { - ACE_OS::sprintf (full_object_manager, "%s", - object_manager); - } - - // create the name for the object manager - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - os->gen_ifdef_macro (object_manager); - - os->indent (); - - // constructor - *os << "// = Initialization and termination methods." << be_nl - << "ACE_INLINE" << be_nl - << full_object_manager << "::" << object_manager << " (const " - << full_object_manager << " &rhs)" << be_idt_nl - << ": ptr_ (rhs.ptr_)," << be_nl - << "release_ (rhs.release_)" << be_uidt_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_object_manager << "::" << object_manager << " ("; - // 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_ci::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } - *os << "** buffer, CORBA::Boolean release)" << be_idt_nl - << ": ptr_ (buffer)," << be_nl - << "release_ (release)" << be_uidt_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // destructor - *os << "ACE_INLINE" << be_nl - << full_object_manager << "::~" << object_manager << " (void)" << be_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // operator= - *os << "ACE_INLINE " << full_object_manager << " &" << be_nl - << full_object_manager << "::operator= (const " << full_object_manager - << " &rhs)" << be_nl - << "{" << be_idt_nl - << "if (this == &rhs)" << be_idt_nl - << "return *this;" << be_uidt_nl - << be_nl - << "if (this->release_)" << be_nl - << "{" << be_idt_nl - << "CORBA::release (*this->ptr_);" << be_nl - << "*this->ptr_ = "; - pt->accept (visitor); - *os << "::_duplicate (*rhs.ptr_);" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "*this->ptr_ = *rhs.ptr_;" << be_uidt_nl - << be_nl - << "return *this;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator= - *os << "ACE_INLINE " << full_object_manager << " &" << be_nl - << full_object_manager << "::operator= ("; - pt->accept (visitor); - *os << " *p)" << be_nl - << "// Assignment from "; - pt->accept (visitor); - *os << " *." << be_nl - << "{" << be_idt_nl - << "if (this->release_)" << be_nl - << "{" << be_idt_nl - << "CORBA::release (*this->ptr_);" << be_nl - << "*this->ptr_ = p;" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "*this->ptr_ = p;" << be_uidt_nl - << be_nl - << "return *this;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // cast operator - *os << "ACE_INLINE " << be_nl - << full_object_manager << "::operator const "; - pt->accept (visitor); - *os << " *() const // Cast (read-only)." << be_nl - << "{" << be_idt_nl - << "return *this->ptr_;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // cast operator - *os << "ACE_INLINE" << be_nl - << full_object_manager << "::operator "; - pt->accept (visitor); - *os << " *&() // Cast." << be_nl - << "{" << be_idt_nl - << "return *this->ptr_;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // in method - *os << "ACE_INLINE const "; - pt->accept (visitor); - *os << " *" << be_nl - << full_object_manager << "::in (void) const // in " - << be_nl - << "{" << be_idt_nl - << "return *this->ptr_;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // inout method - *os << "ACE_INLINE "; - pt->accept (visitor); - *os << " *&" << be_nl - << full_object_manager << "::inout (void) // inout " - << be_nl - << "{" << be_idt_nl - << "return *this->ptr_;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // out method - *os << "ACE_INLINE "; - pt->accept (visitor); - *os << " *&" << be_nl - << full_object_manager << "::out (void) // out " - << be_nl - << "{" << be_idt_nl - << "CORBA::release (*this->ptr_);" << be_nl - << "*this->ptr_ = "; - pt->accept (visitor); - *os << "::_nil ();" - << be_nl - << "return *this->ptr_;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // retn method - *os << "ACE_INLINE "; - pt->accept (visitor); - *os << " *" << be_nl - << full_object_manager << "::_retn (void) // retn " - << be_nl - << "{" << be_idt_nl; - pt->accept (visitor); - *os << " *temp = *this->ptr_;" << be_nl - << "*this->ptr_ = "; - pt->accept (visitor); - *os << "::_nil ();" - << be_nl - << "return temp;" << 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_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp deleted file mode 100644 index 1f9e88780c2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_unbounded_obj_sequence_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client header -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - - -#include "be.h" - -#include "be_visitor_sequence.h" - -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 ()); - 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; // 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; - - - 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); - - const char * object_manager = node->object_manager_name (); - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - os->gen_ifdef_macro (class_name); - - os->indent (); - - //forward declaration of the object manager; - *os << "class " << object_manager << ";" << be_nl << be_nl; - - *os << "class " << class_name << " : public TAO_Unbounded_Base_Sequence" << be_nl - << "{" << be_nl - << "public:" << be_idt_nl - << "// = Initialization and termination methods." << be_nl - << be_nl; - - // constructor - *os << class_name << " (void);" << be_nl; - - // constructor - *os << class_name << " (CORBA::ULong maximum);" << be_nl; - - // constructor - *os << class_name << " (CORBA::ULong maximum," << be_idt_nl - << "CORBA::ULong length," << be_nl; - pt->accept (visitor); - *os <<"* *value," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; - - // constructor - *os << class_name << "(const " << class_name << " &rhs);" << be_nl; - - // destructor - *os << "virtual ~" << class_name << " (void);" << be_nl; - - // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl; - - // operator[] - *os << object_manager << " operator[] (CORBA::ULong index) const;" << be_nl; - - // allocbuf - *os << "static "; - pt->accept (visitor); - *os << " **allocbuf (CORBA::ULong nelems);" << be_nl; - - // freebuf - *os << "static void freebuf ("; - pt->accept (visitor); - *os << " **buffer);" << be_nl; - - // allocate_buffer - *os << "// The Base_Sequence functions, please see tao/Sequence.h" << be_nl - << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; - - // deallocate_buffer - *os << "virtual void _deallocate_buffer (void);" << be_nl; - - // get_buffer - pt->accept(visitor); - *os << "* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; - - // get_buffer - *os << "const "; - pt->accept (visitor); - *os << "* *get_buffer (void) const;" << be_nl; - - // shrink_buffer - *os << "virtual void _shrink_buffer (CORBA::ULong nl, CORBA::ULong ol);" << be_nl; - - be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); - 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")))) - { - // Pseudo objects do not require this methods. - *os << "virtual void _downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src," << be_nl - << "CORBA_Environment &ACE_TRY_ENV = " << be_idt_nl - << "CORBA::Environment::default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "virtual CORBA_Object* _upcast (void *src) const;" << be_nl; - } - *os << be_uidt_nl << "};\n"; - - os->gen_endif (); // endif macro - - // generate #endif for AHETI - os->gen_endif_AHETI(); - - // Due to a bug with g++2.7.2.3 we have to generate the object manager class - // after the sequence class and instead forward declare it above - - this->gen_object_manager (node); - // Generate the code for the object manager - - 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 deleted file mode 100644 index ccb4fff7e11..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp +++ /dev/null @@ -1,329 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_unbounded_obj_sequence_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline. -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - - -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, gen_unbounded_obj_sequence_ci, "$Id$") - - -int -be_visitor_sequence_ci::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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // 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; - - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - ACE_OS::sprintf (full_class_name, "%s", - class_name); - } - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - this->gen_object_manager (node); - - static char object_manager [NAMEBUFSIZE]; - ACE_OS::memset (object_manager, '\0', NAMEBUFSIZE); - - if (node->is_nested ()) - { - ACE_OS::sprintf (object_manager, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->fullname (), - node->object_manager_name ()); - } - else - { - ACE_OS::sprintf (object_manager, "%s", - node->object_manager_name ()); - } - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - os->gen_ifdef_macro (class_name); - - os->indent (); - - // allocbuf - *os << "ACE_INLINE "; - // 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_ci::" - "gen_unbounded_obj_sequence - " - "base type visit failed\n"), - -1); - } - *os << " **" << be_nl - << full_class_name << "::allocbuf (CORBA::ULong nelems)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **buf;" << be_nl - << be_nl - << "ACE_NEW_RETURN (buf, "; - pt->accept (visitor); - *os << "*[nelems], 0);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < nelems; i++)" << be_idt_nl - << "buf[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << be_nl - << "return buf;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // freebuf - *os << "ACE_INLINE void " << be_nl - << full_class_name << "::freebuf ("; - pt->accept (visitor); - *os << " **buffer)" << be_nl - << "{" << be_idt_nl - << "if (buffer == 0)" << be_idt_nl - << "return;" << be_uidt_nl - << "delete[] buffer;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (void)" << be_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (CORBA::ULong maximum)" << be_idt_nl - << ": TAO_Unbounded_Base_Sequence (maximum, " - << full_class_name << "::allocbuf (maximum))" << be_uidt_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (CORBA::ULong maximum," << be_idt_nl - << "CORBA::ULong length," << be_nl; - pt->accept (visitor); - *os <<"* *value," << be_nl - << "CORBA::Boolean release)" << be_uidt_nl - << ": TAO_Unbounded_Base_Sequence (maximum, length, value, release)" << be_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << "(const " - << full_class_name << " &rhs)" << be_idt_nl - << ": TAO_Unbounded_Base_Sequence (rhs)" << be_uidt_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **tmp1 = " << full_class_name << "::allocbuf (this->maximum_);" << be_nl; - pt->accept(visitor); - *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < rhs.length_; ++i)" << be_idt_nl - << "tmp1[i] = "; - pt->accept (visitor); *os << "::_duplicate (tmp2[i]);" << be_uidt_nl - << be_nl - << "this->buffer_ = tmp1;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator= - *os << "ACE_INLINE " << full_class_name << " &" << be_nl - << full_class_name << "::operator= (const " << full_class_name << " &rhs)" << be_nl - << "{" << be_idt_nl - << "if (this == &rhs)" << be_idt_nl - << "return *this;" << be_uidt_nl - << be_nl - << "if (this->release_)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " **, this->buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_nl - << "{" << be_idt_nl - << "CORBA::release (tmp[i]);" << be_nl - << "tmp[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << "}" << be_nl - << "if (this->maximum_ < rhs.maximum_)" << be_nl - << "{" << be_idt_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = " << full_class_name - << "::allocbuf (rhs.maximum_);" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "this->buffer_ = " << full_class_name - << "::allocbuf (rhs.maximum_);" << be_uidt_nl - << be_nl - << "TAO_Unbounded_Base_Sequence::operator= (rhs);" << be_nl - << be_nl; - pt->accept(visitor); - *os <<" **tmp1 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " **, this->buffer_);" << be_nl; - pt->accept(visitor); - *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < rhs.length_; ++i)" << be_idt_nl - << "tmp1[i] = "; - pt->accept (visitor); - *os << "::_duplicate (tmp2[i]);" << be_uidt_nl - << be_nl - << "return *this;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator[] - *os << "ACE_INLINE " << object_manager << be_nl - << full_class_name << "::operator[] (CORBA::ULong index) const" << be_nl - << "// read-write accessor" << be_nl - << "{" << be_idt_nl - << "ACE_ASSERT (index < this->maximum_);" << be_nl; - pt->accept(visitor); - *os <<" ** const tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " ** ACE_CAST_CONST, this->buffer_);" << be_nl - << "return " << object_manager << " (tmp + index, this->release_);" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE "; - pt->accept(visitor); - *os << "* *" << be_nl - << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os << " **result = 0;" << be_nl - << "if (orphan == 0)" << be_nl - << "{" << be_idt_nl - << "// We retain ownership." << be_nl - << "if (this->buffer_ == 0)" << be_nl - << "{" << be_idt_nl - << "result = " << full_class_name << "::allocbuf (this->maximum_);" << be_nl - << "this->buffer_ = result;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "result = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "**, this->buffer_);" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else // if (orphan == 1)" << be_nl - << "{" << be_idt_nl - << "if (this->release_ != 0)" << be_nl - << "{" << be_idt_nl - << "// We set the state back to default and relinquish" << be_nl - << "// ownership." << be_nl - << "result = ACE_reinterpret_cast("; - pt->accept (visitor); - *os << "**,this->buffer_);" << be_nl - << "this->maximum_ = 0;" << be_nl - << "this->length_ = 0;" << be_nl - << "this->buffer_ = 0;" << be_nl - << "this->release_ = 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "return result;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE "; - *os << "const "; - pt->accept (visitor); - *os << "* *" << be_nl - << full_class_name << "::get_buffer (void) const" << be_nl - << "{" << be_idt_nl - << "return ACE_reinterpret_cast(const "; - pt->accept (visitor); - *os << " ** ACE_CAST_CONST, this->buffer_);" << be_uidt_nl - << "}" << be_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_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp deleted file mode 100644 index 9686a29bd3d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp +++ /dev/null @@ -1,223 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_unbounded_obj_sequence_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline. -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - - -#include "be.h" - -#include "be_visitor_sequence.h" - -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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // 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; - - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - 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); - - static char object_manager [NAMEBUFSIZE]; - ACE_OS::memset (object_manager, '\0', NAMEBUFSIZE); - - if (node->is_nested ()) - { - ACE_OS::sprintf (object_manager, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->fullname (), - node->object_manager_name ()); - } - else - { - ACE_OS::sprintf (object_manager, "%s", - node->object_manager_name ()); - } - - // !! 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 - *os << "// The Base_Sequence functions, please see tao/Sequence.h" << be_nl - << "void" << be_nl - << full_class_name << "::_allocate_buffer (CORBA::ULong length)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **tmp = " << full_class_name << "::allocbuf (length);" << be_nl - << be_nl - << "if (this->buffer_ != 0)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **old = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "**, this->buffer_);" << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl - << "if (!this->release_)" << be_idt_nl - << "tmp[i] = "; - pt->accept (visitor); - *os << "::_duplicate (old[i]);" << be_uidt_nl - << "else" << be_idt_nl - << "tmp[i] = old[i];" << be_uidt_nl << be_uidt_nl - << "if (this->release_)" << be_idt_nl - << "delete[] old;" << be_uidt_nl << be_uidt_nl - << "}" << be_nl - << "this->buffer_ = tmp;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // deallocate_buffer - *os << "void" << be_nl - << full_class_name << "::_deallocate_buffer (void)" << be_nl - << "{" << be_idt_nl - << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl - << "return;" << be_uidt_nl; - pt->accept(visitor); - *os <<" **tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "**, this->buffer_);" << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_nl - << "{" << be_idt_nl - << "CORBA::release (tmp[i]);" << be_nl - << "tmp[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << "}" << be_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = 0;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // destructor - *os << full_class_name << "::~" << class_name << " (void)" << be_nl - << "{" << be_idt_nl - << "this->_deallocate_buffer ();" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // shrink_buffer - *os << "void" << be_nl - << full_class_name << "::_shrink_buffer (CORBA::ULong nl, CORBA::ULong ol)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" **tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "**, this->buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = nl; i < ol; ++i)" << be_nl - << "{" << be_idt_nl - << "CORBA::release (tmp[i]);" << be_nl - << "tmp[i] = "; - pt->accept (visitor); - *os << "::_nil ();" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl; - - - be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); - 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")))) - { - // Pseudo objects do not require this methods. - *os << "void " << be_nl - << full_class_name << "::_downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src," << be_nl - << "CORBA_Environment &ACE_TRY_ENV" - << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - pt->accept (visitor); - *os << " **tmp = ACE_static_cast ("; - pt->accept (visitor); - *os << "**, target);" << be_nl - << "*tmp = "; - pt->accept (visitor); - *os << "::_narrow (src, ACE_TRY_ENV);" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA_Object*" << be_nl - << full_class_name << "::_upcast (void *src) const" << be_nl - << "{" << be_idt_nl; - pt->accept (visitor); - *os << " **tmp = ACE_static_cast ("; - pt->accept (visitor); - *os << "**, src);" << be_nl - << "return *tmp;" << 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_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp deleted file mode 100644 index 24a52859130..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_unbounded_sequence_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client header -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -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 ()); - 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; // 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; - - - 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(); - - os->gen_ifdef_macro (class_name); - - os->indent (); - - *os << "class " << class_name << " : public TAO_Unbounded_Base_Sequence" << be_nl - << "{" << be_nl - << "public:" << be_idt_nl - << "// = Initialization and termination methods." << be_nl - << be_nl; - // constructor - *os << class_name << " (void); // Default constructor." << be_nl; - - // constructor - *os << class_name << " (CORBA::ULong maximum); " << be_nl; - - // constructor - *os << class_name << " (CORBA::ULong maximum," << be_idt_nl - << "CORBA::ULong length," << be_nl; - // 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 << " *data," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; - - // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl; - - // operator = - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl; - - // destructor - *os << "virtual ~" << class_name << " (void); // Dtor." << be_nl; - - // Accessors - *os << "// = Accessors." << be_nl; - pt->accept (visitor); - *os <<" &operator[] (CORBA::ULong i);" << be_nl; - - // operator[] - *os << "const "; - pt->accept (visitor); - *os << " &operator[] (CORBA::ULong i) const;" << be_nl; - - // Static operations - *os << "// = Static operations." << be_nl - << "static "; - pt->accept (visitor); - *os << " *allocbuf (CORBA::ULong size);" << be_nl; - - *os << "static void freebuf ("; - pt->accept (visitor); - *os << " *buffer);" << be_nl; - - // allocate_buffer - *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; - - // deallocate_buffer - *os << "virtual void _deallocate_buffer (void);" << be_nl; - - // Implement the TAO_Base_Sequence methods (see Sequence.h) - *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl - << be_nl; - pt->accept(visitor); - *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; - - // get_buffer - *os << "const "; - pt->accept (visitor); - *os << " *get_buffer (void) const;" << be_nl; - - // replace - *os << "void replace (CORBA::ULong max," << be_idt_nl - << "CORBA::ULong length," << be_nl; - pt->accept(visitor); - *os <<" *data," << be_nl - << "CORBA::Boolean release);" << be_uidt << be_uidt_nl; - - *os << "};\n"; - - 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_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp deleted file mode 100644 index 9348769b863..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp +++ /dev/null @@ -1,338 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_unbounded_sequence_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -//#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$") - - -int -be_visitor_sequence_ci::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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // 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; - - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - ACE_OS::sprintf (full_class_name, "%s", - class_name); - } - - // 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 (); - - // Static operations - // allocbuf - *os << "// = Static operations." << be_nl - << "ACE_INLINE "; - // 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_ci::" - "gen_unbounded_sequence - " - "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 - << "return new "; - pt->accept (visitor); - *os << "[size];" << be_uidt_nl - << "}" << be_nl - << be_nl; - - *os << "ACE_INLINE void " - << full_class_name << "::freebuf ("; - pt->accept (visitor); - *os << " *buffer)" << be_nl - << "// Free the sequence." << be_nl - << "{" << be_idt_nl - << "delete [] buffer;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (void) // Default constructor." << be_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (CORBA::ULong maximum) " - << "// Constructor using a maximum length value." << be_idt_nl - << ": TAO_Unbounded_Base_Sequence (maximum, " - << full_class_name << "::allocbuf (maximum))" - << be_uidt_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (CORBA::ULong maximum," << be_idt_nl - << "CORBA::ULong length," << be_nl; - pt->accept (visitor); - *os << " *data," << be_nl - << "CORBA::Boolean release)" << be_uidt_nl - << ": TAO_Unbounded_Base_Sequence (maximum, length, data, release)" << be_nl - << "{" << be_nl - << "}" << be_nl - << be_nl; - - // constructor - *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (const " - << full_class_name << " &rhs)" << be_nl - << "// Copy constructor." << be_idt_nl; - *os << ": TAO_Unbounded_Base_Sequence (rhs)" << be_uidt_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" *tmp1 = " << full_class_name << "::allocbuf (this->maximum_);" << be_nl; - pt->accept(visitor); - *os << " * const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl - << "tmp1[i] = tmp2[i];" << be_uidt_nl - << be_nl - << "this->buffer_ = tmp1;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator = - *os << "ACE_INLINE " << full_class_name << " &" << be_nl - << full_class_name << "::operator= (const " << full_class_name << " &rhs)" << be_nl - << "// Assignment operator." << be_nl - << "{" << be_idt_nl - << "if (this == &rhs)" << be_idt_nl - << "return *this;" << be_uidt_nl - << be_nl - << "if (this->release_)" << be_nl - << "{" << be_idt_nl - << "if (this->maximum_ < rhs.maximum_)" << be_nl - << "{" << be_idt_nl - << "// free the old buffer" << be_nl; - pt->accept (visitor); - *os <<" *tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " *, this->buffer_);" << be_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = " << full_class_name - << "::allocbuf (rhs.maximum_);" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else" << be_idt_nl - << "this->buffer_ = " << full_class_name - << "::allocbuf (rhs.maximum_);" << be_uidt_nl - << be_nl - << "TAO_Unbounded_Base_Sequence::operator= (rhs);" << be_nl - << be_nl; - pt->accept (visitor); - *os <<" *tmp1 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " *, this->buffer_);" << be_nl; - pt->accept (visitor); - *os <<" * const tmp2 = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl - << "tmp1[i] = tmp2[i];" << be_uidt_nl - << be_nl - << "return *this;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // Accessors - *os << "// = Accessors." << be_nl; - *os << "ACE_INLINE "; - pt->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; - pt->accept (visitor); - *os <<"* tmp = ACE_reinterpret_cast("; - pt->accept (visitor); - *os << "*,this->buffer_);" << be_nl - << "return tmp[i];" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // operator[] - *os << "ACE_INLINE const "; - pt->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; - pt->accept (visitor); - *os <<" * const tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "* ACE_CAST_CONST, this->buffer_);" << be_nl - << "return tmp[i];" << be_uidt_nl - << "}" << 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 - << be_nl; - *os << "ACE_INLINE "; - pt->accept(visitor); - *os << " *" << be_nl - << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" *result = 0;" << be_nl - << "if (orphan == 0)" << be_nl - << "{" << be_idt_nl - << "// We retain ownership." << be_nl - << "if (this->buffer_ == 0)" << be_nl - << "{" << be_idt_nl - << "result = " << full_class_name << "::allocbuf (this->length_);" << be_nl - << "this->buffer_ = result;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "result = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << "*, this->buffer_);" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "else // if (orphan == 1)" << be_nl - << "{" << be_idt_nl - << "if (this->release_ != 0)" << be_nl - << "{" << be_idt_nl - << "// We set the state back to default and relinquish" << be_nl - << "// ownership." << be_nl - << "result = ACE_reinterpret_cast("; - pt->accept (visitor); - *os << "*,this->buffer_);" << be_nl - << "this->maximum_ = 0;" << be_nl - << "this->length_ = 0;" << be_nl - << "this->buffer_ = 0;" << be_nl - << "this->release_ = 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "return result;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // get_buffer - *os << "ACE_INLINE const "; - pt->accept (visitor); - *os << " *" << be_nl - << full_class_name << "::get_buffer (void) const" << be_nl - << "{" << be_idt_nl - << "return ACE_reinterpret_cast(const "; - pt->accept (visitor); - *os << " * ACE_CAST_CONST, this->buffer_);" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // replace - *os << "ACE_INLINE void" << be_nl - << full_class_name << "::replace (CORBA::ULong max," << be_nl - << "CORBA::ULong length," << be_nl; - pt->accept(visitor); - *os <<" *data," << be_nl - << "CORBA::Boolean release)" << be_nl - << "{" << be_idt_nl - << "this->maximum_ = max;" << be_nl - << "this->length_ = length;" << be_nl - << "if (this->buffer_ && this->release_ == 1)" << be_nl - << "{" << be_idt_nl; - pt->accept(visitor); - *os <<" *tmp = ACE_reinterpret_cast("; - pt->accept (visitor); - *os << "*,this->buffer_);" << be_nl - << full_class_name << "::freebuf (tmp);" << be_uidt_nl - << "}" << be_nl - << "this->buffer_ = data;" << be_nl - << "this->release_ = release;" << 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_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp deleted file mode 100644 index 3a088b4bb8f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// gen_unbounded_sequence_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client impl -// -// = AUTHOR -// Michael Kircher -// -// Modifications by Aniruddha Gokhale -// -// ============================================================================ - -//#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$") - - -int -be_visitor_sequence_cs::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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // 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; - - - const char * class_name = node->instance_name (); - - static char full_class_name [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 ()->fullname (), - class_name); - } - else - { - ACE_OS::sprintf (full_class_name, "%s", - class_name); - } - - // 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 - *os << "void" << be_nl - << full_class_name << "::_allocate_buffer (CORBA::ULong length)" << be_nl - << "{" << be_idt_nl; - pt->accept (visitor); - *os <<"* tmp = " << full_class_name << "::allocbuf (length);" << be_nl - << be_nl - << "if (this->buffer_ != 0)" << be_nl - << "{" << be_idt_nl; - pt->accept (visitor); - *os <<" *old = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " *,this->buffer_);" << be_nl - << be_nl - << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl - << "tmp[i] = old[i];" << be_uidt_nl - << be_nl - << "if (this->release_)" << be_idt_nl - << full_class_name << "::freebuf (old);" << be_uidt_nl << be_uidt_nl - << "}" << be_nl - << "this->buffer_ = tmp;" << be_uidt_nl - << "}" << be_nl - << be_nl; - - // deallocate_buffer - *os << "void" << be_nl - << full_class_name << "::_deallocate_buffer (void)" << be_nl - << "{" << be_idt_nl - << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl - << "return;" << be_uidt_nl - << be_nl; - pt->accept(visitor); - *os <<" *tmp = ACE_reinterpret_cast ("; - pt->accept (visitor); - *os << " *,this->buffer_);" << be_nl - << be_nl - << full_class_name << "::freebuf (tmp);" << be_nl - << "this->buffer_ = 0;" << be_uidt_nl - << "} " << be_nl - << be_nl; - - // destructor - *os << full_class_name << "::~" << class_name << " (void) // Dtor." << be_nl - << "{" << be_idt_nl - << "this->_deallocate_buffer ();" << be_uidt_nl - << "}" << be_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/sequence_base.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_base.cpp deleted file mode 100644 index 78aaef41f62..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_base.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// sequence_base.cpp -// -// = DESCRIPTION -// Visitor generating code for the base type of the Sequence -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -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_decl (ctx) -{ -} - -be_visitor_sequence_base::~be_visitor_sequence_base (void) -{ -} - -int -be_visitor_sequence_base::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - *os << node->name (); - return 0; -} - -// helper -int -be_visitor_sequence_base::visit_node (be_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BASE_CH) - *os << bt->nested_type_name (this->ctx_->scope ()); - else - *os << bt->name (); - return 0; -} - -int -be_visitor_sequence_base::visit_sequence (be_sequence *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_base::visit_interface (be_interface *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_base::visit_interface_fwd (be_interface_fwd *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_base::visit_string (be_string *) -{ - // NO-OP, we have ad-hoc classes from strings. - return 0; -} - -int -be_visitor_sequence_base::visit_structure (be_structure *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_enum (be_enum *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_base::visit_exception (be_exception *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_base::visit_array (be_array *node) -{ - return this->visit_node (node); -} - -int -be_visitor_sequence_base::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // set the alias node - if (node->primitive_base_type ()->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_sequence_base::" - "visit_typedef - " - "accept on primitive type failed\n"), - -1); - } - this->ctx_->alias (0); - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp deleted file mode 100644 index e256d530afa..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp +++ /dev/null @@ -1,624 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// sequence_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -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) - : be_visitor_decl (ctx) -{ -} - -be_visitor_sequence_ch::~be_visitor_sequence_ch (void) -{ -} - -int -be_visitor_sequence_ch::gen_base_sequence_class (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); - } - - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); - - // this is the instantiation branch - *os << node->instance_name (); - - os->gen_else_AHETI(); - - // generate the appropriate sequence type - switch (node->managed_type ()) - { - case be_sequence::MNG_OBJREF: - if (node->unbounded ()) - *os << "TAO_Unbounded_Object_Sequence<"; - else - *os << "TAO_Bounded_Object_Sequence<"; - break; - case be_sequence::MNG_PSEUDO: - if (node->unbounded ()) - *os << "TAO_Unbounded_Pseudo_Sequence<"; - else - *os << "TAO_Bounded_Pseudo_Sequence<"; - break; - case be_sequence::MNG_STRING: - if (node->unbounded ()) - *os << "TAO_Unbounded_String_Sequence"; - else - *os << "TAO_Bounded_String_Sequence"; - break; - default: // not a managed type - if (node->unbounded ()) - *os << "TAO_Unbounded_Sequence<"; - else - *os << "TAO_Bounded_Sequence<"; - break; - } - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } - delete visitor; - - // 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) - { - if (!node->unbounded ()) - { - *os << "<" << node->max_size () << ">"; - } - } - else - { - if (node->unbounded ()) - { - *os << ">"; - } - else - { - *os << ", " << node->max_size () << ">"; - } - } - - os->gen_endif_AHETI(); - - return 0; -} - - -int -be_visitor_sequence_ch::instantiate_sequence (be_sequence *node) -{ - be_type *bt; - - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_instantiate_template_name - " - "Bad element type\n"), -1); - } - - // generate the appropriate sequence type - switch (node->managed_type ()) - { - case be_sequence::MNG_PSEUDO: - case be_sequence::MNG_OBJREF: - if (node->unbounded ()) - this->gen_unbounded_obj_sequence (node); - else - this->gen_bounded_obj_sequence (node); - break; - case be_sequence::MNG_STRING: // sequence of strings - if (!node->unbounded ()) - this->gen_bounded_str_sequence (node); - // else - // inheriting from the right class is enough - break; - default: // not a managed type - if (node->unbounded ()) - { -#if 1 - // TAO provides extensions for octet sequences, first find out - // 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 = - be_typedef::narrow_from_decl (bt); - - if (alias == 0) - { - predef = - be_predefined_type::narrow_from_decl (bt); - } - else - { - predef = be_predefined_type::narrow_from_decl - (alias->primitive_base_type ()); - } - } - if (predef != 0) - { - if (predef->pt() != AST_PredefinedType::PT_octet) - this->gen_unbounded_sequence (node); - } - else - this->gen_unbounded_sequence (node); -#else - // @@ This needs to be fixed. (Michael) - be_predefined_type * bpt = - be_predefined_type::narrow_from_decl (node->base_type()); - if (bpt) - { - if (bpt->pt() != AST_PredefinedType::PT_octet) - this->gen_unbounded_sequence (node); - } - else - this->gen_unbounded_sequence (node); -#endif - } - else - this->gen_bounded_sequence (node); - break; - } - - return 0; -} - - -int be_visitor_sequence_ch::visit_sequence (be_sequence *node) -{ - be_type *bt; // type node - TAO_OutStream *os = this->ctx_->stream (); - - // first create a name for ourselves - if (node->create_name (this->ctx_->tdef ()) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "failed creating name\n"), -1); - } - - if (node->cli_hdr_gen () || node->imported ()) - return 0; - - // instantiation - - 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); - } - - // end of instantiation - - // generate the ifdefined macro for the sequence type - os->gen_ifdef_macro (node->flatname ()); - - os->indent (); // start with the current indentation level - - // 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); - } - - *os << "// *************************************************************" - << be_nl - << "// " << node->local_name () << be_nl - << "// *************************************************************" - << be_nl << be_nl; - - // generate a typedef to a parametrized sequence - *os << "class " << idl_global->export_macro () - << " " << node->local_name () << " : public "; - - if (this->gen_base_sequence_class (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "codegen for base sequence class\n"), -1); - } - - *os << "{" << be_nl - << "public:" << be_idt_nl - << node->local_name () << " (void); // default ctor" << be_nl; - // for unbounded sequences, we have a different set of constructors - if (node->unbounded ()) - { - *os << node->local_name () << " (CORBA::ULong max); // uses max size" - << be_nl; - } - - *os << node->local_name () << " (" << be_idt_nl; - if (node->unbounded ()) - { - // unbounded seq takes this extra parameter - *os << "CORBA::ULong max, " << be_nl; - } - *os << "CORBA::ULong length, " << be_nl; - // 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); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } - delete visitor; - *os << " *buffer, " << be_nl - << "CORBA::Boolean release=0" << be_uidt_nl - << ");" << be_nl; - *os << node->local_name () << " (const " << node->local_name () - << " &); // copy ctor" << be_nl; - *os << "~" << node->local_name () << " (void); // dtor\n"; - - // TAO provides extensions for octet sequences, first find out 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 = - be_typedef::narrow_from_decl (bt); - - if (alias == 0) - { - predef = be_predefined_type::narrow_from_decl (bt); - } - else - { - predef = be_predefined_type::narrow_from_decl - (alias->primitive_base_type ()); - } - } - // Now generate the extension... - if (predef != 0 && predef->pt () == AST_PredefinedType::PT_octet - && node->unbounded ()) - { - *os << "\n" - << "#if defined(TAO_NO_COPY_OCTET_SEQUENCES)" << be_nl - << node->local_name () << " (" << be_idt << be_idt_nl - << "CORBA::ULong length," << be_nl - << "const ACE_Message_Block* mb" << be_uidt_nl - << ")" << be_uidt_nl - << " : " << node->instance_name () - << " (length, mb) {}" << "\n" - << "#endif /* TAO_NO_COPY_OCTET_SEQUENCE */\n\n"; - } - - os->decr_indent (); - *os << "};" << be_nl; - - // define a _ptr type. This is just an extension for convenience - *os << "typedef " << node->local_name () << " *" - << node->local_name () << "_ptr;\n"; - - if (!this->ctx_->tdef ()) - { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - 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_sequence_ch::" - "visit_sequence - " - "TypeCode declaration failed\n" - ), -1); - } - } - - os->gen_endif (); // endif macro - - // generate the ifdefined macro for the var type - os->gen_ifdef_macro (node->flatname (), "_var"); - - // generate the var and out types - if (this->gen_var_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "codegen for _var failed\n"), -1); - } - - os->gen_endif (); - - // generate the ifdefined macro for the _out type - os->gen_ifdef_macro (node->flatname (), "_out"); - - if (this->gen_out_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "codegen for _out failed\n"), - -1); - } - os->gen_endif (); - node->cli_hdr_gen (1); - - return 0; -} - -// generate the _var definition for ourself -int -be_visitor_sequence_ch::gen_var_defn (be_sequence *node) -{ - TAO_OutStream *os; // output stream - char namebuf [NAMEBUFSIZE]; // names - be_type *bt; // base type - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_var", node->local_name ()->get_string ()); - - os = this->ctx_->stream (); - - *os << "// *************************************************************" - << be_nl; - *os << "// class " << node->name () << "_var" << be_nl; - *os << "// *************************************************************\n\n"; - - // retrieve base type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_var_defn - " - "Bad base type\n"), - -1); - } - - // generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - os->indent (); // start with whatever was our current indent level - *os << "class " << idl_global->export_macro () - << " " << namebuf << be_nl; - *os << "{" << be_nl; - *os << "public:\n"; - os->incr_indent (); - // default constr - *os << namebuf << " (void); // default constructor" << be_nl; - // constr - *os << namebuf << " (" << node->local_name () << " *);" << be_nl; - // copy constructor - *os << namebuf << " (const " << namebuf << - " &); // copy constructor" << be_nl; - // destructor - *os << "~" << namebuf << " (void); // destructor" << be_nl; - *os << be_nl; - // assignment operator from a pointer - *os << namebuf << " &operator= (" << node->local_name () << " *);" << be_nl; - // assignment from _var - *os << namebuf << " &operator= (const " << namebuf << - " &);" << be_nl; - - // arrow operator - *os << node->local_name () << " *operator-> (void);" << be_nl; - *os << "const " << node->local_name () << " *operator-> (void) const;" << be_nl; - *os << be_nl; - - // other extra types (cast operators, [] operator, and others) - - // cast operator - *os << "operator const " << node->local_name () << " &() const;" << be_nl; - *os << "operator " << node->local_name () << " &();" << be_nl; - *os << "operator " << node->local_name () << " &() const;" << be_nl; - - // overloaded [] operator. The const version is not required for sequences - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_var_defn - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_sequence::" - "gen_var_defn - " - "[] ret type gen failed\n"), - -1); - } - delete visitor; - - *os << "operator[] (CORBA::ULong index);" << be_nl; - - *os << "// 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 - *os << "const " << node->local_name () << " &in (void) const;" << be_nl; - *os << node->local_name () << " &inout (void);" << be_nl; - *os << node->local_name () << " *&out (void);" << be_nl; - *os << node->local_name () << " *_retn (void);" << be_nl; - - // generate an additional member function that returns the underlying pointer - *os << node->local_name () << " *ptr (void) const;\n"; - - *os << "\n"; - os->decr_indent (); - - // generate the private section - *os << "private:\n"; - os->incr_indent (); - *os << node->local_name () << " *ptr_;\n"; - - os->decr_indent (); - *os << "};\n\n"; - - return 0; -} - -// generate the _out definition -int -be_visitor_sequence_ch::gen_out_defn (be_sequence *node) -{ - TAO_OutStream *os; // output stream - char namebuf [NAMEBUFSIZE]; // to hold the _out name - be_type *bt; // base type - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_out", node->local_name ()->get_string ()); - os = this->ctx_->stream (); - - // retrieve base type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_out_defn - " - "Bad base type\n"), - -1); - } - - // generate the out definition (always in the client header) - os->indent (); // start with whatever was our current indent level - - *os << "class " << idl_global->export_macro () << " " - << namebuf << be_nl; - *os << "{" << be_nl; - *os << "public:\n"; - os->incr_indent (); - - // No default constructor - - // constructor from a pointer - *os << namebuf << " (" << node->local_name () << " *&);" << be_nl; - // constructor from a _var & - *os << namebuf << " (" << node->local_name () << "_var &);" << be_nl; - // constructor from a _out & - *os << namebuf << " (const " << namebuf << " &);" << be_nl; - // assignment operator from a _out & - *os << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; - // assignment operator from a pointer &, cast operator, ptr fn, operator - // -> and any other extra operators - // assignment - *os << namebuf << " &operator= (" << node->local_name () << " *);" << be_nl; - // operator () - *os << "operator " << node->local_name () << " *&();" << be_nl; - // ptr fn - *os << node->local_name () << " *&ptr (void);" << be_nl; - // operator -> - *os << node->local_name () << " *operator-> (void);" << be_nl; - - // overloaded [] operator only for sequence. The const version is not - // 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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_out_defn - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_sequence::" - "gen_var_defn - " - "[] ret type gen failed\n"), - -1); - } - delete visitor; - *os << "operator[] (CORBA::ULong index);" << be_nl; - *os << "\n"; - os->decr_indent (); - *os << "private:\n"; - os->incr_indent (); - - *os << node->local_name () << " *&ptr_;" << be_nl; - *os << "// assignment from T_var not allowed" << be_nl; - *os << "void operator= (const " << node->local_name () << "_var &);\n"; - - os->decr_indent (); - *os << "};\n\n"; - - 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 deleted file mode 100644 index 2c2bc7bb184..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp +++ /dev/null @@ -1,574 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// sequence_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequence in the client inline file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, sequence_ci, "$Id$") - - -// *********************************************************** -// sequence visitor for inline generation -// *********************************************************** - - -be_visitor_sequence_ci::be_visitor_sequence_ci (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_sequence_ci::~be_visitor_sequence_ci (void) -{ -} - -int -be_visitor_sequence_ci::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (node->cli_inline_gen () || node->imported ()) - return 0; - - // instantiation - - if (this->instantiate_sequence (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "codegen. for the primitive type sequence\n"), - -1); - } - - // end of instantiation - - // generate the ifdefined macro for the sequence type - os->gen_ifdef_macro (node->flatname ()); - - // all we do is generate the _var and _out implementations - if (this->gen_var_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "codegen for _var failed\n"), -1); - } - - if (this->gen_out_impl (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "codegen for _out failed\n"), -1); - } - - // generate the endif macro for the sequence type - os->gen_endif (); - node->cli_inline_gen (1); - - return 0; -} - -int -be_visitor_sequence_ci::instantiate_sequence (be_sequence *node) -{ - be_type *bt; - - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_instantiate_template_name - " - "Bad element type\n"), -1); - } - - // generate the appropriate sequence type - switch (node->managed_type ()) - { - case be_sequence::MNG_PSEUDO: - case be_sequence::MNG_OBJREF: - if (node->unbounded ()) - this->gen_unbounded_obj_sequence (node); - else - this->gen_bounded_obj_sequence (node); - break; - case be_sequence::MNG_STRING: // sequence of strings - if (!node->unbounded ()) - this->gen_bounded_str_sequence (node); - // else - // inheriting from the right class is enough - break; - default: // not a managed type - if (node->unbounded ()) - { -#if 1 - // TAO provides extensions for octet sequences, first find out - // 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 = - be_typedef::narrow_from_decl (bt); - - if (alias == 0) - { - predef = - be_predefined_type::narrow_from_decl (bt); - } - else - { - predef = be_predefined_type::narrow_from_decl - (alias->primitive_base_type ()); - } - } - if (predef != 0) - { - if (predef->pt() != AST_PredefinedType::PT_octet) - this->gen_unbounded_sequence (node); - } - else - this->gen_unbounded_sequence (node); -#else - // @@ This needs to be fixed. (Michael) - be_predefined_type * bpt = - be_predefined_type::narrow_from_decl (node->base_type()); - if (bpt) - { - if (bpt->pt() != AST_PredefinedType::PT_octet) - this->gen_unbounded_sequence (node); - } - else - this->gen_unbounded_sequence (node); -#endif - } - else - this->gen_bounded_sequence (node); - break; - } - - return 0; -} - -int -be_visitor_sequence_ci::gen_var_impl (be_sequence *node) -{ - TAO_OutStream *os; // output stream - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local _var names - be_type *bt; // base type - - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", node->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_var", node->local_name ()->get_string ()); - - os = this->ctx_->stream (); - - // retrieve 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); - } - - // generate the var implementation in the inline file - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // default constr - *os << "ACE_INLINE" << be_nl - << fname << "::" << lname - << " (void) // default constructor" << be_nl - << " " << ": ptr_ (0)" << be_nl - << "{}\n\n"; - - // constr from a _ptr - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << node->name () << " *p)" << be_nl; - *os << " : ptr_ (p)" << be_nl; - *os << "{}\n\n"; - - // copy constructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "if (p.ptr_)" << be_nl; - *os << " this->ptr_ = new " << node->name () << "(*p.ptr_);" << be_nl; - *os << "else" << be_nl; - *os << " this->ptr_ = 0;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // destructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "delete this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // assignment operator from a pointer - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << node->name () << - " *p)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "delete this->ptr_;" << be_nl; - *os << "this->ptr_ = p;" << be_nl; - *os << "return *this;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // assignment operator from _var - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname << - " &p) // deep copy" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "if (this != &p)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "delete this->ptr_;" << be_nl; - *os << "this->ptr_ = new " << node->name () << " (*p.ptr_);\n"; - os->decr_indent (); - *os << "}" << be_nl; - *os << "return *this;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // two arrow operators - os->indent (); - *os << "ACE_INLINE const " << node->name () << " *" << be_nl; - *os << fname << "::operator-> (void) const" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << node->name () << " *" << be_nl; - *os << fname << "::operator-> (void)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // other extra methods - 3 cast operator () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator const " << node->name () << - " &() const // cast" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return *this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << node->name () << " &() // cast " << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return *this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << node->name () << " &() const// cast " << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return *this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // operator [] - os->indent (); - *os << "ACE_INLINE "; - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_var_impl - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_var_impl - " - "[] ret type gen failed\n"), - -1); - } - delete visitor; - - *os << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_->operator[] (index);\n"; - os->decr_indent (); - *os << "}\n\n"; - - // in, inout, out, and _retn - os->indent (); - *os << "ACE_INLINE const " << node->name () << " &" << be_nl; - *os << fname << "::in (void) const" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return *this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << node->name () << " &" << be_nl; - *os << fname << "::inout (void)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return *this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "// mapping for variable size " << be_nl; - *os << "ACE_INLINE " << node->name () << " *&" << be_nl; - *os << fname << "::out (void)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "delete this->ptr_;" << be_nl; - *os << "this->ptr_ = 0;" << be_nl; - *os << "return this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - os->indent (); - *os << "ACE_INLINE " << node->name () << " *" << be_nl; - *os << fname << "::_retn (void)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << node->name () << " *tmp = this->ptr_;" << be_nl; - *os << "this->ptr_ = 0;" << be_nl; - *os << "return tmp;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // the additional ptr () member function - os->indent (); - *os << "ACE_INLINE " << node->name () << " *" << be_nl; - *os << fname << "::ptr (void) const" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_sequence_ci::gen_out_impl (be_sequence *node) -{ - TAO_OutStream *os; // output stream - char fname [NAMEBUFSIZE]; // to hold the full and - char lname [NAMEBUFSIZE]; // local _out names - be_type *bt; // base type - - - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", node->fullname ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", node->local_name ()->get_string ()); - - os = this->ctx_->stream (); - - // retrieve base type - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_out_impl - " - "Bad element type\n"), -1); - } - - // generate the out implementation in the inline file - - os->indent (); // start with whatever was our current indent level - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for class " << fname << be_nl; - *os << "// *************************************************************\n\n"; - - // constr from a pointer - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << node->name () << " *&p)" << be_nl; - *os << " : ptr_ (p)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "this->ptr_ = 0;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // constructor from _var & - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (" << node->name () << - "_var &p) // constructor from _var" << be_nl; - *os << " : ptr_ (p.out ())" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "delete this->ptr_;" << be_nl; - *os << "this->ptr_ = 0;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // copy constructor - os->indent (); - *os << "ACE_INLINE" << be_nl; - *os << fname << "::" << lname << " (const " << fname << - " &p) // copy constructor" << be_nl; - *os << " : ptr_ (ACE_const_cast (" << fname - << "&,p).ptr_)" << be_nl; - *os << "{}\n\n"; - - // assignment operator from _out & - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (const " << fname << - " &p)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "this->ptr_ = ACE_const_cast (" << fname - << "&,p).ptr_;" << be_nl; - *os << "return *this;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // assignment from _var is not allowed by a private declaration - - // assignment operator from pointer - os->indent (); - *os << "ACE_INLINE " << fname << " &" << be_nl; - *os << fname << "::operator= (" << node->name () << - " *p)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "this->ptr_ = p;" << be_nl; - *os << "return *this;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // other extra methods - cast operator () - os->indent (); - *os << "ACE_INLINE " << be_nl; - *os << fname << "::operator " << node->name () << - " *&() // cast" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // ptr function - os->indent (); - *os << "ACE_INLINE " << node->name () << " *&" << be_nl; - *os << fname << "::ptr (void) // ptr" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // operator -> - os->indent (); - *os << "ACE_INLINE " << node->name () << " *" << be_nl; - *os << fname << "::operator-> (void)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_;\n"; - os->decr_indent (); - *os << "}\n\n"; - - // sequence has an additional method - os->indent (); - *os << "ACE_INLINE "; - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_out_impl - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_out_impl - " - "[] ret type gen failed\n"), - -1); - } - delete visitor; - - *os << be_nl; - *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; - *os << "{\n"; - os->incr_indent (); - *os << "return this->ptr_->operator[] (index);\n"; - os->decr_indent (); - *os << "}\n\n"; - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp deleted file mode 100644 index 47d9d6f8a37..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp +++ /dev/null @@ -1,378 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// sequence_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Sequences in the client stubs file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_sequence.h" - -ACE_RCSID(be_visitor_sequence, sequence_cs, "$Id$") - - -// ************************************************************ -// Root visitor for client stub class -// ************************************************************ - -be_visitor_sequence_cs::be_visitor_sequence_cs (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -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; - - - // 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); - } - - os->gen_ifdef_AHETI(); - - // this is the instantiation branch - *os << node->instance_name (); - - os->gen_else_AHETI(); - - // generate the appropriate sequence type - switch (node->managed_type ()) - { - case be_sequence::MNG_OBJREF: - if (node->unbounded ()) - *os << "TAO_Unbounded_Object_Sequence<"; - else - *os << "TAO_Bounded_Object_Sequence<"; - break; - case be_sequence::MNG_PSEUDO: - if (node->unbounded ()) - *os << "TAO_Unbounded_Pseudo_Sequence<"; - else - *os << "TAO_Bounded_Pseudo_Sequence<"; - break; - case be_sequence::MNG_STRING: - if (node->unbounded ()) - *os << "TAO_Unbounded_String_Sequence"; - else - *os << "TAO_Bounded_String_Sequence"; - break; - default: // not a managed type - if (node->unbounded ()) - *os << "TAO_Unbounded_Sequence<"; - else - *os << "TAO_Bounded_Sequence<"; - break; - } - - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } - delete visitor; - - // 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) - { - if (!node->unbounded ()) - { - *os << "<" << node->max_size () << ">"; - } - } - else - { - if (node->unbounded ()) - { - *os << ">"; - } - else - { - *os << ", " << node->max_size () << ">"; - } - } - - os->gen_endif_AHETI(); - - return 0; -} - -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 - - 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); - } - - // end of instantiation - - // generate the ifdefined macro for the sequence type - os->gen_ifdef_macro (node->flatname ()); - - os->indent (); // start with the current indentation level - - // 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); - } - - *os << "// *************************************************************" - << be_nl - << "// " << node->name () << be_nl - << "// *************************************************************" - << be_nl << be_nl; - - // default constructor - *os << node->name () << "::" << node->local_name () << " (void)" << be_nl - << "{}" << be_nl; - - // for unbounded sequences, we have a different set of constructors - if (node->unbounded ()) - { - *os << node->name () << "::" << node->local_name () - << " (CORBA::ULong max) // uses max size" << be_nl - << " : "; - - // 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); - } - - - *os << " (max)" << be_nl - << "{}" << be_nl; - } - - // 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); - } - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } - delete visitor; - *os << " *buffer, CORBA::Boolean release)" << be_nl - << " : "; - // 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); - } - *os << " ("; - if (node->unbounded ()) - { - *os << "max, "; - } - *os << "length, buffer, release)" << be_nl - << "{}" << be_nl; - - // copy constructor - *os << node->name () << "::" << node->local_name () - << " (const " << node->local_name () - << " &seq) // copy ctor" << be_nl - << " : "; - // 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); - } - *os << " (seq)" << be_nl - << "{}" << be_nl; - - // destructor - *os << node->name () << "::~" << node->local_name () - << " (void) // dtor" << be_nl - << "{}\n\n"; - - if (!this->ctx_->tdef ()) - { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "TypeCode definition failed\n" - ), -1); - } - } - - os->gen_endif (); - node->cli_stub_gen (1); - - return 0; -} - -int -be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) -{ - be_type *bt; - - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "gen_instantiate_template_name - " - "Bad element type\n"), -1); - } - - // generate the appropriate sequence type - switch (node->managed_type ()) - { - case be_sequence::MNG_PSEUDO: - case be_sequence::MNG_OBJREF: - if (node->unbounded ()) - this->gen_unbounded_obj_sequence (node); - else - this->gen_bounded_obj_sequence (node); - break; - case be_sequence::MNG_STRING: // sequence of strings - if (!node->unbounded ()) - this->gen_bounded_str_sequence (node); - // else - // inheriting from the right class is enough - break; - default: // not a managed type - if (node->unbounded ()) - { -#if 1 - // TAO provides extensions for octet sequences, first find out - // 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 = - be_typedef::narrow_from_decl (bt); - - if (alias == 0) - { - predef = - be_predefined_type::narrow_from_decl (bt); - } - else - { - predef = be_predefined_type::narrow_from_decl - (alias->primitive_base_type ()); - } - } - if (predef != 0) - { - if (predef->pt() != AST_PredefinedType::PT_octet) - this->gen_unbounded_sequence (node); - } - else - this->gen_unbounded_sequence (node); -#else - // @@ This needs to be fixed. (Michael) - be_predefined_type * bpt = - be_predefined_type::narrow_from_decl (node->base_type()); - if (bpt) - { - if (bpt->pt() != AST_PredefinedType::PT_octet) - this->gen_unbounded_sequence (node); - } - else - this->gen_unbounded_sequence (node); -#endif - } - else - this->gen_bounded_sequence (node); - break; - } - - return 0; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_structure.cpp b/TAO/TAO_IDL/be/be_visitor_structure.cpp deleted file mode 100644 index 5c803e00fc0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_structure.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Structure -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.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" -#include "be_visitor_structure/structure_cs.cpp" -#include "be_visitor_structure/any_op_ch.cpp" -#include "be_visitor_structure/any_op_cs.cpp" -#include "be_visitor_structure/cdr_op_ch.cpp" -#include "be_visitor_structure/cdr_op_cs.cpp" - -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 deleted file mode 100644 index 34b3f3210d3..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/any_op_ch.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for structures -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, any_op_ch, "$Id$") - - -// *************************************************************************** -// Structure visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_structure_any_op_ch::be_visitor_structure_any_op_ch -(be_visitor_context *ctx) - : be_visitor_structure (ctx) -{ -} - -be_visitor_structure_any_op_ch::~be_visitor_structure_any_op_ch (void) -{ -} - -int -be_visitor_structure_any_op_ch::visit_structure (be_structure *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - os->indent (); - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, const " << node->name () - << " &); // copying version" << be_nl; - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, " << node->name () - << "*); // noncopying version" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << 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, - "(%N:%l) be_visitor_structure::visit_structure - " - "codegen for scope failed\n"), -1); - } - - node->cli_hdr_any_op_gen (1); - return 0; -} - -int -be_visitor_structure_any_op_ch::visit_field (be_field *node) -{ - be_type *bt; // field's type - - // 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_structure_any_op_ch::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_any_op_ch::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} 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 deleted file mode 100644 index dee524518eb..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp +++ /dev/null @@ -1,171 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for structures -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, any_op_cs, "$Id$") - - -// *************************************************************************** -// Structure visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_structure_any_op_cs::be_visitor_structure_any_op_cs -(be_visitor_context *ctx) - : be_visitor_structure (ctx) -{ -} - -be_visitor_structure_any_op_cs::~be_visitor_structure_any_op_cs (void) -{ -} - -int -be_visitor_structure_any_op_cs::visit_structure (be_structure *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - *os << "void operator<<= (CORBA::Any &_tao_any, const " - << node->name () << " &_tao_elem) // copying" << be_nl - << "{" << be_idt_nl - << node->name () << " *_any_val;" << be_nl - << "ACE_NEW (_any_val, " << node->name () << " (_tao_elem));" << be_nl - << "if (!_any_val) return;" << be_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () - << ", _any_val, 1, TAO_TRY_ENV);" << " // copy the value" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _any_val;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->name () << " *_tao_elem) // non copying" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " - << "_tao_elem, 1, TAO_TRY_ENV); // consume it" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY {}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << " *&_tao_elem)" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", TAO_TRY_ENV)) return 0; // not equal" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "if (_tao_any.any_owns_data ())" << be_nl - << "{" << be_idt_nl - << "_tao_elem = (" << node->name () << " *)_tao_any.value ();" - << be_nl - << "return 1;" << be_nl - << "}" << be_uidt_nl - << "else" << be_nl // else any does not own the data - << "{" << be_idt_nl - << "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);" - << be_nl - << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any._tao_get_cdr ());" - << be_nl - << "if (stream.decode (" << node->tc_name () - << ", _tao_elem, 0, TAO_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->replace (" - << node->tc_name () << ", _tao_elem, 1, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "delete _tao_elem;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _tao_elem;" << be_nl - << "return 0; " << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\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, - "(%N:%l) be_visitor_structure::visit_structure - " - "codegen for scope failed\n"), -1); - } - - node->cli_stub_any_op_gen (1); - return 0; -} - -int -be_visitor_structure_any_op_cs::visit_field (be_field *node) -{ - be_type *bt; // field's type - - // 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_structure_any_op_cs::" - "visit_field - " - "Bad field type\n" - ), -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_any_op_cs::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} 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 deleted file mode 100644 index 337601a11d5..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_ch.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for structures. This uses -// compiled marshaling. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -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 (ctx) -{ -} - -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 ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - os->indent (); - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const " << node->name () - << " &); // " << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, " - << node->name () << " &);\n"; - - - // set the substate as generating code for the types defined in our scope - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_cdr_op_ch::" - "visit_structure - " - "codegen for scope failed\n"), -1); - } - - - node->cli_hdr_cdr_op_gen (1); - 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 deleted file mode 100644 index f6a9e2fe1a8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/cdr_op_cs.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for structures -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#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_cs, "$Id$") - -// *************************************************************************** -// Structure visitor for generating CDR operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_structure_cdr_op_cs::be_visitor_structure_cdr_op_cs -(be_visitor_context *ctx) - : be_visitor_structure (ctx) -{ -} - -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) -{ - // already generated and/or we are imported. Don't do anything. - if (node->cli_stub_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // First generate code for our children. The reason we do this first is - // because the inlined code for our children must be available before we use - // it in our parent - - // set the substate as generating code for the types defined in our scope - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_cdr_op_cs" - "::visit_structure - " - "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 - << "{" << 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); - } - *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_cs::" - "visit_structure - " - "codegen for scope failed\n"), -1); - } - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; - - // set the substate as generating code for the input operator - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - *os << "ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &strm, " - << node->name () << " &_tao_aggregate)" << be_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); - } - *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_cs" - "::visit_structure - " - "codegen for scope failed\n"), -1); - } - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; - - node->cli_stub_cdr_op_gen (1); - return 0; -} - -int -be_visitor_structure_cdr_op_cs::post_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (!this->last_node (bd)) - { - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_OUTPUT: - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " &&" << be_nl; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - default: - break; - }; - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp deleted file mode 100644 index c4386dafcff..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp +++ /dev/null @@ -1,107 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// structure.cpp -// -// = DESCRIPTION -// Visitor generating code for Structures. This is a generic visitor. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#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) -{ -} - -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 -} - -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 - 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_STRUCT_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - break; - case TAO_CodeGen::TAO_STRUCT_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CI); - break; - case TAO_CodeGen::TAO_STRUCT_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CS); - break; - case TAO_CodeGen::TAO_STRUCT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_STRUCT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure::" - "visit_field - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure::" - "visit_field - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (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 deleted file mode 100644 index f9ce9cb68e2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// structure_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Structure in the client header. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, structure_ch, "$Id$") - - -// ****************************************************** -// for client header -// ****************************************************** - -be_visitor_structure_ch::be_visitor_structure_ch (be_visitor_context *ctx) - : be_visitor_structure (ctx) -{ -} - -be_visitor_structure_ch::~be_visitor_structure_ch (void) -{ -} - -// visit the Structure node and its scope -int be_visitor_structure_ch::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported - { - os = this->ctx_->stream (); - - os->indent (); // start from whatever indentation level we were at - *os << "struct " << idl_global->export_macro () << " " - << node->local_name () << be_nl - << "{" << be_idt << "\n"; - - // generate code for field members - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_ch::" - "visit_structure - " - "codegen for scope failed\n"), -1); - } - - os->decr_indent (); - *os << "};\n\n"; - - // generate var defn - if (node->gen_var_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_ch::" - "visit_structure - " - "codegen for _var failed\n"), -1); - } - - // a class is generated for an out defn only for a variable length struct - if (node->size_type () == be_decl::VARIABLE) - { - if (node->gen_out_defn () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_ch::" - "visit_structure - " - "codegen for _out failed\n"), -1); - } - } - else - { - os->indent (); - *os << "typedef " << node->local_name () << " &" << node->local_name - () << "_out;\n\n"; - } - - // 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_DECL); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (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); - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_ci.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_ci.cpp deleted file mode 100644 index 8271008eb2b..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_ci.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// structure_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Structure in the inline file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, structure_ci, "$Id$") - - -// ****************************************************** -// for client inline -// ****************************************************** - -be_visitor_structure_ci::be_visitor_structure_ci (be_visitor_context *ctx) - : be_visitor_structure (ctx) -{ -} - -be_visitor_structure_ci::~be_visitor_structure_ci (void) -{ -} - -// visit the Structure node and its scope -int be_visitor_structure_ci::visit_structure (be_structure *node) -{ - if (!node->cli_inline_gen () && !node->imported ()) - { - if (node->gen_var_impl () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_ci::" - "visit_structure - " - "codegen for _var failed\n"), -1); - } - if (node->size_type () == be_decl::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); - } - // 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); - } - 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 deleted file mode 100644 index 8ab877e8f35..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// structure_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Structures in the client stubs file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_structure.h" - -ACE_RCSID(be_visitor_structure, structure_cs, "$Id$") - - -// *************************************************************************** -// for client stubs -// *************************************************************************** -be_visitor_structure_cs::be_visitor_structure_cs (be_visitor_context *ctx) - : be_visitor_structure (ctx) -{ -} - -be_visitor_structure_cs::~be_visitor_structure_cs (void) -{ -} - -// visit the Structure_Cs node and its scope -int be_visitor_structure_cs::visit_structure (be_structure *node) -{ - if (!node->cli_stub_gen () && !node->imported ()) - { - // 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); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_cs::" - "visit_structure - " - "TypeCode definition failed\n" - ), -1); - } - - - // do any code generation required for the scope members - // 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_cs::" - "visit_structure - " - "codegen for scope failed\n"), -1); - } - node->cli_stub_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 deleted file mode 100644 index 9267ece581e..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typecode.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_typecode.cpp -// -// = DESCRIPTION -// Visitors for generation of code for TypeCodes for various types -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typecode.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$") - diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp deleted file mode 100644 index 134201bca63..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// typecode_decl.cpp -// -// = DESCRIPTION -// Visitor generating code for TypeCode declaration for a type -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typecode.h" - -ACE_RCSID(be_visitor_typecode, typecode_decl, "$Id$") - - -// ****************************************************** -// TypeCode declarations -// ****************************************************** - -be_visitor_typecode_decl::be_visitor_typecode_decl (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_typecode_decl::~be_visitor_typecode_decl (void) -{ -} - -int -be_visitor_typecode_decl::visit_type (be_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - // Generate the typecode decl - if (node->is_nested ()) - { - // we have a scoped name - os->indent (); - // is our enclosing scope a module? We need this check because for - // platforms that support namespaces, the typecode must be declared - // extern - if (node->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "TAO_NAMESPACE_STORAGE_CLASS "; - else - *os << "static "; - *os << "CORBA::TypeCode_ptr " - << node->tc_name ()->last_component () << ";\n\n"; - } - else - { - // we are in the ROOT scope - os->indent (); - *os << "extern " << idl_global->export_macro () << " CORBA::TypeCode_ptr " - << " " << node->tc_name ()->last_component () << ";\n\n"; - } - return 0; -} - -int -be_visitor_typecode_decl::visit_array (be_array *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_decl::visit_enum (be_enum *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_decl::visit_exception (be_exception *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_decl::visit_interface (be_interface *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_decl::visit_sequence (be_sequence *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_decl::visit_structure (be_structure *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_decl::visit_typedef (be_typedef *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_decl::visit_union (be_union *node) -{ - return this->visit_type (node); -} diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp deleted file mode 100644 index f9e8584abeb..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp +++ /dev/null @@ -1,226 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// typecode_defn.cpp -// -// = DESCRIPTION -// Visitor generating code for TypeCode definitions for types. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typecode.h" - -ACE_RCSID(be_visitor_typecode, typecode_defn, "$Id$") - - -// ****************************************************** -// TypeCode Definitions -// ****************************************************** - -be_visitor_typecode_defn::be_visitor_typecode_defn (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_typecode_defn::~be_visitor_typecode_defn (void) -{ -} - -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler -int -be_visitor_typecode_defn::gen_nested_namespace_begin (be_module *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; - - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // leave the outermost root scope - *os << "TAO_NAMESPACE_BEGIN (" << i->item ()->get_string () - << ")" << be_nl; - } - i->next (); - } - delete i; - return 0; -} - -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler -int -be_visitor_typecode_defn::gen_nested_namespace_end (be_module *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; - - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // leave the outermost root scope - *os << "TAO_NAMESPACE_END" << be_nl; - } - i->next (); - } - delete i; - return 0; -} - -int -be_visitor_typecode_defn::visit_type (be_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); - // generate the typecode information here - *os << "static const CORBA::Long _oc_" << node->flatname () << "[] =" - << be_nl; - *os << "{" << be_idt << "\n"; - // note that we just need the parameters here and hence we generate the - // encapsulation for the parameters - if (node->gen_encapsulation () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::" - "visit_type - " - "codegen for typecode failed\n"), -1); - } - *os << be_uidt << "};" << be_nl; - - *os << "static CORBA::TypeCode _tc_TAO_tc_" << node->flatname () - << " ("; - switch (node->node_type ()) - { - case AST_Decl::NT_array: - *os << "CORBA::tk_array"; - break; - case AST_Decl::NT_enum: - *os << "CORBA::tk_enum"; - break; - case AST_Decl::NT_except: - *os << "CORBA::tk_except"; - break; - case AST_Decl::NT_interface: - *os << "CORBA::tk_objref"; - break; - case AST_Decl::NT_sequence: - *os << "CORBA::tk_sequence"; - break; - case AST_Decl::NT_struct: - *os << "CORBA::tk_struct"; - break; - case AST_Decl::NT_typedef: - *os << "CORBA::tk_alias"; - break; - case AST_Decl::NT_union: - *os << "CORBA::tk_union"; - break; - default: - return -1; // error - } - - *os << ", sizeof (_oc_" << node->flatname () - << "), (char *) &_oc_" << node->flatname () - << ", 0, sizeof (" << node->name () << "));" << be_nl; - - // 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) - { - *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, - "be_visitor_typecode_defn::visit_type - " - "Error parsing nested name\n"), - -1); - } - *os << "TAO_NAMESPACE_DEFINE (CORBA::TypeCode_ptr, _tc_" - << node->local_name () << ", &_tc_TAO_tc_" - << node->flatname () << ")" << be_nl; - if (this->gen_nested_namespace_end (module) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_typecode_defn::visit_type - " - "Error parsing nested name\n"), - -1); - } - } - else - { - // outermost scope. - *os << "CORBA::TypeCode_ptr " << node->tc_name () << " = &_tc_TAO_tc_" - << node->flatname () << ";\n\n"; - } - return 0; -} - -int -be_visitor_typecode_defn::visit_array (be_array *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_defn::visit_enum (be_enum *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_defn::visit_exception (be_exception *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_defn::visit_interface (be_interface *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_defn::visit_sequence (be_sequence *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_defn::visit_structure (be_structure *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_defn::visit_typedef (be_typedef *node) -{ - return this->visit_type (node); -} - -int -be_visitor_typecode_defn::visit_union (be_union *node) -{ - return this->visit_type (node); -} diff --git a/TAO/TAO_IDL/be/be_visitor_typedef.cpp b/TAO/TAO_IDL/be/be_visitor_typedef.cpp deleted file mode 100644 index b1c95a284c8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_typedef.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Typedef -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.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" -#include "be_visitor_typedef/typedef_cs.cpp" -#include "be_visitor_typedef/any_op_ch.cpp" -#include "be_visitor_typedef/any_op_cs.cpp" -#include "be_visitor_typedef/cdr_op_ch.cpp" -#include "be_visitor_typedef/cdr_op_cs.cpp" - -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 deleted file mode 100644 index 77853097361..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/any_op_ch.cpp +++ /dev/null @@ -1,278 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators of a Typedef node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -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 (ctx) -{ -} - -be_visitor_typedef_any_op_ch::~be_visitor_typedef_any_op_ch (void) -{ -} - -int -be_visitor_typedef_any_op_ch::visit_typedef (be_typedef *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - - // In general, we may have a chain of typedefs. i.e., - // typedef sequence<long> X; - // typedef X Y; - // typedef Y Z; and so on - // The first time we will be in will be for node Z for which the code - // generation has to take place. However, it is not enough to just generate - // code that looks like - - // typedef Y Z; - // For different types (in this case we have a sequence), we will need - // typedefs for the _var and _out types for Z. If it had been an array, we - // will additionally have the _forany type as well as inlined *_alloc, _dup, - // and _free methods. - // - // Finally, we need to differentiate between the case where we were - // generating code for - // typedef sequence<long> X; and - // typedef Y Z; where Y was somehow aliased to the sequence. In the former - // case, we will need to generate all the code for sequence<long> or whatever - // the type maybe. In the latter, we just need typedefs for the type and all - // associated _var, _out, and other types. - - be_type *bt; // base type - - if (this->ctx_->tdef ()) - { - // 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 - - this->ctx_->alias (node); // save this alias - - // 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_any_op_ch::" - "visit_typedef - " - "bad primitive base type\n" - ), -1); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_ch::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - this->ctx_->alias (0); // reset - } - 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 - - // 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_any_op_ch::" - "visit_typedef - " - "bad base type\n" - ), -1); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_ch::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - - this->ctx_->tdef (0); // reset - } - - node->cli_hdr_any_op_gen (1); - return 0; -} - -int -be_visitor_typedef_any_op_ch::visit_array (be_array *node) -{ - be_type *bt; - - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); - else - bt = node; - - if (!bt->imported () && - bt->node_type () == AST_Decl::NT_array) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_array (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_ch::" - "visit_array - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_op_ch::visit_enum (be_enum *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_any_op_ch::" - "visit_enum - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_op_ch::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_sequence) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_sequence (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_ch::" - "visit_sequence - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_op_ch::visit_structure (be_structure *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_struct) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_structure (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_ch::" - "visit_structure - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_op_ch::visit_union (be_union *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_union) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_ch::" - "visit_union - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} 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 deleted file mode 100644 index 6d8a868df16..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/any_op_cs.cpp +++ /dev/null @@ -1,279 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators in the client stubs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -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 (ctx) -{ -} - -be_visitor_typedef_any_op_cs::~be_visitor_typedef_any_op_cs (void) -{ -} - -int -be_visitor_typedef_any_op_cs::visit_typedef (be_typedef *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - // Any <<= and >>= operators - os->indent (); - - // In general, we may have a chain of typedefs. i.e., - // typedef sequence<long> X; - // typedef X Y; - // typedef Y Z; and so on - // The first time we will be in will be for node Z for which the code - // generation has to take place. However, it is not enough to just generate - // code that looks like - - // typedef Y Z; - // For different types (in this case we have a sequence), we will need - // typedefs for the _var and _out types for Z. If it had been an array, we - // will additionally have the _forany type as well as inlined *_alloc, _dup, - // and _free methods. - // - // Finally, we need to differentiate between the case where we were - // generating code for - // typedef sequence<long> X; and - // typedef Y Z; where Y was somehow aliased to the sequence. In the former - // case, we will need to generate all the code for sequence<long> or whatever - // the type maybe. In the latter, we just need typedefs for the type and all - // associated _var, _out, and other types. - - be_type *bt; // base type - - if (this->ctx_->tdef ()) - { - // 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 - - this->ctx_->alias (node); // save this alias - - // 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_any_op_cs::" - "visit_typedef - " - "bad primitive base type\n" - ), -1); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_cs::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - this->ctx_->alias (0); // reset - } - 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 - - // 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_any_op_cs::" - "visit_typedef - " - "bad base type\n" - ), -1); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_cs::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - - this->ctx_->tdef (0); // reset - } - - node->cli_stub_any_op_gen (1); - return 0; -} - -int -be_visitor_typedef_any_op_cs::visit_array (be_array *node) -{ - be_type *bt; - - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); - else - bt = node; - - if (!bt->imported () && - bt->node_type () == AST_Decl::NT_array) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_array (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_cs::" - "visit_array - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_op_cs::visit_enum (be_enum *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_any_op_cs::" - "visit_enum - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_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_sequence) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_sequence (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_cs::" - "visit_sequence - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_op_cs::visit_structure (be_structure *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_struct) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_structure (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_cs::" - "visit_structure - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_any_op_cs::visit_union (be_union *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_union) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_any_op_cs::" - "visit_union - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} 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 deleted file mode 100644 index cad32c9e4e0..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_ch.cpp +++ /dev/null @@ -1,277 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Cdr operators of a Typedef node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -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 (ctx) -{ -} - -be_visitor_typedef_cdr_op_ch::~be_visitor_typedef_cdr_op_ch (void) -{ -} - -int -be_visitor_typedef_cdr_op_ch::visit_typedef (be_typedef *node) -{ - if (node->cli_hdr_cdr_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - os->indent (); - - // In general, we may have a chain of typedefs. i.e., - // typedef sequence<long> X; - // typedef X Y; - // typedef Y Z; and so on - // The first time we will be in will be for node Z for which the code - // generation has to take place. However, it is not enough to just generate - // code that looks like - - // typedef Y Z; - // For different types (in this case we have a sequence), we will need - // typedefs for the _var and _out types for Z. If it had been an array, we - // will additionally have the _forcdr type as well as inlined *_alloc, _dup, - // and _free methods. - // - // Finally, we need to differentiate between the case where we were - // generating code for - // typedef sequence<long> X; and - // typedef Y Z; where Y was somehow aliased to the sequence. In the former - // case, we will need to generate all the code for sequence<long> or whatever - // the type maybe. In the latter, we just need typedefs for the type and all - // associated _var, _out, and other types. - - be_type *bt; // base type - - if (this->ctx_->tdef ()) - { - // 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 - - this->ctx_->alias (node); // save this alias - - // 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_ch::" - "visit_typedef - " - "bad primitive base type\n" - ), -1); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_ch::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - this->ctx_->alias (0); // reset - } - else - { - // the context has not stored cdr "tdef" node. So we must be in here for - // the first time - this->ctx_->tdef (node); // save the 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_ch::" - "visit_typedef - " - "bad base type\n" - ), -1); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_ch::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - - this->ctx_->tdef (0); // reset - } - - node->cli_hdr_cdr_op_gen (1); - return 0; -} - -int -be_visitor_typedef_cdr_op_ch::visit_array (be_array *node) -{ - be_type *bt; - - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); - else - bt = node; - - if (!bt->imported () && - bt->node_type () == AST_Decl::NT_array) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_array (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_ch::" - "visit_array - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_cdr_op_ch::visit_enum (be_enum *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_ch::" - "visit_enum - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_cdr_op_ch::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_sequence) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_sequence (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_ch::" - "visit_sequence - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_cdr_op_ch::visit_structure (be_structure *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_struct) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_structure (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_ch::" - "visit_structure - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_cdr_op_ch::visit_union (be_union *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_union) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_op_ch::" - "visit_union - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} 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 deleted file mode 100644 index f29922c1ddd..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/cdr_op_cs.cpp +++ /dev/null @@ -1,279 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Cdr operators in the client stubs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -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 (ctx) -{ -} - -be_visitor_typedef_cdr_op_cs::~be_visitor_typedef_cdr_op_cs (void) -{ -} - -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 (); - - // In general, we may have a chain of typedefs. i.e., - // typedef sequence<long> X; - // typedef X Y; - // typedef Y Z; and so on - // The first time we will be in will be for node Z for which the code - // generation has to take place. However, it is not enough to just generate - // code that looks like - - // typedef Y Z; - // For different types (in this case we have a sequence), we will need - // typedefs for the _var and _out types for Z. If it had been an array, we - // will additionally have the _forcdr type as well as inlined *_alloc, _dup, - // and _free methods. - // - // Finally, we need to differentiate between the case where we were - // generating code for - // typedef sequence<long> X; and - // typedef Y Z; where Y was somehow aliased to the sequence. In the former - // case, we will need to generate all the code for sequence<long> or whatever - // the type maybe. In the latter, we just need typedefs for the type and all - // associated _var, _out, and other types. - - be_type *bt; // base type - - if (this->ctx_->tdef ()) - { - // 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 - - this->ctx_->alias (node); // save this alias - - // 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); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_cs::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - this->ctx_->alias (0); // reset - } - else - { - // the context has not stored cdr "tdef" node. So we must be in here for - // the first time - this->ctx_->tdef (node); // save the 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); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_cs::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - - this->ctx_->tdef (0); // reset - } - - node->cli_stub_cdr_op_gen (1); - return 0; -} - -int -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 (); - else - bt = node; - - if (!bt->imported () && - bt->node_type () == AST_Decl::NT_array) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_array (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_cs::" - "visit_array - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -be_visitor_typedef_cdr_op_cs::visit_enum (be_enum *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); - } - } - - 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; - - if (bt->node_type () == AST_Decl::NT_sequence) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_sequence (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_cs::" - "visit_sequence - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -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 (); - else - bt = node; - - if (bt->node_type () == AST_Decl::NT_struct) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_structure (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_cs::" - "visit_structure - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} - -int -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 (); - else - bt = node; - - if (bt->node_type () == AST_Decl::NT_union) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cdr_op_cs::" - "visit_union - " - "base class visitor failed \n" - ), -1); - } - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp deleted file mode 100644 index d404bd70da2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp +++ /dev/null @@ -1,463 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// typedef.cpp -// -// = DESCRIPTION -// Generic visitor generating code for Typedefs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef, "$Id$") - - -// ****************************************************** -// Generic Typedef visitor -// ****************************************************** - -be_visitor_typedef::be_visitor_typedef (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -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 -} - -// =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 - 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_ARRAY_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_ARRAY_CI); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_array - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_array - " - "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_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 - 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_ENUM_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - 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: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_enum - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_enum - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 - 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_SEQUENCE_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - break; - case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_sequence - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_sequence - " - "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_sequence - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; - return 0; -} - -// visit an structure -int -be_visitor_typedef::visit_string (be_string *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; - 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_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); - } - } - - 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; - case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_structure - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_structure - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 - 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_UNION_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; - case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_union - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_union - " - "NUL visitor\n" - ), -1); - } - - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_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 deleted file mode 100644 index 073ad7649aa..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp +++ /dev/null @@ -1,456 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// typedef_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Typedef in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef_ch, "$Id$") - - -// ****************************************************** -// Typedef visitor for client header -// ****************************************************** - -be_visitor_typedef_ch::be_visitor_typedef_ch (be_visitor_context *ctx) - : be_visitor_typedef (ctx) -{ -} - -be_visitor_typedef_ch::~be_visitor_typedef_ch (void) -{ -} - -int -be_visitor_typedef_ch::visit_typedef (be_typedef *node) -{ - // In general, we may have a chain of typedefs. i.e., - // typedef sequence<long> X; - // typedef X Y; - // typedef Y Z; and so on - // The first time we will be in will be for node Z for which the code - // generation has to take place. However, it is not enough to just generate - // code that looks like - - // typedef Y Z; - // For different types (in this case we have a sequence), we will need - // typedefs for the _var and _out types for Z. If it had been an array, we - // will additionally have the _forany type as well as inlined *_alloc, _dup, - // and _free methods. - // - // Finally, we need to differentiate between the case where we were - // generating code for - // typedef sequence<long> X; and - // typedef Y Z; where Y was somehow aliased to the sequence. In the former - // case, we will need to generate all the code for sequence<long> or whatever - // the type maybe. In the latter, we just need typedefs for the type and all - // associated _var, _out, and other types. - - be_type *bt; // base type - - if (this->ctx_->tdef ()) - { - // 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 - - this->ctx_->alias (node); // save this alias - - // 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); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ch::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - this->ctx_->alias (0); // reset - } - 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 - - // 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); - } - - // accept on this base type, but generate code for the typedef node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ch::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - - // generate the typecode decl for this typedef node - if (!node->imported ()) - { - // 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_DECL); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ch::" - "visit_typedef - " - "TypeCode declaration failed\n" - ), -1); - } - - - } - this->ctx_->tdef (0); // reset - } - - return 0; -} - -int -be_visitor_typedef_ch::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - be_type *bt; - - // is the base type an alias to an array node or an actual array node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - // is our base type an array node. If so, generate code for that array node - if (bt->node_type () == AST_Decl::NT_array) - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_array (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ch::" - "visit_array - " - "base class visitor failed \n" - ), -1); - } - } - else - { - // base type is simply an alias to an array node. Simply output the - // required typedefs - - os->indent (); - // typedef the type and the _slice type - *os << "typedef " << bt->nested_type_name (scope) - << " " << tdef->nested_type_name (scope) << ";" << be_nl; - *os << "typedef " << bt->nested_type_name (scope, "_slice") - << " " << tdef->nested_type_name (scope, "_slice") << ";" << be_nl; - // typedef the _var, _out, and _forany types - *os << "typedef " << bt->nested_type_name (scope, "_var") - << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; - *os << "typedef " << bt->nested_type_name (scope, "_out") - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - *os << "typedef " << bt->nested_type_name (scope, "_forany") - << " " << tdef->nested_type_name (scope, "_forany") << ";" << be_nl; - // the _alloc, _dup, copy, and free methods - *os << "static " << tdef->nested_type_name (scope, "_slice") << " *" - << tdef->nested_type_name (scope, "_alloc") << " (void);" << be_nl; - *os << "static " << tdef->nested_type_name (scope, "_slice") << " *" - << tdef->nested_type_name (scope, "_dup") << " (const " - << tdef->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl; - *os << "static void " << tdef->nested_type_name (scope, "_copy") << " (" - << tdef->nested_type_name (scope, "_slice") << " *_tao_to, const " - << tdef->nested_type_name (scope, "_slice") << " *_tao_from);" << be_nl; - *os << "static void " << tdef->nested_type_name (scope, "_free") << " (" - << tdef->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl; - } - return 0; -} - -int -be_visitor_typedef_ch::visit_enum (be_enum *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - 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_ch::" - "visit_enum - " - "base class visitor failed \n" - ), -1); - } - } - - // now generate the typedefs - os->indent (); - // typedef the type and the _slice type - *os << "typedef " << bt->nested_type_name (scope) - << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _out - *os << "typedef " << bt->nested_type_name (scope, "_out") - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - return 0; -} - -int -be_visitor_typedef_ch::visit_interface (be_interface *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - be_type *bt; - - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); - else - bt = node; - - // now generate the typedefs - os->indent (); - - // typedef the _ptr - *os << "typedef " << bt->nested_type_name (scope, "_ptr") - << " " << tdef->nested_type_name (scope, "_ptr") << ";" << be_nl; - - // typedef the _var - *os << "typedef " << bt->nested_type_name (scope, "_var") - << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; - - // typedef the _out - *os << "typedef " << bt->nested_type_name (scope, "_out") - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - - return 0; -} - -int -be_visitor_typedef_ch::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - be_type *bt; - - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); - else - bt = node; - - // now generate the typedefs - os->indent (); - // typedef the type - *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)) - { - // typedef the _ptr and _var - *os << "typedef " << bt->nested_type_name (scope, "_ptr") - << " " << tdef->nested_type_name (scope, "_ptr") << ";" << be_nl; - *os << "typedef " << bt->nested_type_name (scope, "_var") - << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; - } - // typedef the _out - *os << "typedef " << bt->nested_type_name (scope, "_out") - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - return 0; -} - -int -be_visitor_typedef_ch::visit_string (be_string *) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - - // now generate the typedefs - os->indent (); - // typedef the type and the _slice type - *os << "typedef char *" - << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out, and _forany types - *os << "typedef CORBA::String_var" - << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; - *os << "typedef CORBA::String_out" - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - return 0; -} - -int -be_visitor_typedef_ch::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - 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_sequence) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_sequence (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ch::" - "visit_sequence - " - "base class visitor failed \n" - ), -1); - } - } - else - { - // now generate the typedefs - os->indent (); - // typedef the type - *os << "typedef " << bt->nested_type_name (scope) - << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out types - *os << "typedef " << bt->nested_type_name (scope, "_var") - << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; - *os << "typedef " << bt->nested_type_name (scope, "_out") - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - } - return 0; -} - -int -be_visitor_typedef_ch::visit_structure (be_structure *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - 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_struct) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_structure (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ch::" - "visit_structure - " - "base class visitor failed \n" - ), -1); - } - } - - // now generate the typedefs - os->indent (); - // typedef the type - *os << "typedef " << bt->nested_type_name (scope) - << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out types - *os << "typedef " << bt->nested_type_name (scope, "_var") - << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; - *os << "typedef " << bt->nested_type_name (scope, "_out") - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - return 0; -} - -int -be_visitor_typedef_ch::visit_union (be_union *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef node - be_decl *scope = this->ctx_->scope (); // scope in which it is used - 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_union) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ch::" - "visit_union - " - "base class visitor failed \n" - ), -1); - } - } - - // now generate the typedefs - os->indent (); - // typedef the type and the _slice type - *os << "typedef " << bt->nested_type_name (scope) - << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out types - *os << "typedef " << bt->nested_type_name (scope, "_var") - << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; - *os << "typedef " << bt->nested_type_name (scope, "_out") - << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl; - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ci.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ci.cpp deleted file mode 100644 index de9c0463431..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ci.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// typedef_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Typedefs in the client inline file. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef_ci, "$Id$") - - -// ****************************************************** -// Typedef visitor for client inline -// ****************************************************** - -be_visitor_typedef_ci::be_visitor_typedef_ci (be_visitor_context *ctx) - : be_visitor_typedef (ctx) -{ -} - -be_visitor_typedef_ci::~be_visitor_typedef_ci (void) -{ -} - -int -be_visitor_typedef_ci::visit_typedef (be_typedef *node) -{ - // In general, we may have a chain of typedefs. i.e., - // typedef sequence<long> X; - // typedef X Y; - // typedef Y Z; and so on - // The first time we will be in will be for node Z for which the code - // generation has to take place. However, it is not enough to just generate - // code that looks like - - // typedef Y Z; - // For different types (in this case we have a sequence), we will need - // typedefs for the _var and _out types for Z. If it had been an array, we - // will additionally have the _forany type as well as inlined *_alloc - // methods. - // - // Finally, we need to differentiate between the case where we were - // generating code for - // typedef sequence<long> X; and - // typedef Y Z; where Y was somehow aliased to the sequence. In the former - // case, we will need to generate all the code for sequence<long> or whatever - // the type maybe. In the latter, we just need typedefs for the type and all - // associated _var, _out, and other types. - - be_type *bt; // base type - - if (this->ctx_->tdef ()) - { - // 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 - - this->ctx_->alias (node); // save this alias - - // 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); - } - // 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); - } - - 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 - - // 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); - } - // 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); - } - - this->ctx_->tdef (0); - } - return 0; -} - -int -be_visitor_typedef_ci::visit_array (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_typedef *tdef = this->ctx_->tdef (); // typedef 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_array) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_array (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ci::" - "visit_array - " - "base class visitor failed \n" - ), -1); - } - } - else - { - // generate the inline code for alloc, dup, copy, and free methods - - // alloc method - os->indent (); - *os << "ACE_INLINE " << tdef->name () << "_slice *" << be_nl; - *os << tdef->name () << "_alloc (void)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return " << bt->name () << "_alloc ();" << be_uidt_nl; - *os << "}\n\n"; - - // dup method - os->indent (); - *os << "ACE_INLINE " << tdef->name () << "_slice *" << be_nl; - *os << tdef->name () << "_dup (const " << tdef->name () - << "_slice *_tao_src)" << be_nl; - *os << "{" << be_idt_nl; - *os << "return " << bt->name () << "_dup (_tao_src);" << be_uidt_nl; - *os << "}\n\n"; - - // copy method - os->indent (); - *os << "ACE_INLINE void" << be_nl; - *os << tdef->name () << "_copy (" << tdef->name () - << "_slice *_tao_dest, const " << tdef->name () - << "_slice *_tao_src)" << be_nl; - *os << "{" << be_idt_nl; - *os << bt->name () << "_copy (_tao_dest, _tao_src);" << be_uidt_nl; - *os << "}\n\n"; - - // free method - os->indent (); - *os << "ACE_INLINE void" << be_nl; - *os << tdef->name () << "_free (" << tdef->name () - << "_slice *_tao_src)" << be_nl; - *os << "{" << be_idt_nl; - *os << bt->name () << "_free (_tao_src);" << be_uidt_nl; - *os << "}\n\n"; - } - return 0; -} - -int -be_visitor_typedef_ci::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_sequence) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_sequence (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ci::" - "visit_sequence - " - "base class visitor failed \n" - ), -1); - } - } - return 0; -} - -int -be_visitor_typedef_ci::visit_structure (be_structure *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_struct) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_structure (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ci::" - "visit_structure - " - "base class visitor failed \n" - ), -1); - } - } - return 0; -} - -int -be_visitor_typedef_ci::visit_union (be_union *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_union) // direct typedef of a base node - // type - { - // let the base class visitor handle this case - if (this->be_visitor_typedef::visit_union (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_ci::" - "visit_union - " - "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 deleted file mode 100644 index 1efcfa25292..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// typedef_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Typedef in the client stubs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_typedef.h" - -ACE_RCSID(be_visitor_typedef, typedef_cs, "$Id$") - - -// ****************************************************** -// Typedef visitor for client stubs -// ****************************************************** - -be_visitor_typedef_cs::be_visitor_typedef_cs (be_visitor_context *ctx) - : be_visitor_typedef (ctx) -{ -} - -be_visitor_typedef_cs::~be_visitor_typedef_cs (void) -{ -} - -int -be_visitor_typedef_cs::visit_typedef (be_typedef *node) -{ - // In general, we may have a chain of typedefs. i.e., - // typedef sequence<long> X; - // typedef X Y; - // typedef Y Z; and so on - // The first time we will be in will be for node Z for which the code - // generation has to take place. However, it is not enough to just generate - // code that looks like - - // typedef Y Z; - // For different types (in this case we have a sequence), we will need - // typedefs for the _var and _out types for Z. If it had been an array, we - // will additionally have the _forany type as well as inlined *_alloc - // methods. - // - // Finally, we need to differentiate between the case where we were - // generating code for - // typedef sequence<long> X; and - // typedef Y Z; where Y was somehow aliased to the sequence. In the former - // case, we will need to generate all the code for sequence<long> or whatever - // the type maybe. In the latter, we just need typedefs for the type and all - // associated _var, _out, and other types. - - be_type *bt; // base type - - if (this->ctx_->tdef ()) - { - // 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 - - this->ctx_->alias (node); // save this alias - - // 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); - } - // 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); - } - 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 - - // 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); - } - // 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); - } - - if (!node->imported ()) - { - // 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); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef_cs::" - "visit_typedef - " - "TypeCode definition failed\n" - ), -1); - } - - } - this->ctx_->tdef (0); - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_union.cpp b/TAO/TAO_IDL/be/be_visitor_union.cpp deleted file mode 100644 index 0aa88dff8b8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_union.cpp -// -// = DESCRIPTION -// Visitors for generation of code for Union -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.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" -#include "be_visitor_union/union.cpp" -#include "be_visitor_union/union_ch.cpp" -#include "be_visitor_union/union_ci.cpp" -#include "be_visitor_union/union_cs.cpp" -#include "be_visitor_union/any_op_ch.cpp" -#include "be_visitor_union/any_op_cs.cpp" -#include "be_visitor_union/cdr_op_ch.cpp" -#include "be_visitor_union/cdr_op_cs.cpp" - -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 deleted file mode 100644 index f743a905db8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/any_op_ch.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for Union. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, any_op_ch, "$Id$") - - -// *************************************************************************** -// Union visitor for generating Any operator declarations in the client header -// *************************************************************************** - -be_visitor_union_any_op_ch::be_visitor_union_any_op_ch -(be_visitor_context *ctx) - : be_visitor_union (ctx) -{ -} - -be_visitor_union_any_op_ch::~be_visitor_union_any_op_ch (void) -{ -} - -int -be_visitor_union_any_op_ch::visit_union (be_union *node) -{ - if (node->cli_hdr_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - os->indent (); - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, const " << node->name () - << " &); // copying version" << be_nl; - *os << "void " << idl_global->export_macro () - << " operator<<= (CORBA::Any &, " << node->name () - << "*); // noncopying version" << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>>= (const CORBA::Any &, " - << 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, - "(%N:%l) be_visitor_union::visit_union - " - "codegen for scope failed\n"), -1); - } - - node->cli_hdr_any_op_gen (1); - return 0; -} - -int -be_visitor_union_any_op_ch::visit_union_branch (be_union_branch *node) -{ - be_type *bt; // field's type - - // 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_any_op_ch::" - "visit_union_branch - " - "Bad field type\n" - ), -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_any_op_ch::" - "visit_field - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} 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 deleted file mode 100644 index c2c762b19ef..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// any_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Any operators for Union. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, any_op_cs, "$Id$") - - -// *************************************************************************** -// Union visitor for generating Any operator declarations in the client -// stubs file -// *************************************************************************** - -be_visitor_union_any_op_cs::be_visitor_union_any_op_cs -(be_visitor_context *ctx) - : be_visitor_union (ctx) -{ -} - -be_visitor_union_any_op_cs::~be_visitor_union_any_op_cs (void) -{ -} - -int -be_visitor_union_any_op_cs::visit_union (be_union *node) -{ - if (node->cli_stub_any_op_gen () || node->imported ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the Any <<= and >>= operator declarations - os->indent (); - *os << "void operator<<= (CORBA::Any &_tao_any, const " - << node->name () << " &_tao_elem) // copying" << be_nl - << "{" << be_idt_nl - << node->name () << " *_any_val;" << be_nl - << "ACE_NEW (_any_val, " << node->name () << " (_tao_elem));" << be_nl - << "if (!_any_val) return;" << be_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () - << ", _any_val, 1, TAO_TRY_ENV);" << " // copy the value" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _any_val;" << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->name () << " *_tao_elem) // non copying" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "_tao_any.replace (" << node->tc_name () << ", " - << "_tao_elem, 1, TAO_TRY_ENV); // consume it" << be_nl - << "TAO_CHECK_ENV;" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY {}" << be_nl - << "TAO_ENDTRY;" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << " *&_tao_elem)" << be_nl - << "{" << be_idt_nl - << "TAO_TRY" << be_nl - << "{" << be_idt_nl - << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl - << "if (!type->equal (" << node->tc_name () - << ", TAO_TRY_ENV)) return 0; // not equal" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "if (_tao_any.any_owns_data ())" << be_nl - << "{" << be_idt_nl - << "_tao_elem = (" << node->name () << " *)_tao_any.value ();" - << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // else any does not own the data - << "{" << be_idt_nl - << "ACE_NEW_RETURN (_tao_elem, " << node->name () << ", 0);" - << be_nl - << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any._tao_get_cdr ());" - << be_nl - << "if (stream.decode (" << node->tc_name () - << ", _tao_elem, 0, TAO_TRY_ENV)" << be_nl - << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl - << "{" << be_idt_nl - << "((CORBA::Any *)&_tao_any)->replace (" - << node->tc_name () << ", _tao_elem, 1, TAO_TRY_ENV);" << be_nl - << "TAO_CHECK_ENV;" << be_nl - << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl - << "{" << be_idt_nl - << "delete _tao_elem;" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_uidt_nl - << "}" << be_nl - << "TAO_CATCHANY" << be_nl - << "{" << be_idt_nl - << "delete _tao_elem;" << be_nl - << "return 0; " << be_uidt_nl - << "}" << be_nl - << "TAO_ENDTRY;" << be_nl - << "return 0;" << be_uidt_nl - << "}\n\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, - "(%N:%l) be_visitor_union::visit_union - " - "codegen for scope failed\n"), -1); - } - - node->cli_stub_any_op_gen (1); - return 0; -} - -int -be_visitor_union_any_op_cs::visit_union_branch (be_union_branch *node) -{ - be_type *bt; // field's type - - // 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_any_op_cs::" - "visit_union_branch - " - "Bad field type\n" - ), -1); - } - - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_any_op_cs::" - "visit_union_branch - " - "codegen for field type failed\n" - ), -1); - } - return 0; -} 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 deleted file mode 100644 index 2e970cebac2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ch.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for unions. This uses -// compiled marshaling. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -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 (ctx) -{ -} - -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 ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // generate the CDR << and >> operator declarations - os->indent (); - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator<< (TAO_OutputCDR &, const " << node->name () - << " &); // " << be_nl; - *os << "CORBA::Boolean " << idl_global->export_macro () - << " operator>> (TAO_InputCDR &, " - << node->name () << " &);\n"; - - - // set the substate as generating code for the types defined in our scope - this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE); - // all we have to do is to visit the scope and generate code - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cdr_op_ch::" - "visit_union - " - "codegen for scope failed\n"), -1); - } - - - node->cli_hdr_cdr_op_gen (1); - return 0; -} - 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 deleted file mode 100644 index 48fdbbf9fc8..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for CDR operators for unions -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -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 (ctx) -{ -} - -be_visitor_union_cdr_op_cs::~be_visitor_union_cdr_op_cs (void) -{ -} - -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 ()) - return 0; - - TAO_OutStream *os = this->ctx_->stream (); - - // 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_union)" << be_nl - << "{" << be_idt_nl - << "return 1;" << be_uidt_nl - << "}\n\n"; -#if 0 /* TO-DO */ - << "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_union_cdr_op_cs::" - "visit_union - " - "codegen for scope failed\n"), -1); - } - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; -#endif - - // 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_union)" << be_nl - << "{" << be_idt_nl - << "return 1;" << be_uidt_nl - << "}\n\n"; - -#if 0 /* TO-DO */ - << "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_union_cdr_op_cs" - "::visit_union - " - "codegen for scope failed\n"), -1); - } - *os << be_uidt_nl << ")" - << be_idt_nl - << "return 1;" << be_uidt_nl - << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; -#endif - - // 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); - } - - node->cli_stub_cdr_op_gen (1); - return 0; -} - -int -be_visitor_union_cdr_op_cs::post_process (be_decl *bd) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (!this->last_node (bd)) - { - switch (this->ctx_->sub_state ()) - { - case TAO_CodeGen::TAO_CDR_OUTPUT: - case TAO_CodeGen::TAO_CDR_INPUT: - *os << " &&" << be_nl; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - default: - break; - }; - } - - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp deleted file mode 100644 index 66c3002b440..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// discriminant_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for discriminant of the Union -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, discriminant_ch, "$Id$") - - -// ************************************************************************* -// be_visitor_discriminant_ch - visitor for discriminant in client header file -// ************************************************************************* - -be_visitor_union_discriminant_ch::be_visitor_union_discriminant_ch -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_union_discriminant_ch::~be_visitor_union_discriminant_ch (void) -{ -} - -int -be_visitor_union_discriminant_ch::visit_enum (be_enum *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 (); - else - bt = node; - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_discriminant_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_discriminant_ch::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - os->indent (); - // the set method - *os << "void _d (" << bt->nested_type_name (bu) << ");" << be_nl; - // the get method - *os << bt->nested_type_name (bu) << " _d (void) const;\n\n"; - return 0; -} - -int -be_visitor_union_discriminant_ch::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 (); - else - bt = node; - - os = this->ctx_->stream (); - - os->indent (); - // the set method - *os << "void _d (" << bt->nested_type_name (bu) << ");" << be_nl; - // the get method - *os << bt->nested_type_name (bu) << " _d (void) const;\n\n"; - return 0; -} - -int -be_visitor_union_discriminant_ch::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_discriminant_ch::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - this->ctx_->alias (0); - return 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 deleted file mode 100644 index cfee3582b2f..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// discriminant_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for discriminant of the union. -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -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_decl (ctx) -{ -} - -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 - 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; - - os = this->ctx_->stream (); - - os->indent (); - // the set method - *os << "// accessor to set the discriminant" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::_d (" << bt->name () - << " discval)" << be_nl - << "{" << be_idt_nl - << "this->disc_ = discval;" << be_uidt_nl - << "}" << be_nl; - - // 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_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 (); - else - bt = node; - - os = this->ctx_->stream (); - - os->indent (); - // the set method - *os << "// accessor to set the discriminant" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::_d (" << bt->name () - << " discval)" << be_nl - << "{" << be_idt_nl - << "this->disc_ = discval;" << be_uidt_nl - << "}" << be_nl; - - // 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 - - // 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); - } - 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 deleted file mode 100644 index 79f75f66a28..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// discriminant_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for discriminant of the union -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, discriminant_cs, "$Id$") - - -// ************************************************************************* -// be_visitor_discriminant_cs - visitor for discriminant in client stubs -// ************************************************************************* - -be_visitor_union_discriminant_cs::be_visitor_union_discriminant_cs -(be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -be_visitor_union_discriminant_cs::~be_visitor_union_discriminant_cs (void) -{ -} - -int -be_visitor_union_discriminant_cs::visit_enum (be_enum *node) -{ - 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 (); - else - bt = node; - - 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 - - // 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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_discriminant_cs::" - "visit_enum - " - "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 deleted file mode 100644 index 1af46336cfe..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/union.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// union.cpp -// -// = DESCRIPTION -// Generic visitor generating code for Unions -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#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) -{ -} - -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 -} - -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 - 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_UNION_PUBLIC_CH: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); - break; - case TAO_CodeGen::TAO_UNION_PRIVATE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); - break; - case TAO_CodeGen::TAO_UNION_PUBLIC_CI: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CI); - break; - case TAO_CodeGen::TAO_UNION_PUBLIC_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); - break; - case TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); - 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; - case TAO_CodeGen::TAO_UNION_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_UNION_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CS); - break; - default: - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union::" - "visit_union_branch - " - "Bad context state\n" - ), -1); - } - } - - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union::" - "visit_union_branch - " - "NUL 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 deleted file mode 100644 index 0fd71f3ad11..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// union_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Unions in the client header -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, union_ch, "$Id$") - - -// ****************************************************** -// for client header -// ****************************************************** - -be_visitor_union_ch::be_visitor_union_ch (be_visitor_context *ctx) - : be_visitor_union (ctx) -{ -} - -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; // 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 - - - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported - { - os = this->ctx_->stream (); - - // generate the ifdefined macro for the union type - os->gen_ifdef_macro (node->flatname ()); - os->indent (); // start with the current indentation level - *os << "class " << idl_global->export_macro () << " " - << node->local_name () << ": public TAO_Base_Union " << be_nl - << "{" << be_nl - << "public:" << be_idt_nl - - // generate default and copy constructors - << node->local_name () << " (void); // default constructor" << be_nl - << node->local_name () << " (const " << node->local_name () - << " &); // copy constructor" << be_nl - // generate destructor - << "~" << node->local_name () << " (void); // destructor" << be_nl - // generate assignment operator - << node->local_name () << " &operator= (const " - << node->local_name () << " &); // copy constructor\n\n"; - - // retrieve the disriminant type - bt = be_type::narrow_from_decl (node->disc_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "bad disciminant type\n"), -1); - } - - // the discriminant type may have to be defined here if it was an enum - // declaration inside of the union statement. - - ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CH); // 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_ch::" - "visit_union - " - "bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - " visit_union - " - "codegen for discriminant failed\n"), -1); - } - delete visitor; - - // 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); // set current code - // gen state - 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 private data members of the union - os->decr_indent (); - *os << "private:\n"; - os->incr_indent (); - *os << bt->nested_type_name (node) << " disc_;" << be_nl; // emit the - // ACE_NESTED_CLASS macro - - // the members are inside of a union - *os << "union" << be_nl; - *os << "{\n"; - os->incr_indent (0); - this->ctx_->state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); // set current - // code gen state - 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); - } - - os->decr_indent (); - *os << "} u_; // end of union" << be_nl; - - // the reset method (TAO extension) - *os << "// TAO extensions" << be_nl; - *os << "void _reset (" << bt->nested_type_name (node) - << ", CORBA::Boolean);" << be_nl; - *os << "// Frees any allocated storage" << be_nl << be_nl; - // the virtual overloaded _discriminant method - *os << "virtual void *_discriminant (void);" << be_nl; - *os << "// returns pointer to the discriminant" << be_nl << be_nl; - // the overloaded virtual reset method - *os << "virtual void _reset (void);" << be_nl; - *os << "// calls the above reset with finalize=1" << be_nl << be_nl; - // the _access method - *os << "virtual void *_access (CORBA::Boolean flag);" << be_nl; - *os << "// accesses the right data member. " - << "Also will allocate on TRUE flag" << be_nl << be_uidt_nl; - *os << "}; // " << node->name () << "\n\n"; - - // 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 - 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_union_ch::" - "visit_union - " - "TypeCode declaration failed\n" - ), -1); - } - - - os->gen_endif (); - - // generate the ifdefined macro for the _var type - os->gen_ifdef_macro (node->flatname (), "_var"); - // generate var defn - 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->flatname (), "_out"); - // 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 - { - os->indent (); - *os << "typedef " << node->local_name () << " &" << node->local_name - () << "_out;\n\n"; - } - 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 deleted file mode 100644 index 8790e6a339b..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// union_ci.cpp -// -// = DESCRIPTION -// Visitor generating code for Union in the client inline file -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, union_ci, "$Id$") - - -// ****************************************************** -// for client inline -// ****************************************************** - -be_visitor_union_ci::be_visitor_union_ci (be_visitor_context *ctx) - : be_visitor_union (ctx) -{ -} - -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 - - - if (!node->cli_inline_gen () && !node->imported ()) - { - os = this->ctx_->stream (); - - *os << "// *************************************************************" - << be_nl; - *os << "// Inline operations for union " << node->name () << be_nl; - *os << "// *************************************************************\n\n"; - - // generate the default constructor and the destructor here - os->indent (); - *os << "// destructor" << be_nl - << "ACE_INLINE" << 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; - - // the virtual overloaded _reset method - *os << "// this reset method is used by the decoding engine" << be_nl; - *os << "ACE_INLINE void" << be_nl - << node->name () << "::_reset (void)" << be_nl - << "{" << be_idt_nl - << "this->_reset (this->disc_, 1);" << be_nl - << "ACE_OS::memcpy (&this->u_, 0, sizeof (this->u_));" << be_uidt_nl - << "}" << be_nl << be_nl; - - // the virtual overloaded _discriminant method - *os << "// returns pointer to the discriminant" << be_nl; - *os << "ACE_INLINE void *" << be_nl - << node->name () << "::_discriminant (void)" << be_nl - << "{" << be_idt_nl - << "return &this->disc_;" << be_uidt_nl - << "}\n\n"; - - // 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 ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ci::" - "visit_union - " - "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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ci::" - "visit union - " - "codegen for discrminant failed\n"), -1); - } - - // 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); - } - - // generate the ifdefined macro for the array type - os->gen_ifdef_macro (node->flatname (), "_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); - } - os->gen_endif (); - - // generate the ifdefined macro for the array type then generate the _out - // impl - os->gen_ifdef_macro (node->flatname (), "_out"); - if (node->size_type () == be_decl::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); - } - 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 deleted file mode 100644 index 87a6b5285ca..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// union_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Unions in the client stubs -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union.h" - -ACE_RCSID(be_visitor_union, union_cs, "$Id$") - - -// ****************************************************** -// for client stubs -// ****************************************************** - -be_visitor_union_cs::be_visitor_union_cs (be_visitor_context *ctx) - : be_visitor_union (ctx) -{ -} - -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; // output stream - be_type *bt; // for discriminant type - - 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); - } - - ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CS); // 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_cs::" - "visit_union - " - "bad visitor\n"), -1); - } - // generate code for the discriminant - if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs::" - "visit union - " - "codegen for discrminant failed\n"), -1); - } - - // 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); // set current code - // gen state - 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; - *os << "// *************************************************************\n\n"; - - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); - - // generate the copy constructor and the assignment operator here - os->indent (); - *os << "// default constructor" << be_nl - << node->name () << "::" << node->local_name () << " (void)" << be_nl - << " : TAO_Base_Union ()" << 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_uidt_nl - << "}" << be_nl << be_nl; - - *os << "// copy constructor" << be_nl; - *os << node->name () << "::" << node->local_name () << " (const " << - node->name () << " &u)" << be_nl; - *os << "{" << be_idt_nl; - // first reset and set the discriminant - *os << "this->_reset (u.disc_, 0);" << be_nl; - *os << "this->disc_ = u.disc_;" << be_nl; - // now switch based on the disc value - *os << "switch (this->disc_)" << be_nl; - *os << "{\n"; - os->incr_indent (0); - 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); - } - - os->decr_indent (); - *os << "}\n"; - os->decr_indent (); - *os << "}\n\n"; - - // assignment operator - os->indent (); - *os << "// assignment operator" << be_nl; - *os << node->name () << " &" << be_nl; // return type - *os << node->name () << "::operator= (const " << - node->name () << " &u)" << be_nl; - *os << "{\n"; - os->incr_indent (); - // first reset and set the discriminant - *os << "this->_reset (u.disc_, 0);" << be_nl; - *os << "this->disc_ = u.disc_;" << be_nl; - // now switch based on the disc value - *os << "switch (this->disc_)" << be_nl; - *os << "{\n"; - os->incr_indent (0); - 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->decr_indent (); - *os << "}" << be_nl; - *os << "return *this;\n"; - os->decr_indent (); - *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 () - << " new_disc_val, CORBA::Boolean finalize)" << be_nl; - *os << "{" << be_idt_nl; - *os << "if ((this->disc_ != new_disc_val) || 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 - << "}" << be_uidt_nl - << "}\n\n"; - - // the access method - os->indent (); - *os << "// the virtual overloaded access method" << be_nl; - *os << "void *" << node->name () << "::_access (" - << " CORBA::Boolean alloc_flag)" << be_nl; - *os << "{" << be_idt_nl; - *os << "switch (this->disc_)" << be_nl; - *os << "{" << be_idt_nl; - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ACCESS_CS); - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_cs" - "visit_union - " - "codegen for access failed\n"), -1); - } - - *os << be_uidt_nl << "}" << be_nl; - *os << "return 0; // default" << be_uidt_nl - << "}\n\n"; - - - // 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 - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -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); - } - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch.cpp deleted file mode 100644 index 5cb1335b6ce..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// $Id$ -// -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// be_visitor_union_branch.cpp -// -// = DESCRIPTION -// Concrete visitor for the base "BE_Union_Branch" node -// -// = AUTHOR -// Aniruddha Gokhale -// -// ============================================================================ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_union_branch.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" -#include "be_visitor_union_branch/cdr_op_ch.cpp" -#include "be_visitor_union_branch/cdr_op_cs.cpp" - -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 deleted file mode 100644 index 74108181d13..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp +++ /dev/null @@ -1,295 +0,0 @@ - -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// cdr_op_ch.cpp -// -// = DESCRIPTION -// Visitor generating CDR operator declarator for union_branch in the client header -// -// = 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, cdr_op_ch, "$Id$") - - -// ********************************************** -// 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_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); - } - - this->ctx_->node (node); // save the 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); - } - - return 0; -} - -// =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 (!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 - 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_array - " - "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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_enum - " - "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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_sequence - " - "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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_struct - " - "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); - } - 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 - && 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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - return 0; -} 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 deleted file mode 100644 index c2bf43934a2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp +++ /dev/null @@ -1,645 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// union_branch_cdr_op_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Union_Branch in the client stubs 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, cdr_op_cs, "$Id$") - - -// ********************************************** -// 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_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); - } - - this->ctx_->node (node); // save the 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); - } - return 0; -} - -// visit array -int -be_visitor_union_branch_cdr_op_cs::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_array - " - "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 << "(strm >> _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef - && node->is_child (this->ctx_->scope ())) - { - // this is the case for anonymous arrays. - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the declaration - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_array - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit enum type -int -be_visitor_union_branch_cdr_op_cs::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_array - " - "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 << "(strm >> _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_enum - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the typcode for enums - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_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; -} - -// visit interface type -int -be_visitor_union_branch_cdr_op_cs::visit_interface (be_interface *) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_interface - " - "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 << "(strm >> _tao_union." << f->local_name () << ".out ())"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ".in ())"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an interface cannit be declared inside a - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_interface - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit interface forward type -int -be_visitor_union_branch_cdr_op_cs::visit_interface_fwd (be_interface_fwd *) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_interface_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 << "(strm >> _tao_union." << f->local_name () << ").out ()"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ").in ()"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an interface cannit be declared inside a - // structure - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_interface_fwd - " - "bad sub state\n" - ), -1); - } - return 0; -} - -// visit predefined type -int -be_visitor_union_branch_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_predefined_type - " - "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: - // is a psuedo obj - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm >> _tao_union." << f->local_name () << ".out ())"; - else - *os << "(strm >> _tao_union." << f->local_name () << ")"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - // is a psuedo obj - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm << _tao_union." << f->local_name () << ".in ())"; - else - *os << "(strm << _tao_union." << f->local_name () << ")"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - return 0; -} - -int -be_visitor_union_branch_cdr_op_cs::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_sequence - " - "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 << "(strm >> _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_sequence - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef - && node->is_child (this->ctx_->scope ())) - // not a typedef AND - // node is defined inside the structure - { - // Anonymous sequence - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - return 0; -} - -// visit string type -int -be_visitor_union_branch_cdr_op_cs::visit_string (be_string *) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_string - " - "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 << "(strm >> _tao_union." << f->local_name () << ".out ())"; - break; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ".in ())"; - break; - case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_array - " - "bad sub state\n" - ), -1); - } - - return 0; -} - -// visit structure type -int -be_visitor_union_branch_cdr_op_cs::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_structure - " - "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 << "(strm >> _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_structure - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_struct - " - "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 - - // the node to be visited in the base primitve type that gets typedefed - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_union_branch_cdr_op_cs::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - 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_cs::" - "visit_union - " - "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 << "(strm >> _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_OUTPUT: - *os << "(strm << _tao_union." << f->local_name () << ")"; - return 0; - case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further - break; - default: - // error - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_union - " - "bad sub state\n" - ), -1); - } - - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_union - " - "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 deleted file mode 100644 index 6c98c9b7dc2..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp +++ /dev/null @@ -1,409 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// private_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Union branch for the private part of the -// class. -// -// = 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, 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_decl (ctx) -{ -} - -// destructor -be_visitor_union_branch_private_ch::~be_visitor_union_branch_private_ch (void) -{ -} - -// visit the union_branch node -int -be_visitor_union_branch_private_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_private_ch::" - "visit_union_branch - " - "Bad union_branch type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "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_private_ch::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_array - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // case of anonymous array in union - os->indent (); - *os << "_" << bt->local_name () << "_slice *" << ub->local_name () - << "_;\n"; - } - else - { - os->indent (); - *os << bt->nested_type_name (bu, "_slice") << " *" << ub->local_name () - << "_;\n"; - } - - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_enum - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - *os << bt->nested_type_name (bu) << " " << ub->local_name () << "_;\n"; - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_interface - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // C++ does not allow an object declaration inside a union. Hence we - // must have a pointer. This changes some of the methods. - // We use TAO_Object_Field_T<> so that _upcast() and _downcast() will work. - *os << "TAO_Object_Field_T<" << bt->nested_type_name (bu, "") - << "> *" << ub->local_name () << "_;\n"; - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_interface_fwd - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // C++ does not allow an object declaration inside a union. Hence we - // must have a pointer. This changes some of the methods. - // We use TAO_Object_Field_T<> so that _upcast() and _downcast() will work. - *os << "TAO_Object_Field_T<" << bt->nested_type_name (bu, "") - << "> *" << ub->local_name () << "_;\n"; - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_predefined_type - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (node->pt () == AST_PredefinedType::PT_pseudo) - { - // Cannot have an object inside of a union - os->indent (); // start from current indentation - *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () << - "_;\n"; - } - else if (node->pt () == AST_PredefinedType::PT_any) - { - // Cannot have an object inside of a union. In addition, an Any is a - // variable data type - os->indent (); // start from current indentation - *os << bt->nested_type_name (bu) << " *" << ub->local_name () << - "_;\n"; - } - else - { - os->indent (); // start from current indentation - *os << bt->nested_type_name (bu) << " " << ub->local_name () << - "_;\n"; - } - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_sequence - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); - // C++ doesn't allow object instances inside unions, so we need a - // pointer - *os << bt->nested_type_name (bu) << " *" << ub->local_name () << "_;\n"; - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_string (be_string *) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_string - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); - *os << "char *" << ub->local_name () << "_;\n"; - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_structure - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); - - // if we are variable sized, we need a pointer type - if (node->size_type () == be_type::VARIABLE) - { - *os << bt->nested_type_name (bu) << " *" << ub->local_name () << "_;\n"; - } - else - { - *os << bt->nested_type_name (bu) << " " << ub->local_name () << "_;\n"; - } - - return 0; -} - -int -be_visitor_union_branch_private_ch::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_private_ch::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_union_branch_private_ch::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_private_ch::" - "visit_union - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); - // C++ doesn't allow instances of classes - *os << bt->nested_type_name (bu) << " *" << ub->local_name () << "_;\n"; - return 0; -} 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 892d4eab0d7..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_access_cs.cpp +++ /dev/null @@ -1,417 +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 - - if (node->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "case " << node->label ()->label_val ()->n () << ":" << be_idt_nl; - } - else - { - *os << "case " << node->label ()->label_val () << ":" << be_idt_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->fullname (), - bt->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", bt->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->fullname ()); - } - - os = this->ctx_->stream (); - *os << "if (alloc_flag)" << be_idt_nl; - *os << "this->u_." << ub->local_name () << "_ = " << fname - << "_alloc ();" << be_uidt_nl; - *os << "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 << "return &this->u_." << ub->local_name () << "_;" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_access_cs::visit_interface (be_interface *) -{ - 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 << "return (CORBA::Object_ptr *) &this->u_." << ub->local_name () - << "_->inout ();" << 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 << "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 << "return &this->u_." << ub->local_name () << "_;" << be_uidt_nl; - break; - case AST_PredefinedType::PT_any: - *os << "if (alloc_flag)" << be_idt_nl; - *os << "this->u_." << ub->local_name () << "_ = new " << bt->name () - << ";" << be_uidt_nl; - *os << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - break; - case AST_PredefinedType::PT_void: - break; - default: - *os << "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; - *os << "this->u_." << ub->local_name () << "_ = new " << bt->name () - << ";" << be_uidt_nl; - *os << "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 << "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) - { - *os << "if (alloc_flag)" << be_idt_nl; - *os << "this->u_." << ub->local_name () << "_ = new " << bt->name () - << ";" << be_uidt_nl; - *os << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - } - else - { - *os << "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; - *os << "this->u_." << ub->local_name () << "_ = new " << bt->name () - << ";" << be_uidt_nl; - *os << "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 deleted file mode 100644 index 41073c58db3..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp +++ /dev/null @@ -1,624 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// public_assign_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Union Branch for the assignment operator -// -// = 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_assign_cs, "$Id$") - - -// ********************************************** -// visitor for union_branch in the client stubs file generating the code for -// the copy ctor and assignment operator -// ********************************************** - -// constructor -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) -{ -} - -// visit the union_branch node -int -be_visitor_union_branch_public_assign_cs::visit_union_branch (be_union_branch *node) -{ - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - - TAO_OutStream *os = this->ctx_->stream (); - - // This visitor is used when we are generating the copy ctor and - // assignment operator for the union. - // Individual assignment of the members takes place inside a case - // statement because the type of member assigned is based on the value - // of the discriminant - os->indent (); - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "case " << ub->label ()->label_val ()->n () << ":" << be_nl; - *os << "{" << be_idt << "\n"; - } - else - { - *os << "case " << ub->label ()->label_val () << ":" << be_nl; - *os << "{" << be_idt << "\n"; - } - - // 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_union_branch_public_assign_cs::" - "visit_union_branch - " - "Bad union_branch type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_assign_cs::" - "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); - } - *os << "}" << be_nl; - *os << "break;\n"; - return 0; -} - -// =visit operations on all possible data types that a union_branch can be - -int -be_visitor_union_branch_public_assign_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_assign_cs::" - "visit_array - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // for anonymous arrays, the type name has a _ prepended. We compute the - // fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - - if (bt->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (bt->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - bt->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", bt->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->fullname ()); - } - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free " - << "it on an assignment" << be_nl; - *os << fname << "_var " << ub->local_name () - << "_var (this->u_." << ub->local_name () << "_);" << be_nl; - *os << "// make a deep copy" << be_nl; - *os << ub->local_name () << "_var = " << fname - << "_dup (u.u_." << ub->local_name () << "_);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - - return 0; -} - -int -be_visitor_union_branch_public_assign_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_assign_cs::" - "visit_enum - " - "bad context information\n" - ), -1); - } - - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the value" << be_nl - << "this->u_." << ub->local_name () << "_ = u.u_." - << ub->local_name () << "_;" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} - -int -be_visitor_union_branch_public_assign_cs::visit_interface (be_interface *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_assign_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_->ptr ());" << be_nl; - *os << "// make a copy" << be_nl; - *os << ub->local_name () << "_var = " << bt->name () - << "::_duplicate (u.u_." << ub->local_name () << "_->ptr ());" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "*this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} - -int -be_visitor_union_branch_public_assign_cs::visit_interface_fwd (be_interface_fwd *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_assign_cs::" - "visit_interface_fwd - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_->ptr ());" << be_nl; - *os << "// make a copy" << be_nl; - *os << ub->local_name () << "_var = " << bt->name () - << "::_duplicate (u.u_." << ub->local_name () << "_->ptr ());" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "*this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} - -int -be_visitor_union_branch_public_assign_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_assign_cs::" - "visit_predefined_type - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// make a copy" << be_nl; - *os << ub->local_name () << "_var = " << bt->name () - << "::_duplicate (u.u_." << ub->local_name () << "_);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - break; - case AST_PredefinedType::PT_any: - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (*u.u_." << ub->local_name () << "_);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - break; - case AST_PredefinedType::PT_void: - break; - default: - *os << "// set the value" << be_nl - << "this->u_." << ub->local_name () << "_ = u.u_." - << ub->local_name () << "_;" << be_uidt_nl; - break; - } - - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} - -int -be_visitor_union_branch_public_assign_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_assign_cs::" - "visit_array - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (*u.u_." << ub->local_name () << "_);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} - -int -be_visitor_union_branch_public_assign_cs::visit_string (be_string *) -{ - 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 - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_assign_cs::" - "visit_array - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << "CORBA::String_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// make a deep copy" << be_nl; - *os << ub->local_name () << "_var = CORBA::string_dup (u.u_." - << ub->local_name () << "_);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} - -int -be_visitor_union_branch_public_assign_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_assign_cs::" - "visit_array - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - if (bt->size_type () == be_type::VARIABLE) - { - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (*u.u_." << ub->local_name () << "_);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - *os << "// set the value" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = u.u_." - << ub->local_name () << "_;" << be_uidt_nl; - } - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} - -int -be_visitor_union_branch_public_assign_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_assign_cs::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_union_branch_public_assign_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_assign_cs::" - "visit_array - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (*u.u_." << ub->local_name () << "_);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - return 0; -} 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 deleted file mode 100644 index 847eede719c..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp +++ /dev/null @@ -1,630 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// public_ch.cpp -// -// = DESCRIPTION -// Visitor generating code for Union_branch in the public part. -// -// = 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_ch, "$Id$") - - -// ********************************************** -// 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_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) -{ - 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_ch::" - "visit_union_branch - " - "Bad union_branch type\n" - ), -1); - } - - this->ctx_->node (node); // save the node - if (bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "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 - -// visit array type -int -be_visitor_union_branch_public_ch::visit_array (be_array *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch member - be_decl *bu = this->ctx_->scope (); // get the enclosing union node - be_type *bt; - - // check if we are visiting this via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_array - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // this is the case of an anonymous array inside a union - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the array declaration - ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_array - " - "codegen failed\n" - ), -1); - } - delete visitor; - // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method - *os << "void " << ub->local_name () << " (" - << "_" << bt->local_name () << ");// set" << be_nl; - // the get method - *os << "_" << bt->local_name () << "_slice * " << ub->local_name () - << " (void) const; // get method\n\n"; - } - else - { - // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method - *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ");// set" - << be_nl; - // the get method - *os << bt->nested_type_name (bu, "_slice *") << " " << ub->local_name () - << " (void) const; // get method\n\n"; - } - - return 0; -} - -// visit enum type -int -be_visitor_union_branch_public_ch::visit_enum (be_enum *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch member - be_decl *bu = this->ctx_->scope (); // get the enclosing union node - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_enum - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // now use this enum as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method - *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ");// set" - << be_nl; - // the get method - *os << bt->nested_type_name (bu) << " " << ub->local_name () - << " (void) const; // get method\n\n"; - - return 0; -} - -// visit interface type -int -be_visitor_union_branch_public_ch::visit_interface (be_interface *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_interface - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set method - *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "_ptr") - << ");// set" << be_nl; - // get method - *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const; // get method\n\n"; - return 0; -} - -// visit interface forward type -int -be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_interface_fwd - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - // set method - *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "_ptr") - << ");// set" << be_nl; - // get method - *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const; // get method\n\n"; - return 0; -} - -// visit predefined type -int -be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_predefined_type - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); // start from current indentation - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - // set method - *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu, "_ptr") << ");// set" << be_nl; - // get method - *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const; // get method\n\n"; - break; - case AST_PredefinedType::PT_any: - // set method - *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ");// set" << be_nl; - // get method (read-only) - *os << "const " << bt->nested_type_name (bu) << " " - << ub->local_name () << " (void) const; // get method\n\n"; - // get method (read/write) - *os << bt->nested_type_name (bu) << " " - << ub->local_name () << " (void); // get method\n\n"; - break; - case AST_PredefinedType::PT_void: - break; - default: - // set method - *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ");// set" << be_nl; - // get method - *os << bt->nested_type_name (bu) << " " << ub->local_name () - << " (void) const; // get method\n\n"; - } - return 0; -} - -// visit sequence type -int -be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_sequence - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_sequence - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - os->indent (); - // set method - *os << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &);// set" << be_nl; - // read-only - *os << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const; // get method (read only)" - << be_nl; - // read/write - *os << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void); // get method (read/write only)\n\n"; - - return 0; -} - -// visit string type -int -be_visitor_union_branch_public_ch::visit_string (be_string *) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_string - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - os->indent (); - // three methods to set the string value - *os << "void " << ub->local_name () << " (char *); // set" << be_nl; - *os << "void " << ub->local_name () << " (const char *); // set" - << be_nl; - *os << "void " << ub->local_name () << " (const CORBA::String_var&); // set" - << be_nl; - //get method - *os << "const char *" << ub->local_name () - << " (void) const; // get method\n\n"; - return 0; -} - -// visit structure type -int -be_visitor_union_branch_public_ch::visit_structure (be_structure *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_structure - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_structure - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_structure - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - os->indent (); - // set method - *os << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &);// set" << be_nl - // read-only - << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const; // get method (read only)" - << be_nl - // read/write - << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void); // get method (read/write only)\n\n"; - - return 0; -} - -// visit typedefed type -int -be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) -{ - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - os->indent (); // start from current indentation level - this->ctx_->alias (node); // save the node for use in code generation and - // indicate that the union_branch of the union_branch node - // is a typedefed quantity - - // make a decision based on the primitive base type - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_spec_ch::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - this->ctx_->alias (0); - return 0; -} - -// visit union type -int -be_visitor_union_branch_public_ch::visit_union (be_union *node) -{ - TAO_OutStream *os; // output stream - be_decl *ub = this->ctx_->node (); // get union branch - be_decl *bu = this->ctx_->scope (); // get the enclosing union backend - be_type *bt; - - // check if we are visiting this node via a visit to a typedef node - if (this->ctx_->alias ()) - bt = this->ctx_->alias (); - else - bt = node; - - if (!ub || !bu) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_union - " - "bad context information\n" - ), -1); - } - - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_union - " - "Bad visitor\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->indent (); - // set method - *os << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &);// set" << be_nl - // read-only - << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const; // get method (read only)" - << be_nl - // read/write - << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void); // get method (read/write only)\n\n"; - - return 0; -} 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 deleted file mode 100644 index 366137876c4..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp +++ /dev/null @@ -1,1171 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// public_ci.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_ci, "$Id$") - - -// ***************************************************** -// visitor for union_branch in the client inline file -// ***************************************************** - -// constructor -be_visitor_union_branch_public_ci:: -be_visitor_union_branch_public_ci (be_visitor_context *ctx) - : be_visitor_decl (ctx) -{ -} - -// destructor -be_visitor_union_branch_public_ci:: -~be_visitor_union_branch_public_ci (void) -{ -} - -// visit the union_branch node -int -be_visitor_union_branch_public_ci:: -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_cs::" - "visit_union_branch - " - "Bad union_branch type\n" - ), -1); - } - - this->ctx_->node (node); // save the 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); - } - return 0; -} - -// =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) -{ - 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_ci::" - "visit_enum - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the 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); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_array - " - "codegen failed\n" - ), -1); - } - delete visitor; - } - - // for anonymous arrays, the type name has a _ prepended. We compute the - // fullname with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and - - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - - if (bt->is_nested ()) - { - be_decl *parent = be_scope::narrow_from_scope (bt->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), - bt->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", bt->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->fullname ()); - } - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () << " (" << fname - << " val)// set" << be_nl - << "{" << be_idt_nl; - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << fname << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// release old and make a deep copy" << be_nl; - *os << ub->local_name () << "_var = " << fname - << "_dup (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << "ACE_INLINE " << fname << "_slice *" << 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 << "}\n\n"; - return 0; -} - -int -be_visitor_union_branch_public_ci::visit_enum (be_enum *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_ci::" - "visit_enum - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << " val)// set" << be_nl - << "{\n"; - os->incr_indent (); - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl - << "this->u_." << ub->local_name () << "_ = val;\n"; - } - else - { - // default label - // XXXASG - TODO - } - os->decr_indent (); - *os << "}" << be_nl; - - // get method - *os << "// retrieve the member" << be_nl - << "ACE_INLINE " << bt->name () << be_nl - << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl - << "{\n"; - os->incr_indent (); - *os << "return this->u_." << ub->local_name () << "_;\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_union_branch_public_ci::visit_interface (be_interface *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_ci::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl - << "{\n"; - os->incr_indent (); - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << "if (!u_." << ub->local_name () << "_)" << be_idt_nl; - *os << "{" << be_idt_nl; - *os << "u_." << ub->local_name () << "_ = new TAO_Object_Field_T<" - << bt->nested_type_name (bu, "") << ">;" << be_uidt_nl; - *os << "}" << be_uidt_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_->ptr ());" << be_nl; - *os << "// release old storage and make a copy" << be_nl; - *os << ub->local_name () << "_var = " << bt->name () - << "::_duplicate (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "*this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << 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 - << "{\n"; - os->incr_indent (); - *os << "return this->u_." << ub->local_name () << "_->ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *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_ci::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl - << "{\n"; - os->incr_indent (); - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << "if (!u_." << ub->local_name () << "_)" << be_idt_nl; - *os << "{" << be_idt_nl; - *os << "u_." << ub->local_name () << "_ = new TAO_Object_Field_T<" - << bt->nested_type_name (bu, "") << ">;" << be_uidt_nl; - *os << "}" << be_uidt_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_->ptr ());" << be_nl; - *os << "// release old storage and make a copy" << be_nl; - *os << ub->local_name () << "_var = " << bt->name () - << "::_duplicate (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "*this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << 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 - << "{\n"; - os->incr_indent (); - *os << "return this->u_." << ub->local_name () << "_->ptr ();\n"; - os->decr_indent (); - *os << "}\n\n"; - return 0; -} - -int -be_visitor_union_branch_public_ci::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_ci::" - "visit_interface - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () << " (" << bt->name (); - if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "_ptr"; - *os << " val) // set" << be_nl - << "{" << be_idt_nl; - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// release old storage and make a copy" << be_nl; - *os << ub->local_name () << "_var = " << bt->name () - << "::_duplicate (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - break; - case AST_PredefinedType::PT_any: - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// release old and make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - break; - case AST_PredefinedType::PT_void: - break; - default: - *os << "// set the value" << be_nl - << "this->u_." << ub->local_name () << "_ = val;" << be_uidt_nl; - } - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << be_nl; - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - // get method - *os << "// retrieve the member" << be_nl - << "ACE_INLINE " << bt->name () << "_ptr" << be_nl; - *os << bu->name () << "::" << ub->local_name () - << " (void) const" << be_nl - << "{" << be_idt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\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; - *os << bu->name () << "::" << ub->local_name () - << " (void) const" << be_nl - << "{" << be_idt_nl - << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}" << be_nl; - - // get method with read/write access - *os << "// retrieve the member" << be_nl - << "ACE_INLINE " << bt->name () << be_nl; - *os << bu->name () << "::" << ub->local_name () - << " (void)" << be_nl - << "{" << be_idt_nl - << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; - break; - case AST_PredefinedType::PT_void: - break; - default: - // get method - *os << "// retrieve the member" << be_nl - << "ACE_INLINE " << bt->name () << be_nl; - *os << bu->name () << "::" << ub->local_name () - << " (void) const" << be_nl - << "{" << be_idt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; - } - return 0; -} - -int -be_visitor_union_branch_public_ci::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_ci::" - "visit_sequence - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous sequence type - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -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); - } - delete visitor; - } - - // (1) set from a const - *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 to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" - << be_nl; - } - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// release old and make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << be_nl; - - // readonly get method - *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 - << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}" << be_nl; - - // read/write get method - *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"; - - return 0; -} - -int -be_visitor_union_branch_public_ci::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_ci::" - "visit_string - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - - // three methods to set the string value - - // (1) set method from char* - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () << " (char *val)" - << be_nl - << "{" << be_idt_nl; - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << "CORBA::String_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// release old and make a deep copy" << be_nl; - *os << ub->local_name () << "_var = CORBA::string_dup (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << be_nl; - - // (2) set method from const char * - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () - << " (const char *val)" << be_nl - << "{\n"; - os->incr_indent (); - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl - << "CORBA::String_var " << ub->local_name () - << "_var (val);" << be_nl - << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - - *os << "}" << be_nl; - - // (3) set from const String_var& - *os << "// accessor to set the member" << be_nl - << "ACE_INLINE void" << be_nl - << bu->name () << "::" << ub->local_name () - << " (const CORBA::String_var &val)" << be_nl - << "{" << be_idt_nl; - // set the discriminant to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl - << "CORBA::String_var " << ub->local_name () - << "_var = val;" << be_nl - << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << be_nl; - - // get method - *os << "ACE_INLINE const char *" << be_nl - << bu->name () << "::" << ub->local_name () - << " (void) const // get method" << be_nl - << "{" << be_idt_nl - << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}\n\n"; - return 0; -} - -int -be_visitor_union_branch_public_ci::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_ci::" - "visit_structure - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_structure - " - "Bad visitor\n" - ), -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); - } - delete visitor; - } - - // (1) set from a const - *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 to the appropriate label - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" - << be_nl; - } - if (bt->size_type () == be_type::VARIABLE) - { - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// release old and make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - *os << "this->u_." << ub->local_name () << "_ = val;" << be_uidt_nl; - } - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << be_nl; - - // readonly get method - *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; - if (bt->size_type () == be_type::VARIABLE) - *os << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl; - else - *os << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - *os << "}" << be_nl; - - // read/write get method - *os << "// read/write get method " << be_nl - << "ACE_INLINE " << bt->name () << " &" << be_nl - << bu->name () << "::" << ub->local_name () << " (void)" << be_nl - << "{" << be_idt_nl; - if (bt->size_type () == be_type::VARIABLE) - *os << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl; - else - *os << "return this->u_." << ub->local_name () << "_;" << be_uidt_nl; - *os << "}\n\n"; - - return 0; -} - -int -be_visitor_union_branch_public_ci::visit_typedef (be_typedef *node) -{ - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed - be_type *bt = node->primitive_base_type (); - if (!bt || (bt->accept (this) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_typedef - " - "Bad primitive type\n" - ), -1); - } - - this->ctx_->alias (0); - return 0; -} - -int -be_visitor_union_branch_public_ci::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_ci::" - "visit_union - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration - ctx.state (TAO_CodeGen::TAO_UNION_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_union - " - "Bad visitor\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; - } - - // (1) set from a const - *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; - if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) - { - // valid label - *os << "// set the discriminant val" << be_nl; - // check if the case label is a symbol or a literal - if (ub->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "this->_reset (" << ub->label ()->label_val ()->n () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val ()->n () - << ";" << be_nl; - } - else - { - *os << "this->_reset (" << ub->label ()->label_val () - << ", 0);" << be_nl; - *os << "this->disc_ = " << ub->label ()->label_val () << ";" << - be_nl; - } - *os << "// set the value" << be_nl; - *os << "// store current val in a _var so as to free it on an assignment" - << be_nl; - *os << bt->name () << "_var " << ub->local_name () << "_var (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "// release old and make a deep copy" << be_nl; - *os << ub->local_name () << "_var = new " << bt->name () - << " (val);" << be_nl; - *os << "// the _var gives up ownership" << be_nl; - *os << "this->u_." << ub->local_name () << "_ = " - << ub->local_name () << "_var._retn ();" << be_uidt_nl; - } - else - { - // default label - // XXXASG - TODO - } - *os << "}" << be_nl; - - // readonly get method - *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 - << "return *this->u_." << ub->local_name () << "_;" << be_uidt_nl - << "}" << be_nl; - - // read/write get method - *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"; - - 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 deleted file mode 100644 index 5d8424c9b92..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// public_cs.cpp -// -// = DESCRIPTION -// Visitor generating code for Union Branch in the client stubs -// -// = 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_cs, "$Id$") - - -// ********************************************** -// 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_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); - } - - this->ctx_->node (node); // save the 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); - } - 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 - && 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 - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous array type - ctx.state (TAO_CodeGen::TAO_ARRAY_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_array - " - "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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_enum - " - "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 (!this->ctx_->alias () // not a typedef - && 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 - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous sequence type - ctx.state (TAO_CodeGen::TAO_SEQUENCE_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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_sequence - " - "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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_struct - " - "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.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) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_union - " - "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 deleted file mode 100644 index 0c3d1b7dcfc..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_reset_cs.cpp +++ /dev/null @@ -1,391 +0,0 @@ -// -// $Id$ -// - -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// public_reset_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_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) -{ -} - -// visit the union_branch node -int -be_visitor_union_branch_public_reset_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 - - if (node->label ()->label_val ()->ec () == AST_Expression::EC_symbol) - { - *os << "case " << node->label ()->label_val ()->n () << ":" << be_idt_nl; - } - else - { - *os << "case " << node->label ()->label_val () << ":" << be_idt_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_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 - 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_reset_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->fullname (), - bt->local_name ()->get_string ()); - } - else - { - ACE_OS::sprintf (fname, "_%s", bt->fullname ()); - } - } - else - { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->fullname ()); - } - - os = this->ctx_->stream (); - *os << fname << "_free (this->u_." << ub->local_name () - << "_);" << be_nl; - *os << "break;" << be_uidt_nl; - return 0; -} - -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 - 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_reset_cs::" - "visit_enum - " - "bad context information\n" - ), -1); - } - - TAO_OutStream *os = this->ctx_->stream (); - *os << "break;" << be_uidt_nl; - - return 0; -} - -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 - 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_reset_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - *os << "delete this->u_." << ub->local_name () << "_;" << be_nl; - *os << "ACE_OS::memset ((void *) &this->u_, 0, sizeof (this->u_));" << be_nl; - *os << "break;" << be_uidt_nl; - - return 0; -} - -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 - 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_reset_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - TAO_OutStream *os = this->ctx_->stream (); - *os << "delete this->u_." << ub->local_name () << "_;" << be_nl; - *os << "ACE_OS::memset ((void *) &this->u_, 0, sizeof (this->u_));" << be_nl; - *os << "break;" << be_uidt_nl; - - return 0; -} - -int -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 - 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_reset_cs::" - "visit_interface - " - "bad context information\n" - ), -1); - } - - TAO_OutStream *os = this->ctx_->stream (); - - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "CORBA::release (this->u_." - << ub->local_name () << "_);" << be_nl; - *os << "break;" << be_uidt_nl; - break; - case AST_PredefinedType::PT_any: - *os << "delete this->u_." - << ub->local_name () << "_;" << be_nl; - *os << "break;" << be_uidt_nl; - break; - case AST_PredefinedType::PT_void: - break; - default: - *os << "break;" << be_uidt_nl; - } - return 0; -} - -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 - 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_reset_cs::" - "visit_sequence - " - "bad context information\n" - ), -1); - } - - TAO_OutStream *os = this->ctx_->stream (); - *os << "delete this->u_." << ub->local_name () << "_;" << be_nl; - *os << "break;" << be_uidt_nl; - - return 0; -} - -int -be_visitor_union_branch_public_reset_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_reset_cs::" - "visit_string - " - "bad context information\n" - ), -1); - } - - TAO_OutStream *os = this->ctx_->stream (); - *os << "CORBA::string_free (this->u_." << ub->local_name () << "_);" << be_nl; - *os << "break;" << be_uidt_nl; - - return 0; -} - -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 - 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_reset_cs::" - "visit_structure - " - "bad context information\n" - ), -1); - } - os = this->ctx_->stream (); - if (bt->size_type () == be_type::VARIABLE) - { - *os << "delete this->u_." << ub->local_name () << "_;" << be_nl; - } - - *os << "break;" << be_uidt_nl; - - return 0; -} - -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 - - // 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); - } - - this->ctx_->alias (0); - return 0; -} - -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 - 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_reset_cs::" - "visit_union - " - "bad context information\n" - ), -1); - } - - TAO_OutStream *os = this->ctx_->stream (); - *os << "delete this->u_." << ub->local_name () << "_;" << be_nl; - *os << "break;" << be_uidt_nl; - - return 0; -} |