diff options
author | bala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-22 20:53:09 +0000 |
---|---|---|
committer | bala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-04-22 20:53:09 +0000 |
commit | 44b81cd111b358fa4d8ee055f719d8824679efd1 (patch) | |
tree | b325bb726be5c711dfe09e642820f85ea7c01e02 /TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp | |
parent | cc6af3602c9ebafccde48c64ce53e26f19eb5e4c (diff) | |
download | ATCD-44b81cd111b358fa4d8ee055f719d8824679efd1.tar.gz |
ChangeLogTag:Tue Apr 22 14:58:33 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp | 431 |
1 files changed, 74 insertions, 357 deletions
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 b2045432825..2d4bf035662 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp @@ -1,7 +1,3 @@ -// -// $Id$ -// - // ============================================================================ // // = LIBRARY @@ -18,8 +14,8 @@ // // ============================================================================ -ACE_RCSID (be_visitor_array, - array_ch, +ACE_RCSID (be_visitor_array, + array_ch, "$Id$") // ************************************************************************ @@ -175,14 +171,22 @@ int be_visitor_array_ch::visit_array (be_array *node) *os << " "; - if (!this->ctx_->tdef ()) + char anon_p [2]; + ACE_OS::memset (anon_p, + '\0', + 2); + + if (this->ctx_->tdef ()) { - // We are dealing with an anonymous array case. Generate a typedef with - // an _ prepended to the name. - *os << "_"; + anon_p[0] = '\0'; + } + else + { + ACE_OS::sprintf (anon_p, + "_"); } - *os << node->local_name () << "_slice"; + *os << anon_p << node->local_name () << "_slice"; if (node->gen_dimensions (os, 1) == -1) { @@ -195,53 +199,74 @@ int be_visitor_array_ch::visit_array (be_array *node) *os << ";"; + // Generate helper struct for use of array in a sequence. + *os << be_nl << be_nl + << "struct " << be_global->stub_export_macro () + << " tao_" << node->local_name () << "_life" << be_nl + << "{" << be_idt_nl + << "static " << anon_p << node->local_name () + << "_slice * tao_alloc (void);" << be_nl + << "static void tao_free (" << anon_p << node->local_name () + << "_slice * _tao_slice);" << be_nl + << "static " << anon_p << node->local_name () + << "_slice * tao_dup (" << be_idt << be_idt_nl + << "const " << anon_p << node->local_name () << "_slice * _tao_slice" + << be_uidt_nl + << ");" << be_uidt_nl + << "static void tao_copy (" << be_idt << be_idt_nl + << anon_p << node->local_name () << "_slice * _tao_to," << be_nl + << "const " << anon_p << node->local_name () + << "_slice * _tao_from" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "};"; + // No _var or _out class for an anonymous (non-typedef'd) array. if (this->ctx_->tdef () != 0) { - // Generate the _var and _out class declarations. - if (this->gen_var_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "var_defn failed\n"), - -1); - } - - // An out defn is generated only for a variable size array. + // Generate _var class decl. + // An _out decl is generated only for a variable size array. if (node->size_type () == AST_Type::VARIABLE) { - if (this->gen_out_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "out_defn failed\n"), - -1); - } + *os << be_nl << be_nl + << "typedef" << be_idt_nl + << "TAO_VarArray_Var_T<" << be_idt << be_idt_nl + << node->local_name () << "_slice," << be_nl + << "tao_" << node->local_name () << "_life" << be_uidt_nl + << ">" << be_uidt_nl + << node->local_name () << "_var;" << be_uidt_nl; + + *os << "typedef" << be_idt_nl + << "TAO_Array_Out_T<" << be_idt << be_idt_nl + << node->local_name () << "_var," << be_nl + << node->local_name () << "_slice," << be_nl + << "tao_" << node->local_name () << "_life" << be_uidt_nl + << ">" << be_uidt_nl + << node->local_name () << "_out;" << be_uidt; } else { - *os << be_nl << be_nl << "// TAO_IDL - Generated from " << be_nl - << "// " __FILE__ << ":" << __LINE__; - - *os << be_nl << be_nl - << "typedef " << node->local_name () << " " - << node->local_name () << "_out;"; + *os << be_nl << be_nl + << "typedef" << be_idt_nl + << "TAO_FixedArray_Var_T<" << be_idt << be_idt_nl + << node->local_name () << "_slice," << be_nl + << "tao_" << node->local_name () << "_life" << be_uidt_nl + << ">" << be_uidt_nl + << node->local_name () << "_var;" << be_uidt; + + *os << be_nl << be_nl + << "typedef" << be_idt_nl << node->local_name () << be_nl + << node->local_name () << "_out;" << be_uidt; } } - if (this->gen_forany_defn (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_array_ch::" - "visit_argument - " - "forany_defn failed\n"), - -1); - } - - *os << be_nl << be_nl << "// TAO_IDL - Generated from " << be_nl - << "// " __FILE__ << ":" << __LINE__; + // Generate _forany decl. + *os << be_nl << be_nl + << "typedef" << be_idt_nl + << "TAO_Array_Forany_T<" << be_idt << be_idt_nl + << anon_p << node->local_name () << "_slice," << be_nl + << "tao_" << node->local_name () << "_life" << be_uidt_nl + << ">" << be_uidt_nl + << anon_p << node->local_name () << "_forany;" << be_uidt; *os << be_nl << be_nl; @@ -270,7 +295,7 @@ int be_visitor_array_ch::visit_array (be_array *node) // Typedefed array. *os << storage_class << node->nested_type_name (scope, "_slice") << " *" << be_nl; - *os << node->nested_type_name (scope, "_alloc") << " (void);" + *os << node->nested_type_name (scope, "_alloc") << " (void);" << be_nl << be_nl; *os << storage_class << "void" << be_nl << node->nested_type_name (scope, "_free") @@ -278,7 +303,7 @@ int be_visitor_array_ch::visit_array (be_array *node) *os << node->nested_type_name (scope, "_slice") << " *_tao_slice " << be_uidt_nl << ");" << be_uidt_nl << be_nl; - *os << storage_class << node->nested_type_name (scope, "_slice") + *os << storage_class << node->nested_type_name (scope, "_slice") << " *" << be_nl; *os << node->nested_type_name (scope, "_dup") << " (" << be_idt << be_idt_nl @@ -333,311 +358,3 @@ int be_visitor_array_ch::visit_array (be_array *node) node->cli_hdr_gen (1); return 0; } - -// Generate the var definition. -int -be_visitor_array_ch::gen_var_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - char namebuf [NAMEBUFSIZE]; - char varnamebuf [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 ()); - } - else - { - ACE_OS::sprintf (namebuf, - "_%s", - node->local_name ()->get_string ()); - ACE_OS::sprintf (varnamebuf, - "_%s_var", - node->local_name ()->get_string ()); - } - - // Generate the var definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - *os << be_nl << be_nl << "// TAO_IDL - Generated from " << be_nl - << "// " __FILE__ << ":" << __LINE__; - - *os << be_nl << be_nl - << "class " << be_global->stub_export_macro () - << " " << varnamebuf << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - // default constr - *os << varnamebuf << " (void);" << be_nl; - // constr from pointer to slice - *os << varnamebuf << " (" << namebuf << "_slice *);" << be_nl; - // copy constructor - *os << varnamebuf << " (const " << varnamebuf << - " &);" << be_nl; - // destructor - *os << "~" << varnamebuf << " (void);" << be_nl; - *os << be_nl; - // assignment operator from a pointer to slice - *os << varnamebuf << " &operator= (" << namebuf << "_slice *);" - << be_nl; - // assignment from _var - *os << varnamebuf << " &operator= (const " << varnamebuf << " &);" << be_nl; - - // arrow operator - // nothing here - *os << be_nl; - - // other extra types (cast operators, [] operator, and others) - // overloaded [] operator - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" - << be_nl; - *os << "const " << namebuf - << "_slice &operator[] (CORBA::ULong index) const;" << be_nl; - - // cast operators - *os << "operator " << namebuf << "_slice * const &() const;" - << be_nl; - - if (node->size_type () == AST_Type::VARIABLE) - { - *os << "operator " << namebuf << "_slice *&();" << be_nl; - } - - *os << be_nl; - - // Non-spec helper function used if array is a sequence element. - *os << "// Calls " << namebuf << "_copy " - << "(used in sequences of " << namebuf << ")." << 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; - *os << "const " << namebuf << "_slice *in (void) const;" << be_nl; - - if (node->size_type () == AST_Type::FIXED) - { - *os << namebuf << "_slice *inout (void);" << be_nl; - } - else - { - *os << namebuf << "_slice *&inout (void);" << be_nl; - } - - *os << namebuf << "_slice *&out (void);" << be_nl; - *os << namebuf << "_slice *_retn (void);" << be_nl; - - // Generate an additional member function that returns the - // underlying pointer. - *os << namebuf << "_slice *ptr (void) const;" << be_uidt_nl; - - // Generate the private section. - *os << "private:" << be_idt_nl; - *os << namebuf << "_slice *ptr_;" << be_uidt_nl; - *os << "};"; - - return 0; -} - -// Generate the _out definition. -int -be_visitor_array_ch::gen_out_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - char namebuf [NAMEBUFSIZE]; - char outnamebuf [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 ()); - } - else - { - // Anonymous array. - ACE_OS::sprintf (namebuf, - "_%s", - node->local_name ()->get_string ()); - ACE_OS::sprintf (outnamebuf, - "_%s_out", - node->local_name ()->get_string ()); - } - - *os << be_nl << be_nl << "// TAO_IDL - Generated from " << be_nl - << "// " __FILE__ << ":" << __LINE__; - - // Generate the out definition (always in the client header). - *os << be_nl << be_nl - << "class " << be_global->stub_export_macro () - << " " << outnamebuf << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - - // No default constructor - - // Constructor from a pointer to slice. - *os << outnamebuf << " (" << namebuf << "_slice *&);" << be_nl; - // Constructor from a _var & - *os << outnamebuf << " (" << namebuf << "_var &);" << be_nl; - // Constructor from a _out & - *os << outnamebuf << " (const " << outnamebuf << " &);" << be_nl << be_nl; - // Assignment operator from a _out & - *os << outnamebuf << " &operator= (const " << outnamebuf << " &);" << be_nl; - // Assignment from slice * - *os << outnamebuf << " &operator= (" << namebuf << "_slice *);" - << be_nl << be_nl; - // Cast - *os << "operator " << namebuf << "_slice *&();" << 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[] " - << "(CORBA::ULong index) const;" << be_uidt_nl; - - *os << "private:" << be_idt_nl; - *os << namebuf << "_slice *&ptr_;" << be_nl; - *os << "// Assignment from T_var not allowed." << be_nl; - *os << "void operator= (const " << namebuf << "_var &);" << be_uidt_nl; - *os << "};"; - - return 0; -} - -// Generate the _forany definition for ourself. -int -be_visitor_array_ch::gen_forany_defn (be_array *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - char namebuf [NAMEBUFSIZE]; - char foranyname [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 ()); - } - else - { - // Anonymous array case. - ACE_OS::sprintf (namebuf, - "_%s", - node->local_name ()->get_string ()); - ACE_OS::sprintf (foranyname, - "_%s_forany", - node->local_name ()->get_string ()); - } - - // Generate the forany definition (always in the client header). - // Depending upon the data type, there are some differences which we account - // for over here. - - *os << be_nl << be_nl << "// TAO_IDL - Generated from " << be_nl - << "// " __FILE__ << ":" << __LINE__; - - *os << be_nl << be_nl - << "class " << be_global->stub_export_macro () - << " " << foranyname << be_nl; - *os << "{" << be_nl; - *os << "public:" << be_idt_nl; - - // 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 - << " &);" << be_nl; - // Destructor. - *os << "~" << foranyname << " (void);" << be_nl << be_nl; - - if (be_global->any_support ()) - { - *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 << be_nl; - - // Other extra types (cast operators, [] operator, and others) - // overloaded [] operator - *os << namebuf << "_slice &operator[] (CORBA::ULong index);" - << be_nl; - *os << "const " << namebuf - << "_slice &operator[] (CORBA::ULong index) const;" << be_nl << be_nl; - - // cast operators - *os << "operator " << namebuf << "_slice * const &() const;" - << be_nl; - *os << "operator " << namebuf << "_slice *&();" << be_nl << be_nl; - - // in, inout, out and _retn - *os << "// in, inout, out, _retn " << be_nl; - *os << "const " << namebuf << "_slice *in (void) const;" << be_nl; - *os << namebuf << "_slice *inout (void);" << be_nl; - *os << namebuf << "_slice *&out (void);" << be_nl; - *os << namebuf << "_slice *_retn (void);" << be_nl; - - // Generate an additional member function that returns the - // underlying pointer. - *os << namebuf << "_slice *ptr (void) const;" << be_nl; - - // Additional member function that returns the NOCOPY flag. - *os << "CORBA::Boolean nocopy (void) const;" << be_nl << be_nl; - - *os << "static " << namebuf << "_slice * tao_alloc (void);" - << be_uidt_nl << be_nl; - - // Generate the private section. - *os << "private:" << be_idt_nl; - *os << namebuf << "_slice *ptr_;" << be_nl; - *os << "CORBA::Boolean nocopy_;" << be_uidt_nl; - *os << "};"; - - return 0; -} |