summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/be/be_interface.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_interface.cpp173
1 files changed, 108 insertions, 65 deletions
diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp
index f2d84c938ad..26b9ed29d28 100644
--- a/TAO/TAO_IDL/be/be_interface.cpp
+++ b/TAO/TAO_IDL/be/be_interface.cpp
@@ -351,18 +351,27 @@ be_interface::gen_def_ctors_helper (be_interface* node, be_interface* base, TAO_
}
-// generate the var definition
+// generate the var definition. If <interface_name> is not 0, generate
+// the var defn for that name. Otherwise, do it for the interface you
+// are visiting (this).
int
-be_interface::gen_var_defn (void)
+be_interface::gen_var_defn (char* interface_name)
{
- TAO_OutStream *ch; // output stream
- TAO_NL nl; // end line
+ TAO_OutStream *ch; // output stream
+ TAO_NL nl; // end line
char namebuf [NAMEBUFSIZE]; // names
- ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE);
- ACE_OS::sprintf (namebuf, "%s_var", this->local_name ()->get_string ());
+ // Decide which name to use.
+ if (interface_name == 0)
+ interface_name = this->local_name ()->get_string ();
- // retrieve a singleton instance of the code generator
+ // Buffer with name of the var class.
+ ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE);
+ ACE_OS::sprintf (namebuf,
+ "%s_var",
+ interface_name);
+
+ // Retrieve a singleton instance of the code generator
TAO_CodeGen *cg = TAO_CODEGEN::instance ();
ch = cg->client_header ();
@@ -380,7 +389,7 @@ be_interface::gen_var_defn (void)
// default constr
*ch << namebuf << " (void); // default constructor" << nl;
- *ch << namebuf << " (" << local_name () << "_ptr);" << nl;
+ *ch << namebuf << " (" << interface_name << "_ptr);" << nl;
// copy constructor
*ch << namebuf << " (const " << namebuf <<
@@ -391,31 +400,31 @@ be_interface::gen_var_defn (void)
*ch << nl;
// assignment operator from a pointer
- *ch << namebuf << " &operator= (" << local_name () << "_ptr);" << nl;
+ *ch << namebuf << " &operator= (" << interface_name << "_ptr);" << nl;
// assignment from _var
*ch << namebuf << " &operator= (const " << namebuf <<
" &);" << nl;
// arrow operator
- *ch << local_name () << "_ptr operator-> (void) const;" << nl;
+ *ch << interface_name << "_ptr operator-> (void) const;" << nl;
*ch << nl;
// other extra types (cast operators, [] operator, and others)
- *ch << "operator const " << local_name () << "_ptr &() const;" << nl;
- *ch << "operator " << local_name () << "_ptr &();" << nl;
+ *ch << "operator const " << interface_name << "_ptr &() const;" << nl;
+ *ch << "operator " << interface_name << "_ptr &();" << nl;
*ch << "// in, inout, out, _retn " << nl;
// the return types of in, out, inout, and _retn are based on the parameter
// passing rules and the base type
- *ch << local_name () << "_ptr in (void) const;" << nl;
- *ch << local_name () << "_ptr &inout (void);" << nl;
- *ch << local_name () << "_ptr &out (void);" << nl;
- *ch << local_name () << "_ptr _retn (void);" << nl;
+ *ch << interface_name << "_ptr in (void) const;" << nl;
+ *ch << interface_name << "_ptr &inout (void);" << nl;
+ *ch << interface_name << "_ptr &out (void);" << nl;
+ *ch << interface_name << "_ptr _retn (void);" << nl;
// generate an additional member function that returns the underlying pointer
- *ch << local_name () << "_ptr ptr (void) const;\n";
+ *ch << interface_name << "_ptr ptr (void) const;\n";
*ch << "\n";
ch->decr_indent ();
@@ -423,7 +432,7 @@ be_interface::gen_var_defn (void)
// private
*ch << "private:\n";
ch->incr_indent ();
- *ch << local_name () << "_ptr ptr_;\n";
+ *ch << interface_name << "_ptr ptr_;\n";
ch->decr_indent ();
*ch << "};\n\n";
@@ -431,21 +440,33 @@ be_interface::gen_var_defn (void)
return 0;
}
-// implementation of the _var class. All of these get generated in the inline
-// file
+// implementation of the _var class. All of these get generated in the
+// inline file.
+// If the argument is 0, then use the name in <this>, otherwise use
+// the name given. Just making the class more useful.
int
-be_interface::gen_var_impl (void)
+be_interface::gen_var_impl (char *interface_local_name,
+ char *interface_full_name)
{
TAO_OutStream *ci; // output stream
TAO_NL nl; // end line
char fname [NAMEBUFSIZE]; // to hold the full and
char lname [NAMEBUFSIZE]; // local _var names
+ // Decide on the names to use.
+ // Even if one argument is 0, there is no point using the
+ // arguments. Let us then use the name in this node.
+ if (interface_local_name == 0 || interface_full_name == 0)
+ {
+ interface_local_name = local_name ()->get_string ();
+ interface_full_name = (char *) this->fullname ();
+ }
+
ACE_OS::memset (fname, '\0', NAMEBUFSIZE);
- ACE_OS::sprintf (fname, "%s_var", this->fullname ());
+ ACE_OS::sprintf (fname, "%s_var", interface_full_name);
ACE_OS::memset (lname, '\0', NAMEBUFSIZE);
- ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ());
+ ACE_OS::sprintf (lname, "%s_var", interface_local_name);
// retrieve a singleton instance of the code generator
TAO_CodeGen *cg = TAO_CODEGEN::instance ();
@@ -453,8 +474,8 @@ be_interface::gen_var_impl (void)
ci = cg->client_inline ();
// generate the var implementation in the inline file
- // Depending upon the data type, there are some differences which we account
- // for over here.
+ // Depending upon the data type, there are some differences which we
+ // account for over here.
ci->indent (); // start with whatever was our current indent level
@@ -467,13 +488,13 @@ be_interface::gen_var_impl (void)
*ci << "ACE_INLINE" << nl;
*ci << fname << "::" << lname <<
" (void) // default constructor" << nl;
- *ci << " " << ": ptr_ (" << this->name () << "::_nil ())" << nl;
+ *ci << " " << ": ptr_ (" << interface_full_name << "::_nil ())" << nl;
*ci << "{}\n\n";
// constr from a _ptr
ci->indent ();
*ci << "ACE_INLINE" << nl;
- *ci << fname << "::" << lname << " (" << name () << "_ptr p)" << nl;
+ *ci << fname << "::" << lname << " (" << interface_full_name << "_ptr p)" << nl;
*ci << " : ptr_ (p)" << nl;
*ci << "{}\n\n";
@@ -482,7 +503,7 @@ be_interface::gen_var_impl (void)
// constructor because this inline function is used elsewhere. Hence to make
// inlining of this function possible, we must define it before its use.
ci->indent ();
- *ci << "ACE_INLINE " << name () << "_ptr " << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr " << nl;
*ci << fname << "::ptr (void) const" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -495,7 +516,7 @@ be_interface::gen_var_impl (void)
*ci << "ACE_INLINE" << nl;
*ci << fname << "::" << lname << " (const " << fname <<
" &p) // copy constructor" << nl;
- *ci << " : ptr_ (" << name () << "::_duplicate (p.ptr ()))" << nl;
+ *ci << " : ptr_ (" << interface_full_name << "::_duplicate (p.ptr ()))" << nl;
*ci << "{}\n\n";
// destructor
@@ -511,7 +532,7 @@ be_interface::gen_var_impl (void)
// assignment operator
ci->indent ();
*ci << "ACE_INLINE " << fname << " &" << nl;
- *ci << fname << "::operator= (" << name () <<
+ *ci << fname << "::operator= (" << interface_full_name <<
"_ptr p)" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -542,7 +563,7 @@ be_interface::gen_var_impl (void)
// other extra methods - cast operator ()
ci->indent ();
*ci << "ACE_INLINE " << nl;
- *ci << fname << "::operator const " << name () <<
+ *ci << fname << "::operator const " << interface_full_name <<
"_ptr &() const // cast" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -552,7 +573,7 @@ be_interface::gen_var_impl (void)
ci->indent ();
*ci << "ACE_INLINE " << nl;
- *ci << fname << "::operator " << name () << "_ptr &() // cast " << nl;
+ *ci << fname << "::operator " << interface_full_name << "_ptr &() // cast " << nl;
*ci << "{\n";
ci->incr_indent ();
*ci << "return this->ptr_;\n";
@@ -561,7 +582,7 @@ be_interface::gen_var_impl (void)
// operator->
ci->indent ();
- *ci << "ACE_INLINE " << name () << "_ptr " << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr " << nl;
*ci << fname << "::operator-> (void) const" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -571,7 +592,7 @@ be_interface::gen_var_impl (void)
// in, inout, out, and _retn
ci->indent ();
- *ci << "ACE_INLINE " << name () << "_ptr" << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr" << nl;
*ci << fname << "::in (void) const" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -580,7 +601,7 @@ be_interface::gen_var_impl (void)
*ci << "}\n\n";
ci->indent ();
- *ci << "ACE_INLINE " << name () << "_ptr &" << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr &" << nl;
*ci << fname << "::inout (void)" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -589,24 +610,24 @@ be_interface::gen_var_impl (void)
*ci << "}\n\n";
ci->indent ();
- *ci << "ACE_INLINE " << name () << "_ptr &" << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr &" << nl;
*ci << fname << "::out (void)" << nl;
*ci << "{\n";
ci->incr_indent ();
*ci << "CORBA::release (this->ptr_);" << nl;
- *ci << "this->ptr_ = " << this->name () << "::_nil ();" << nl;
+ *ci << "this->ptr_ = " << interface_full_name << "::_nil ();" << nl;
*ci << "return this->ptr_;\n";
ci->decr_indent ();
*ci << "}\n\n";
ci->indent ();
- *ci << "ACE_INLINE " << name () << "_ptr " << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr " << nl;
*ci << fname << "::_retn (void)" << nl;
*ci << "{\n";
ci->incr_indent ();
*ci << "// yield ownership of managed obj reference" << nl;
- *ci << this->name () << "_ptr val = this->ptr_;" << nl;
- *ci << "this->ptr_ = " << this->name () << "::_nil ();" << nl;
+ *ci << interface_full_name << "_ptr val = this->ptr_;" << nl;
+ *ci << "this->ptr_ = " << interface_full_name << "::_nil ();" << nl;
*ci << "return val;\n";
ci->decr_indent ();
*ci << "}\n\n";
@@ -614,18 +635,27 @@ be_interface::gen_var_impl (void)
return 0;
}
-// generate the _out definition
+// Generate the out definition. If <interface_name> is not 0, generate
+// the out defn for that name. Otherwise, do it for the interface you
+// are visiting (this).
int
-be_interface::gen_out_defn (void)
+be_interface::gen_out_defn (char *interface_name)
{
TAO_OutStream *ch; // output stream
TAO_NL nl; // end line
char namebuf [NAMEBUFSIZE]; // to hold the _out name
+
+ // Decide which name to use.
+ if (interface_name == 0)
+ interface_name = this->local_name ()->get_string ();
+ // Create the buffer with the name of the out class.
ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE);
- ACE_OS::sprintf (namebuf, "%s_out", local_name ()->get_string ());
+ ACE_OS::sprintf (namebuf,
+ "%s_out",
+ interface_name);
- // retrieve a singleton instance of the code generator
+ // Retrieve a singleton instance of the code generator
TAO_CodeGen *cg = TAO_CODEGEN::instance ();
ch = cg->client_header ();
@@ -642,9 +672,9 @@ be_interface::gen_out_defn (void)
// No default constructor
// constructor from a pointer
- *ch << namebuf << " (" << local_name () << "_ptr &);" << nl;
+ *ch << namebuf << " (" << interface_name << "_ptr &);" << nl;
// constructor from a _var &
- *ch << namebuf << " (" << local_name () << "_var &);" << nl;
+ *ch << namebuf << " (" << interface_name << "_var &);" << nl;
// constructor from a _out &
*ch << namebuf << " (const " << namebuf << " &);" << nl;
// assignment operator from a _out &
@@ -652,39 +682,52 @@ be_interface::gen_out_defn (void)
// assignment operator from a pointer &, cast operator, ptr fn, operator
// -> and any other extra operators
// only interface allows assignment from var &
- *ch << namebuf << " &operator= (const " << local_name () << "_var &);" << nl;
- *ch << namebuf << " &operator= (" << local_name () << "_ptr);" << nl;
+ *ch << namebuf << " &operator= (const " << interface_name << "_var &);" << nl;
+ *ch << namebuf << " &operator= (" << interface_name << "_ptr);" << nl;
// cast
- *ch << "operator " << local_name () << "_ptr &();" << nl;
+ *ch << "operator " << interface_name << "_ptr &();" << nl;
// ptr fn
- *ch << local_name () << "_ptr &ptr (void);" << nl;
+ *ch << interface_name << "_ptr &ptr (void);" << nl;
// operator ->
- *ch << local_name () << "_ptr operator-> (void);" << nl;
+ *ch << interface_name << "_ptr operator-> (void);" << nl;
*ch << "\n";
ch->decr_indent ();
*ch << "private:\n";
ch->incr_indent ();
- *ch << local_name () << "_ptr &ptr_;\n";
+ *ch << interface_name << "_ptr &ptr_;\n";
ch->decr_indent ();
*ch << "};\n\n";
return 0;
}
+
+// Generate the out class definition. If <interface_name> is not 0,
+// generate the out defn for that name. Otherwise, do it for the
+// interface you are visiting (this).
int
-be_interface::gen_out_impl (void)
+be_interface::gen_out_impl (char *interface_local_name,
+ char *interface_full_name)
{
TAO_OutStream *ci; // output stream
TAO_NL nl; // end line
char fname [NAMEBUFSIZE]; // to hold the full and
char lname [NAMEBUFSIZE]; // local _out names
+ // Even if one argument is 0, there is no point using the
+ // arguments. Let us then use the name in this node.
+ if (interface_local_name == 0 || interface_full_name == 0)
+ {
+ interface_local_name = local_name ()->get_string ();
+ interface_full_name = (char *) this->fullname ();
+ }
+
ACE_OS::memset (fname, '\0', NAMEBUFSIZE);
- ACE_OS::sprintf (fname, "%s_out", this->fullname ());
+ ACE_OS::sprintf (fname, "%s_out", interface_full_name);
ACE_OS::memset (lname, '\0', NAMEBUFSIZE);
- ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ());
+ ACE_OS::sprintf (lname, "%s_out", interface_local_name);
// retrieve a singleton instance of the code generator
TAO_CodeGen *cg = TAO_CODEGEN::instance ();
@@ -705,24 +748,24 @@ be_interface::gen_out_impl (void)
// constr from a _ptr
ci->indent ();
*ci << "ACE_INLINE" << nl;
- *ci << fname << "::" << lname << " (" << name () << "_ptr &p)" << nl;
+ *ci << fname << "::" << lname << " (" << interface_full_name << "_ptr &p)" << nl;
*ci << " : ptr_ (p)" << nl;
*ci << "{\n";
ci->incr_indent ();
- *ci << "this->ptr_ = " << this->name () << "::_nil ();\n";
+ *ci << "this->ptr_ = " << interface_full_name << "::_nil ();\n";
ci->decr_indent ();
*ci << "}\n\n";
// constructor from _var &
ci->indent ();
*ci << "ACE_INLINE" << nl;
- *ci << fname << "::" << lname << " (" << this->name () <<
+ *ci << fname << "::" << lname << " (" << interface_full_name <<
"_var &p) // constructor from _var" << nl;
*ci << " : ptr_ (p.out ())" << nl;
*ci << "{\n";
ci->incr_indent ();
*ci << "CORBA::release (this->ptr_);" << nl;
- *ci << "this->ptr_ = " << this->name () << "::_nil ();\n";
+ *ci << "this->ptr_ = " << interface_full_name << "::_nil ();\n";
ci->decr_indent ();
*ci << "}\n\n";
@@ -749,11 +792,11 @@ be_interface::gen_out_impl (void)
// assignment operator from _var
ci->indent ();
*ci << "ACE_INLINE " << fname << " &" << nl;
- *ci << fname << "::operator= (const " << this->name () <<
+ *ci << fname << "::operator= (const " << interface_full_name <<
"_var &p)" << nl;
*ci << "{\n";
ci->incr_indent ();
- *ci << "this->ptr_ = " << this->name () << "::_duplicate (p.ptr ());" << nl;
+ *ci << "this->ptr_ = " << interface_full_name << "::_duplicate (p.ptr ());" << nl;
*ci << "return *this;\n";
ci->decr_indent ();
*ci << "}\n\n";
@@ -761,7 +804,7 @@ be_interface::gen_out_impl (void)
// assignment operator from _ptr
ci->indent ();
*ci << "ACE_INLINE " << fname << " &" << nl;
- *ci << fname << "::operator= (" << this->name () <<
+ *ci << fname << "::operator= (" << interface_full_name <<
"_ptr p)" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -773,7 +816,7 @@ be_interface::gen_out_impl (void)
// other extra methods - cast operator ()
ci->indent ();
*ci << "ACE_INLINE " << nl;
- *ci << fname << "::operator " << this->name () <<
+ *ci << fname << "::operator " << interface_full_name <<
"_ptr &() // cast" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -783,7 +826,7 @@ be_interface::gen_out_impl (void)
// ptr function
ci->indent ();
- *ci << "ACE_INLINE " << this->name () << "_ptr &" << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr &" << nl;
*ci << fname << "::ptr (void) // ptr" << nl;
*ci << "{\n";
ci->incr_indent ();
@@ -793,7 +836,7 @@ be_interface::gen_out_impl (void)
// operator->
ci->indent ();
- *ci << "ACE_INLINE " << this->name () << "_ptr " << nl;
+ *ci << "ACE_INLINE " << interface_full_name << "_ptr " << nl;
*ci << fname << "::operator-> (void)" << nl;
*ci << "{\n";
ci->incr_indent ();