diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-05-15 15:48:36 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2001-05-15 15:48:36 +0000 |
commit | 3877187ce9cb397687d9e5710d14e4b8315fd849 (patch) | |
tree | ad8a1b9d077b93a3e95d5b6e0e5a1aff5a97d0ca /TAO | |
parent | e64b0aecaaf8c093672674179528ebea76b1c138 (diff) | |
download | ATCD-3877187ce9cb397687d9e5710d14e4b8315fd849.tar.gz |
ChangeLogTag: Tue May 15 10:43:23 2001 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO')
53 files changed, 2484 insertions, 2153 deletions
diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp index d0ba7ca4a4d..8a853af2476 100644 --- a/TAO/TAO_IDL/be/be_helper.cpp +++ b/TAO/TAO_IDL/be/be_helper.cpp @@ -271,7 +271,7 @@ TAO_OutStream::gen_ifdef_macro (const char *flat_name, return -1; } *this << "\n#if !defined (" << macro << ")\n"; - *this << "#define " << macro << "\n\n"; + *this << "#define " << macro << be_nl << be_nl; return 0; } @@ -279,7 +279,7 @@ TAO_OutStream::gen_ifdef_macro (const char *flat_name, int TAO_OutStream::gen_endif (void) { - *this << "\n#endif /* end #if !defined */\n\n"; + *this << "\n#endif /* end #if !defined */" << be_nl << be_nl; return 0; } @@ -291,7 +291,7 @@ TAO_OutStream::gen_ifdef_AHETI (void) { *this << "\n" << "#if !defined (TAO_USE_SEQUENCE_TEMPLATES)" - << be_idt_nl; + << be_nl; return 0; } @@ -308,8 +308,7 @@ TAO_OutStream::gen_else_AHETI (void) int TAO_OutStream::gen_endif_AHETI (void) { - *this << be_uidt - << "\n#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ " + *this << "\n#endif /* !TAO_USE_SEQUENCE_TEMPLATES */ " << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 109550b7427..fbc907f0e08 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -532,7 +532,6 @@ be_interface::gen_var_defn (char *interface_name) // 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 " << be_global->stub_export_macro () << " " << namebuf << " : public TAO_Base_var" << be_nl; @@ -596,8 +595,10 @@ be_interface::gen_var_defn (char *interface_name) << "static " << interface_name << "_ptr nil (void);" << be_nl << "static " << interface_name - << "_ptr narrow (CORBA::Object *, " - << "CORBA::Environment &);" << be_nl + << "_ptr narrow (" << be_idt << be_idt_nl + << "CORBA::Object *," << be_nl + << "CORBA::Environment &" << be_uidt_nl + << ");" << be_uidt_nl << "static CORBA::Object * upcast (void *);" << be_uidt_nl << be_nl; // Private. @@ -849,9 +850,6 @@ be_interface::gen_out_defn (char *interface_name) TAO_OutStream *ch = tao_cg->client_header (); // Generate the out definition (always in the client header) - // start with whatever was our current indent level. - ch->indent (); - *ch << "class " << be_global->stub_export_macro () << " " << namebuf << be_nl; *ch << "{" << be_nl; @@ -896,7 +894,7 @@ be_interface::gen_out_defn (char *interface_name) *ch << "private:" << be_idt_nl; *ch << interface_name << "_ptr &ptr_;" << be_uidt_nl; - *ch << "};\n\n"; + *ch << "};" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index e6afc7990a2..2612da8d7ff 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -47,7 +47,7 @@ int be_structure::gen_var_defn (char *) { TAO_OutStream *ch = 0; - TAO_NL nl; + TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; ACE_OS::memset (namebuf, @@ -65,97 +65,93 @@ be_structure::gen_var_defn (char *) // we account for here. // Start with whatever was our current indent level. - ch->indent (); *ch << "class " << be_global->stub_export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); + << " " << namebuf << be_nl; + *ch << "{" << be_nl; + *ch << "public:" << be_idt_nl; // Default constructor. - *ch << namebuf << " (void); // default constructor" << nl; + *ch << namebuf << " (void);" << be_nl; // Constructor. - *ch << namebuf << " (" << this->local_name () << " *);" << nl; + *ch << namebuf << " (" << this->local_name () << " *);" << be_nl; // Copy constructor. - *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << nl; + *ch << namebuf << " (const " << namebuf << " &);" << be_nl; // Fixed-size types only. if (this->size_type () == be_decl::FIXED) { + *ch << "// Fixed-size types only." << be_nl; *ch << namebuf << " (const " << this->local_name () - << " &); // fixed-size types only" << nl; + << " &);" << be_nl; } // Destructor. - *ch << "~" << namebuf << " (void); // destructor" << nl; - *ch << nl; + *ch << "~" << namebuf << " (void);" << be_nl; + *ch << be_nl; // Assignment operator from a pointer. - *ch << namebuf << " &operator= (" << this->local_name () << " *);" << nl; + *ch << namebuf << " &operator= (" << this->local_name () + << " *);" << be_nl; // Assignment from _var. - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; + *ch << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // Fixed-size types only. if (this->size_type () == be_decl::FIXED) { + *ch << "// Fixed-size types only." << be_nl; *ch << namebuf << " &operator= (const " << this->local_name () - << " &); // fixed-size types only" << nl; + << " &);" << be_nl; } // Arrow operator. - *ch << this->local_name () << " *operator-> (void);" << nl; + *ch << this->local_name () << " *operator-> (void);" << be_nl; *ch << "const " << this->local_name () - << " *operator-> (void) const;" << nl; - *ch << nl; + << " *operator-> (void) const;" << be_nl; + *ch << be_nl; // Other extra types (cast operators, [] operator, and others). - *ch << "operator const " << this->local_name () << " &() const;" << nl; - *ch << "operator " << this->local_name () << " &();" << nl; - *ch << "operator " << this->local_name () << " &() const;" << nl; + *ch << "operator const " << this->local_name () << " &() const;" << be_nl; + *ch << "operator " << this->local_name () << " &();" << be_nl; + *ch << "operator " << this->local_name () << " &() const;" << be_nl; if (this->size_type () == be_decl::VARIABLE) { + *ch << "// Variable-size types only." << be_nl; *ch << "operator " << this->local_name () - << " *&(); // variable-size types only" << nl; + << " *&();" << be_nl; } - *ch << nl; - *ch << "// in, inout, out, _retn " << nl; + *ch << be_nl; + *ch << "// in, inout, out, _retn " << be_nl; // The return types of in, out, inout, and _retn are based on the // parameter passing rules and the base type. if (this->size_type () == be_decl::FIXED) { - *ch << "const " << this->local_name () << " &in (void) const;" << nl; - *ch << this->local_name () << " &inout (void);" << nl; - *ch << this->local_name () << " &out (void);" << nl; - *ch << this->local_name () << " _retn (void);" << nl; + *ch << "const " << this->local_name () << " &in (void) const;" << be_nl; + *ch << this->local_name () << " &inout (void);" << be_nl; + *ch << this->local_name () << " &out (void);" << be_nl; + *ch << this->local_name () << " _retn (void);" << be_nl; } else { - *ch << "const " << this->local_name () << " &in (void) const;" << nl; - *ch << this->local_name () << " &inout (void);" << nl; - *ch << this->local_name () << " *&out (void);" << nl; - *ch << this->local_name () << " *_retn (void);" << nl; + *ch << "const " << this->local_name () << " &in (void) const;" << be_nl; + *ch << this->local_name () << " &inout (void);" << be_nl; + *ch << this->local_name () << " *&out (void);" << be_nl; + *ch << this->local_name () << " *_retn (void);" << be_nl; } // Generate an additional member function // that returns the underlying pointer. - *ch << this->local_name () << " *ptr (void) const;\n"; - - *ch << "\n"; - ch->decr_indent (); + *ch << this->local_name () << " *ptr (void) const;" << be_uidt_nl << be_nl; // Generate the private section. - *ch << "private:\n"; - ch->incr_indent (); - *ch << this->local_name () << " *ptr_;\n"; - ch->decr_indent (); - *ch << "};\n\n"; + *ch << "private:" << be_idt_nl; + *ch << this->local_name () << " *ptr_;" << be_uidt_nl; + *ch << "};" << be_nl << be_nl; return 0; } @@ -166,7 +162,7 @@ be_structure::gen_var_impl (char *, char *) { TAO_OutStream *ci = 0; - TAO_NL nl; // end line + TAO_NL be_nl; // end line char fname [NAMEBUFSIZE]; char lname [NAMEBUFSIZE]; @@ -192,36 +188,35 @@ be_structure::gen_var_impl (char *, ci->indent (); *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; + << be_nl; + *ci << "// Inline operations for class " << fname << be_nl; *ci << "// *************************************************************\n\n"; // Default constructor. - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname - << " (void) // default constructor" << nl; - *ci << " " << ": ptr_ (0)" << nl; - *ci << "{}\n\n"; + << " (void) // default constructor" << be_nl; + *ci << " " << ": ptr_ (0)" << be_nl; + *ci << "{}" << be_nl << be_nl; // Constructor from a pointer. - ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << this->local_name () - << " *p)" << nl; - *ci << " : ptr_ (p)" << nl; + << " *p)" << be_nl; + *ci << " : ptr_ (p)" << be_nl; *ci << "{}\n\n"; // Copy constructor. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const ::" << fname - << " &p) // copy constructor" << nl; + << " &p) // copy constructor" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "if (p.ptr_)" << nl; + *ci << "if (p.ptr_)" << be_nl; *ci << " ACE_NEW (this->ptr_, " << "::" << this->name () - << " (*p.ptr_));" << nl; - *ci << "else" << nl; + << " (*p.ptr_));" << be_nl; + *ci << "else" << be_nl; *ci << " this->ptr_ = 0;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -229,10 +224,10 @@ be_structure::gen_var_impl (char *, // Fixed-size types only. if (this->size_type () == be_decl::FIXED) { - *ci << "// fixed-size types only" << nl; - *ci << "ACE_INLINE" << nl; + *ci << "// fixed-size types only" << be_nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const " - << "::" << this->name () << " &p)" << nl; + << "::" << this->name () << " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "ACE_NEW (this->ptr_, " << "::" << this->name () @@ -243,8 +238,8 @@ be_structure::gen_var_impl (char *, // Destructor. ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::~" << lname << " (void) // destructor" << nl; + *ci << "ACE_INLINE" << be_nl; + *ci << fname << "::~" << lname << " (void) // destructor" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "delete this->ptr_;\n"; @@ -253,13 +248,13 @@ be_structure::gen_var_impl (char *, // Assignment operator from a pointer. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (" << this->local_name () - << " *p)" << nl; + << " *p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = p;" << nl; + *ci << "delete this->ptr_;" << be_nl; + *ci << "this->ptr_ = p;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -298,20 +293,20 @@ be_structure::gen_var_impl (char *, if (this->size_type () == be_decl::FIXED) { ci->indent (); - *ci << "// fixed-size types only" << nl; - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "// fixed-size types only" << be_nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (const " << "::" << this->name () - << " &p)" << nl; + << " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "if (this->ptr_ != &p)" << nl; + *ci << "if (this->ptr_ != &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; + *ci << "delete this->ptr_;" << be_nl; *ci << "ACE_NEW_RETURN (this->ptr_, ::" << this->name () << " (p), *this);\n"; ci->decr_indent (); - *ci << "}" << nl; + *ci << "}" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -319,8 +314,8 @@ be_structure::gen_var_impl (char *, // Two arrow operators. ci->indent (); - *ci << "ACE_INLINE const " << "::" << this->name () << " *" << nl; - *ci << fname << "::operator-> (void) const" << nl; + *ci << "ACE_INLINE const " << "::" << this->name () << " *" << be_nl; + *ci << fname << "::operator-> (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -328,8 +323,8 @@ be_structure::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << "::" << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; + *ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl; + *ci << fname << "::operator-> (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -338,9 +333,9 @@ be_structure::gen_var_impl (char *, // Other extra methods - 3 cast operator (). ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::operator const " << "::" << this->name () - << " &() const // cast" << nl; + << " &() const // cast" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -348,9 +343,9 @@ be_structure::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::operator " << "::" << this->name () - << " &() // cast " << nl; + << " &() // cast " << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -358,9 +353,9 @@ be_structure::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::operator " << "::" << this->name () - << " &() const // cast " << nl; + << " &() const // cast " << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -371,10 +366,10 @@ be_structure::gen_var_impl (char *, if (this->size_type () == be_decl::VARIABLE) { ci->indent (); - *ci << "// variable-size types only" << nl; - *ci << "ACE_INLINE" << nl; + *ci << "// variable-size types only" << be_nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::operator " << "::" << this->name () - << " *&() // cast " << nl; + << " *&() // cast " << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -384,8 +379,8 @@ be_structure::gen_var_impl (char *, // in, inout, out, and _retn ci->indent (); - *ci << "ACE_INLINE const " << "::" << this->name () << " &" << nl; - *ci << fname << "::in (void) const" << nl; + *ci << "ACE_INLINE const " << "::" << this->name () << " &" << be_nl; + *ci << fname << "::in (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -393,8 +388,8 @@ be_structure::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << "::" << this->name () << " &" << nl; - *ci << fname << "::inout (void)" << nl; + *ci << "ACE_INLINE " << "::" << this->name () << " &" << be_nl; + *ci << fname << "::inout (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -405,24 +400,24 @@ be_structure::gen_var_impl (char *, ci->indent (); if (this->size_type () == be_decl::VARIABLE) { - *ci << "// mapping for variable size " << nl; - *ci << "ACE_INLINE " << "::" << this->name () << " *&" << nl; - *ci << fname << "::out (void)" << nl; + *ci << "// mapping for variable size " << be_nl; + *ci << "ACE_INLINE " << "::" << this->name () << " *&" << be_nl; + *ci << fname << "::out (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; + *ci << "delete this->ptr_;" << be_nl; + *ci << "this->ptr_ = 0;" << be_nl; *ci << "return this->ptr_;\n"; ci->decr_indent (); *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << "::" << this->name () << " *" << nl; - *ci << fname << "::_retn (void)" << nl; + *ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl; + *ci << fname << "::_retn (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "::" << this->name () << " *tmp = this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; + *ci << "::" << this->name () << " *tmp = this->ptr_;" << be_nl; + *ci << "this->ptr_ = 0;" << be_nl; *ci << "return tmp;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -430,9 +425,9 @@ be_structure::gen_var_impl (char *, } else { - *ci << "// mapping for fixed size " << nl; - *ci << "ACE_INLINE " << "::" << this->name () << " &" << nl; - *ci << fname << "::out (void)" << nl; + *ci << "// mapping for fixed size " << be_nl; + *ci << "ACE_INLINE " << "::" << this->name () << " &" << be_nl; + *ci << fname << "::out (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -440,8 +435,8 @@ be_structure::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << "::" << this->name () << nl; - *ci << fname << "::_retn (void)" << nl; + *ci << "ACE_INLINE " << "::" << this->name () << be_nl; + *ci << fname << "::_retn (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -452,8 +447,8 @@ be_structure::gen_var_impl (char *, // The additional ptr () member function. ci->indent (); - *ci << "ACE_INLINE " << "::" << this->name () << " *" << nl; - *ci << fname << "::ptr (void) const" << nl; + *ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl; + *ci << fname << "::ptr (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -468,7 +463,7 @@ int be_structure::gen_out_defn (char *) { TAO_OutStream *ch = 0; - TAO_NL nl; + TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; ACE_OS::memset (namebuf, @@ -483,55 +478,49 @@ be_structure::gen_out_defn (char *) // Generate the out definition (always in the client header). - // Start with whatever was our current indent level. - ch->indent (); - *ch << "class " << be_global->stub_export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); + << " " << namebuf << be_nl; + *ch << "{" << be_nl; + *ch << "public:" << be_idt_nl; // No default constructor // Constructor from a pointer. - *ch << namebuf << " (" << this->local_name () << " *&);" << nl; + *ch << namebuf << " (" << this->local_name () << " *&);" << be_nl; // Constructor from a _var &. - *ch << namebuf << " (" << this->local_name () << "_var &);" << nl; + *ch << namebuf << " (" << this->local_name () << "_var &);" << be_nl; // Constructor from a _out &. - *ch << namebuf << " (const " << namebuf << " &);" << nl; + *ch << namebuf << " (const " << namebuf << " &);" << be_nl; // Assignment operator from a _out &. - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; + *ch << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // Assignment operator from a pointer &, cast operator, ptr fn, operator // -> and any other extra operators. // Assignment. *ch << namebuf << " &operator= (" - << this->local_name () << " *);" << nl; + << this->local_name () << " *);" << be_nl; // Operator (). - *ch << "operator " << this->local_name () << " *&();" << nl; + *ch << "operator " << this->local_name () << " *&();" << be_nl; // ptr fn - *ch << this->local_name () << " *&ptr (void);" << nl; + *ch << this->local_name () << " *&ptr (void);" << be_nl; // operator -> - *ch << this->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 " << this->local_name () << "_var &);\n"; - - ch->decr_indent (); - *ch << "};\n\n"; + *ch << this->local_name () << " *operator-> (void);" << be_nl; + + *ch << be_uidt_nl; + *ch << "private:" << be_idt_nl; + *ch << local_name () << " *&ptr_;" << be_nl; + *ch << "// Assignment from T_var not allowed." << be_nl; + *ch << "void operator= (const " << this->local_name () + << "_var &);" << be_uidt_nl; + + *ch << "};" << be_nl << be_nl; return 0; } @@ -540,7 +529,7 @@ be_structure::gen_out_impl (char *, char *) { TAO_OutStream *ci = 0; - TAO_NL nl; + TAO_NL be_nl; char fname [NAMEBUFSIZE]; char lname [NAMEBUFSIZE]; @@ -568,16 +557,16 @@ be_structure::gen_out_impl (char *, ci->indent (); *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; + << be_nl; + *ci << "// Inline operations for class " << fname << be_nl; *ci << "// *************************************************************\n\n"; // Constructor from a pointer. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << "::" - << this->name () << " *&p)" << nl; - *ci << " : ptr_ (p)" << nl; + << this->name () << " *&p)" << be_nl; + *ci << " : ptr_ (p)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "this->ptr_ = 0;\n"; @@ -586,33 +575,33 @@ be_structure::gen_out_impl (char *, // Constructor from _var &. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << this->local_name () - << "_var &p) // constructor from _var" << nl; - *ci << " : ptr_ (p.out ())" << nl; + << "_var &p) // constructor from _var" << be_nl; + *ci << " : ptr_ (p.out ())" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; + *ci << "delete this->ptr_;" << be_nl; *ci << "this->ptr_ = 0;\n"; ci->decr_indent (); *ci << "}\n\n"; // Copy constructor. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const ::" << fname - << " &p) // copy constructor" << nl; - *ci << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << nl; + << " &p) // copy constructor" << be_nl; + *ci << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << be_nl; *ci << "{}\n\n"; // assignment operator from _out &. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (const ::" << fname << - " &p)" << nl; + " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << nl; + *ci << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -621,20 +610,20 @@ be_structure::gen_out_impl (char *, // Assignment operator from pointer. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; - *ci << fname << "::operator= (" << this->local_name () << " *p)" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; + *ci << fname << "::operator= (" << this->local_name () << " *p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "this->ptr_ = p;" << nl; + *ci << "this->ptr_ = p;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; // Other extra methods - cast operator (). ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator " << "::" << this->name () - << " *&() // cast" << nl; + << " *&() // cast" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -643,8 +632,8 @@ be_structure::gen_out_impl (char *, // ptr function ci->indent (); - *ci << "ACE_INLINE " << "::" << this->name () << " *&" << nl; - *ci << fname << "::ptr (void) // ptr" << nl; + *ci << "ACE_INLINE " << "::" << this->name () << " *&" << be_nl; + *ci << fname << "::ptr (void) // ptr" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -653,8 +642,8 @@ be_structure::gen_out_impl (char *, // operator -> ci->indent (); - *ci << "ACE_INLINE " << "::" << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; + *ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl; + *ci << fname << "::operator-> (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp index 44b647df47e..185f110c6d6 100644 --- a/TAO/TAO_IDL/be/be_type.cpp +++ b/TAO/TAO_IDL/be/be_type.cpp @@ -27,7 +27,6 @@ ACE_RCSID(be, be_type, "$Id$") be_type::be_type (void) : tc_name_ (0), - type_name_ (0), nested_type_name_ (0) { } @@ -39,7 +38,6 @@ be_type::be_type (AST_Decl::NodeType nt, n, p), tc_name_ (0), - type_name_ (0), nested_type_name_ (0) { } @@ -608,12 +606,6 @@ be_type::destroy (void) delete this->tc_name_; this->tc_name_ = 0; } - - if (this->type_name_ != 0) - { - ACE_OS::free (this->type_name_); - this->type_name_ = 0; - } if (this->nested_type_name_ != 0) { diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index cc42bc9d9ec..72e630495b4 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -63,7 +63,7 @@ int be_union::gen_var_defn (char *) { TAO_OutStream *ch = 0; - TAO_NL nl; + TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; ACE_OS::memset (namebuf, @@ -80,98 +80,93 @@ be_union::gen_var_defn (char *) // 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 " << be_global->stub_export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); + << " " << namebuf << be_nl; + *ch << "{" << be_nl; + *ch << "public:" << be_idt_nl; // Default constructor. - *ch << namebuf << " (void); // default constructor" << nl; + *ch << namebuf << " (void);" << be_nl; // Constructor. - *ch << namebuf << " (" << this->local_name () << " *);" << nl; + *ch << namebuf << " (" << this->local_name () << " *);" << be_nl; // Copy constructor. - *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << nl; + *ch << namebuf << " (const " << namebuf + << " &);" << be_nl; // Fixed-size types only. if (this->size_type () == be_decl::FIXED) { *ch << namebuf << " (const " << this->local_name () - << " &); // fixed-size types only" << nl; + << " &); // fixed-size types only" << be_nl; } // Destructor. - *ch << "~" << namebuf << " (void); // destructor" << nl; - *ch << nl; + *ch << "~" << namebuf << " (void);" << be_nl; + *ch << be_nl; // Assignment operator from a pointer. *ch << namebuf << " &operator= (" - << this->local_name () << " *);" << nl; + << this->local_name () << " *);" << be_nl; // Assignment from _var. - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; + *ch << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // Fixed-size types only. if (this->size_type () == be_decl::FIXED) { *ch << namebuf << " &operator= (const " << this->local_name () - << " &); // fixed-size types only" << nl; + << " &); // fixed-size types only" << be_nl; } // Arrow operator. - *ch << local_name () << " *operator-> (void);" << nl; + *ch << local_name () << " *operator-> (void);" << be_nl; *ch << "const " << this->local_name () - << " *operator-> (void) const;" << nl; - *ch << nl; + << " *operator-> (void) const;" << be_nl; + *ch << be_nl; // Other extra types (cast operators, [] operator, and others). - *ch << "operator const " << this->local_name () << " &() const;" << nl; - *ch << "operator " << this->local_name () << " &();" << nl; - *ch << "operator " << this->local_name () << " &() const;" << nl; + *ch << "operator const " << this->local_name () << " &() const;" << be_nl; + *ch << "operator " << this->local_name () << " &();" << be_nl; + *ch << "operator " << this->local_name () << " &() const;" << be_nl; if (this->size_type () == be_decl::VARIABLE) { + *ch << " // Variable size types only." << be_nl; *ch << "operator " << this->local_name () - << " *&(); // variable-size types only" << nl; + << " *&();" << be_nl; } - *ch << nl; - *ch << "// in, inout, out, _retn " << nl; + *ch << be_nl; + *ch << "// in, inout, out, _retn " << be_nl; // The return types of in, out, inout, and _retn are based on the parameter // passing rules and the base type. if (this->size_type () == be_decl::FIXED) { - *ch << "const " << local_name () << " &in (void) const;" << nl; - *ch << this->local_name () << " &inout (void);" << nl; - *ch << this->local_name () << " &out (void);" << nl; - *ch << this->local_name () << " _retn (void);" << nl; + *ch << "const " << local_name () << " &in (void) const;" << be_nl; + *ch << this->local_name () << " &inout (void);" << be_nl; + *ch << this->local_name () << " &out (void);" << be_nl; + *ch << this->local_name () << " _retn (void);" << be_nl; } else { - *ch << "const " << this->local_name () << " &in (void) const;" << nl; - *ch << this->local_name () << " &inout (void);" << nl; - *ch << this->local_name () << " *&out (void);" << nl; - *ch << this->local_name () << " *_retn (void);" << nl; + *ch << "const " << this->local_name () << " &in (void) const;" << be_nl; + *ch << this->local_name () << " &inout (void);" << be_nl; + *ch << this->local_name () << " *&out (void);" << be_nl; + *ch << this->local_name () << " *_retn (void);" << be_nl; } // Generate an additional member function that // returns the underlying pointer. - *ch << this->local_name () << " *ptr(void) const;\n"; - - *ch << "\n"; - ch->decr_indent (); + *ch << this->local_name () << " *ptr (void) const;" + << be_uidt_nl << be_nl; // Generate the private section - *ch << "private:\n"; - ch->incr_indent (); - *ch << this->local_name () << " *ptr_;\n"; - ch->decr_indent (); - *ch << "};\n\n"; + *ch << "private:" << be_idt_nl; + *ch << this->local_name () << " *ptr_;" << be_uidt_nl; + *ch << "};" << be_nl << be_nl; return 0; } @@ -183,7 +178,7 @@ be_union::gen_var_impl (char *, char *) { TAO_OutStream *ci = 0; - TAO_NL nl; + TAO_NL be_nl; // To hold the full and local _var names. char fname [NAMEBUFSIZE]; @@ -211,36 +206,36 @@ be_union::gen_var_impl (char *, ci->indent (); *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; + << be_nl; + *ci << "// Inline operations for class " << fname << be_nl; *ci << "// *************************************************************\n\n"; // Default constructor. - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << - " (void) // default constructor" << nl; - *ci << " " << ": ptr_ (0)" << nl; + " (void) // default constructor" << be_nl; + *ci << " " << ": ptr_ (0)" << be_nl; *ci << "{}\n\n"; // Constructor from a pointer. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << this->local_name () - << " *p)" << nl; - *ci << " : ptr_ (p)" << nl; + << " *p)" << be_nl; + *ci << " : ptr_ (p)" << be_nl; *ci << "{}\n\n"; // Copy constructor. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const ::" << fname - << " &p) // copy constructor" << nl; + << " &p) // copy constructor" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "if (p.ptr_)" << nl; + *ci << "if (p.ptr_)" << be_nl; *ci << " ACE_NEW (this->ptr_, ::" << this->name () - << " (*p.ptr_));" << nl; - *ci << "else" << nl; + << " (*p.ptr_));" << be_nl; + *ci << "else" << be_nl; *ci << " this->ptr_ = 0;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -248,10 +243,10 @@ be_union::gen_var_impl (char *, // Fixed-size types only. if (this->size_type () == be_decl::FIXED) { - *ci << "// fixed-size types only" << nl; - *ci << "ACE_INLINE" << nl; + *ci << "// fixed-size types only" << be_nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const ::" - << this->name () << " &p)" << nl; + << this->name () << " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "ACE_NEW (this->ptr_, ::" << this->name () @@ -262,8 +257,8 @@ be_union::gen_var_impl (char *, // Destructor. ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::~" << lname << " (void) // destructor" << nl; + *ci << "ACE_INLINE" << be_nl; + *ci << fname << "::~" << lname << " (void) // destructor" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "delete this->ptr_;\n"; @@ -272,13 +267,13 @@ be_union::gen_var_impl (char *, // Assignment operator from a pointer. ci->indent (); - *ci << "ACE_INLINE ::" << fname << " &" << nl; + *ci << "ACE_INLINE ::" << fname << " &" << be_nl; *ci << fname << "::operator= (" << this->local_name () - << " *p)" << nl; + << " *p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = p;" << nl; + *ci << "delete this->ptr_;" << be_nl; + *ci << "this->ptr_ = p;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -317,20 +312,20 @@ be_union::gen_var_impl (char *, if (this->size_type () == be_decl::FIXED) { ci->indent (); - *ci << "// fixed-size types only" << nl; - *ci << "ACE_INLINE ::" << fname << " &" << nl; + *ci << "// fixed-size types only" << be_nl; + *ci << "ACE_INLINE ::" << fname << " &" << be_nl; *ci << fname << "::operator= (const ::" << this->name () - << " &p)" << nl; + << " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "if (this->ptr_ != &p)" << nl; + *ci << "if (this->ptr_ != &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; + *ci << "delete this->ptr_;" << be_nl; *ci << "ACE_NEW_RETURN (this->ptr_, ::" << this->name () << " (p), *this);\n"; ci->decr_indent (); - *ci << "}" << nl; + *ci << "}" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -338,8 +333,8 @@ be_union::gen_var_impl (char *, // Two arrow operators. ci->indent (); - *ci << "ACE_INLINE const ::" << this->name () << " *" << nl; - *ci << fname << "::operator-> (void) const" << nl; + *ci << "ACE_INLINE const ::" << this->name () << " *" << be_nl; + *ci << fname << "::operator-> (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -347,8 +342,8 @@ be_union::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE ::" << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; + *ci << "ACE_INLINE ::" << this->name () << " *" << be_nl; + *ci << fname << "::operator-> (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -357,9 +352,9 @@ be_union::gen_var_impl (char *, // Other extra methods - 3 cast operator (). ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator const ::" << this->name () - << " &() const // cast" << nl; + << " &() const // cast" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -367,9 +362,9 @@ be_union::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator ::" << this->name () - << " &() // cast " << nl; + << " &() // cast " << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -377,9 +372,9 @@ be_union::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator ::" << this->name () - << " &() const// cast " << nl; + << " &() const// cast " << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -390,10 +385,10 @@ be_union::gen_var_impl (char *, if (this->size_type () == be_decl::VARIABLE) { ci->indent (); - *ci << "// variable-size types only" << nl; - *ci << "ACE_INLINE" << nl; + *ci << "// variable-size types only" << be_nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::operator ::" << this->name () - << " *&() // cast " << nl; + << " *&() // cast " << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -403,8 +398,8 @@ be_union::gen_var_impl (char *, // in, inout, out, _retn, and ptr. ci->indent (); - *ci << "ACE_INLINE const ::" << this->name () << " &" << nl; - *ci << fname << "::in (void) const" << nl; + *ci << "ACE_INLINE const ::" << this->name () << " &" << be_nl; + *ci << fname << "::in (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -412,8 +407,8 @@ be_union::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE ::" << this->name () << " &" << nl; - *ci << fname << "::inout (void)" << nl; + *ci << "ACE_INLINE ::" << this->name () << " &" << be_nl; + *ci << fname << "::inout (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -424,24 +419,24 @@ be_union::gen_var_impl (char *, ci->indent (); if (this->size_type () == be_decl::VARIABLE) { - *ci << "// mapping for variable size " << nl; - *ci << "ACE_INLINE ::" << this->name () << " *&" << nl; - *ci << fname << "::out (void)" << nl; + *ci << "// mapping for variable size " << be_nl; + *ci << "ACE_INLINE ::" << this->name () << " *&" << be_nl; + *ci << fname << "::out (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; + *ci << "delete this->ptr_;" << be_nl; + *ci << "this->ptr_ = 0;" << be_nl; *ci << "return this->ptr_;\n"; ci->decr_indent (); *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE ::" << this->name () << " *" << nl; - *ci << fname << "::_retn (void)" << nl; + *ci << "ACE_INLINE ::" << this->name () << " *" << be_nl; + *ci << fname << "::_retn (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "::" << this->name () << " *tmp = this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; + *ci << "::" << this->name () << " *tmp = this->ptr_;" << be_nl; + *ci << "this->ptr_ = 0;" << be_nl; *ci << "return tmp;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -449,9 +444,9 @@ be_union::gen_var_impl (char *, } else { - *ci << "// mapping for fixed size " << nl; - *ci << "ACE_INLINE ::" << this->name () << " &" << nl; - *ci << fname << "::out (void)" << nl; + *ci << "// mapping for fixed size " << be_nl; + *ci << "ACE_INLINE ::" << this->name () << " &" << be_nl; + *ci << fname << "::out (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -459,8 +454,8 @@ be_union::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE ::" << this->name () << nl; - *ci << fname << "::_retn (void)" << nl; + *ci << "ACE_INLINE ::" << this->name () << be_nl; + *ci << fname << "::_retn (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return *this->ptr_;\n"; @@ -470,8 +465,8 @@ be_union::gen_var_impl (char *, // The additional ptr () member function. ci->indent (); - *ci << "ACE_INLINE ::" << this->name () << " *" << nl; - *ci << fname << "::ptr (void) const" << nl; + *ci << "ACE_INLINE ::" << this->name () << " *" << be_nl; + *ci << fname << "::ptr (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -486,7 +481,7 @@ int be_union::gen_out_defn (char *) { TAO_OutStream *ch = 0; - TAO_NL nl; + TAO_NL be_nl; // To hold the _out name. char namebuf [NAMEBUFSIZE]; @@ -503,54 +498,49 @@ be_union::gen_out_defn (char *) // Generate the out definition (always in the client header). - // Start with whatever was our current indent level. - ch->indent (); - *ch << "class " << be_global->stub_export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); + << " " << namebuf << be_nl; + *ch << "{" << be_nl; + *ch << "public:" << be_idt_nl; // No default constructor. // Constructor from a pointer. - *ch << namebuf << " (" << this->local_name () << " *&);" << nl; + *ch << namebuf << " (" << this->local_name () << " *&);" << be_nl; // Constructor from a _var &. - *ch << namebuf << " (" << this->local_name () << "_var &);" << nl; + *ch << namebuf << " (" << this->local_name () << "_var &);" << be_nl; // Constructor from a _out &. - *ch << namebuf << " (const " << namebuf << " &);" << nl; + *ch << namebuf << " (const " << namebuf << " &);" << be_nl; // Assignment operator from a _out &. - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; + *ch << namebuf << " &operator= (const " << namebuf << " &);" << be_nl; // Assignment operator from a pointer &, cast operator, ptr fn, operator // -> and any other extra operators. // Assignment. - *ch << namebuf << " &operator= (" << this->local_name () << " *);" << nl; + *ch << namebuf << " &operator= (" << this->local_name () + << " *);" << be_nl; // operator (). - *ch << "operator " << local_name () << " *&();" << nl; + *ch << "operator " << local_name () << " *&();" << be_nl; // ptr function. - *ch << this->local_name () << " *&ptr (void);" << nl; + *ch << this->local_name () << " *&ptr (void);" << be_nl; // operator -> - *ch << this->local_name () << " *operator-> (void);" << nl; - - *ch << "\n"; - ch->decr_indent (); - *ch << "private:\n"; - ch->incr_indent (); - *ch << this->local_name () << " *&ptr_;" << nl; - *ch << "// assignment from T_var not allowed" << nl; - *ch << "void operator= (const " << this->local_name () << "_var &);\n"; - - ch->decr_indent (); - *ch << "};\n\n"; + *ch << this->local_name () << " *operator-> (void);" << be_nl; + + *ch << be_uidt_nl; + *ch << "private:" << be_idt_nl; + *ch << this->local_name () << " *&ptr_;" << be_nl; + *ch << "// assignment from T_var not allowed." << be_nl; + *ch << "void operator= (const " << this->local_name () + << "_var &);" << be_uidt_nl; + *ch << "};" << be_nl << be_nl; + return 0; } @@ -559,7 +549,7 @@ be_union::gen_out_impl (char *, char *) { TAO_OutStream *ci = 0; - TAO_NL nl; + TAO_NL be_nl; // To hold the full and local _out names. char fname [NAMEBUFSIZE]; @@ -589,16 +579,16 @@ be_union::gen_out_impl (char *, ci->indent (); *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; + << be_nl; + *ci << "// Inline operations for class " << fname << be_nl; *ci << "// *************************************************************\n\n"; // Constructor from a pointer. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << this->local_name () - << " *&p)" << nl; - *ci << " : ptr_ (p)" << nl; + << " *&p)" << be_nl; + *ci << " : ptr_ (p)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "this->ptr_ = 0;\n"; @@ -607,33 +597,33 @@ be_union::gen_out_impl (char *, // Constructor from _var &. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << this->local_name () - << "_var &p) // constructor from _var" << nl; - *ci << " : ptr_ (p.out ())" << nl; + << "_var &p) // constructor from _var" << be_nl; + *ci << " : ptr_ (p.out ())" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "delete this->ptr_;" << nl; + *ci << "delete this->ptr_;" << be_nl; *ci << "this->ptr_ = 0;\n"; ci->decr_indent (); *ci << "}\n\n"; // Copy constructor. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const ::" << fname - << " &p) // copy constructor" << nl; - *ci << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << nl; + << " &p) // copy constructor" << be_nl; + *ci << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << be_nl; *ci << "{}\n\n"; // Assignment operator from _out &. ci->indent (); - *ci << "ACE_INLINE ::" << fname << " &" << nl; + *ci << "ACE_INLINE ::" << fname << " &" << be_nl; *ci << fname << "::operator= (const ::" << fname - << " &p)" << nl; + << " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << nl; + *ci << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -642,20 +632,20 @@ be_union::gen_out_impl (char *, // Assignment operator from pointer. ci->indent (); - *ci << "ACE_INLINE ::" << fname << " &" << nl; - *ci << fname << "::operator= (" << this->local_name () << " *p)" << nl; + *ci << "ACE_INLINE ::" << fname << " &" << be_nl; + *ci << fname << "::operator= (" << this->local_name () << " *p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "this->ptr_ = p;" << nl; + *ci << "this->ptr_ = p;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; // Other extra methods - cast operator (). ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator ::" << this->name () - << " *&() // cast" << nl; + << " *&() // cast" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -664,8 +654,8 @@ be_union::gen_out_impl (char *, // ptr function. ci->indent (); - *ci << "ACE_INLINE ::" << this->name () << " *&" << nl; - *ci << fname << "::ptr (void) // ptr" << nl; + *ci << "ACE_INLINE ::" << this->name () << " *&" << be_nl; + *ci << fname << "::ptr (void) // ptr" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -674,8 +664,8 @@ be_union::gen_out_impl (char *, // operator -> ci->indent (); - *ci << "ACE_INLINE ::" << this->name () << " *" << nl; - *ci << fname << "::operator-> (void)" << nl; + *ci << "ACE_INLINE ::" << this->name () << " *" << be_nl; + *ci << fname << "::operator-> (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index 6830aeb695b..e2edec79ca7 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -148,7 +148,7 @@ int be_valuetype::gen_var_defn (char *) { TAO_OutStream *ch = 0; - TAO_NL nl; + TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; ACE_OS::memset (namebuf, @@ -166,67 +166,62 @@ be_valuetype::gen_var_defn (char *) // for over here. // Start with whatever was our current indent level. - ch->indent (); *ch << "class " << be_global->stub_export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); + << " " << namebuf << be_nl; + *ch << "{" << be_nl; + *ch << "public:" << be_idt_nl; // Default constructor. - *ch << namebuf << " (void); // default constructor" << nl; - *ch << namebuf << " (" << this->local_name () << "*);" << nl; + *ch << namebuf << " (void); // default constructor" << be_nl; + *ch << namebuf << " (" << this->local_name () << "*);" << be_nl; *ch << namebuf << " (const " << this->local_name () - << "*); // (TAO extension)" << nl; + << "*); // (TAO extension)" << be_nl; // Copy constructor. *ch << namebuf << " (const " << namebuf << - " &); // copy constructor" << nl; + " &); // copy constructor" << be_nl; // Destructor. - *ch << "~" << namebuf << " (void); // destructor" << nl; - *ch << nl; + *ch << "~" << namebuf << " (void); // destructor" << be_nl; + *ch << be_nl; // Assignment operator from a pointer. *ch << namebuf << " &operator= (" << this->local_name () - << "*);" << nl; + << "*);" << be_nl; // Assignment from _var. *ch << namebuf << " &operator= (const " << namebuf << - " &);" << nl; + " &);" << be_nl; // Arrow operator. - *ch << local_name () << "* operator-> (void) const;" << nl; + *ch << local_name () << "* operator-> (void) const;" << be_nl; - *ch << nl; + *ch << be_nl; // Other extra types (cast operators, [] operator, and others). *ch << "operator const " << this->local_name () - << "* () const;" << nl; - *ch << "operator " << this->local_name () << "* ();" << nl; + << "* () const;" << be_nl; + *ch << "operator " << this->local_name () << "* ();" << be_nl; - *ch << "// in, inout, out, _retn " << nl; + *ch << "// in, inout, out, _retn " << be_nl; // The return types of in, out, inout, and _retn are based on the parameter // passing rules and the base type. - *ch << this->local_name () << "* in (void) const;" << nl; - *ch << this->local_name () << "* &inout (void);" << nl; - *ch << this->local_name () << "* &out (void);" << nl; - *ch << this->local_name () << "* _retn (void);" << nl; + *ch << this->local_name () << "* in (void) const;" << be_nl; + *ch << this->local_name () << "* &inout (void);" << be_nl; + *ch << this->local_name () << "* &out (void);" << be_nl; + *ch << this->local_name () << "* _retn (void);" << be_nl; // Generate an additional member function that returns // the underlying pointer. - *ch << this->local_name () << "* ptr (void) const;\n"; + *ch << this->local_name () << "* ptr (void) const;"; - *ch << "\n"; - ch->decr_indent (); + *ch << be_uidt_nl << be_nl; // Private. - *ch << "private:\n"; - ch->incr_indent (); - *ch << this->local_name () << "* ptr_;\n"; + *ch << "private:" << be_idt_nl; + *ch << this->local_name () << "* ptr_;" << be_uidt_nl; - ch->decr_indent (); - *ch << "};\n\n"; + *ch << "};" << be_nl << be_nl; return 0; } @@ -238,7 +233,7 @@ be_valuetype::gen_var_impl (char *, char *) { TAO_OutStream *ci = 0; - TAO_NL nl; + TAO_NL be_nl; // To hold the full and local _var names. char fname [NAMEBUFSIZE]; @@ -269,34 +264,34 @@ be_valuetype::gen_var_impl (char *, ci->indent (); // start with whatever was our current indent level *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; + << be_nl; + *ci << "// Inline operations for class " << fname << be_nl; *ci << "// *************************************************************\n\n"; // Default constructor. - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << - " (void) // default constructor" << nl; - *ci << " " << ": ptr_ (0)" << nl; + " (void) // default constructor" << be_nl; + *ci << " " << ": ptr_ (0)" << be_nl; *ci << "{}\n\n"; // Constructor from a pointer. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" - << this->local_name () << "* p)" << nl; - *ci << " : ptr_ (p)" << nl; + << this->local_name () << "* p)" << be_nl; + *ci << " : ptr_ (p)" << be_nl; *ci << "{}\n\n"; // Constructor from a const pointer. // TAO extension - it appears that there are problems with at least g++ // which reclaims amguity between T(T*) and T(const T_var &) ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const " - << this->local_name () << "* p)" << nl; + << this->local_name () << "* p)" << be_nl; *ci << " : ptr_ (ACE_const_cast(" - << this->local_name () << "*, p))" << nl; + << this->local_name () << "*, p))" << be_nl; *ci << "{}\n\n"; // The additional ptr () member function. This member function must be @@ -304,8 +299,8 @@ be_valuetype::gen_var_impl (char *, // 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 " << this->name () << "* " << nl; - *ci << fname << "::ptr (void) const" << nl; + *ci << "ACE_INLINE " << this->name () << "* " << be_nl; + *ci << fname << "::ptr (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -314,9 +309,9 @@ be_valuetype::gen_var_impl (char *, // Copy constructor. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const " << lname << - " &p) // copy constructor" << nl; + " &p) // copy constructor" << be_nl; *ci << "{" << be_idt_nl << "CORBA::add_ref (p.ptr ());" << be_nl << "this->ptr_ = p.ptr ();" << be_uidt_nl @@ -324,8 +319,8 @@ be_valuetype::gen_var_impl (char *, // Destructor. ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fname << "::~" << lname << " (void) // destructor" << nl; + *ci << "ACE_INLINE" << be_nl; + *ci << fname << "::~" << lname << " (void) // destructor" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "CORBA::remove_ref (this->ptr_);\n"; @@ -334,42 +329,42 @@ be_valuetype::gen_var_impl (char *, // Assignment operator. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (" << this->local_name () - << "* p)" << nl; + << "* p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "CORBA::remove_ref (this->ptr_);" << nl; - *ci << "this->ptr_ = p;" << nl; + *ci << "CORBA::remove_ref (this->ptr_);" << be_nl; + *ci << "this->ptr_ = p;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; // Assignment operator from _var. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (const " << lname - << " &p)" << nl; + << " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "if (this != &p)" << nl; + *ci << "if (this != &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "CORBA::remove_ref (this->ptr_);" << nl + *ci << "CORBA::remove_ref (this->ptr_);" << be_nl << this->local_name() << "* tmp = p.ptr ();" << be_nl << "CORBA::add_ref (tmp);" << be_nl << "this->ptr_ = tmp;\n"; ci->decr_indent (); - *ci << "}" << nl; + *ci << "}" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; // Other extra methods - cast operator (). ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator const " << this->name () - << "* () const // cast" << nl; + << "* () const // cast" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -377,9 +372,9 @@ be_valuetype::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator " << this->name () - << "* () // cast " << nl; + << "* () // cast " << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -388,8 +383,8 @@ be_valuetype::gen_var_impl (char *, // operator-> ci->indent (); - *ci << "ACE_INLINE " << this->name () << "* " << nl; - *ci << fname << "::operator-> (void) const" << nl; + *ci << "ACE_INLINE " << this->name () << "* " << be_nl; + *ci << fname << "::operator-> (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -398,8 +393,8 @@ be_valuetype::gen_var_impl (char *, // in, inout, out, and _retn. ci->indent (); - *ci << "ACE_INLINE " << this->name () << "*" << nl; - *ci << fname << "::in (void) const" << nl; + *ci << "ACE_INLINE " << this->name () << "*" << be_nl; + *ci << fname << "::in (void) const" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -407,8 +402,8 @@ be_valuetype::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << this->name () << "* &" << nl; - *ci << fname << "::inout (void)" << nl; + *ci << "ACE_INLINE " << this->name () << "* &" << be_nl; + *ci << fname << "::inout (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -416,24 +411,24 @@ be_valuetype::gen_var_impl (char *, *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << this->name () << "* &" << nl; - *ci << fname << "::out (void)" << nl; + *ci << "ACE_INLINE " << this->name () << "* &" << be_nl; + *ci << fname << "::out (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "CORBA::remove_ref (this->ptr_);" << nl; - *ci << "this->ptr_ = 0;" << nl; + *ci << "CORBA::remove_ref (this->ptr_);" << be_nl; + *ci << "this->ptr_ = 0;" << be_nl; *ci << "return this->ptr_;\n"; ci->decr_indent (); *ci << "}\n\n"; ci->indent (); - *ci << "ACE_INLINE " << this->name () << "* " << nl; - *ci << fname << "::_retn (void)" << nl; + *ci << "ACE_INLINE " << this->name () << "* " << be_nl; + *ci << fname << "::_retn (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "// yield ownership of managed obj reference" << nl; - *ci << this->local_name () << "* tmp = this->ptr_;" << nl; - *ci << "this->ptr_ = 0;" << nl; + *ci << "// yield ownership of managed obj reference" << be_nl; + *ci << this->local_name () << "* tmp = this->ptr_;" << be_nl; + *ci << "this->ptr_ = 0;" << be_nl; *ci << "return tmp;\n"; ci->decr_indent (); *ci << "}\n\n"; @@ -446,7 +441,7 @@ int be_valuetype::gen_out_defn (char *) { TAO_OutStream *ch = 0; - TAO_NL nl; + TAO_NL be_nl; char namebuf [NAMEBUFSIZE]; ACE_OS::memset (namebuf, @@ -461,54 +456,47 @@ be_valuetype::gen_out_defn (char *) // Generate the out definition (always in the client header). - // Start with whatever was our current indent level. - ch->indent (); - *ch << "class " << be_global->stub_export_macro () - << " " << namebuf << nl; - *ch << "{" << nl; - *ch << "public:\n"; - ch->incr_indent (); + << " " << namebuf << be_nl; + *ch << "{" << be_nl; + *ch << "public:" << be_idt_nl; // No default constructor. // Constructor from a pointer. - *ch << namebuf << " (" << this->local_name () << "* &);" << nl; + *ch << namebuf << " (" << this->local_name () << "* &);" << be_nl; // Constructor from a _var &. - *ch << namebuf << " (" << this->local_name () << "_var &);" << nl; + *ch << namebuf << " (" << this->local_name () << "_var &);" << be_nl; // Constructor from a _out &. - *ch << namebuf << " (const " << namebuf << " &);" << nl; + *ch << namebuf << " (const " << namebuf << " &);" << be_nl; // Assignment operator from a _out &. - *ch << namebuf << " &operator= (const " << namebuf << " &);" << nl; + *ch << namebuf << " &operator= (const " << namebuf << " &);" << be_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 " << this->local_name () - << "_var &);" << nl; + << "_var &);" << be_nl; *ch << namebuf << " &operator= (" << this->local_name () - << "*);" << nl; + << "*);" << be_nl; // Cast. - *ch << "operator " << this->local_name () << "* &();" << nl; + *ch << "operator " << this->local_name () << "* &();" << be_nl; // ptr function. - *ch << this->local_name () << "* &ptr (void);" << nl; + *ch << this->local_name () << "* &ptr (void);" << be_nl; // operator -> - *ch << this->local_name () << "* operator-> (void);" << nl; + *ch << this->local_name () << "* operator-> (void);" << be_nl; - *ch << "\n"; - ch->decr_indent (); - *ch << "private:\n"; - ch->incr_indent (); - *ch << this->local_name () << "* &ptr_;\n"; + *ch << be_uidt_nl; + *ch << "private:" << be_idt_nl; + *ch << this->local_name () << "* &ptr_;" << be_uidt_nl; + *ch << "};" << be_nl << be_nl; - ch->decr_indent (); - *ch << "};\n\n"; return 0; } @@ -517,7 +505,7 @@ be_valuetype::gen_out_impl (char *, char *) { TAO_OutStream *ci = 0; - TAO_NL nl; + TAO_NL be_nl; // To hold the full and local _out names. char fname [NAMEBUFSIZE]; @@ -549,16 +537,16 @@ be_valuetype::gen_out_impl (char *, ci->indent (); *ci << "// *************************************************************" - << nl; - *ci << "// Inline operations for class " << fname << nl; + << be_nl; + *ci << "// Inline operations for class " << fname << be_nl; *ci << "// *************************************************************\n\n"; // Constructor from a pointer. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << this->local_name () - << "* &p)" << nl; - *ci << " : ptr_ (p)" << nl; + << "* &p)" << be_nl; + *ci << " : ptr_ (p)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "this->ptr_ = 0;\n"; @@ -567,42 +555,42 @@ be_valuetype::gen_out_impl (char *, // Constructor from _var &. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (" << this->local_name () - << "_var &p) // constructor from _var" << nl; - *ci << " : ptr_ (p.out ())" << nl; + << "_var &p) // constructor from _var" << be_nl; + *ci << " : ptr_ (p.out ())" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "CORBA::remove_ref (this->ptr_);" << nl; + *ci << "CORBA::remove_ref (this->ptr_);" << be_nl; *ci << "this->ptr_ = 0;\n"; ci->decr_indent (); *ci << "}\n\n"; // Copy constructor. ci->indent (); - *ci << "ACE_INLINE" << nl; + *ci << "ACE_INLINE" << be_nl; *ci << fname << "::" << lname << " (const " << lname - << " &p) // copy constructor" << nl; - *ci << " : ptr_ (ACE_const_cast (" << lname << "&,p).ptr_)" << nl; + << " &p) // copy constructor" << be_nl; + *ci << " : ptr_ (ACE_const_cast (" << lname << "&,p).ptr_)" << be_nl; *ci << "{}\n\n"; // Assignment operator from _out &. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (const " << lname << - " &p)" << nl; + " &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "this->ptr_ = ACE_const_cast (" << lname << "&,p).ptr_;" << nl; + *ci << "this->ptr_ = ACE_const_cast (" << lname << "&,p).ptr_;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; // Assignment operator from _var. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (const " << this->local_name () - << "_var &p)" << nl; + << "_var &p)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << this->local_name () << "* tmp = p.ptr ();" << be_nl @@ -614,21 +602,21 @@ be_valuetype::gen_out_impl (char *, // Assignment operator from *. ci->indent (); - *ci << "ACE_INLINE " << fname << " &" << nl; + *ci << "ACE_INLINE " << fname << " &" << be_nl; *ci << fname << "::operator= (" << this->local_name () - << "* p)" << nl; + << "* p)" << be_nl; *ci << "{\n"; ci->incr_indent (); - *ci << "this->ptr_ = p;" << nl; + *ci << "this->ptr_ = p;" << be_nl; *ci << "return *this;\n"; ci->decr_indent (); *ci << "}\n\n"; // Other extra methods - cast operator (). ci->indent (); - *ci << "ACE_INLINE " << nl; + *ci << "ACE_INLINE " << be_nl; *ci << fname << "::operator " << this->name () - << "* &() // cast" << nl; + << "* &() // cast" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -637,8 +625,8 @@ be_valuetype::gen_out_impl (char *, // ptr function. ci->indent (); - *ci << "ACE_INLINE " << this->name () << "* &" << nl; - *ci << fname << "::ptr (void) // ptr" << nl; + *ci << "ACE_INLINE " << this->name () << "* &" << be_nl; + *ci << fname << "::ptr (void) // ptr" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; @@ -647,8 +635,8 @@ be_valuetype::gen_out_impl (char *, // operator-> ci->indent (); - *ci << "ACE_INLINE " << this->name () << "* " << nl; - *ci << fname << "::operator-> (void)" << nl; + *ci << "ACE_INLINE " << this->name () << "* " << be_nl; + *ci << fname << "::operator-> (void)" << be_nl; *ci << "{\n"; ci->incr_indent (); *ci << "return this->ptr_;\n"; diff --git a/TAO/TAO_IDL/be/be_valuetype_fwd.cpp b/TAO/TAO_IDL/be/be_valuetype_fwd.cpp index 6f8eb673de3..894febbcccc 100644 --- a/TAO/TAO_IDL/be/be_valuetype_fwd.cpp +++ b/TAO/TAO_IDL/be/be_valuetype_fwd.cpp @@ -411,7 +411,7 @@ be_valuetype_fwd::gen_out_defn (char *) *ch << this->local_name () << "_ptr &ptr_;\n"; ch->decr_indent (); - *ch << "};\n\n"; + *ch << "};" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp index 5b5b4d32575..a0a9d80cb3c 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp @@ -42,18 +42,19 @@ 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 + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; + be_decl *scope = this->ctx_->scope (); - // nothing to do if we are imported or code is already generated + // 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 + this->ctx_->node (node); - // retrieve the type + // Retrieve the type. bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -63,7 +64,7 @@ int be_visitor_array_ch::visit_array (be_array *node) -1); } - // generate the ifdefined macro + // Generate the ifdefined macro. os->gen_ifdef_macro (node->flat_name ()); // If we contain an anonymous sequence, @@ -82,8 +83,8 @@ int be_visitor_array_ch::visit_array (be_array *node) } } - os->indent (); *os << "typedef "; + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -92,13 +93,16 @@ int be_visitor_array_ch::visit_array (be_array *node) "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 + // 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) @@ -109,10 +113,12 @@ int be_visitor_array_ch::visit_array (be_array *node) "gen dimensions failed\n"), -1); } + *os << ";" << be_nl; - // now define the slice type and other required operations + // Now define the slice type and other required operations *os << "typedef "; + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -121,14 +127,18 @@ int be_visitor_array_ch::visit_array (be_array *node) "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 + // 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, @@ -137,7 +147,8 @@ int be_visitor_array_ch::visit_array (be_array *node) "gen slice dimensions failed\n"), -1); } - *os << ";\n"; + + *os << ";" << be_nl << be_nl; // No _var or _out class for an anonymous (non-typedef'd) array. if (this->ctx_->tdef () != 0) @@ -151,6 +162,7 @@ int be_visitor_array_ch::visit_array (be_array *node) "var_defn failed\n"), -1); } + // An out defn is generated only for a variable length struct if (node->size_type () == be_decl::VARIABLE) { @@ -165,9 +177,8 @@ int be_visitor_array_ch::visit_array (be_array *node) } else { - os->indent (); *os << "typedef " << node->local_name () << " " - << node->local_name () << "_out;\n"; + << node->local_name () << "_out;" << be_nl << be_nl; } } @@ -179,101 +190,148 @@ int be_visitor_array_ch::visit_array (be_array *node) "forany_defn failed\n"), -1); } - // the _alloc, _dup, copy, and free methods. If the node is nested, the + + // The _alloc, _dup, copy, and free methods. If the node is nested, the // methods become static - os->indent (); const char *storage_class = 0; if (node->is_nested ()) { if (scope->node_type () != AST_Decl::NT_module) - storage_class = "static "; + { + storage_class = "static "; + } else - storage_class = "TAO_NAMESPACE_STORAGE_CLASS "; + { + storage_class = "TAO_NAMESPACE_STORAGE_CLASS "; + } } else - storage_class = ""; + { + storage_class = ""; + } if (this->ctx_->tdef ()) { - // typedefed array - *os << storage_class << node->nested_type_name (scope, "_slice") << " *"; + // Typedefed array. + *os << storage_class << node->nested_type_name (scope, "_slice") + << " *"; *os << node->nested_type_name (scope, "_alloc") << " (void);" << be_nl; - *os << storage_class << "void " << node->nested_type_name (scope, "_free") << " ("; - *os << node->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl; + *os << storage_class << "void " + << node->nested_type_name (scope, "_free") + << " (" << be_idt << be_idt_nl; + *os << node->nested_type_name (scope, "_slice") + << " *_tao_slice " << be_uidt_nl + << ");" << be_uidt_nl; *os << storage_class << node->nested_type_name (scope, "_slice") << " *"; - *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 << node->nested_type_name (scope, "_dup") + << " (" << be_idt << be_idt_nl + << "const "; + *os << node->nested_type_name (scope, "_slice") + << " *_tao_slice" << be_uidt_nl + << ");" << be_uidt_nl; + *os << storage_class << "void " + << node->nested_type_name (scope, "_copy") + << " (" << be_idt << be_idt_nl; + *os << node->nested_type_name (scope, "_slice") << " *_tao_to," << be_nl + << "const "; + *os << node->nested_type_name (scope, "_slice") + << " *_tao_from" << be_uidt_nl + << ");" << be_uidt_nl; } else { - // anonymous array - *os << storage_class << node->nested_type_name (scope, "_slice", "_") << " *"; - *os << node->nested_type_name (scope, "_alloc", "_") << " (void);" << be_nl; + // Anonymous array. + *os << storage_class << node->nested_type_name (scope, "_slice", "_") + << " *"; + *os << node->nested_type_name (scope, "_alloc", "_") + << " (void);" << be_nl; *os << storage_class << "void " - << node->nested_type_name (scope, "_free", "_") << " ("; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice);" << be_nl; - *os << storage_class << node->nested_type_name (scope, "_slice", "_") << " *"; - *os << node->nested_type_name (scope, "_dup", "_") << " (const "; - *os << node->nested_type_name (scope, "_slice", "_") << " *_tao_slice);" << be_nl; + << node->nested_type_name (scope, "_free", "_") + << " (" << be_idt << be_idt_nl; + *os << node->nested_type_name (scope, "_slice", "_") + << " *_tao_slice" << be_uidt_nl + << ");" << be_uidt_nl; + *os << storage_class << node->nested_type_name (scope, "_slice", "_") + << " *"; + *os << node->nested_type_name (scope, "_dup", "_") + << " (" << be_idt << be_idt_nl + << "const "; + *os << node->nested_type_name (scope, "_slice", "_") + << " *_tao_slice" << be_uidt_nl + << ");" << be_uidt_nl; *os << storage_class << "void " - << 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; + << node->nested_type_name (scope, "_copy", "_") + << " (" << be_idt << be_idt_nl; + *os << node->nested_type_name (scope, "_slice", "_") + << " *_tao_to," << be_nl + << "const "; + *os << node->nested_type_name (scope, "_slice", "_") + << " *_tao_from" << be_uidt_nl + << ");" << be_uidt_nl; } - *os << "\n"; + *os << be_nl; - // generate the endif macro + // Generate the endif macro. os->gen_endif (); node->cli_hdr_gen (1); return 0; } -// generate the var defn +// Generate the var definition. 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 + TAO_OutStream *os = this->ctx_->stream (); + char namebuf [NAMEBUFSIZE]; + char varnamebuf [NAMEBUFSIZE]; + + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (varnamebuf, + '\0', + NAMEBUFSIZE); - 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 ()); + // 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 ()); + 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). + // 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 " << be_global->stub_export_macro () << " " << varnamebuf << be_nl; *os << "{" << be_nl; *os << "public:" << be_idt_nl; // default constr - *os << varnamebuf << " (void); // default constructor" << be_nl; + *os << varnamebuf << " (void);" << be_nl; // constr from pointer to slice *os << varnamebuf << " (" << namebuf << "_slice *);" << be_nl; // copy constructor *os << varnamebuf << " (const " << varnamebuf << - " &); // copy constructor" << be_nl; + " &);" << be_nl; // destructor - *os << "~" << varnamebuf << " (void); // destructor" << be_nl; + *os << "~" << varnamebuf << " (void);" << be_nl; *os << be_nl; // assignment operator from a pointer to slice *os << varnamebuf << " &operator= (" << namebuf << "_slice *);" @@ -301,11 +359,15 @@ be_visitor_array_ch::gen_var_defn (be_array *node) *os << "operator " << namebuf << "_slice *&();" << be_nl; } + *os << be_nl; + // Non-spec helper function used if array is a sequence element. - *os << "//Calls " << namebuf << "_copy " + *os << "// Calls " << namebuf << "_copy " << "(used in sequences of " << namebuf << ")." << be_nl; - *os << "static void copy (" << namebuf << "_slice *_tao_to, " - << "const " << namebuf << "_slice *_tao_from);" << be_nl; + *os << "static void copy (" << be_idt << be_idt_nl + << namebuf << "_slice *_tao_to," << be_nl + << "const " << namebuf << "_slice *_tao_from" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; // in, inout, out and _retn *os << "// in, inout, out, _retn " << be_nl; @@ -323,42 +385,54 @@ be_visitor_array_ch::gen_var_defn (be_array *node) *os << namebuf << "_slice *&out (void);" << be_nl; *os << namebuf << "_slice *_retn (void);" << be_nl; - // generate an additional member function that returns the underlying pointer + // Generate an additional member function that returns the + // underlying pointer. *os << namebuf << "_slice *ptr (void) const;" << be_uidt_nl; - // generate the private section + // Generate the private section. *os << "private:" << be_idt_nl; *os << namebuf << "_slice *ptr_;" << be_uidt_nl; - *os << "};\n\n"; + *os << "};" << be_nl << be_nl; return 0; } -// generate the _out definition +// 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 + TAO_OutStream *os = this->ctx_->stream (); + char namebuf [NAMEBUFSIZE]; + char outnamebuf [NAMEBUFSIZE]; + + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (outnamebuf, + '\0', + NAMEBUFSIZE); - 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 ()); + 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 ()); + // 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 - + // Generate the out definition (always in the client header). *os << "class " << be_global->stub_export_macro () << " " << outnamebuf << be_nl; *os << "{" << be_nl; @@ -366,21 +440,21 @@ be_visitor_array_ch::gen_out_defn (be_array *node) // No default constructor - // constructor from a pointer to slice + // Constructor from a pointer to slice. *os << outnamebuf << " (" << namebuf << "_slice *&);" << be_nl; - // constructor from a _var & + // 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 & + // Constructor from a _out & + *os << outnamebuf << " (const " << outnamebuf << " &);" << be_nl << be_nl; + // Assignment operator from a _out & *os << outnamebuf << " &operator= (const " << outnamebuf << " &);" << be_nl; - // assignment from slice * + // Assignment from slice * *os << outnamebuf << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // cast + << be_nl << be_nl; + // Cast *os << "operator " << namebuf << "_slice *&();" << be_nl; - // ptr fn - *os << namebuf << "_slice *&ptr (void);" << be_nl; + // ptr function + *os << namebuf << "_slice *&ptr (void);" << be_nl << be_nl; // operator [] instead of -> *os << namebuf << "_slice &operator[] (CORBA::ULong index);" << be_nl; *os << "const " << namebuf << "_slice &operator[] " @@ -388,83 +462,95 @@ be_visitor_array_ch::gen_out_defn (be_array *node) *os << "private:" << be_idt_nl; *os << namebuf << "_slice *&ptr_;" << be_nl; - *os << "// assignment from T_var not allowed" << be_nl; + *os << "// Assignment from T_var not allowed." << be_nl; *os << "void operator= (const " << namebuf << "_var &);" << be_uidt_nl; - *os << "};\n\n"; + *os << "};" << be_nl << be_nl; + return 0; } -// generate the _var definition for ourself +// generate the _forany definition for ourself. int be_visitor_array_ch::gen_forany_defn (be_array *node) { if (node->is_local ()) - return 0; + { + return 0; + } - TAO_OutStream *os = this->ctx_->stream (); // output stream - char namebuf [NAMEBUFSIZE]; // names - char foranyname [NAMEBUFSIZE]; // forany class names + TAO_OutStream *os = this->ctx_->stream (); + char namebuf [NAMEBUFSIZE]; + char foranyname [NAMEBUFSIZE]; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::memset (foranyname, '\0', NAMEBUFSIZE); + 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 ()); + 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", + // 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). + // 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 " << be_global->stub_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 + // Default constuctor. + *os << foranyname << " (void);" << be_nl; + // Constuctor from pointer to slice. + *os << foranyname << " (" << be_idt << be_idt_nl + << namebuf << "_slice *," << be_nl + << "CORBA::Boolean nocopy = 0" << be_uidt_nl + << ");" << be_uidt_nl; + // Copy constructor. *os << foranyname << " (const " << foranyname - << " &); // copy constructor" << be_nl; - // destructor - *os << "~" << foranyname << " (void); // destructor" << be_nl; + << " &);" << be_nl; + // Destructor. + *os << "~" << foranyname << " (void);" << be_nl << be_nl; - *os << "static void _tao_any_destructor (void*);" << be_nl; + *os << "static void _tao_any_destructor (void*);" << be_nl << 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; + *os << foranyname << " &operator= (const " << foranyname << " &);" + << be_nl << be_nl; - // arrow operator - // nothing here - *os << be_nl; - - // other extra types (cast operators, [] operator, and others) + // 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; + << "_slice &operator[] (CORBA::ULong index) const;" << be_nl << be_nl; // cast operators *os << "operator " << namebuf << "_slice * const &() const;" << be_nl; - *os << "operator " << namebuf << "_slice *&();" << be_nl; + *os << "operator " << namebuf << "_slice *&();" << be_nl << be_nl; // in, inout, out and _retn *os << "// in, inout, out, _retn " << be_nl; @@ -473,18 +559,18 @@ be_visitor_array_ch::gen_forany_defn (be_array *node) *os << namebuf << "_slice *&out (void);" << be_nl; *os << namebuf << "_slice *_retn (void);" << be_nl; - // generate an additional member function that returns the underlying pointer + // 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 + // Additional member function that returns the NOCOPY flag. *os << "CORBA::Boolean nocopy (void) const;" << be_uidt_nl; - // generate the private section + // 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"; + *os << "};" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp index 5f38c6e62fc..89879fdbb8c 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp @@ -41,7 +41,7 @@ be_visitor_constant_ch::~be_visitor_constant_ch (void) { } -// visit the Constant_Ch node and its scope +// Visit the Constant node and its scope. int be_visitor_constant_ch::visit_constant (be_constant *node) { @@ -49,28 +49,36 @@ be_visitor_constant_ch::visit_constant (be_constant *node) 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 + // 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 + // Is our enclosing scope a module? We need this check because for // platforms that support namespaces, the typecode must be declared - // extern + // extern. if (node->is_nested () && (node->defined_in ()->scope_node_type () == AST_Decl::NT_module)) - *os << "TAO_NAMESPACE_STORAGE_CLASS "; + { + *os << "TAO_NAMESPACE_STORAGE_CLASS "; + } else - *os << "static "; + { + *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 + // header itself. *os << " = " << node->constant_value (); } - *os << ";\n\n"; + + *os << ";" << be_nl << be_nl; + node->cli_hdr_gen (I_TRUE); } + 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 index 9fd0bbb37ac..fcd2b30f412 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp @@ -52,27 +52,25 @@ be_visitor_enum_ch::visit_enum (be_enum *node) if (!node->cli_hdr_gen () && !node->imported ()) { - // Start from whatever indentation level we were at. - os->indent (); *os << "enum " << node->local_name () << be_nl; *os << "{" << be_idt_nl; if (this->visit_scope (node) == 1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_enum_ch::" - "visit_enum - " - "scope generation failed\n" - ), -1); - } + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_enum_ch::" + "visit_enum - " + "scope generation failed\n" + ), + -1); + } - os->indent (); *os << be_uidt_nl; - *os << "};" << be_nl; + *os << "};" << be_nl << be_nl; // As per the ORBOS spec, we need the following typedef *os << "typedef " << node->local_name () << " &" << node->local_name () - << "_out;\n"; + << "_out;" << be_nl; if (!node->is_local ()) { @@ -119,7 +117,6 @@ 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_exception/exception_ch.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp index 23ae9580a40..f5bd68ac4ca 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp @@ -50,12 +50,11 @@ int be_visitor_exception_ch::visit_exception (be_exception *node) os->gen_ifdef_macro (node->flat_name ()); - os->indent (); *os << "class " << be_global->stub_export_macro () << " " << node->local_name () << " : public CORBA::UserException" << be_nl; *os << "{" << be_nl - << "public:\n" << be_idt; + << "public:" << be_idt_nl; // Generate code for field members. if (this->visit_scope (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp index 19053b09ec5..b91688e46d1 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp @@ -31,27 +31,27 @@ ACE_RCSID(be_visitor_field, field_ch, "$Id$") // visitor for field in the client header file // ********************************************** -// constructor +// Constructor. be_visitor_field_ch::be_visitor_field_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor +// Destructor. be_visitor_field_ch::~be_visitor_field_ch (void) { } -// visit the field node +// 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 + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - os = this->ctx_->stream (); - // first generate the type information + // First generate the type information. bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -61,7 +61,8 @@ be_visitor_field_ch::visit_field (be_field *node) ), -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -70,43 +71,47 @@ be_visitor_field_ch::visit_field (be_field *node) "codegen for field type failed\n" ), -1); } - // now output the field name. - *os << " " << node->local_name () << ";\n"; + + // Now output the field name. + *os << " " << node->local_name () << ";" << be_nl; + return 0; } -// =visit operations on all possible data types that a field can be +// =Visit operations on all possible data types that a field can be. -// visit array type +// Visit array type. int be_visitor_field_ch::visit_array (be_array *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = 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 + { + bt = node; + } - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. + // This is the case for anonymous arrays. - // instantiate a visitor context with a copy of our context. This info + // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); ctx.node (node); // set the node to be the node being visited. The scope // is still the same - // first generate the struct declaration + // 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, @@ -115,6 +120,7 @@ be_visitor_field_ch::visit_array (be_array *node) "Bad visitor\n" ), -1); } + if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -123,57 +129,60 @@ be_visitor_field_ch::visit_array (be_array *node) "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 (); + // Having defined all array type and its supporting operations, now + // generate the actual variable that is a field of the structure. *os << "_" << bt->local_name (); } else { - // this was a typedefed array - os->indent (); // start from current indentation level - + // This was a typedefed array. // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } } return 0; } -// visit enum type +// Visit enum type. int be_visitor_field_ch::visit_enum (be_enum *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - - // set the right type; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the enum declaration + // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CH); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -182,6 +191,7 @@ be_visitor_field_ch::visit_enum (be_enum *node) "Bad visitor\n" ), -1); } + if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -190,39 +200,42 @@ be_visitor_field_ch::visit_enum (be_enum *node) "codegen failed\n" ), -1); } + delete visitor; } - // now use this enum as a "type" for the subsequent declarator - os->indent (); // start from current indentation level - + // Now use this enum as a "type" for the subsequent declarator. // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } return 0; } -// visit interface type +// Visit interface type. int be_visitor_field_ch::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = 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 (); + { + bt = node; + } + // If not a typedef and we are defined in the use scope, we must be defined. // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) @@ -237,23 +250,23 @@ be_visitor_field_ch::visit_interface (be_interface *node) return 0; } -// visit interface forward type +// Visit interface forward type. int be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = 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 (); + { + bt = node; + } + // If not a typedef and we are defined in the use scope, we must be defined. // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) @@ -270,81 +283,90 @@ be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) #ifdef IDL_HAS_VALUETYPE -// visit valuetype type +// Visit valuetype type. int be_visitor_field_ch::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = 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 (); + { + bt = node; + } + // If not a typedef and we are defined in the use scope, we must be defined. // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + { + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + } else - *os << bt->name () << "_var"; + { + *os << bt->name () << "_var"; + } return 0; } -// visit valuetype forward type +// Visit valuetype forward type. int be_visitor_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = 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 (); + { + bt = node; + } + // If not a typedef and we are defined in the use scope, we must be defined. // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + { + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + } else - *os << bt->name () << "_var"; + { + *os << bt->name () << "_var"; + } return 0; } #endif /* IDL_HAS_VALUETYPE */ -// visit predefined type +// Visit predefined type. int be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + 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 + // If not a typedef and we are defined in the use scope, we must be defined. + if (node->pt () == AST_PredefinedType::PT_pseudo) { - // check if we are dealing with a CORBA::Object + // Check if we are dealing with a CORBA::Object, if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) { *os << bt->name () << "_var"; @@ -354,9 +376,13 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (bt->defined_in ()->scope_node_type () == AST_Decl::NT_interface) - *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + { + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); + } else - *os << bt->name () << "_var"; + { + *os << bt->name () << "_var"; + } } } else @@ -364,56 +390,67 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } } + return 0; } -// visit sequence type +// Visit sequence type. int be_visitor_field_ch::visit_sequence (be_sequence *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the sequence declaration + // First generate the sequence declaration. ctx.state (TAO_CodeGen::TAO_SEQUENCE_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); + ), + -1); } + if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" "visit_sequence - " "codegen failed\n" - ), -1); + ), + -1); } + delete visitor; // If we are being reused by valutype, this would get generated @@ -426,42 +463,41 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) // This provides a consistent name to use instead of the // implementation-specific name. be_decl *bs = this->ctx_->scope (); - os->decr_indent (0); - *os << "#if !defined (__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_idt_nl + *os << "\n#if !defined (__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" + << be_nl << "typedef " << bt->nested_type_name (bs) << " _" << this->ctx_->node ()->local_name () - << "_seq;" << be_uidt_nl; + << "_seq;\n"; *os << "#endif /* ! __GNUC__ || ACE_HAS_GNUG_PRE_2_8 */\n" << be_nl; - os->incr_indent (); } } - os->indent (); // start from current indentation level - // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. be_typedef *tdef = be_typedef::narrow_from_decl (bt); if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME || !tdef) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } return 0; } -// visit string type +// Visit string type. int be_visitor_field_ch::visit_string (be_string *node) { TAO_OutStream *os; // output stream os = this->ctx_->stream (); - os->indent (); // start from current indentation level - // set the right type; + // Set the right type. if (node->width () == (long) sizeof (char)) { *os << "TAO_String_Manager"; @@ -474,34 +510,35 @@ be_visitor_field_ch::visit_string (be_string *node) return 0; } -// visit structure type +// Visit structure type. int be_visitor_field_ch::visit_structure (be_structure *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = 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 + { + 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 + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the struct declaration + // First generate the struct declaration. ctx.state (TAO_CodeGen::TAO_STRUCT_CH); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -510,6 +547,7 @@ be_visitor_field_ch::visit_structure (be_structure *node) "Bad visitor\n" ), -1); } + if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -518,31 +556,33 @@ be_visitor_field_ch::visit_structure (be_structure *node) "codegen failed\n" ), -1); } + delete visitor; } - os->indent (); // start from current indentation level - // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } return 0; } -// visit typedefed type +// 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 + this->ctx_->alias (node); - // make a decision based on the primitive base type + // Make a decision based on the primitive base type. be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, @@ -551,7 +591,8 @@ be_visitor_field_ch::visit_typedef (be_typedef *node) "Bad primitive type\n" ), -1); } - // reset the alias + + // Reset the alias. this->ctx_->alias (0); return 0; } @@ -560,56 +601,64 @@ be_visitor_field_ch::visit_typedef (be_typedef *node) int be_visitor_field_ch::visit_union (be_union *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - os = this->ctx_->stream (); - // set the right type; if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the union declaration + // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_CH); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" "visit_union - " "Bad visitor\n" - ), -1); + ), + -1); } + if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" "visit_union - " "codegen failed\n" - ), -1); + ), + -1); } + delete visitor; } - os->indent (); // start from current indentation level - // ACE_NESTED_CLASS macro generated by nested_type_name // is not necessary in all cases. if (this->ctx_->sub_state () != TAO_CodeGen::TAO_USE_FULL_NAME) - *os << bt->nested_type_name (this->ctx_->scope ()); + { + *os << bt->nested_type_name (this->ctx_->scope ()); + } else - *os << bt->name (); + { + *os << bt->name (); + } return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp index 3673627002a..ba0bc444b7e 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_interface_ch.cpp @@ -44,31 +44,29 @@ be_visitor_ami_interface_ch::~be_visitor_ami_interface_ch (void) int be_visitor_ami_interface_ch::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream - // No need to check for code already having been generated. This // is a separate pass through the AST specific to AMI, and will // happen only once. - if (!node->imported () && // not imported - !node->is_local ()) // and not local interface. + if (node->imported () || node->is_local ()) { - // Grab the stream. - os = this->ctx_->stream (); + return 0; + } + // Grab the stream. + TAO_OutStream *os = this->ctx_->stream (); - os->gen_ifdef_macro (node->replacement ()->flat_name (), "_ptr"); - os->indent (); // start with whatever indentation level we are at - // forward declaration - *os << "class " << node->replacement ()->local_name () << ";" << be_nl; + os->gen_ifdef_macro (node->replacement ()->flat_name (), "_ptr"); - // generate the _ptr declaration - *os << "typedef " << node->replacement ()->local_name () - << " *" << node->replacement ()->local_name () - << "_ptr;" << be_nl << be_nl; + // Forward declaration. + *os << "class " << node->replacement ()->local_name () << ";" << be_nl; - os->gen_endif (); - } + // Generate the _ptr declaration. + *os << "typedef " << node->replacement ()->local_name () + << " *" << node->replacement ()->local_name () + << "_ptr;" << be_nl << be_nl; + + os->gen_endif (); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp index 0e82eb9b6fa..923c51e2978 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_broker_ch.cpp @@ -45,7 +45,7 @@ be_visitor_interface_base_proxy_broker_ch::visit_interface (be_interface *node) // Accessor Method *os << "virtual " << node->base_proxy_impl_name () << " &" << "select_proxy (" - << be_idt_nl; // idt = 2 + << be_idt << be_idt_nl; *os << node->local_name () << " *object," << be_nl << "CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()" << be_uidt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp index b033c856af8..3fab08b2919 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp @@ -29,16 +29,18 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) *os << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl - << "// Base Impl. Declaration" << be_nl + << "// Base Proxy Impl. Declaration" << be_nl << "//" << be_nl << be_nl; // Generate Class Declaration. *os << "class " << be_global->stub_export_macro () - << " " << node->base_proxy_impl_name (); + << " " << node->base_proxy_impl_name () << be_idt_nl + << ": "; if (node->n_inherits () > 0) { - *os << " : " << be_idt_nl; // idt = 1 + *os << be_idt; + for (int i = 0; i < node->n_inherits (); i++) { be_interface *inherited = @@ -46,29 +48,28 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) *os << "public virtual "; *os << inherited->full_base_proxy_impl_name (); - if (i < node->n_inherits () - 1) // node is the case of multiple - // inheritance, so put a comma + + if (i < node->n_inherits () - 1) { + // Node is the case of multiple + // inheritance, so put a comma. *os << ", " << be_nl; } - } // end of for loop - *os << be_uidt_nl; // idt = 0 + } + + *os << be_uidt << be_uidt_nl; // idt = 0 } else { - *os << " : public virtual TAO_Object_Proxy_Impl" << be_nl; + *os << "public virtual TAO_Object_Proxy_Impl" << be_uidt_nl; } + *os << "{" << be_nl << "public:" << be_idt_nl; // idt = 1 - - // Destructor Declaration. *os << "virtual ~" << node->base_proxy_impl_name () << " (void) { }" - << be_nl << be_nl; - - - + << be_nl; if (this->visit_scope (node) == -1) { @@ -78,17 +79,16 @@ be_visitor_interface_base_proxy_impl_ch::visit_interface (be_interface *node) "codegen for scope failed\n"), -1); } - *os << be_uidt; // idt = 0 + *os << be_uidt_nl; // Constructor Declaration. *os << "protected:" << be_idt_nl // idt = 1 << node->base_proxy_impl_name () << " (void);" - << be_uidt_nl // idt = 0 - << be_nl; + << be_uidt_nl; - *os << "};" << be_nl + *os << "};" << be_nl << be_nl << "//" << be_nl - << "// Base Proxy Impl. Declaration" << be_nl + << "// End Base Proxy Impl. Declaration" << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp index 32585b020d8..1646a138c6c 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp @@ -59,8 +59,6 @@ be_visitor_interface_ch::visit_interface (be_interface *node) // The following two are required to be under the ifdef macro to avoid // multiple declarations. - // Start with whatever indentation level we are at. - os->indent (); // Forward declaration. *os << "class " << node->local_name () << ";" << be_nl; // Generate the _ptr declaration. @@ -78,8 +76,10 @@ be_visitor_interface_ch::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ch::" "visit_interface - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } + os->gen_endif (); // Generate the ifdef macro for the _out class. @@ -94,6 +94,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) "visit_interface - " "codegen for _out failed\n"), -1); } + // Generate the endif macro. os->gen_endif (); } @@ -108,7 +109,6 @@ be_visitor_interface_ch::visit_interface (be_interface *node) // Now the interface definition itself. os->gen_ifdef_macro (node->flat_name ()); - os->indent (); if (!node->is_local ()) { @@ -120,14 +120,17 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << "class " << node->remote_proxy_broker_name () << ";" << be_nl << be_nl; } + // Now generate the class definition. *os << "class " << be_global->stub_export_macro () - << " " << node->local_name (); + << " " << node->local_name () << be_idt_nl + << ": " ; // If node interface inherits from other interfaces. if (node->n_inherits () > 0) { - *os << ": "; + *os << be_idt; + for (i = 0; i < node->n_inherits (); i++) { be_interface *inherited = @@ -148,17 +151,17 @@ be_visitor_interface_ch::visit_interface (be_interface *node) if (i < node->n_inherits () - 1) { // Node has multiple inheritance, so put a comma. - *os << ", "; + *os << ", " << be_nl; } } // end of for loop - *os << be_nl; + *os << be_uidt << be_uidt_nl; } else { // We do not inherit from anybody, hence we do so from the base // CORBA::Object class. - *os << " : public virtual CORBA_Object" << be_nl; + *os << "public virtual CORBA_Object" << be_uidt_nl; } // Generate the body. @@ -179,14 +182,14 @@ be_visitor_interface_ch::visit_interface (be_interface *node) // Generate the static _duplicate, _narrow, and _nil operations. *os << "// the static operations" << be_nl << "static " << node->local_name () << "_ptr " << "_duplicate (" - << node->local_name () << "_ptr obj);" << be_nl + << node->local_name () << "_ptr obj);" << be_nl << be_nl << "static " << node->local_name () << "_ptr " << "_narrow (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj," << be_nl << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl << "TAO_default_environment ()" << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; + << ");" << be_uidt_nl << be_nl; // There's no need for an _unchecked_narrow for locality // constrained object. @@ -196,7 +199,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl << "TAO_default_environment ()" << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; + << ");" << be_uidt_nl << be_nl; // This method is defined in the header file to workaround old // g++ problems. @@ -204,13 +207,12 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << be_idt_nl << "{" << be_idt_nl << "return (" << node->local_name () << "_ptr)0;" << be_uidt_nl - << "}" << be_uidt << "\n\n"; + << "}" << be_uidt_nl << be_nl; // No Any operator for local interfaces. if (! node->is_local ()) { - os->indent (); - *os << "static void _tao_any_destructor (void*);\n\n"; + *os << "static void _tao_any_destructor (void*);" << be_nl << be_nl; } // Generate code for the interface definition by traversing thru the @@ -226,8 +228,6 @@ be_visitor_interface_ch::visit_interface (be_interface *node) } // The _is_a method - os->indent (); - if (! node->is_local ()) { *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl @@ -235,7 +235,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl << "TAO_default_environment ()" << be_uidt << be_uidt_nl - << ");" << be_uidt << be_nl; + << ");" << be_uidt_nl << be_nl; } // The _tao_QueryInterface method. @@ -265,8 +265,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) *os << node->local_name () << " (int collocated = 0);" << be_nl << be_nl; - *os << "protected:" << be_idt_nl - << "// This methods travese the inheritance tree and set the" + *os << "// This methods travese the inheritance tree and set the" << be_nl << "// parents piece of the given class in the right mode" << be_nl @@ -282,9 +281,9 @@ be_visitor_interface_ch::visit_interface (be_interface *node) if (! node->is_local ()) { *os << node->local_name () - << " (" << be_idt << be_nl << "TAO_Stub *objref, " << be_nl + << " (" << be_idt << be_idt_nl << "TAO_Stub *objref, " << be_nl << "CORBA::Boolean _tao_collocated = 0," << be_nl - << "TAO_Abstract_ServantBase *servant = 0" << be_nl + << "TAO_Abstract_ServantBase *servant = 0" << be_uidt_nl << ");" << be_uidt_nl << be_nl; // Friends declarations. @@ -293,10 +292,11 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << "friend class " << node->thru_poa_proxy_impl_name () << ";" << be_nl << "friend class " << node->direct_proxy_impl_name () << ";" - << be_uidt_nl << be_nl; + << be_nl << be_nl; } // Protected destructor. - *os << "virtual ~" << node->local_name () << " (void);" << be_uidt_nl; + *os << "virtual ~" << node->local_name () << " (void);" + << be_uidt_nl << be_nl; // private copy constructor and assignment operator. These are not // allowed, hence they are private. @@ -318,11 +318,11 @@ be_visitor_interface_ch::visit_interface (be_interface *node) if (!visitor || (node->accept (visitor) == -1)) { delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ch::" - "visit_interface - " - "codegen for interceptor classes failed\n"), - -1); + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ch::" + "visit_interface - " + "codegen for interceptor classes failed\n"), + -1); } delete visitor; @@ -331,7 +331,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) ctx = *this->ctx_; *os << be_uidt_nl; - *os << "};\n\n"; + *os << "};" << be_nl << be_nl; // Don't support smart proxies for local interfaces. if (! node->is_local ()) @@ -398,24 +398,21 @@ be_visitor_interface_ch::visit_interface (be_interface *node) os->gen_endif (); - if (! node->is_local ()) + if (!node->is_local ()) { - // By using a visitor to declare and define the TypeCode, we - // have the added advantage to conditionally not generate - // any code. This will be based on the command line - // options. This is still TO-DO be_visitor *visitor; visitor = 0; 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); + ), + -1); } - } node->cli_hdr_gen (I_TRUE); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp index 7cd93dadf21..357e932f3af 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp @@ -24,14 +24,12 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); // Generate Guards. - // os->gen_ifdef_macro (node->local_name (), "PROXY_BROKERS"); // Generate the class declaration. - os->indent (); - *os << "\n// The Proxy Brokers are used by each interface to get\n" - << "// the right proxy for performing a call. In the new \n" - << "// collocation scheme, the proxy to be used can vary on\n" - << "// a call by call basis. \n\n\n"; + *os << "// The Proxy Brokers are used by each interface to get" << be_nl + << "// the right proxy for performing a call. In the new " << be_nl + << "// collocation scheme, the proxy to be used can vary on" << be_nl + << "// a call by call basis." << be_nl << be_nl; // Code Generation for the proxy brokers base class. be_visitor *visitor = 0; @@ -48,13 +46,14 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) "codegen for Base Proxy Broker class failed\n"), -1); } + delete visitor; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CH); visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (!visitor || (node->accept (visitor) == -1)) { delete visitor; ACE_ERROR_RETURN ((LM_ERROR, @@ -63,10 +62,8 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) "codegen for Remote Proxy Broker class failed\n"), -1); } - delete visitor; - // Close #ifdef Guard. - // os->gen_endif (); + delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp index 125340e615f..bc902079089 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp @@ -22,13 +22,13 @@ int be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - // Generate Guards. - // os->gen_ifdef_macro (node->local_name (), "PROXY_IMPLS"); - *os << "\n// The Proxy Implementations are used by each interface to\n" - << "// perform a call. Each different implementation encapsulate\n" - << "// an invocation logics.\n\n"; + // Generate Guards. + *os << "// The Proxy Implementations are used by each interface to" + << be_nl + << "// perform a call. Each different implementation encapsulate" + << be_nl + << "// an invocation logics." << be_nl << be_nl; // Code Generation for the proxy imlpementations base class. be_visitor *visitor = 0; @@ -45,13 +45,14 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) "codegen for Base Proxy Impl. class failed\n"), -1); } + delete visitor; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH); visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (!visitor || (node->accept (visitor) == -1)) { delete visitor; ACE_ERROR_RETURN ((LM_ERROR, @@ -60,10 +61,8 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) "codegen for Remote Proxy Broker class failed\n"), -1); } - delete visitor; - // Close #ifdef Guard. - // os->gen_endif (); + delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp index ea74a83a16b..431c12602b5 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_broker_ch.cpp @@ -32,52 +32,44 @@ be_visitor_interface_remote_proxy_broker_ch::visit_interface (be_interface *node << "//" << be_nl << be_nl; *os << "class " << be_global->stub_export_macro () << " " - << node->remote_proxy_broker_name () << " : public virtual " - << node->base_proxy_broker_name () << be_nl << "{" << be_nl + << node->remote_proxy_broker_name () << be_idt_nl + << ": public virtual " + << node->base_proxy_broker_name () << be_uidt_nl + << "{" << be_nl << "public: " << be_idt_nl; // Constructor *os << node->remote_proxy_broker_name () << " (void);" << be_nl << be_nl; // Destructor - *os << "virtual ~" << node->remote_proxy_broker_name () << " (void);" << be_nl << be_nl; + *os << "virtual ~" << node->remote_proxy_broker_name () << " (void);" + << be_nl << be_nl; // Accessor Method - *os << "virtual " << node->base_proxy_impl_name () << " &" << "select_proxy (" << be_idt_nl; + *os << "virtual " << node->base_proxy_impl_name () << " &" << "select_proxy (" + << be_idt << be_idt_nl; *os << node->local_name () << " *object," << be_nl << "CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; + << ");" << be_uidt_nl << be_uidt_nl; *os << "private:" << be_idt_nl << node->remote_proxy_impl_name () << " remote_proxy_impl_;" - << be_uidt_nl; + << be_uidt_nl << be_nl; + + *os << "public:" << be_idt_nl; // Factory Member Function declaration. *os << "// This member function is used to get an handle to the unique instance" << be_nl << "// of the Remote Proxy Broker that is available for a given" << be_nl - << "// interface." - << be_nl << be_nl; - *os << "public:" << be_idt_nl + << "// interface." << be_nl << "static " << node->remote_proxy_broker_name () << " *the" << node->remote_proxy_broker_name () << " (void);" << be_uidt_nl; *os << "};" << be_nl << be_nl; - - /* - if (node->is_nested ()) - *os << "TAO_NAMESPACE_STORAGE_CLASS "; - else - *os << "static "; - - *os << node->remote_proxy_broker_name () << " *the" - << node->remote_proxy_broker_name () - << " (void);" << be_nl; - */ - *os << be_nl - << "//" << be_nl + *os << "//" << be_nl << "// End Remote Proxy Broker Declaration " << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp index 60387be3eb2..63495aaa3a6 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp @@ -23,21 +23,22 @@ be_visitor_interface_remote_proxy_impl_ch::visit_interface (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - os->decr_indent (0); - *os << be_nl - << "///////////////////////////////////////////////////////////////////////" << be_nl - << "// Remote Impl. Declaration" << be_nl + << "///////////////////////////////////////////////////////////////////////" + << be_nl + << "// Remote Proxy Impl. Declaration" << be_nl << "//" << be_nl << be_nl; + // Generate Class Declaration. *os << "class " << be_global->stub_export_macro () - << " " << node->remote_proxy_impl_name (); - *os << " : " << be_idt_nl << "public virtual " << node->base_proxy_impl_name () - << "," << be_nl << "public virtual " << "TAO_Remote_Object_Proxy_Impl"; + << " " << node->remote_proxy_impl_name () << be_idt_nl; + *os << ": " << "public virtual " << node->base_proxy_impl_name () + << "," << be_idt_nl << "public virtual " << "TAO_Remote_Object_Proxy_Impl"; if (node->n_inherits () > 0) { *os << "," << be_nl; + for (int i = 0; i < node->n_inherits (); i++) { be_interface *inherited = @@ -45,16 +46,18 @@ be_visitor_interface_remote_proxy_impl_ch::visit_interface (be_interface *node) *os << "public virtual "; *os << inherited->full_remote_proxy_impl_name (); - if (i < node->n_inherits () - 1) // node is the case of multiple - // inheritance, so put a comma + + if (i < node->n_inherits () - 1) { + // Node is the case of multiple + // inheritance, so put a comma. *os << ", "; + *os << be_nl; } - *os << be_nl; - } // end of for loop + } } - *os << be_uidt_nl; + *os << be_uidt << be_uidt_nl; *os << "{" << be_nl << "public:" << be_idt_nl; // Constructor Declaration. @@ -63,23 +66,23 @@ be_visitor_interface_remote_proxy_impl_ch::visit_interface (be_interface *node) // Destructor Declaration. *os << "virtual ~" << node->remote_proxy_impl_name () << " (void) { }" - << be_nl << be_nl; + << be_nl; if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ch::" "visit_interface - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - *os << "};" << be_uidt << be_nl; + *os << be_uidt_nl << "};" << be_nl; *os << be_nl << "//" << be_nl - << "// Base Proxy Impl. Declaration" << be_nl + << "// End Remote Proxy Impl. Declaration" << be_nl << "///////////////////////////////////////////////////////////////////////" << be_nl << be_nl; 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 index 4c06d4bf7e3..9157fa79405 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ch.cpp @@ -52,19 +52,15 @@ be_visitor_interface_fwd_ch::visit_interface_fwd (be_interface_fwd *node) return 0; } - os->indent (); // start from the current - - // all we do in this is generate a forward declaration of the class + // 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->flat_name (), "_ptr"); - os->indent (); // start from the current - // Generate the _ptr typedef. *os << "typedef " << node->local_name () << " *" << node->local_name () - << "_ptr;\n"; + << "_ptr;" << be_nl; os->gen_endif (); @@ -86,12 +82,14 @@ be_visitor_interface_fwd_ch::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_fwd_ch::" "visit_interface_fwd - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } - // gen an endif + + // Generate an endif. os->gen_endif (); - // enclose under an ifdef macro + // Enclose under an ifdef macro. os->gen_ifdef_macro (node->flat_name (), "_out"); // generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec @@ -100,9 +98,11 @@ be_visitor_interface_fwd_ch::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_fwd_ch::" "visit_interface_fwd - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } - // generate the endif macro + + // Generate the endif macro. os->gen_endif (); node->cli_hdr_gen (I_TRUE); diff --git a/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp b/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp index d3987cc2013..8f6ec45705d 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/module_ch.cpp @@ -48,19 +48,12 @@ be_visitor_module_ch::visit_module (be_module *node) { 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->stub_export_macro () + os->indent (); + *os << "TAO_NAMESPACE " << " " << node->local_name () << be_nl - << "{\n"; - os->incr_indent (0); + << "{" << be_idt_nl; - // generate code for the module definition by traversing thru the + // 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) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp index c01dfeb555d..04cda155428 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp @@ -46,45 +46,48 @@ be_visitor_operation_ami_ch::visit_operation (be_operation *node) { // No sendc method for oneway operations. if (node->flags () == AST_Operation::OP_oneway) - return 0; + { + return 0; + } // Output stream. - TAO_OutStream *os ; - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os->indent (); // start with the current indentation level - - // every operation is declared virtual in the client code + // Every operation is declared virtual in the client code. *os << "virtual "; // STEP I: Return type is void. *os << "void "; - // STEP 2: generate the operation name. + // STEP 2: Generate the operation name. // First the sendc prefix. *os << "sendc_"; - // check if we are an attribute node in disguise + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "set_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name (); - // STEP 3: generate the argument list with the appropriate + // STEP 3: Generate the argument list with the appropriate // mapping. For these we grab a visitor that generates the // parameter listing. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -103,9 +106,10 @@ be_visitor_operation_ami_ch::visit_operation (be_operation *node) "codegen for argument list failed\n"), -1); } + delete visitor; - *os << "\n"; +// *os << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_ch.cpp index 123c4b6d4cc..00aab1e66cb 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_ch.cpp @@ -45,24 +45,20 @@ be_visitor_operation_ami_exception_holder_operation_ch::~be_visitor_operation_am int be_visitor_operation_ami_exception_holder_operation_ch::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (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 + // Every operation is declared virtual in the client code. *os << be_idt << "virtual "; - // STEP I: generate the return type. Return type is simpy void. + // STEP I: Generate the return type. Return type is simpy void. *os << "void raise_"; - // check if we are an attribute node in disguise + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) *os << "set_"; else *os << "get_"; @@ -73,11 +69,17 @@ be_visitor_operation_ami_exception_holder_operation_ch::visit_operation (be_oper << " ("; if (!idl_global->exception_support ()) - *os << "CORBA::Environment &ACE_TRY_ENV =" << be_idt << be_idt_nl - << "TAO_default_environment ()" << be_uidt << be_uidt; - *os << ")" << be_idt; + { + *os << "CORBA::Environment &ACE_TRY_ENV =" << be_idt << be_idt_nl + << "TAO_default_environment ()" << be_uidt << be_uidt_nl + << ")"; + } + else + { + *os << ")"; + } - // now generate the throw specs + // Now generate the throw specs. if (this->gen_throw_spec (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -87,7 +89,7 @@ be_visitor_operation_ami_exception_holder_operation_ch::visit_operation (be_oper -1); } - *os << ";\n" << be_uidt << be_uidt; + *os << be_uidt << be_uidt_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp index 59d44bd274c..af3aee2ba65 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_ch.cpp @@ -56,21 +56,21 @@ be_visitor_operation_ami_handler_reply_stub_operation_ch::visit_operation (be_op if (!node->has_native ()) { - // Indent. - os->indent (); - // Next line. - *os << be_nl - << "static void "; + *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_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } } *os << node->local_name () << "_reply_stub (" << be_idt << be_idt_nl; @@ -81,11 +81,8 @@ be_visitor_operation_ami_handler_reply_stub_operation_ch::visit_operation (be_op *os << "," << be_nl << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl - << "TAO_default_environment ()" << be_uidt; - - *os << ");" - << be_uidt << be_nl - << be_uidt << "\n\n"; + << "TAO_default_environment ()" << be_uidt << be_uidt_nl + << ");" << be_uidt_nl << be_nl; } return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp index ba303381b40..e2cca6d452f 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp @@ -125,23 +125,23 @@ be_visitor_operation_arglist::visit_operation (be_operation *node) case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: if (node->is_local ()) - *os << " = 0;\n\n"; + *os << " = 0;" << be_nl << be_nl; else - *os << ";\n\n"; + *os << ";" << be_nl << be_nl; break; case TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XH: - *os << ";\n\n"; + *os << ";" << be_nl << be_nl; break; case TAO_CodeGen::TAO_OPERATION_ARGLIST_BASE_PROXY_IMPL_CH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: // each method is pure virtual in the server header - *os << " = 0;\n\n"; + *os << " = 0;" << be_nl << be_nl; break; case TAO_CodeGen::TAO_OPERATION_ARGLIST_IS: case TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS: default: - *os << "\n"; + *os << be_nl; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp index a2cc2e08023..5cf6a728d1b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp @@ -26,13 +26,14 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node os = this->ctx_->stream (); this->ctx_->node (node); // save the node - os->indent (); // start with the current indentation level +// 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, @@ -65,6 +66,7 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node "codegen for return type failed\n"), -1); } + delete visitor; // STEP 2: generate the operation name @@ -75,6 +77,7 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_BASE_PROXY_IMPL_CH); visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -93,6 +96,7 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node "codegen for argument list failed\n"), -1); } + delete visitor; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index e661447d52c..54b517bac68 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -124,16 +124,20 @@ be_visitor_operation::gen_throw_spec (be_operation *node) *os << excp->name (); ei->next (); } // end of while loop + delete ei; } // end of if if (be_global->use_raw_throw ()) - *os << be_uidt_nl << ")"<< be_uidt; + { + *os << be_uidt_nl << ")" << be_uidt; + } else - *os << be_uidt_nl << "))"<< be_uidt; - - return 0; + { + *os << be_uidt_nl << "))" << be_uidt; + } + return 0; } //Method that returns the appropriate CORBA::Environment variable diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp index ab6e43918d2..08ef81d3e6a 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp @@ -43,19 +43,17 @@ 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 + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + this->ctx_->node (node); - os->indent (); // start with the current indentation level - - // every operation is declared virtual in the client code + // Every operation is declared virtual in the client code. *os << "virtual "; - // STEP I: generate the return type + // STEP I: generate the return type. bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -65,7 +63,7 @@ be_visitor_operation_ch::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type + // 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); @@ -88,16 +86,18 @@ be_visitor_operation_ch::visit_operation (be_operation *node) "codegen for return type failed\n"), -1); } + delete visitor; - // STEP 2: generate the operation name + // STEP 2: generate the operation name. *os << " " << node->local_name (); // STEP 3: generate the argument list with the appropriate mapping. For these - // we grab a visitor that generates the parameter listing + // 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, @@ -116,6 +116,7 @@ be_visitor_operation_ch::visit_operation (be_operation *node) "codegen for argument list failed\n"), -1); } + delete visitor; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp index 1b979fc845b..716787d0da4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp @@ -46,13 +46,12 @@ be_visitor_operation_ih::visit_operation (be_operation *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, @@ -85,6 +84,7 @@ be_visitor_operation_ih::visit_operation (be_operation *node) "codegen for return type failed\n"), -1); } + delete visitor; // STEP 2: generate the operation name @@ -95,6 +95,7 @@ be_visitor_operation_ih::visit_operation (be_operation *node) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_IH); visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -113,6 +114,7 @@ be_visitor_operation_ih::visit_operation (be_operation *node) "codegen for argument list failed\n"), -1); } + delete visitor; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp index 42f4ae47409..fd9bb00d90e 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_ch.cpp @@ -43,7 +43,7 @@ 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 + // First open the client-side header file for writing if (tao_cg->start_client_header (be_global->be_get_client_hdr_fname ()) == -1) { @@ -53,7 +53,7 @@ be_visitor_root_ch::init (void) return -1; } - // init the stream + // Initialize the stream. this->ctx_->stream (tao_cg->client_header ()); return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp index e47aa2e5a34..1159d2dffea 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp @@ -33,9 +33,10 @@ 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 + // 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, @@ -44,18 +45,19 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) "Bad element type\n"), -1); } - // generate the class name - be_type *pt; // base types + // Generate the class name. + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } + { + // Get the primitive base type of this typedef node. + be_typedef *t = be_typedef::narrow_from_decl (bt); + pt = t->primitive_base_type (); + } else - pt = bt; - + { + pt = bt; + } const char * class_name = node->instance_name (); @@ -63,14 +65,12 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) 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 instantiation + // !! Branching in either compile time template instantiation + // or manual template instantiation. 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 @@ -82,32 +82,30 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) *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 (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } + *os << class_name << " (" << be_idt << be_idt_nl + << "CORBA::ULong length," << be_nl; + + bt->accept (visitor); + *os <<"* *value," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; + << "CORBA::Boolean release = 0" << be_uidt_nl + << ");" << be_uidt_nl; // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl - << "// Copy constructor." << be_nl; + *os << class_name << " (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; + + // operator= + *os << class_name << " &operator= (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // destructor - *os << "virtual ~" << class_name << " (void);" << be_nl - << "// destructor" << be_nl; + *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; - // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl - << "// Assignment from another Bounded sequence." << be_nl; + // Accessors + *os << "// = Accessors." << be_nl; be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); int is_pseudo_object = @@ -128,23 +126,30 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) *os << bt->name () << "," << bt->name () << "_var>" - << " operator[] (CORBA::ULong index) const;" - << "// Read-write accessor." << be_nl; + << " operator[] (CORBA::ULong index) const;" << be_nl << be_nl; + + // Static operations + *os << "// = Static operations." << be_nl; // allocbuf *os << "static "; + bt->accept (visitor); - *os << " **allocbuf (CORBA::ULong length); " - << "// Allocate storage for a sequence.." << be_nl; + + *os << " **allocbuf (CORBA::ULong length);" << be_nl; // freebuf *os << "static void freebuf ("; + bt->accept (visitor); - *os << " **buffer);" << be_nl; + + *os << " **buffer);" << be_nl << be_nl; + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; // allocate_buffer - *os << "// The Base_Sequence functions, please see tao/sequence.h" << be_nl - << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; + *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; // deallocate_buffer *os << "virtual void _deallocate_buffer (void);" << be_nl; @@ -155,26 +160,31 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) // get_buffer *os << "const "; + bt->accept (visitor); + *os << "* *get_buffer (void) const;" << be_nl; - // _shrink_buffer - *os << "virtual void _shrink_buffer (CORBA::ULong nl, CORBA::ULong ol);" << be_nl; + // shrink_buffer + *os << "virtual void _shrink_buffer (" << be_idt << be_idt_nl + << "CORBA::ULong nl," << be_nl + << "CORBA::ULong ol" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; if (!is_pseudo_object) { - // Pseudo objects do not require this methods. + // Pseudo objects do not require these methods. *os << "virtual void _downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src," << be_nl - << "CORBA_Environment &ACE_TRY_ENV = " << be_idt_nl - << "TAO_default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "virtual CORBA_Object* _upcast (void *src) const;" << be_nl; + << "void* target," << be_nl + << "CORBA_Object *src," << be_nl + << "CORBA_Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");" << be_uidt_nl; + + *os << "virtual CORBA_Object* _upcast (void *src) const;"; } - *os << be_uidt_nl << "};\n"; + *os << be_uidt_nl << "};" << be_nl; os->gen_endif (); diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp index 6d89387b8a0..fddd7d53d48 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp @@ -88,55 +88,68 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) os->gen_ifdef_macro (class_name); - os->indent (); - - *os << "class " << class_name << " : public TAO_Bounded_Base_Sequence" << be_nl + *os << "class " << class_name << be_idt_nl + << ": public TAO_Bounded_Base_Sequence" << be_uidt_nl << "{" << be_nl << "public:" << be_idt_nl - << "// = Initialization and termination methods." << be_nl - << be_nl; + << "// = Initialization and termination methods." << be_nl; // default Constructor *os << class_name << " (void);" << be_nl; // constructor - *os << class_name << " (CORBA::ULong length," << be_idt_nl; + *os << class_name << " (" << be_idt << be_idt_nl + << "CORBA::ULong length," << be_nl; + bt->accept (visitor); + *os <<" *data," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; + << "CORBA::Boolean release = 0" << be_uidt_nl + << ");" << be_uidt_nl; // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl - << "// Copy constructor." << be_nl; + *os << class_name << " (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl - << "// Assignment operator. " << be_nl; + *os << class_name << " &operator= (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // destructor - *os << "virtual ~" << class_name << " (void); // Dtor." << be_nl; + *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; // Accessors // operator[] *os << "// = Accessors." << be_nl; + bt->accept(visitor); - *os <<" &operator[] (CORBA::ULong i);// operator []" << be_nl; + + *os <<" &operator[] (CORBA::ULong i);" << be_nl; // operator[] *os << "const "; bt->accept (visitor); - *os << " &operator[] (CORBA::ULong i) const;" << be_nl; + *os << " &operator[] (CORBA::ULong i) const;" << be_nl << be_nl; // Static Operations *os << "// = Static operations." << be_nl << "static "; + bt->accept (visitor); - *os << " *allocbuf (CORBA::ULong); // Allocate storage for the sequence." << be_nl; + + *os << " *allocbuf (CORBA::ULong);" << be_nl; // free_buf *os << "static void freebuf ("; + bt->accept (visitor); - *os << " *buffer); // Free the sequence." << be_nl; + + *os << " *buffer);" << be_nl << be_nl; + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -145,22 +158,28 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept(visitor); + bt->accept (visitor); *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; + bt->accept (visitor); + *os << " *get_buffer (void) const;" << be_nl; // replace - *os << "void replace (CORBA::ULong max," << be_idt_nl + *os << "void replace (" << be_idt << be_idt_nl + << "CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept(visitor); + + bt->accept (visitor); + *os <<" *data," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt << be_uidt_nl; + << "CORBA::Boolean release = 0" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; - *os << "};\n"; + *os << "};" << be_nl; os->gen_endif (); // endif macro diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp index bb34ba31db0..63574335d41 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp @@ -32,9 +32,10 @@ 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 + // 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, @@ -43,22 +44,22 @@ be_visitor_sequence_ch::gen_bounded_str_sequence (be_sequence *node) "Bad element type\n"), -1); } - // generate the class name - be_type *pt; // base types + // Generate the class name. + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } + { + // Get the primitive base type of this typedef node. + be_typedef *t = be_typedef::narrow_from_decl (bt); + pt = t->primitive_base_type (); + } else - pt = bt; - + { + pt = bt; + } const char * class_name = node->instance_name (); - // get the visitor for the type of the sequence be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); @@ -70,50 +71,65 @@ be_visitor_sequence_ch::gen_bounded_str_sequence (be_sequence *node) os->gen_ifdef_macro (class_name); - os->indent (); - // the accept is here the first time used and if an + // The accept is used here the first time and if an // error occurs, it will occur here. Later no check // for errors will be done. if (pt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } - + { + 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 + *os << "class " << class_name << be_idt_nl + << ": public TAO_Bounded_Base_Sequence" << be_uidt_nl << "{" << be_nl - << "public:" << be_idt_nl; + << "public:" << be_idt_nl + << "// = Initialization and termination methods." << be_nl; // constructor *os << class_name << " (void);" << be_nl; // constructor - *os << class_name << " (CORBA::ULong length," << be_idt_nl + *os << class_name << " (" << be_idt << be_idt_nl + << "CORBA::ULong length," << be_nl << "char* *value," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; + << "CORBA::Boolean release = 0" << be_uidt_nl + << ");" << be_uidt_nl; // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl; + *os << class_name << " (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl; + *os << class_name << " &operator= (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // destructor - *os << "virtual ~" << class_name << " (void);" << be_nl; + *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; + + // Accessors + *os << "// = Accessors." << be_nl; // operator[] - *os << "TAO_SeqElem_String_Manager operator[] (CORBA::ULong index) const;" << be_nl - << "// read-write accessor" << be_nl; + *os << "TAO_SeqElem_String_Manager operator[] (CORBA::ULong index) const;" + << be_nl << be_nl; + + // Static operations + *os << "// = Static operations." << be_nl; // allocbuf *os << "static char **allocbuf (CORBA::ULong length);" << be_nl; // freebuf - *os << "static void freebuf (char **buffer);" << be_nl; + *os << "static void freebuf (char **buffer);" << be_nl << be_nl; + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -128,10 +144,12 @@ be_visitor_sequence_ch::gen_bounded_str_sequence (be_sequence *node) *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 << "virtual void _shrink_buffer (" << be_idt << be_idt_nl + << "CORBA::ULong nl," << be_nl + << "CORBA::ULong ol" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; - *os << "};\n"; + *os << "};" << be_nl; os->gen_endif (); // endif macro diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp index 6711f5d5e5b..796e6a89103 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp @@ -29,9 +29,10 @@ be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) TAO_OutStream *os = this->ctx_->stream (); be_type *bt; - // retrieve the base type since we may need to do some code + // 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, @@ -40,18 +41,19 @@ be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) "Bad element type\n"), -1); } - // generate the class name - be_type *pt; // base types + // Generate the class name. + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } + { + // Get the primitive base type of this typedef node. + be_typedef *t = be_typedef::narrow_from_decl (bt); + pt = t->primitive_base_type (); + } else - pt = bt; - + { + pt = bt; + } const char * class_name = node->instance_name (); @@ -72,45 +74,61 @@ be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) // 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); - } - + { + 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 + *os << "class " << class_name << be_idt_nl + << ": public TAO_Bounded_Base_Sequence" << be_uidt_nl << "{" << be_nl - << "public:" << be_idt_nl; + << "public:" << be_idt_nl + << "// = Initialization and termination methods." << be_nl; // constructor *os << class_name << " (void);" << be_nl; // constructor - *os << class_name << " (CORBA::ULong length," << be_idt_nl + *os << class_name << " (" << be_idt << be_idt_nl + << "CORBA::ULong length," << be_nl << "CORBA::WChar* *value," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; + << "CORBA::Boolean release = 0" << be_uidt_nl + << ");" << be_uidt_nl; // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl; + *os << class_name << " (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl; + *os << class_name << " &operator= (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // destructor - *os << "virtual ~" << class_name << " (void);" << be_nl; + *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; + + // Accessors + *os << "// = Accessors." << be_nl; // operator[] - *os << "TAO_SeqElem_WString_Manager operator[] (CORBA::ULong index) const;" << be_nl - << "// read-write accessor" << be_nl; + *os << "TAO_SeqElem_WString_Manager operator[] (CORBA::ULong index) const;" + << be_nl << be_nl; + + // Static operations + *os << "// = Static operations." << be_nl; // allocbuf *os << "static CORBA::WChar **allocbuf (CORBA::ULong length);" << be_nl; // freebuf - *os << "static void freebuf (CORBA::WChar **buffer);" << be_nl; + *os << "static void freebuf (CORBA::WChar **buffer);" << be_nl << be_nl; + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -125,10 +143,12 @@ be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) *os << "const CORBA::WChar* *get_buffer (void) const;" << be_nl; // shrink_buffer - *os << "virtual void _shrink_buffer (CORBA::ULong nl,CORBA::ULong ol);" - << be_uidt_nl; + *os << "virtual void _shrink_buffer (" << be_idt << be_idt_nl + << "CORBA::ULong nl," << be_nl + << "CORBA::ULong ol" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; - *os << "};\n"; + *os << "};" << be_nl; os->gen_endif (); // endif macro diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp index d5e6ac80b9f..ac874fa6e41 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp @@ -34,9 +34,10 @@ 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 + // Retrieve the base type since we may need to do some code // generation for the base type. bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -45,18 +46,19 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) "Bad element type\n"), -1); } - // generate the class name - be_type *pt; // base types + // Generate the class name. + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } + { + // Get the primitive base type of this typedef node. + be_typedef *t = be_typedef::narrow_from_decl (bt); + pt = t->primitive_base_type (); + } else - pt = bt; - + { + pt = bt; + } const char * class_name = node->instance_name (); @@ -64,41 +66,50 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) 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 + // !! 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 + *os << "class " << class_name << be_idt_nl + << ": public TAO_Unbounded_Base_Sequence" << be_uidt_nl << "{" << be_nl << "public:" << be_idt_nl - << "// = Initialization and termination methods." << be_nl - << be_nl; + << "// = Initialization and termination methods." << be_nl; - // constructor + // default 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 + *os << class_name << " (" << be_idt << be_idt_nl + << "CORBA::ULong maximum," << be_nl << "CORBA::ULong length," << be_nl; + bt->accept (visitor); + *os <<"* *value," << be_nl - << "CORBA::Boolean release = 0);" << be_uidt_nl; + << "CORBA::Boolean release = 0" << be_uidt_nl + << ");" << be_uidt_nl; // constructor - *os << class_name << "(const " << class_name << " &rhs);" << be_nl; + *os << class_name << " (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; + + // operator= + *os << class_name << " &operator= (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // destructor - *os << "virtual ~" << class_name << " (void);" << be_nl; + *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; - // operator= - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl; + // Accessors + *os << "// = Accessors." << be_nl; // operator[] be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); @@ -119,51 +130,67 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) *os << bt->name () << "," << bt->name () << "_var>" - << " operator[] (CORBA::ULong index) const;" << be_nl; + << " operator[] (CORBA::ULong index) const;" << be_nl << be_nl; + + // Static operations + *os << "// = Static operations." << be_nl; // allocbuf *os << "static "; + bt->accept (visitor); + *os << " **allocbuf (CORBA::ULong nelems);" << be_nl; // freebuf *os << "static void freebuf ("; + bt->accept (visitor); - *os << " **buffer);" << be_nl; + + *os << " **buffer);" << be_nl << be_nl; + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; // allocate_buffer - *os << "// The Base_Sequence functions, please see tao/Sequence.h" << be_nl - << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; + *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; // deallocate_buffer *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept(visitor); + bt->accept (visitor); + *os << "* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; + bt->accept (visitor); + *os << "* *get_buffer (void) const;" << be_nl; // shrink_buffer - *os << "virtual void _shrink_buffer (CORBA::ULong nl, CORBA::ULong ol);" << be_nl; + *os << "virtual void _shrink_buffer (" << be_idt << be_idt_nl + << "CORBA::ULong nl," << be_nl + << "CORBA::ULong ol" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; if (!is_pseudo_object) { - // Pseudo objects do not require this methods. + // Pseudo objects do not require these methods. *os << "virtual void _downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src," << be_nl - << "CORBA_Environment &ACE_TRY_ENV = " << be_idt_nl - << "TAO_default_environment ()" - << be_uidt << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "virtual CORBA_Object* _upcast (void *src) const;" << be_nl; + << "void* target," << be_nl + << "CORBA_Object *src," << be_nl + << "CORBA_Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");" << be_uidt_nl; + + *os << "virtual CORBA_Object* _upcast (void *src) const;"; } - *os << be_uidt_nl << "};\n"; + + *os << be_uidt_nl << "};" << be_nl; os->gen_endif (); // endif macro diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp index b36054f9176..9d8ffc639a1 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp @@ -34,6 +34,7 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // retrieve the base type since we may need to do some code // generation for the base type. bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -58,24 +59,8 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) } } -// May not need variable 'pt at all -#if 0 - // generate the class name - be_type *pt; // base types - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } - else - pt = bt; -#endif /* 0 */ - const char * class_name = node->instance_name (); - // get the visitor for the type of the sequence be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); @@ -83,69 +68,86 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // !! branching in either compile time template instantiation // or manual template instatiation - os->gen_ifdef_AHETI(); + os->gen_ifdef_AHETI (); os->gen_ifdef_macro (class_name); - os->indent (); - *os << "class TAO_EXPORT_NESTED_MACRO " - << class_name << " : public TAO_Unbounded_Base_Sequence" << be_nl + << class_name << be_idt_nl + << ": public TAO_Unbounded_Base_Sequence" << be_uidt_nl << "{" << be_nl << "public:" << be_idt_nl - << "// = Initialization and termination methods." << be_nl - << be_nl; + << "// = Initialization and termination methods." << be_nl; // constructor - *os << class_name << " (void); // Default constructor." << be_nl; + *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 + *os << class_name << " (" << be_idt << be_idt_nl + << "CORBA::ULong maximum," << be_nl << "CORBA::ULong length," << be_nl; - // the accept is here the first time used and if an + + // The accept is used here the first time and if an // error occurs, it will occur here. Later no check // for errors will be done. if (bt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -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; + << "CORBA::Boolean release = 0" << be_uidt_nl + << ");" << be_uidt_nl; // constructor - *os << class_name << " (const " << class_name << " &rhs);" << be_nl; + *os << class_name << " (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // operator = - *os << class_name << " &operator= (const " << class_name << " &rhs);" << be_nl; + *os << class_name << " &operator= (" << be_idt << be_idt_nl + << "const " << class_name << " &rhs" << be_uidt_nl + << ");" << be_uidt_nl; // destructor - *os << "virtual ~" << class_name << " (void); // Dtor." << be_nl; + *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; // Accessors *os << "// = Accessors." << be_nl; + bt->accept (visitor); + *os <<" &operator[] (CORBA::ULong i);" << be_nl; // operator[] *os << "const "; + bt->accept (visitor); - *os << " &operator[] (CORBA::ULong i) const;" << be_nl; + + *os << " &operator[] (CORBA::ULong i) const;" << be_nl << be_nl; // Static operations *os << "// = Static operations." << be_nl << "static "; + bt->accept (visitor); + *os << " *allocbuf (CORBA::ULong size);" << be_nl; *os << "static void freebuf ("; + bt->accept (visitor); - *os << " *buffer);" << be_nl; + + *os << " *buffer);" << be_nl << be_nl; + + // Implement the TAO_Base_Sequence methods (see Sequence.h) + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -153,9 +155,6 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // 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; bt->accept(visitor); *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; @@ -165,13 +164,17 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) *os << " *get_buffer (void) const;" << be_nl; // replace - *os << "void replace (CORBA::ULong max," << be_idt_nl + *os << "void replace (" << be_idt << be_idt_nl + << "CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; + bt->accept(visitor); + *os <<" *data," << be_nl - << "CORBA::Boolean release);" << be_uidt << be_uidt_nl; + << "CORBA::Boolean release" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; - *os << "};\n"; + *os << "};" << be_nl; os->gen_endif (); // endif macro diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp index cc2ce275d93..e84a5314d57 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp @@ -46,6 +46,7 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) // Retrieve the base type since we may need to do some code // generation for the base type. bt = be_type::narrow_from_decl (node->base_type ()); + if (bt == 0) { ACE_ERROR_RETURN ((LM_ERROR, @@ -337,8 +338,6 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) // Generate the ifdefined macro for the sequence type. os->gen_ifdef_macro (node->flat_name ()); - os->indent (); - // 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 ()); @@ -369,7 +368,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "codegen for base sequence class\n"), -1); + "codegen for base sequence class\n"), + -1); } *os << "{" << be_nl @@ -383,7 +383,7 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) << be_nl; } - *os << node->local_name () << " (" << be_idt_nl; + *os << node->local_name () << " (" << be_idt << be_idt_nl; if (node->unbounded ()) { @@ -403,7 +403,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "Bad visitor\n"), -1); + "Bad visitor\n"), + -1); } if (bt->accept (visitor) == -1) @@ -419,18 +420,18 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) *os << " *buffer, " << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl - << ");" << be_nl; + << ");" << be_uidt_nl; *os << node->local_name () << " (const " << node->local_name () << " &); // copy ctor" << be_nl; *os << "~" << node->local_name () << " (void);" << be_nl - << "static void _tao_any_destructor (void*);\n\n"; + << "static void _tao_any_destructor (void*);" << be_nl; // Generate the _ptr_type and _var_type typedefs // but we must protect against certain versions of g++. - *os << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)\n"; - os->indent (); + *os << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" + << be_nl; *os << "typedef " << node->local_name () << "_var _var_type;\n" - << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n\n"; + << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl; // TAO provides extensions for octet sequences, first find out if // the base type is an octet (or an alias for octet). @@ -458,19 +459,17 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) if (predef != 0 && predef->pt () == AST_PredefinedType::PT_octet && node->unbounded ()) { - *os << "\n" - << "#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)" << be_nl + *os << "\n#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)" << 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 == 1 */\n\n"; + << "#endif /* TAO_NO_COPY_OCTET_SEQUENCE == 1 */" << be_nl; } - os->decr_indent (); - *os << "};" << be_nl; + *os << be_uidt_nl << "};" << be_nl; os->gen_endif (); // Endif macro. @@ -527,11 +526,11 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) "%s_var", node->local_name ()->get_string ()); - os->indent (); *os << "// *************************************************************" << be_nl; *os << "// class " << node->name () << "_var" << be_nl; - *os << "// *************************************************************\n\n"; + *os << "// *************************************************************" + << be_nl << be_nl; // Retrieve base type. bt = be_type::narrow_from_decl (node->base_type ()); @@ -549,32 +548,30 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) // Depending upon the data type, there are some differences which we account // for over here. - os->indent (); *os << "class " << be_global->stub_export_macro () << " " << namebuf << be_nl; *os << "{" << be_nl; - *os << "public:\n"; - os->incr_indent (); + *os << "public:" << be_idt_nl; // Default constuctor. - *os << namebuf << " (void); // default constructor" << be_nl; + *os << namebuf << " (void);" << be_nl; // Constuctor. *os << namebuf << " (" << node->local_name () << " *);" << be_nl; // Copy constructor. - *os << namebuf << " (const " << namebuf << - " &); // copy constructor" << be_nl; + *os << namebuf << " (const " << namebuf << " &);" << be_nl; // Fixed-size base types only. if (bt->size_type () == be_decl::FIXED) { + *os << "// Fixed-size base types only." << be_nl; *os << namebuf << " (const " << node->local_name () - << " &); // fixed-size base types only" << be_nl; + << " &);" << be_nl; } // Destructor. - *os << "~" << namebuf << " (void); // destructor" << be_nl; + *os << "~" << namebuf << " (void);" << be_nl; *os << be_nl; // Assignment operator from a pointer. @@ -587,8 +584,9 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) // Fixed-size base types only. if (bt->size_type () == be_decl::FIXED) { + *os << "// Fixed-size base types only." << be_nl; *os << namebuf << " &operator= (const " << node->local_name () - << " &); // fixed-size base types only" << be_nl; + << " &);" << be_nl; } // Arrow operator. @@ -697,18 +695,13 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) // Generate an additional member function that // returns the underlying pointer. - *os << node->local_name () << " *ptr (void) const;\n"; - - *os << "\n"; - os->decr_indent (); + *os << node->local_name () << " *ptr (void) const;" << be_uidt_nl << be_nl; // Generate the private section. - *os << "private:\n"; - os->incr_indent (); - *os << node->local_name () << " *ptr_;\n"; + *os << "private:" << be_idt_nl; + *os << node->local_name () << " *ptr_;" << be_uidt_nl; - os->decr_indent (); - *os << "};\n\n"; + *os << "};" << be_nl << be_nl; return 0; } @@ -721,8 +714,12 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) char namebuf [NAMEBUFSIZE]; be_type *bt = 0; - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_out", node->local_name ()->get_string ()); + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); + ACE_OS::sprintf (namebuf, + "%s_out", + node->local_name ()->get_string ()); // Retrieve base type. bt = be_type::narrow_from_decl (node->base_type ()); @@ -737,13 +734,10 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) } // Generate the out definition (always in the client header). - os->indent (); - *os << "class " << be_global->stub_export_macro () << " " << namebuf << be_nl; *os << "{" << be_nl; - *os << "public:\n"; - os->incr_indent (); + *os << "public:" << be_idt_nl; // No default constructor. @@ -799,18 +793,15 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) delete visitor; - *os << " operator[] (CORBA::ULong index);" << be_nl; - *os << "\n"; - os->decr_indent (); - *os << "private:\n"; - os->incr_indent (); + *os << " operator[] (CORBA::ULong index);" << be_uidt_nl << be_nl; + *os << "private:" << be_idt_nl; *os << node->local_name () << " *&ptr_;" << be_nl; - *os << "// assignment from T_var not allowed" << be_nl; - *os << "void operator= (const " << node->local_name () << "_var &);\n"; + *os << "// Assignment from T_var not allowed." << be_nl; + *os << "void operator= (const " << node->local_name () + << "_var &);" << be_uidt_nl; - os->decr_indent (); - *os << "};\n\n"; + *os << "};" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp index 60d96548220..fc63cb633f5 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp @@ -40,57 +40,60 @@ be_visitor_structure_ch::~be_visitor_structure_ch (void) { } -// visit the Structure node and its scope +// Visit the Structure node and its scope. int be_visitor_structure_ch::visit_structure (be_structure *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os; - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported + if (!node->cli_hdr_gen () && !node->imported ()) { os = this->ctx_->stream (); - os->indent (); // start from whatever indentation level we were at - *os << "struct " << node->local_name () << ";" << be_nl; *os << "class " << node->local_name () << "_var;" << be_nl << be_nl; *os << "struct " << be_global->stub_export_macro () << " " << node->local_name () << be_nl - << "{" << be_idt << "\n\n"; + << "{" << be_idt << be_nl; - // generate the _ptr_type and _var_type typedefs + // Generate the _ptr_type and _var_type typedefs // but we must protect against certain versions of g++ - *os << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)\n"; - os->indent (); + *os << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" + << be_nl; *os << "typedef " << node->local_name () << "_var _var_type;\n" << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n" << be_nl; if (!node->is_local ()) - *os << "static void _tao_any_destructor (void*);\n\n"; + { + *os << "static void _tao_any_destructor (void*);" + << be_nl << be_nl; + } - // generate code for field members + // 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); + "codegen for scope failed\n"), + -1); } - os->decr_indent (); - *os << "};\n\n"; + *os << be_uidt_nl; + *os << "};" << be_nl << be_nl; - // generate var defn + // Generate var definition. 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); + "codegen for _var failed\n"), + -1); } - // a class is generated for an out defn only for a variable length struct + // 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) @@ -98,37 +101,36 @@ int be_visitor_structure_ch::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure_ch::" "visit_structure - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } } else { - os->indent (); - *os << "typedef " << node->local_name () << " &" << node->local_name - () << "_out;\n\n"; + *os << "typedef " << node->local_name () << " &" + << node->local_name () << "_out;" << be_nl << be_nl; } if (!node->is_local ()) { - // by using a visitor to declare and define the TypeCode, we - // have the added advantage to conditionally not generate - // any code. This will be based on the command line - // options. This is still TO-DO be_visitor *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); + ), + -1); } } node->cli_hdr_gen (I_TRUE); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp index 1c062214ac4..1f5a772d9d8 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_decl.cpp @@ -51,27 +51,32 @@ be_visitor_typecode_decl::visit_type (be_type *node) if (node->is_nested ()) { - // we have a scoped name - os->indent (); - // is our enclosing scope a module? We need this check because for + // We have a scoped name. + // Is our enclosing scope a module? We need this check because for // platforms that support namespaces, the typecode must be declared - // extern + // extern. if (node->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "TAO_NAMESPACE_STORAGE_CLASS "; + { + *os << "TAO_NAMESPACE_STORAGE_CLASS "; + } else - *os << "static "; + { + *os << "static "; + } + *os << "CORBA::TypeCode_ptr " - << node->tc_name (prefix, postfix)->last_component () << ";\n\n"; + << node->tc_name (prefix, postfix)->last_component () + << ";" << be_nl << be_nl; } else { - // we are in the ROOT scope - os->indent (); + // We are in the ROOT scope. *os << "extern " << be_global->stub_export_macro () << " CORBA::TypeCode_ptr " << " " << node->tc_name (prefix, postfix)->last_component () - << ";\n\n"; + << ";" << be_nl << be_nl; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp index e4f0d1e7a7b..4bde77964a4 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp @@ -68,86 +68,91 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) 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 + // The fact that we are here indicates that we were generating code for + // a typedef node whose base type also happens to be another typedefed + // (i.e. an alias) node for another (possibly alias) node. - this->ctx_->alias (node); // save this alias + this->ctx_->alias (node); - // grab the most primitive base type in the chain to avoid recusrsively - // going thru this visit method + // Grab the most primitive base type in the chain to avoid recusrsively + // going thru this visit method. bt = node->primitive_base_type (); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " "bad primitive base type\n" - ), -1); + ), + -1); } - // accept on this base type, but generate code for the typedef node + // 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); + ), + -1); } - this->ctx_->alias (0); // reset + + this->ctx_->alias (0); } else { - // the context has not stored any "tdef" node. So we must be in here for - // the first time - this->ctx_->tdef (node); // save the typedef node + // The context has not stored any "tdef" node. So we must be in here for + // the first time. + this->ctx_->tdef (node); - // grab the immediate base type node + // Grab the immediate base type node. bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " "bad base type\n" - ), -1); + ), + -1); } - // accept on this base type, but generate code for the typedef node + // 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); + ), + -1); } - // generate the typecode decl for this typedef node + // Generate the typecode decl for this typedef node. // @@ NW: !bt->is_local () is a hack. There should be a way to // propagate bt's info up to typedef. if (!node->imported () && !node->is_local () && !bt->is_local ()) { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO be_visitor *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_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); + ), + -1); } - - } - this->ctx_->tdef (0); // reset + + this->ctx_->tdef (0); } return 0; @@ -156,21 +161,25 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) 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 + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); be_type *bt; - // is the base type an alias to an array node or an actual array node + // Is the base type an alias to an array node or an actual array node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - // is our base type an array node. If so, generate code for that array 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 + // Let the base class visitor handle this case. if (this->be_visitor_typedef::visit_array (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -182,16 +191,15 @@ be_visitor_typedef_ch::visit_array (be_array *node) } else { - // base type is simply an alias to an array node. Simply output the - // required typedefs + // Base type is simply an alias to an array node. Simply output the + // required typedefs. - os->indent (); - // typedef the type and the _slice type + // 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 + // 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") @@ -199,7 +207,7 @@ be_visitor_typedef_ch::visit_array (be_array *node) *os << "typedef " << bt->nested_type_name (scope, "_forany") << " " << tdef->nested_type_name (scope, "_forany") << ";" << be_nl; - // the _alloc, _dup, copy, and free methods + // The _alloc, _dup, copy, and free methods // Since the function nested_type_name() contains a static buffer, // we can have only one call to it from any instantiation per stream @@ -220,72 +228,79 @@ be_visitor_typedef_ch::visit_array (be_array *node) *os << "ACE_INLINE void " << tdef->nested_type_name (scope, "_free") << " ("; *os << 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 + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); be_type *bt; - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + // Typedef of a typedef? + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - if (bt->node_type () == AST_Decl::NT_enum) // direct typedef of a base node - // type + if (bt->node_type () == AST_Decl::NT_enum) { - // let the base class visitor handle this case + // 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); + ), + -1); } } - // now generate the typedefs - os->indent (); - // typedef the type and the _slice type + // typedef the type and the _slice type. *os << "typedef " << bt->nested_type_name (scope) << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _out + // 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 + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); be_type *bt; - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + // Typedef of a typedef? + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; - - // now generate the typedefs - os->indent (); + { + bt = node; + } - // typedef the object + // Typedef the object. *os << "typedef " << bt->nested_type_name (scope) << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _ptr + // Typedef the _ptr. *os << "typedef " << bt->nested_type_name (scope, "_ptr") << " " << tdef->nested_type_name (scope, "_ptr") << ";" << be_nl; - // typedef the _var + // Typedef the _var. *os << "typedef " << bt->nested_type_name (scope, "_var") << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; @@ -299,51 +314,54 @@ be_visitor_typedef_ch::visit_interface (be_interface *node) 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 + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); be_type *bt; - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + // Typedef of a typedef? + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - // now generate the typedefs - os->indent (); - // typedef the type + // 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 + // 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 + + // 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 *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 - - // now generate the typedefs - os->indent (); + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); if (node->width () == (long) sizeof (char)) { *os << "typedef char *" << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out, and _forany types + // Typedef the _var and _out types. *os << "typedef CORBA::String_var" << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; *os << "typedef CORBA::String_out" @@ -353,7 +371,7 @@ be_visitor_typedef_ch::visit_string (be_string *node) { *os << "typedef CORBA::WChar *" << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out, and _forany types + // Typedef the _var and _out types. *os << "typedef CORBA::WString_var" << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl; *os << "typedef CORBA::WString_out" @@ -366,20 +384,24 @@ be_visitor_typedef_ch::visit_string (be_string *node) 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 + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); be_type *bt; - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + // Typedef of a typedef? + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - if (bt->node_type () == AST_Decl::NT_sequence) // direct typedef of a base node - // type + if (bt->node_type () == AST_Decl::NT_sequence) { - // let the base class visitor handle this case + // Let the base class visitor handle this case. if (this->be_visitor_typedef::visit_sequence (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -391,37 +413,40 @@ be_visitor_typedef_ch::visit_sequence (be_sequence *node) } else { - // now generate the typedefs - os->indent (); - // typedef the type + // Typedef the type. *os << "typedef " << bt->nested_type_name (scope) << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out types + // Typedef the _var and _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 + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); be_type *bt; - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + // Typedef of a typedef? + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - if (bt->node_type () == AST_Decl::NT_struct) // direct typedef of a base node - // type + if (bt->node_type () == AST_Decl::NT_struct) { - // let the base class visitor handle this case + // Let the base class visitor handle this case if (this->be_visitor_typedef::visit_structure (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -432,36 +457,39 @@ be_visitor_typedef_ch::visit_structure (be_structure *node) } } - // now generate the typedefs - os->indent (); - // typedef the type + // Typedef the type. *os << "typedef " << bt->nested_type_name (scope) << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out types + // typedef the _var and _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 + TAO_OutStream *os = this->ctx_->stream (); + be_typedef *tdef = this->ctx_->tdef (); + be_decl *scope = this->ctx_->scope (); be_type *bt; - if (this->ctx_->alias ()) // typedef of a typedef - bt = this->ctx_->alias (); + // Typedef of a typedef? + if (this->ctx_->alias ()) + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - if (bt->node_type () == AST_Decl::NT_union) // direct typedef of a base node - // type + if (bt->node_type () == AST_Decl::NT_union) { - // let the base class visitor handle this case + // Let the base class visitor handle this case. if (this->be_visitor_typedef::visit_union (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -472,15 +500,14 @@ be_visitor_typedef_ch::visit_union (be_union *node) } } - // now generate the typedefs - os->indent (); - // typedef the type and the _slice type + // Typedef the type. *os << "typedef " << bt->nested_type_name (scope) << " " << tdef->nested_type_name (scope) << ";" << be_nl; - // typedef the _var, _out types + // Typedef the _var and _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_union/discriminant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp index 66c3002b440..8995f570b1e 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp @@ -44,31 +44,35 @@ 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 + // Get the enclosing union backend. + be_union *bu = this->ctx_->be_node_as_union (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + // Not a typedef and bt is defined inside the union. + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the enum declaration + // 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, @@ -77,6 +81,7 @@ be_visitor_union_discriminant_ch::visit_enum (be_enum *node) "Bad visitor\n" ), -1); } + if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -85,14 +90,15 @@ be_visitor_union_discriminant_ch::visit_enum (be_enum *node) "codegen failed\n" ), -1); } + delete visitor; } - os->indent (); - // the set method + // 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"; + // The get method. + *os << bt->nested_type_name (bu) << " _d (void) const;" << be_nl; + return 0; } @@ -100,35 +106,38 @@ 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 + // get the enclosing union backend. + be_union *bu = this->ctx_->be_node_as_union (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - // the set method + // 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"; + // The get method. + *os << bt->nested_type_name (bu) << " _d (void) const;" << be_nl; + 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 + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // The node to be visited in the base primitve type that gets typedefed. be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, @@ -137,6 +146,7 @@ be_visitor_union_discriminant_ch::visit_typedef (be_typedef *node) "Bad primitive type\n" ), -1); } + this->ctx_->alias (0); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp index e47e52b51af..31fca95f411 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp @@ -40,26 +40,23 @@ be_visitor_union_ch::~be_visitor_union_ch (void) { } -// visit the Union node and its scope +// 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 + TAO_OutStream *os; + be_type *bt; + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. + be_visitor_context ctx (*this->ctx_); + ctx.node (node); - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported + if (!node->cli_hdr_gen () && !node->imported ()) { os = this->ctx_->stream (); - // generate the ifdefined macro for the union type + // Generate the ifdefined macro for the union type. os->gen_ifdef_macro (node->flat_name ()); - os->indent (); // start with the current indentation level *os << "class " << node->local_name () << ";" << be_nl; *os << "class " << node->local_name () << "_var;" << be_nl << be_nl; @@ -69,21 +66,26 @@ int be_visitor_union_ch::visit_union (be_union *node) << "{" << be_nl << "public:" << be_idt_nl - // generate default and copy constructors + // Generate default and copy constructors. << node->local_name () << " (void);" << be_nl << node->local_name () << " (const " << node->local_name () << " &);" << be_nl - // generate destructor + // Generate destructor. << "~" << node->local_name () << " (void);" << be_nl; if (!node->is_local ()) - *os << "static void _tao_any_destructor (void*);\n" << be_nl; - // generate assignment operator + { + *os << "static void _tao_any_destructor (void*);" + << be_nl << be_nl; + } + + // Generate assignment operator. *os << node->local_name () << " &operator= (const " - << node->local_name () << " &);\n\n"; + << node->local_name () << " &);" << be_nl << be_nl; - // retrieve the disriminant type + // Retrieve the disriminant type. bt = be_type::narrow_from_decl (node->disc_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -92,12 +94,12 @@ int be_visitor_union_ch::visit_union (be_union *node) "bad disciminant type\n"), -1); } - // the discriminant type may have to be defined here if it was an enum + // 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 + ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CH); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -113,19 +115,20 @@ int be_visitor_union_ch::visit_union (be_union *node) " visit_union - " "codegen for discriminant failed\n"), -1); } + delete visitor; - // generate the _ptr_type and _var_type typedefs - // but we must protect against certain versions of g++ - *os << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)\n"; - os->indent (); + // Generate the _var_type typedef + // but we must protect against certain versions of g++. + *os << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" + << be_nl; *os << "typedef " << node->local_name () << "_var _var_type;\n" - << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n"; + << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl; + + // Now generate the public defn for the union branch members. For this, + // set our state to reflect what we are aiming to do. + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); - // now 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, @@ -135,8 +138,9 @@ int be_visitor_union_ch::visit_union (be_union *node) -1); } - // now check if we need to generate the _default () method + // Now check if we need to generate the _default () method. be_union::DefaultValue dv; + if (node->default_value (dv) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -145,28 +149,27 @@ int be_visitor_union_ch::visit_union (be_union *node) "computing default value failed\n"), -1); } + if ((dv.computed_ != 0) && (node->default_index () == -1)) { - // only if all cases are not covered AND there is no explicit - // default, we get the _default () method - os->indent (); - *os << "void _default ();\n"; + // Only if all cases are not covered AND there is no explicit + // default, we get the _default () method. + *os << "void _default (void);"; } - // now generate the private data members of the union - os->decr_indent (); - *os << "private:\n"; - os->incr_indent (); + *os << be_uidt_nl; + + // Now generate the private data members of the union. + *os << "private:" << be_idt_nl; *os << bt->nested_type_name (node) << " disc_;" << be_nl; - *os << bt->nested_type_name (node) << " holder_;" << be_nl; + *os << bt->nested_type_name (node) << " holder_;" << be_nl << be_nl; // Emit the ACE_NESTED_CLASS macro. - // the members are inside of a union + // 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 + *os << "{" << be_idt_nl; + this->ctx_->state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); + if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -175,27 +178,24 @@ int be_visitor_union_ch::visit_union (be_union *node) "codegen for private members of union\n"), -1); } - os->decr_indent (); - *os << "} u_; // end of union" << be_nl; + *os << be_uidt_nl; + *os << "} u_;" << be_nl << be_nl; - // the reset method (TAO extension) - *os << "// TAO extensions" << 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; + << ", CORBA::Boolean /* finalize */);" << be_nl; + *os << "// Frees any allocated storage." << be_nl << be_nl; *os << "void _reset (void);" << be_nl; - *os << "// calls the above reset with finalize=1" << be_nl << be_nl; - *os << "}; // " << node->name () << "\n\n"; + *os << "// Calls the above reset with finalize = 1." << be_uidt_nl; + *os << "}; //" << node->name () << be_nl << be_nl; if (!node->is_local ()) { - // by using a visitor to declare and define the TypeCode, we - // have the added advantage to conditionally not generate - // any code. This will be based on the command line - // options. This is still TO-DO 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, @@ -208,9 +208,10 @@ int be_visitor_union_ch::visit_union (be_union *node) os->gen_endif (); - // generate the ifdefined macro for the _var type + // Generate the ifdefined macro for the _var type. os->gen_ifdef_macro (node->flat_name (), "_var"); - // generate var defn + + // Generate var definition. if (node->gen_var_defn () == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -218,11 +219,14 @@ int be_visitor_union_ch::visit_union (be_union *node) "visit_union - " "codegen for _var\n"), -1); } + os->gen_endif (); - // generate the ifdefined macro for the array type + // Generate the ifdefined macro for the array type. os->gen_ifdef_macro (node->flat_name (), "_out"); - // a class is generated for an out defn only for a variable length struct + + // 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) @@ -235,10 +239,10 @@ int be_visitor_union_ch::visit_union (be_union *node) } else { - os->indent (); - *os << "typedef " << node->local_name () << " &" << node->local_name - () << "_out;\n\n"; + *os << "typedef " << node->local_name () << " &" + << node->local_name () << "_out;" << be_nl << be_nl; } + os->gen_endif (); node->cli_hdr_gen (I_TRUE); diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp index 7bcc99e9fb8..6702c1703b0 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp @@ -32,58 +32,66 @@ ACE_RCSID(be_visitor_union_branch, private_ch, "$Id$") // visitor for union_branch in the client header generating the private information // ********************************************** -// constructor +// Constructor. be_visitor_union_branch_private_ch::be_visitor_union_branch_private_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor +// Destructor. be_visitor_union_branch_private_ch::~be_visitor_union_branch_private_ch (void) { } -// visit the union_branch node +// 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); + ), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_union_branch - " "codegen for union_branch type failed\n" - ), -1); + ), + -1); } + return 0; } -// =visit operations on all possible data types that a union_branch can be +// Visit operations on all possible data types that a union_branch can be. int be_visitor_union_branch_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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -91,24 +99,24 @@ be_visitor_union_branch_private_ch::visit_array (be_array *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_array - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + // Not a typedef and bt is defined inside the union. + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // case of anonymous array in union - os->indent (); + // Case of anonymous array in union *os << "_" << bt->local_name () << "_slice *" << ub->local_name () - << "_;\n"; + << "_;" << be_nl; } else { - os->indent (); *os << bt->nested_type_name (bu, "_slice") << " *" << ub->local_name () - << "_;\n"; + << "_;" << be_nl; } return 0; @@ -117,16 +125,19 @@ be_visitor_union_branch_private_ch::visit_array (be_array *node) 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -134,29 +145,34 @@ be_visitor_union_branch_private_ch::visit_enum (be_enum *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_enum - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); + + *os << bt->nested_type_name (bu) << " " << ub->local_name () + << "_;" << be_nl; - 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -164,30 +180,34 @@ be_visitor_union_branch_private_ch::visit_interface (be_interface *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_interface - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start from current indentation *os << bt->nested_type_name (bu, "_var") - << " *" << ub->local_name () << "_;\n"; + << " *" << ub->local_name () << "_;" << be_nl; + 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -195,30 +215,36 @@ be_visitor_union_branch_private_ch::visit_interface_fwd (be_interface_fwd *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_interface_fwd - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start from current indentation *os << bt->nested_type_name (bu, "_var") - << " *" << ub->local_name () << "_;\n"; + << " *" << ub->local_name () << "_;" << be_nl; + return 0; } int -be_visitor_union_branch_private_ch::visit_predefined_type (be_predefined_type *node) +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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -226,55 +252,57 @@ be_visitor_union_branch_private_ch::visit_predefined_type (be_predefined_type *n "(%N:%l) be_visitor_union_branch_private_ch::" "visit_predefined_type - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *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 - // check if we are dealing with a CORBA::Object + // Cannot have an object inside of a union. + // Check if we are dealing with a CORBA::Object if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) { *os << bt->name () << "_var" - << " *" << ub->local_name () << "_;\n"; + << " *" << ub->local_name () << "_;" << be_nl; } else *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << "_;\n"; + << "_;" << be_nl; } 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"; + // variable data type. + *os << bt->nested_type_name (bu) << " *" << ub->local_name () + << "_;" << be_nl; } else { - os->indent (); // start from current indentation - *os << bt->nested_type_name (bu) << " " << ub->local_name () << - "_;\n"; + *os << bt->nested_type_name (bu) << " " << ub->local_name () + << "_;" << be_nl; } + 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -282,24 +310,25 @@ be_visitor_union_branch_private_ch::visit_sequence (be_sequence *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_sequence - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *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"; + // pointer. + *os << bt->nested_type_name (bu) << " *" << ub->local_name () + << "_;" << be_nl; + return 0; } int be_visitor_union_branch_private_ch::visit_string (be_string *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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); if (!ub || !bu) { @@ -307,20 +336,19 @@ be_visitor_union_branch_private_ch::visit_string (be_string *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_string - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); - - os->indent (); + TAO_OutStream *os = this->ctx_->stream (); if (node->width () == (long) sizeof (char)) { - *os << "char *" << ub->local_name () << "_;\n"; + *os << "char *" << ub->local_name () << "_;" << be_nl; } else { - *os << "CORBA::WChar *" << ub->local_name () << "_;\n"; + *os << "CORBA::WChar *" << ub->local_name () << "_;" << be_nl; } return 0; @@ -329,16 +357,19 @@ be_visitor_union_branch_private_ch::visit_string (be_string *node) 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -346,22 +377,23 @@ be_visitor_union_branch_private_ch::visit_structure (be_structure *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_structure - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - // if we are variable sized, we need a pointer type + // If we are variable sized, we need a pointer type. if (node->size_type () == be_decl::VARIABLE || node->has_constructor ()) { - *os << bt->nested_type_name (bu) << " *" << ub->local_name () << "_;\n"; + *os << bt->nested_type_name (bu) << " *" << ub->local_name () + << "_;" << be_nl; } else { - *os << bt->nested_type_name (bu) << " " << ub->local_name () << "_;\n"; + *os << bt->nested_type_name (bu) << " " << ub->local_name () + << "_;" << be_nl; } return 0; @@ -370,18 +402,19 @@ be_visitor_union_branch_private_ch::visit_structure (be_structure *node) 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 + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // The node to be visited in the base primitve type that gets typedefed. be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_private_ch::" "visit_typedef - " "Bad primitive type\n" - ), -1); + ), + -1); } this->ctx_->alias (0); @@ -391,16 +424,19 @@ be_visitor_union_branch_private_ch::visit_typedef (be_typedef *node) 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -408,13 +444,16 @@ be_visitor_union_branch_private_ch::visit_union (be_union *node) "(%N:%l) be_visitor_union_branch_private_ch::" "visit_union - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); + + // C++ doesn't allow object instances inside unions, so we need a + // pointer. + *os << bt->nested_type_name (bu) << " *" << ub->local_name () + << "_;" << be_nl; - 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_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp index fb69fc6d8c3..abfa5e15d52 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp @@ -31,60 +31,68 @@ ACE_RCSID(be_visitor_union_branch, public_ch, "$Id$") // visitor for union_branch in the client header file // ********************************************** -// constructor +// Constructor. be_visitor_union_branch_public_ch::be_visitor_union_branch_public_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor +// Destructor. be_visitor_union_branch_public_ch::~be_visitor_union_branch_public_ch (void) { } -// visit the union_branch node +// 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); + ), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_union_branch - " "codegen for union_branch type failed\n" - ), -1); + ), + -1); } + return 0; } -// =visit operations on all possible data types that a union_branch can be +// Visit operations on all possible data types that a union_branch can be. -// visit array type +// 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -92,81 +100,89 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_array - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + // Not a typedef and bt is defined inside the union. + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // this is the case of an anonymous array inside a 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 + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the array declaration + // 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); + ), + -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); + ), + -1); } + delete visitor; - // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method + + // Now use this array as a "type" for the subsequent declarator + // the set method. *os << "void " << ub->local_name () << " (" - << "_" << bt->local_name () << ");// set" << be_nl; - // the get method + << "_" << bt->local_name () << ");" << be_nl; + // The get method. *os << "_" << bt->local_name () << "_slice * " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const; // get method" << be_nl << be_nl; } else { - // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method + // Now use this array as a "type" for the subsequent declarator + // the set method. *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ");// set" + << bt->nested_type_name (bu) << ");" << be_nl; - // the get method + // The get method. *os << bt->nested_type_name (bu, "_slice *") << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; } return 0; } -// visit enum type +// 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -174,69 +190,77 @@ be_visitor_union_branch_public_ch::visit_enum (be_enum *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_enum - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); + // Not a typedef and bt is defined inside the union. if (bt->node_type () != AST_Decl::NT_typedef // not a typedef && bt->is_child (bu)) // bt is defined inside the union { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the enum declaration + // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_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); + ), + -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); + ), + -1); } + delete visitor; } - // now use this enum as a "type" for the subsequent declarator - os->indent (); // start from current indentation - // the set method + // Now use this enum as a "type" for the subsequent declarator + // the set method. *os << "void " << ub->local_name () << " (" - << bt->nested_type_name (bu) << ");// set" + << bt->nested_type_name (bu) << ");" << be_nl; - // the get method + // the get method. *os << bt->nested_type_name (bu) << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; return 0; } -// visit interface type +// 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -244,36 +268,39 @@ be_visitor_union_branch_public_ch::visit_interface (be_interface *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_interface - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start from current indentation - // set method + // Set method. *os << "void " << ub->local_name () << " (" << bt->nested_type_name (bu, "_ptr") - << ");// set" << be_nl; - // get method + << ");" << be_nl; + // Get method. *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; return 0; } -// visit interface forward type +// 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -281,38 +308,42 @@ be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_interface_fwd - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start from current indentation - // set method + // Set method. *os << "void " << ub->local_name () << " (" << bt->nested_type_name (bu, "_ptr") - << ");// set" << be_nl; - // get method + << ");" << be_nl; + // Get method. *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; + return 0; } #ifdef IDL_HAS_VALUETYPE -// visit valuetype type +// Visit valuetype type. int be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -320,36 +351,40 @@ be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_valuetype - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start from current indentation - // set method + // Set method. *os << "void " << ub->local_name () << " (" << bt->nested_type_name (bu, "*") - << ");// set" << be_nl; - // get method + << ");" << be_nl; + // Get method. *os << bt->nested_type_name (bu, "*") << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; + return 0; } -// visit valuetype forward type +// Visit valuetype forward type. int be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -357,38 +392,42 @@ be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_fwd *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_valuetype_fwd - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start from current indentation - // set method + // Set method. *os << "void " << ub->local_name () << " (" << bt->nested_type_name (bu, "*") - << ");// set" << be_nl; - // get method + << ")" << be_nl; + // Get method. *os << bt->nested_type_name (bu, "*") << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; + return 0; } #endif /* IDL_HAS_VALUETYPE */ -// visit predefined type +// 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -396,43 +435,37 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no "(%N:%l) be_visitor_union_branch_public_ch::" "visit_predefined_type - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *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 + << bt->nested_type_name (bu, "_ptr") << ");" << be_nl; *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; 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) + << bt->nested_type_name (bu) << ");" << be_nl; *os << "const " << bt->nested_type_name (bu) << " " - << ub->local_name () << " (void) const; // get method\n\n"; - // get method (read/write) + << ub->local_name () << " (void) const;" << be_nl << be_nl; *os << bt->nested_type_name (bu) << " " - << ub->local_name () << " (void); // get method\n\n"; + << ub->local_name () << " (void);" << be_nl << be_nl; 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 + << bt->nested_type_name (bu) << ");" << be_nl; *os << bt->nested_type_name (bu) << " " << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; } + return 0; } @@ -440,16 +473,19 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -457,75 +493,76 @@ be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_sequence - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + // Not a typedef and bt is defined inside the union. + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the sequence declaration + // 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); + ), + -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); + ), + -1); } + delete visitor; - // Generate the anonymous sequence member typedef - // but we must protect against certain versions of g++. - // This provides a consistent name to use instead of the - // implementation-specific name. - os->decr_indent (0); - *os << "#if !defined (__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_idt_nl - << "typedef " << bt->nested_type_name (bu) - << " _" << ub->local_name () << "_seq;" << be_uidt_nl; - *os << "#endif /* ! __GNUC__ || ACE_HAS_GNUG_PRE_2_8 */\n" << be_nl; - os->incr_indent (); - } - os->indent (); - // set method + // Generate the anonymous sequence member typedef + // but we must protect against certain versions of g++. + // This provides a consistent name to use instead of the + // implementation-specific name. + *os << "\n#if !defined (__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" + << be_nl + << "typedef " << bt->nested_type_name (bu) + << " _" << ub->local_name () << "_seq;\n"; + *os << "#endif /* ! __GNUC__ || ACE_HAS_GNUG_PRE_2_8 */" + << be_nl << be_nl; + } + *os << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &);// set" << be_nl; - // read-only + << bt->nested_type_name (bu) << " &);" << be_nl; *os << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const; // get method (read only)" + << ub->local_name () << " (void) const;" << be_nl; - // read/write *os << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void); // get method (read/write only)\n\n"; + << " (void);" << be_nl << be_nl; return 0; } -// visit string type +// Visit string type. int be_visitor_union_branch_public_ch::visit_string (be_string *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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); if (!ub || !bu) { @@ -533,54 +570,54 @@ be_visitor_union_branch_public_ch::visit_string (be_string *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_string - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - // three methods to set the string value + // Three methods to set the string value if (node->width () == (long) sizeof (char)) { - *os << "void " << ub->local_name () << " (char *); // set" << be_nl; - *os << "void " << ub->local_name () << " (const char *); // set" + *os << "void " << ub->local_name () << " (char *);" << be_nl; + *os << "void " << ub->local_name () << " (const char *);" << be_nl; - *os << "void " << ub->local_name () << " (const CORBA::String_var&); // set" + *os << "void " << ub->local_name () << " (const CORBA::String_var&);" << be_nl; - //get method *os << "const char *" << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; } else { - *os << "void " << ub->local_name () << " (CORBA::WChar *); // set" << be_nl; - *os << "void " << ub->local_name () << " (const CORBA::WChar *); // set" + *os << "void " << ub->local_name () << " (CORBA::WChar *);" << be_nl; + *os << "void " << ub->local_name () << " (const CORBA::WChar *);" << be_nl; - *os << "void " << ub->local_name () << " (const CORBA::WString_var&); // set" + *os << "void " << ub->local_name () << " (const CORBA::WString_var&);" << be_nl; - //get method *os << "const CORBA::WChar *" << ub->local_name () - << " (void) const; // get method\n\n"; + << " (void) const;" << be_nl << be_nl; } return 0; } -// visit structure type +// 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -588,96 +625,101 @@ be_visitor_union_branch_public_ch::visit_structure (be_structure *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_structure - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + // Not a typedef and bt is defined inside the union. + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); // set the node to be the node being visited. The scope // is still the same - // first generate the sequence declaration + // 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); + ), + -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); + ), + -1); } + delete visitor; } - os->indent (); - // set method + *os << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &);// set" << be_nl - // read-only + << bt->nested_type_name (bu) << " &);" << be_nl << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const; // get method (read only)" + << ub->local_name () << " (void) const;" << be_nl - // read/write << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void); // get method (read/write only)\n\n"; + << " (void);" << be_nl << be_nl; return 0; } -// visit typedefed type +// Visit typedefed type. int be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) { - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->alias (node); - 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 + // 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); + ), + -1); } + this->ctx_->alias (0); return 0; } -// visit union type +// 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_decl *ub = this->ctx_->node (); + be_decl *bu = this->ctx_->scope (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { @@ -685,52 +727,55 @@ be_visitor_union_branch_public_ch::visit_union (be_union *node) "(%N:%l) be_visitor_union_branch_public_ch::" "visit_union - " "bad context information\n" - ), -1); + ), + -1); } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + // Not a typedef and bt is defined inside the union. + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the union declaration + // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_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); + ), + -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); + ), + -1); } + delete visitor; } - os->indent (); - // set method + *os << "void " << ub->local_name () << " (const " - << bt->nested_type_name (bu) << " &);// set" << be_nl - // read-only + << bt->nested_type_name (bu) << " &);" << be_nl << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const; // get method (read only)" + << ub->local_name () << " (void) const;" << be_nl - // read/write << bt->nested_type_name (bu) << " &" << ub->local_name () - << " (void); // get method (read/write only)\n\n"; + << " (void);" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp index 214e4cea59d..a448991e636 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp @@ -42,15 +42,7 @@ be_visitor_valuetype_ami_exception_holder_ch::~be_visitor_valuetype_ami_exceptio int be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os; // output stream - - - os = this->ctx_->stream (); - - // Open the namespace again. - - //*os << be_nl - // << "TAO_NAME_S + TAO_OutStream *os = this->ctx_->stream (); // Generate the implemenation of the Messaging aware ORB *os << be_nl @@ -58,39 +50,41 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *nod << ": public "; if (!node->is_nested ()) - *os << "OBV_"; + { + *os << "OBV_"; + } *os << node->local_name () << "," << be_nl << " public virtual OBV_Messaging::ExceptionHolder," << be_nl << " public virtual CORBA::DefaultValueRefCountBase" << be_uidt_nl - << "{" << be_idt_nl; + << "{" << be_nl; - *os << be_uidt_nl << "public:" << be_idt_nl; + *os << "public:" << be_idt_nl; *os << "_tao_" << node->local_name () << " ();" << be_nl << be_nl; - *os << "~_tao_" << node->local_name () << " ();\n\n"; + *os << "~_tao_" << node->local_name () << " ();" << be_nl << be_nl; if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ami_exception_holder_cs::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - os->indent (); - *os << be_uidt_nl << "};" << be_nl << be_nl; // Create code for the valuetype factory - *os << "class " << node->local_name () << "_factory : public " - << node->full_name () << "_init" << be_idt_nl + *os << "class " << node->local_name () << "_factory" << be_idt_nl + << ": public " + << node->full_name () << "_init" << be_uidt_nl << "{" << be_idt_nl - << "friend class " << node->local_name () << ";" << be_nl - << be_uidt_nl << "public:" << be_idt_nl + << "friend class " << node->local_name () << ";" << be_uidt_nl + << "public:" << be_idt_nl << "// create (...) would go here" << be_nl << be_uidt_nl << "private:" << be_idt_nl; @@ -100,10 +94,6 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *nod << ") create_for_unmarshal ();" << be_nl << be_uidt_nl << "};" << be_uidt_nl; - // close the namespace again. - //*os << "}" << be_nl - // << "TAO_NAMESPACE_CLOSE" << be_nl << be_nl; - return 0; } @@ -113,6 +103,7 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_operation (be_operation *nod be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_IH); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -131,6 +122,7 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_operation (be_operation *nod "codegen for argument list failed\n"), -1); } + delete visitor; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp index c4f33bccd4c..303d12ffce2 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp @@ -51,9 +51,13 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); *os << " ("; - // *os << " (" << be_idt << be_idt << "\n"; + + if (node->argument_count () > 0) + { + *os << be_idt << be_idt_nl; + } - // all we do is hand over code generation to our scope + // All we do is hand over code generation to our scope. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -63,29 +67,32 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) -1); } - // generate the CORBA::Environment parameter for the alternative mapping + // Generate the CORBA::Environment parameter for the alternative mapping. if (!be_global->exception_support ()) { - // if the operation node has parameters, then we need to insert a comma + // If the operation node has parameters, then we need to insert a comma. if (node->argument_count () > 0) - *os << ",\n"; - - os->indent (); + { + *os << "," << be_nl; + } + else + { + *os << be_idt << be_idt_nl; + } - // @@ Michael: This switch statement needs urgently attention! switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_OBV_CH: case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CH: - // last argument - is always CORBA::Environment + // Last argument - is always CORBA::Environment. *os << "CORBA::Environment &ACE_TRY_ENV"; *os << " = " << be_idt_nl - << "TAO_default_environment ())" - << be_uidt; + << "TAO_default_environment ()" << be_uidt + << be_uidt_nl << ")"; break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IMPL_CS: - // last argument - is always CORBA::Environment + // Last argument - is always CORBA::Environment. *os << "CORBA::Environment &ACE_TRY_ENV)"; break; default: @@ -95,15 +102,14 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) } else { - os->indent (); - *os << ")";// << be_uidt; + *os << ")"; } switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - // each method is pure virtual in the Valuetype class - *os << " = 0;\n"; + // Each method is pure virtual in the Valuetype class. + *os << " = 0;" << be_uidt_nl; break; case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: break; @@ -116,9 +122,9 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) *os << "\n"; } - // @@ Michael: Can we get rid of this one, please! if (!this->ctx_->attribute ()) // hack to get a nice newline - *os << "\n"; + *os << be_nl; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp index 00669fc296b..40bab9605e1 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp @@ -45,6 +45,7 @@ int be_visitor_valuetype_field_ch::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -55,6 +56,7 @@ be_visitor_valuetype_field_ch::visit_field (be_field *node) } this->ctx_->node (node); // save the node + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -127,7 +129,6 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) } delete visitor; // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation // the set method *os << pre_op () << "void " << ub->local_name () << " (" << "_" << bt->local_name () << ")" @@ -143,7 +144,6 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) else { // now use this array as a "type" for the subsequent declarator - os->indent (); // start from current indentation // the set method *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << ")" << post_op () << " // set" @@ -219,7 +219,6 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) } // now use this enum as a "type" for the subsequent declarator - os->indent (); // start from current indentation // the set method *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << ")" << post_op () << " // set" @@ -257,7 +256,6 @@ be_visitor_valuetype_field_ch::visit_interface (be_interface *node) os = this->ctx_->stream (); - os->indent (); // start from current indentation // set method *os << pre_op() << "void " << ub->local_name () << " (" << bt->name () << "_ptr" @@ -295,7 +293,6 @@ be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node) os = this->ctx_->stream (); - os->indent (); // start from current indentation // set method *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << "_ptr" @@ -333,7 +330,6 @@ be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node) os = this->ctx_->stream (); - os->indent (); // start from current indentation // set method *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << " *" @@ -371,7 +367,6 @@ be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) os = this->ctx_->stream (); - os->indent (); // start from current indentation // set method *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << " *" @@ -408,7 +403,7 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) } os = this->ctx_->stream (); - os->indent (); // start from current indentation + switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: @@ -520,7 +515,6 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) } - os->indent (); // set method *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" @@ -556,8 +550,6 @@ be_visitor_valuetype_field_ch::visit_string (be_string *node) os = this->ctx_->stream (); - os->indent (); - // three methods to set the string value if (node->width () == (long) sizeof (char)) { @@ -649,7 +641,7 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) } delete visitor; } - os->indent (); + // set method *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" @@ -672,7 +664,6 @@ be_visitor_valuetype_field_ch::visit_typedef (be_typedef *node) TAO_OutStream *os; // output stream os = this->ctx_->stream (); - os->indent (); // start from current indentation level this->ctx_->alias (node); // save the node for use in code generation and // indicate that the union_branch of the union_branch node // is a typedefed quantity @@ -747,7 +738,7 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) } delete visitor; } - os->indent (); + // set method *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp index 5fcd2d7ab55..da337df77fb 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp @@ -46,47 +46,55 @@ be_visitor_valuetype_marshal_ch::~be_visitor_valuetype_marshal_ch (void) int be_visitor_valuetype_marshal_ch::visit_valuetype (be_valuetype *node) { - // proceed if the number of members in our scope is greater than 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 + // Initialize an iterator to iterate thru our scope UTL_ScopeActiveIterator *si; ACE_NEW_RETURN (si, UTL_ScopeActiveIterator (node, UTL_Scope::IK_decls), -1); this->elem_number_ = 0; - // continue until each field is visited + + // Continue until each field is visited. for (;!si->is_done ();si->next()) { AST_Decl *d = si->item (); + if (!d) { delete si; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } + be_field *field = be_field::narrow_from_decl (d); + if (field) { be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); + new be_visitor_context (*this->ctx_); be_visitor_valuetype_field_cdr_ch visitor (new_ctx); visitor.pre_ = node->field_pd_prefix (); visitor.post_ = node->field_pd_postfix (); + if (visitor.visit_field (field) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_marshal_ch::" + "(%N:%l) be_visitor_valuetype_marshal_ch::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } + } + } - } - } // end of for loop delete si; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index 280108ce3f9..75491a3450c 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -66,6 +66,7 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) for (;!si->is_done ();si->next()) { AST_Decl *d = si->item (); + if (!d) { delete si; @@ -74,16 +75,16 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) "bad node in this scope\n"), -1); } + AST_Field *field = AST_Field::narrow_from_decl (d); + if (field && field->visibility() == AST_Field::vis_PRIVATE) { continue; // ignore private fields in this run // AST_Attribute derives from AST_Field, so test for // vis_PRIVATE is ok (the attribute has it set to vis_NA) } - ++ n_processed; - if (n_processed == 1) - this->begin_public (); + be_decl *bd = be_decl::narrow_from_decl (d); // set the scope node as "node" in which the code is being // generated so that elements in the node's scope can use it @@ -104,9 +105,10 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) } } // end of for loop + delete si; - // next run with private fields only - n_processed = 0; + + // next run with private fields only ACE_NEW_RETURN (si, UTL_ScopeActiveIterator (node, UTL_Scope::IK_decls), @@ -790,7 +792,6 @@ be_visitor_valuetype::gen_init_defn (be_valuetype *node) TAO_OutStream *os; // output stream os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at *os << "class " << be_global->skel_export_macro () << " " << node->local_name () @@ -808,7 +809,7 @@ be_visitor_valuetype::gen_init_defn (be_valuetype *node) *os << "virtual const char* tao_repository_id (void);\n" << be_nl; *os << "// create () goes here" << be_nl; // %! - *os << be_uidt_nl << "};\n"; + *os << be_uidt_nl << "};" << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp index 83df8603550..264ff7af24c 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp @@ -47,39 +47,38 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) { TAO_OutStream *os; // output stream - if (!node->cli_hdr_gen () && !node->imported ()) // not already generated and - // not imported + if (!node->cli_hdr_gen () && !node->imported ()) { - os = this->ctx_->stream (); - *os << "// valuetype class\n"; + *os << "// Valuetype class" << be_nl; - // == STEP 1: generate the class name and class names we inherit == + // == STEP 1: Generate the class name and class names we inherit == - os->indent (); // start with whatever indentation level we are at - // forward declaration + // Forward declaration. *os << "class " << node->local_name () << ";" << be_nl; *os << "typedef " << node->local_name () << " *" << node->local_name () << "_ptr;" << be_nl; - // generate the ifdefined macro for the _var type + // Generate the ifdefined macro for the _var type. os->gen_ifdef_macro (node->flat_name (), "_var"); - // generate the _var declaration + // Generate the _var declaration. if (node->gen_var_defn () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } + os->gen_endif (); - // generate the ifdef macro for the _out class + // Generate the ifdef macro for the _out class. os->gen_ifdef_macro (node->flat_name (), "_out"); - // generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec + // Generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec. if (node->gen_out_defn () == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -87,13 +86,14 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) "visit_valuetype - " "codegen for _out failed\n"), -1); } - // generate the endif macro + + // generate the endif macro. os->gen_endif (); - // generate the ifdef macro for the _init class + // Generate the ifdef macro for the _init class. os->gen_ifdef_macro (node->flat_name (), "_init"); - // generate the _init declaration - ptc/98-09-03 20.17.10 p.20-93 + // Generate the _init declaration - ptc/98-09-03 20.17.10 p.20-93. if (this->gen_init_defn (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -101,24 +101,25 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) "visit_valuetype - " "codegen for _init failed\n"), -1); } - // generate the endif macro + + // Generate the endif macro. os->gen_endif (); - // now the valuetype definition itself + // Now the valuetype definition itself. os->gen_ifdef_macro (node->flat_name ()); - // now generate the class definition - os->indent (); + // Now generate the class definition. *os << "class " << be_global->stub_export_macro () << " " << node->local_name (); - // node valuetype inherits from other valuetypes (OMG 20.17.9) - // (ordinary (not abstract) interfaces ignored) + // Node valuetype inherits from other valuetypes (OMG 20.17.9) + // (ordinary (not abstract) interfaces ignored). - *os << " : "; + *os << be_idt_nl <<": "; int i; // loop index int n_inherits_valuetypes = 0; idl_bool valuebase_inherited = 0; + if (node->n_inherits () > 0) { for (i = 0; i < node->n_inherits (); i++) @@ -127,98 +128,109 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) // AST_Interface, then type AST_Interface can be used be_interface *inherited = be_interface::narrow_from_decl (node->inherits ()[i]); - if (!inherited->is_valuetype () && - !inherited->is_abstract ()) - continue; + + if (!inherited->is_valuetype () + && !inherited->is_abstract ()) + { + continue; + } ++ n_inherits_valuetypes; + if (inherited->is_valuetype()) - valuebase_inherited = 1; - if (n_inherits_valuetypes > 1) // node is the case of multiple - // inheritance, so put a comma { - *os << ", "; + valuebase_inherited = 1; + } + + if (n_inherits_valuetypes > 1) + { + *os << "," << be_nl; } + 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 (); + // Inherited node is used in the scope of "node" node. + scope = + be_scope::narrow_from_scope (node->defined_in ())->decl (); } - // dump the scoped name + // Dump the scoped name. *os << "public virtual "; *os << inherited->nested_type_name (scope); } // end of for loop + if (n_inherits_valuetypes > 0) - *os << be_nl; + { + *os << be_uidt_nl; + } } + if (!valuebase_inherited) { - // we do not inherit from any valuetype, hence we do so from the base - // CORBA::ValueBase class - // Generate code that uses the macro. This is required to deal with - // the MSVC++ insanity - if (n_inherits_valuetypes > 1) // node is the case of multiple - // inheritance, so put a comma + // We do not inherit from any valuetype, hence we do so from the base + // CORBA::ValueBase class. + if (n_inherits_valuetypes > 1) { *os << ", "; } - *os << "public virtual CORBA_ValueBase" << be_nl; - } - // generate the body + *os << "public virtual CORBA_ValueBase" << be_uidt_nl; + } + // Generate the body. *os << "{" << be_nl - << "public:" << be_nl + << "public:" << be_idt_nl - // generate the _ptr_type and _var_type typedef + // Generate the _ptr_type and _var_type typedef // but we must protect against certain versions of g++ - << "#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" - << be_idt_nl + << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" + << be_nl << "typedef " << node->local_name () << "* _ptr_type;" << be_nl - << "typedef " << node->local_name () << "_var _var_type;" - << be_uidt_nl - << "#endif /* ! __GNUC__ || g++ >= 2.8 */\n" << be_idt_nl + << "typedef " << node->local_name () << "_var _var_type;\n" + << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl - // generate the static _downcast operation - // (see OMG 20.17.{4,5}) + // Generate the static _downcast operation. + // (see OMG 20.17.{4,5}). << "static " << node->local_name () << "* " << "_downcast (CORBA::ValueBase* );" << be_nl << "// The address of static _downcast is implicit used as type id\n" << be_nl - << "// (TAO extensions or internals)" << be_nl - << "static CORBA::Boolean _tao_unmarshal (TAO_InputCDR &, " - << node->local_name () << " *&);" << be_nl + << "static CORBA::Boolean _tao_unmarshal (" << be_idt << be_idt_nl + << "TAO_InputCDR &," << be_nl + << node->local_name () << " *&" << be_uidt_nl + << ");" << be_uidt_nl << "virtual const char* " << "_tao_obv_repository_id () const;" << be_nl << "static const char* " - << "_tao_obv_static_repository_id ();\n"; + << "_tao_obv_static_repository_id ();" << be_nl << be_nl; - // generate code for the valuetype definition + // Generate code for the valuetype definition. if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - // protected member: + // Protected member: - // generate the "protected" constructor so that users cannot instantiate - // us + // Generate the "protected" constructor so that users cannot + // instantiate us. *os << be_uidt_nl << "protected:" << be_idt_nl - << node->local_name () - << " (); // default constructor" << be_nl + << node->local_name () + << " ();" << be_nl << "virtual ~" << node->local_name () << " ();\n" << be_nl; *os << "// TAO internals" << be_nl << "virtual void *_tao_obv_narrow (ptr_arith_t);" << be_nl; - // support for marshalling + + // Support for marshalling. if (!node->is_abstract_valuetype ()) { *os << "virtual CORBA::Boolean " @@ -226,13 +238,13 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) *os << "virtual CORBA::Boolean " << "_tao_unmarshal_v (TAO_InputCDR &);" << be_nl; // %! optimize _downcast away: extra parameter with type info - // set (void *) in CDR Stream with the right derived pointer + // set (void *) in CDR Stream with the right derived pointer. } - // private member: + // Private member: - // private copy constructor and assignment operator. These are not + // Private copy constructor and assignment operator. These are not // allowed, hence they are private. *os << be_uidt_nl << "private:" << be_idt_nl; *os << node->local_name () << " (const " << node->local_name () << " &);" @@ -240,18 +252,19 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "void operator= (const " << node->local_name () << " &);" << be_nl; - // map fields to private data (if optimizing) + // Map fields to private data (if optimizing). if (node->opt_accessor ()) { *os << be_uidt_nl << "protected:" << be_idt_nl; *os << "CORBA::Boolean " << "_tao_marshal_state (TAO_OutputCDR &);" << be_nl << "CORBA::Boolean " - << "_tao_unmarshal_state (TAO_InputCDR &);\n\n"; - *os << be_uidt_nl << "private:\n" << be_idt; + << "_tao_unmarshal_state (TAO_InputCDR &);" + << be_uidt_nl << be_nl; + *os << "private:" << be_idt_nl; this->gen_pd (node); } - else // need a way to access the state of derived OBV_ classes + else // Need a way to access the state of derived OBV_ classes. { if (!node->is_abstract_valuetype ()) { @@ -265,37 +278,30 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) } } - *os << be_uidt_nl << "};\n"; + *os << be_uidt_nl << "};" << be_nl; os->gen_endif (); - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - // (see interface code how to do this. not yet impl.) - node->cli_hdr_gen (I_TRUE); - } // if !cli_hdr_gen + } + return 0; } int be_visitor_valuetype_ch::visit_operation (be_operation *node) -// derived from be_visitor_operation_ch::visit_operation { - TAO_OutStream *os; // output stream - be_type *bt; // type node + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; - 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 + // Every operation is declared virtual in the client code. *os << "virtual "; - // STEP I: generate the return type + // STEP I: Generate the return type. bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -305,7 +311,7 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type + // 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); @@ -328,16 +334,18 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) "codegen for return type failed\n"), -1); } + delete visitor; - // STEP 2: generate the operation name + // STEP 2: Generate the operation name. *os << " " << node->local_name (); - // STEP 3: generate the argument list with the appropriate mapping. For these - // we grab a visitor that generates the parameter listing + // STEP 3: Generate the argument list with the appropriate mapping. For these + // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH); visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, @@ -356,6 +364,7 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) "codegen for argument list failed\n"), -1); } + delete visitor; // @@ Michael: We need to put the exception throw spec here @@ -367,12 +376,16 @@ int be_visitor_valuetype_ch::visit_field (be_field *node) { be_valuetype *vt = be_valuetype::narrow_from_scope (node->defined_in ()); + if (!vt) - return -1; + { + return -1; + } + be_visitor_context* ctx = new be_visitor_context (*this->ctx_); ctx->state (TAO_CodeGen::TAO_FIELD_OBV_CH); be_visitor_valuetype_field_ch *visitor = - new be_visitor_valuetype_field_ch (ctx); + new be_visitor_valuetype_field_ch (ctx); if (!visitor) { @@ -383,9 +396,13 @@ be_visitor_valuetype_ch::visit_field (be_field *node) } if (vt->opt_accessor ()) - visitor->setenclosings ("",";"); + { + visitor->setenclosings ("",";"); + } else - visitor->setenclosings ("virtual "," = 0;"); + { + visitor->setenclosings ("virtual "," = 0;"); + } if (node->accept (visitor) == -1) { @@ -395,29 +412,22 @@ be_visitor_valuetype_ch::visit_field (be_field *node) "visit_field - codegen failed\n"), -1); } + delete visitor; return 0; } void -be_visitor_valuetype_ch::begin_public () +be_visitor_valuetype_ch::begin_public (void) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "public:\n" << be_idt; + TAO_OutStream *os = this->ctx_->stream (); + *os << "public:" << be_idt_nl; } void -be_visitor_valuetype_ch::begin_private () +be_visitor_valuetype_ch::begin_private (void) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "protected:\n" << be_idt; + TAO_OutStream *os = this->ctx_->stream (); + *os << "protected:" << be_idt_nl; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp index 4199ac38692..6daf1e66e85 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp @@ -45,55 +45,63 @@ be_visitor_valuetype_obv_ch::~be_visitor_valuetype_obv_ch (void) } -// OBV_ class must be in OBV_ namespace +// OBV_ class must be in OBV_ namespace. int be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) { - // only visit non-abstract non-imported valuetype + // Only visit non-abstract non-imported valuetype. if (node->is_abstract_valuetype () || node->imported ()) - return 0; - - TAO_OutStream *os; // output stream + { + return 0; + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // OBV_ class maps only to a typedef if we are optimizing accessors + // OBV_ class maps only to a typedef if we are optimizing accessors. if (node->opt_accessor ()) { - os->indent (); *os << "typedef " << node->full_name () << " "; + if (!node->is_nested ()) - *os << "OBV_"; + { + *os << "OBV_"; + } + *os << node->local_name () << ";" << be_nl; } else { - // == STEP 1: generate the class name and the class name we inherit == - + // STEP 1: Generate the class name and the class name we inherit. os->gen_ifdef_macro (node->flat_name (), "_OBV"); - os->indent (); *os << "// OBV_ class" << be_nl; *os << "class "; - if (!node->is_nested()) // we are in root ? - *os << "OBV_"; - *os << node->local_name () << " : public virtual " - << node->full_name () << be_nl; - // == STEP 2: generate the body == + if (!node->is_nested()) + { + *os << "OBV_"; + } + + *os << node->local_name () << be_idt_nl + << ": public virtual " + << node->full_name () << be_uidt_nl; - *os << "{\n" << be_idt; + // STEP 2: Generate the body == - // generate code for the OBV_ class definition + *os << "{" << be_idt_nl; + + // Generate code for the OBV_ class definition. if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_obv_ch::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - // map fields to private data - if (!node->opt_accessor ()) // check again (redundant) + + // Map fields to private data. + if (!node->opt_accessor ()) { *os << be_uidt_nl << "protected:" << be_idt_nl; *os << "virtual CORBA::Boolean _tao_marshal__" @@ -103,15 +111,18 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) *os << "CORBA::Boolean " << "_tao_marshal_state (TAO_OutputCDR &);" << be_nl << "CORBA::Boolean " - << "_tao_unmarshal_state (TAO_InputCDR &);\n\n"; - *os << be_uidt_nl << "private:" << be_idt_nl; + << "_tao_unmarshal_state (TAO_InputCDR &);" + << be_uidt_nl << be_nl; + *os << "private:" << be_idt_nl; + this->gen_pd (node); } - *os << be_uidt; - os->indent (); - *os << "};\n"; + + *os << be_uidt_nl; + *os << "};" << be_nl; + os->gen_endif (); - } // if !opt_accessor () + } return 0; } @@ -121,15 +132,19 @@ int be_visitor_valuetype_obv_ch::visit_field (be_field *node) { be_valuetype *vt = be_valuetype::narrow_from_scope (node->defined_in ()); + if (!vt) - return -1; - // only in OBV_ class, if we are not optimizing accessors (and modifiers) + { + return -1; + } + + // Only in OBV_ class, if we are not optimizing accessors (and modifiers). if (!vt->opt_accessor ()) { be_visitor_context* ctx = new be_visitor_context (*this->ctx_); ctx->state (TAO_CodeGen::TAO_FIELD_OBV_CH); be_visitor_valuetype_field_ch *visitor = - new be_visitor_valuetype_field_ch (ctx); + new be_visitor_valuetype_field_ch (ctx); if (!visitor) { @@ -140,6 +155,7 @@ be_visitor_valuetype_obv_ch::visit_field (be_field *node) } visitor->setenclosings ("virtual ",";"); + if (node->accept (visitor) == -1) { delete visitor; @@ -148,29 +164,25 @@ be_visitor_valuetype_obv_ch::visit_field (be_field *node) "visit_field - codegen failed\n"), -1); } + delete visitor; } + return 0; } void -be_visitor_valuetype_obv_ch::begin_public () +be_visitor_valuetype_obv_ch::begin_public (void) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "public:\n" << be_idt; + TAO_OutStream *os = this->ctx_->stream (); + *os << be_uidt_nl; + *os << "public:" << be_idt_nl; } void -be_visitor_valuetype_obv_ch::begin_private () +be_visitor_valuetype_obv_ch::begin_private (void) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - *os << be_uidt; - os->indent (); - *os << "protected:\n" << be_idt; + TAO_OutStream *os = this->ctx_->stream (); + *os << be_uidt_nl; + *os << "protected:" << be_idt_nl; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp index a8a1c6bc183..4edf19ad739 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp @@ -45,7 +45,7 @@ be_visitor_valuetype_fwd_ch::~be_visitor_valuetype_fwd_ch (void) { } -// visit the Interface_Fwd_Ch node and its scope +// Visit the valuetype_fwd node and its scope. int be_visitor_valuetype_fwd_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { @@ -53,48 +53,51 @@ be_visitor_valuetype_fwd_ch::visit_valuetype_fwd (be_valuetype_fwd *node) 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 + // 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 + // Generate the ifdefined macro for the _ptr type. os->gen_ifdef_macro (node->flat_name (), "_ptr"); - // generate the _ptr declaration + // Generate the _ptr declaration. *os << "typedef " << node->local_name () << " *" << node->local_name () - << "_ptr;\n"; + << "_ptr;" << be_nl; os->gen_endif (); - // enclose under an ifdef macro + // Enclose under an ifdef macro. os->gen_ifdef_macro (node->flat_name (), "_var"); - // generate the _var declaration + // generate the _var declaration. if (node->gen_var_defn () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_fwd_ch::" "visit_valuetype_fwd - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + s-1); } - // gen an endif + + // Generate an endif. os->gen_endif (); - // enclose under an ifdef macro + // enclose under an ifdef macro. os->gen_ifdef_macro (node->flat_name (), "_out"); - // generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec + // Generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec. if (node->gen_out_defn () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_fwd_ch::" "visit_valuetype_fwd - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } - // generate the endif macro + + // generate the endif macro. os->gen_endif (); node->cli_hdr_gen (I_TRUE); } + return 0; } |