diff options
author | gokhale <gokhale@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-01 00:57:28 +0000 |
---|---|---|
committer | gokhale <gokhale@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-01 00:57:28 +0000 |
commit | f208987fb66336b51cdac121e95c380b1a728a99 (patch) | |
tree | 96980c376ed14d9815ce95d0db97b89944a34dd3 | |
parent | bcfb0889a273e3b596a051f65635ab029400a1fe (diff) | |
download | ATCD-f208987fb66336b51cdac121e95c380b1a728a99.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/ChangeLog-98c | 37 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_sequence.cpp | 491 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_state_argument.cpp | 4 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_state_attribute.cpp | 2 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_state_operation.cpp | 2 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_state_sequence.cpp | 51 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_string.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/decode.cpp | 1 | ||||
-rw-r--r-- | TAO/tao/invoke.cpp | 58 | ||||
-rw-r--r-- | TAO/tao/nvlist.cpp | 10 | ||||
-rw-r--r-- | TAO/tests/Param_Test/Makefile | 14 | ||||
-rw-r--r-- | TAO/tests/Param_Test/README | 3 | ||||
-rw-r--r-- | TAO/tests/Param_Test/driver.cpp | 32 | ||||
-rw-r--r-- | TAO/tests/Param_Test/options.cpp | 4 | ||||
-rw-r--r-- | TAO/tests/Param_Test/options.h | 4 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test.idl | 34 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test_i.cpp | 42 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test_i.h | 14 | ||||
-rw-r--r-- | TAO/tests/Param_Test/tests.cpp | 290 | ||||
-rw-r--r-- | TAO/tests/Param_Test/tests.h | 116 |
20 files changed, 879 insertions, 332 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 1aaf2da1422..f270f303a16 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,38 @@ +Wed Dec 31 18:29:57 1997 Aniruddha Gokhale <gokhale@mambo.cs.wustl.edu> + + * TAO_IDL/be/{be_sequence, be_state_sequence}.cpp: Changed the way + we use managed types. Instead of allocating an array, we now + instantiate the + managed type on the fly i.e., when the operator [] is invoked. The + reasons for doing this are: (1) no need for dynamic memory + allocation for maintaining the array of managers (2) It was + causing all kinds of problems while decoding because the sizeof + such sequence classes was bigger than those without managed + types. However, due to this scheme, we can no longer define the [] + operator to return a reference because that would mean that a + reference to a local variable/temporary will be returned. Hence + changes were necessary in files. + + TypeCode generation was also erroneous. This is fixed. We were + generating wrong encapsulation length. + + * TAO_IDL/be/be_string.cpp: Indentation in typecode generation. + + * TAO_IDL/be/be_type.cpp: nested_type_name - improved to + eliminate one more strange error message getting generated by the + MSVC++ compiler. Still needs testing. + + * TAO/tao/{invoke, decode}.cpp: Reversed the changes which were + made to account for sequencese with managed types. We no longer + need these changes because sequences with managed types no longer + keep an extra data member. Thus the size of all sequences (top + level) is the same (so is the layout). + + * TAO/tao/nvlist.cpp: commneted out unused variables, parameters. + + * TAO/tests/Param_Test: Included tests for string sequences, + variable sized structs as well as nested structs. + Tue Dec 30 13:46:44 1997 Nanbor Wang <nw1@cs.wustl.edu> * tests/Cubit/TAO/IDL_Cubit/clnt.h (portnum_): Changed its data @@ -9,7 +44,7 @@ Tue Dec 30 13:46:44 1997 Nanbor Wang <nw1@cs.wustl.edu> * doc/releasenotes/index.html: Added documentation for adding IDL files into Visual C++'s projects. - + * tests/Param_Test/Param_Test.dsw: * tests/Param_Test/client.dsp: * tests/Param_Test/server.dsp: New workspace and projects were added. diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index f10aec1f658..32b473673ad 100644 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ b/TAO/TAO_IDL/be/be_sequence.cpp @@ -311,7 +311,7 @@ be_sequence::gen_client_header (void) "state based codegen failed\n"), -1); } - *ch << " &operator[] (CORBA::ULong index);" << nl; + *ch << "operator[] (CORBA::ULong index);" << nl; *ch << "const "; if (s->gen_code (bt, this) == -1) { @@ -321,20 +321,9 @@ be_sequence::gen_client_header (void) "state based codegen failed\n"), -1); } - *ch << " &operator[] (CORBA::ULong index) const;" << nl; + *ch << "operator[] (CORBA::ULong index) const;" << nl; cg->pop (); // back to the previous state - // init_mgr method for managed types - switch (this->managed_type ()) - { - case be_sequence::MNG_OBJREF: - case be_sequence::MNG_STRING: - ch->indent (); - *ch << "void init_mgr (void);" << nl; - break; - default: - break; - } s = cg->make_state (); // generate the static allocbuf and freebuf methods *ch << "static "; @@ -357,6 +346,31 @@ be_sequence::gen_client_header (void) -1); } *ch << " *);\n" ; + + // the spec says that for managed sequence types, the freebuf method + // should individually free up the elements before deleting the + // buffer. However, freebuf does not have a parameter that indicates the + // total number of elements that are in the buffer. Hence we provide a + // helper method to freebuf + switch (this->managed_type ()) + { + case be_sequence::MNG_OBJREF: + case be_sequence::MNG_STRING: + ch->indent (); + *ch << "static void freebuf (" << nl; + if (s->gen_code (bt, this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_sequence::" + "gen_client_header - " + "state based codegen failed\n"), + -1); + } + *ch << " *, CORBA::ULong);\n" ; + break; + default: + break; + } ch->decr_indent (); *ch << "private:\n"; ch->incr_indent (); @@ -373,18 +387,6 @@ be_sequence::gen_client_header (void) *ch << " *buffer_;" << nl; *ch << "CORBA::Boolean release_;\n"; - // any managed type ? - switch (this->managed_type ()) - { - case be_sequence::MNG_OBJREF: - ch->indent (); - *ch << "TAO_ObjRefMngType *mgr_;\n"; - break; - case be_sequence::MNG_STRING: - ch->indent (); - *ch << "TAO_StrMngType *mgr_;\n"; - break; - } ch->decr_indent (); *ch << "};\n"; ch->indent (); @@ -521,27 +523,19 @@ be_sequence::gen_client_stubs (void) { case be_sequence::MNG_OBJREF: { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_ObjRefMngType [seq.maximum_];" << nl; *cs << "for (CORBA::ULong i=0; i < seq.length_; i++)" << nl; *cs << "{" << nl; *cs << "\tthis->buffer_[i] = " << bt->name () << "::_duplicate (" << "seq.buffer_[i]);" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; *cs << "}\n"; } break; case be_sequence::MNG_STRING: { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_StrMngType [seq.maximum_];" << nl; *cs << "for (CORBA::ULong i=0; i < seq.length_; i++)" << nl; *cs << "{" << nl; *cs << "\tthis->buffer_[i] = CORBA::string_dup (" << "seq.buffer_[i]);" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; *cs << "}\n"; } break; @@ -564,35 +558,6 @@ be_sequence::gen_client_stubs (void) *cs << "\t buffer_ (" << this->name () << "::allocbuf (max))," << nl; *cs << "\t release_ (1) // owns" << nl; *cs << "{\n"; - cs->incr_indent (); - // copy each element - switch (this->managed_type ()) - { - case be_sequence::MNG_OBJREF: - { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_ObjRefMngType [this->maximum_];" << nl; - *cs << "for (CORBA::ULong i=0; i < max; i++)" << nl; - *cs << "{" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; - *cs << "}" << nl; - } - break; - case be_sequence::MNG_STRING: - { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_StrMngType [this->maximum_];" << nl; - *cs << "for (CORBA::ULong i=0; i < max; i++)" << nl; - *cs << "{" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; - *cs << "}" << nl; - } - break; - } - *cs << "\n"; - cs->decr_indent (); *cs << "}\n\n"; } @@ -628,35 +593,6 @@ be_sequence::gen_client_stubs (void) *cs << "\t buffer_ (value)," << nl; *cs << "\t release_ (release) // ownership depends on release" << nl; *cs << "{\n"; - cs->incr_indent (); - // copy each element - switch (this->managed_type ()) - { - case be_sequence::MNG_OBJREF: - { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_ObjRefMngType [this->maximum_];" << nl; - *cs << "for (CORBA::ULong i=0; i < this->maximum_; i++)" << nl; - *cs << "{" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; - *cs << "}" << nl; - } - break; - case be_sequence::MNG_STRING: - { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_StrMngType [this->maximum_];" << nl; - *cs << "for (CORBA::ULong i=0; i < this->maximum_; i++)" << nl; - *cs << "{" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; - *cs << "}" << nl; - } - break; - } - *cs << "\n"; - cs->decr_indent (); *cs << "}\n\n"; // destructor @@ -671,12 +607,15 @@ be_sequence::gen_client_stubs (void) // only for obj references and strings, we need to free each individual // element + // call the appropriate freebuf on the buffer if (this->managed_type () != be_sequence::MNG_NONE) { - *cs << "delete []this->mgr_; // ensures each element is freed" << nl; + *cs << this->name () << "::freebuf (this->buffer_, " << + "this->maximum_);\n"; } - // call freebuf on the buffer - *cs << this->name () << "::freebuf (this->buffer_);\n"; + else + *cs << this->name () << "::freebuf (this->buffer_);\n"; + cs->decr_indent (); *cs << "}\n"; cs->decr_indent (); @@ -698,11 +637,15 @@ be_sequence::gen_client_stubs (void) cs->incr_indent (); // only for obj references and strings, we need to free each individual // element + // call the appropriate freebuf on the buffer if (this->managed_type () != be_sequence::MNG_NONE) { - *cs << "delete []this->mgr_; // ensures each element is freed" << nl; + *cs << this->name () << "::freebuf (this->buffer_, " << + "this->maximum_);\n"; } - *cs << this->name () << "::freebuf (this->buffer_);\n"; + else + *cs << this->name () << "::freebuf (this->buffer_);\n"; + cs->decr_indent (); *cs << "}" << nl; @@ -716,27 +659,19 @@ be_sequence::gen_client_stubs (void) { case be_sequence::MNG_OBJREF: { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_ObjRefMngType [seq.maximum_];" << nl; *cs << "for (CORBA::ULong i=0; i < seq.length_; i++)" << nl; *cs << "{" << nl; *cs << "\tthis->buffer_[i] = " << bt->name () << "::_duplicate (" << "seq.buffer_[i]);" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; *cs << "}" << nl; } break; case be_sequence::MNG_STRING: { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_StrMngType [seq.maximum_];" << nl; *cs << "for (CORBA::ULong i=0; i < seq.length_; i++)" << nl; *cs << "{" << nl; *cs << "\tthis->buffer_[i] = CORBA::string_dup (" << "seq.buffer_[i]);" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = this->release_;" << nl; *cs << "}" << nl; } break; @@ -748,59 +683,6 @@ be_sequence::gen_client_stubs (void) cs->decr_indent (); *cs << "}\n\n"; - // the init manager method for managed typed sequences - if (this->managed_type () != be_sequence::MNG_NONE) - { - cs->indent (); - *cs << "// init manager" << nl; - *cs << "void " << this->name () << "::init_mgr (void)" << nl; - *cs << "{\n"; - cs->incr_indent (); - - // if release flag, free the manager - *cs << "if (this->release_)" << nl; - *cs << "{\n"; - cs->incr_indent (); - // only for obj references and strings, we need to free each individual - // element - if (this->managed_type () != be_sequence::MNG_NONE) - { - *cs << "delete []this->mgr_; // ensures each element is freed" << nl; - } - cs->decr_indent (); - *cs << "}" << nl; - // copy each element - switch (this->managed_type ()) - { - case be_sequence::MNG_OBJREF: - { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_ObjRefMngType [this->maximum_];" << nl; - *cs << "for (CORBA::ULong i=0; i < this->length_; i++)" << nl; - *cs << "{" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = 1;" << nl; - *cs << "}\n"; - } - break; - case be_sequence::MNG_STRING: - { - *cs << "this->mgr_ = new " << this->name () << - "::TAO_StrMngType [this->maximum_];" << nl; - *cs << "for (CORBA::ULong i=0; i < this->length_; i++)" << nl; - *cs << "{" << nl; - *cs << "\tthis->mgr_[i].ptr_ = &this->buffer_[i];" << nl; - *cs << "\tthis->mgr_[i].release_ = 1;" << nl; - *cs << "}\n"; - } - break; - default: - break; - } - cs->decr_indent (); - *cs << "}\n\n"; - } - // the length method cs->indent (); *cs << "void" << nl; @@ -846,9 +728,6 @@ be_sequence::gen_client_stubs (void) { case be_sequence::MNG_OBJREF: { - *cs << this->name () << "::TAO_ObjRefMngType *tmp_mgr_" << - " = new " << this->name () << - "::TAO_ObjRefMngType [length];" << nl; *cs << "CORBA::ULong i;" << nl; *cs << "// copy old buffer" << nl; *cs << "for (i=0; i < this->length_; i++)" << nl; @@ -856,19 +735,10 @@ be_sequence::gen_client_stubs (void) *cs << "\ttmp[i] = " << bt->name () << "::_duplicate (" << "this->buffer_[i]);" << nl; *cs << "}" << nl; - *cs << "// initialize the new manager" << nl; - *cs << "for (i=0; i < length; i++)" << nl; - *cs << "{" << nl; - *cs << "\ttmp_mgr_[i].ptr_ = &tmp[i];" << nl; - *cs << "\ttmp_mgr_[i].release_ = 1; // always" << nl; - *cs << "}" << nl; } break; case be_sequence::MNG_STRING: { - *cs << this->name () << "::TAO_StrMngType *tmp_mgr_" << - " = new " << this->name () << - "::TAO_StrMngType [length];" << nl; *cs << "CORBA::ULong i;" << nl; *cs << "// copy old buffer" << nl; *cs << "for (i=0; i < this->length_; i++)" << nl; @@ -876,12 +746,6 @@ be_sequence::gen_client_stubs (void) *cs << "\ttmp[i] = CORBA::string_dup (" << "this->buffer_[i]);" << nl; *cs << "}" << nl; - *cs << "// initialize the new manager" << nl; - *cs << "for (i=0; i < length; i++)" << nl; - *cs << "{" << nl; - *cs << "\ttmp_mgr_[i].ptr_ = &tmp[i];" << nl; - *cs << "\ttmp_mgr_[i].release_ = 1;" << nl; - *cs << "}" << nl; } break; default: // all other types are self managed, just assign them. @@ -900,22 +764,21 @@ be_sequence::gen_client_stubs (void) cs->incr_indent (); // only for obj references and strings, we need to free each individual // element. Others are self managed. + // call the appropriate freebuf on the buffer if (this->managed_type () != be_sequence::MNG_NONE) { - *cs << "delete []this->mgr_; // ensures each element is freed" << - nl; + *cs << this->name () << "::freebuf (this->buffer_, " << + "this->maximum_);\n"; } - *cs << this->name () << "::freebuf (this->buffer_);\n"; + else + *cs << this->name () << "::freebuf (this->buffer_);\n"; + cs->decr_indent (); *cs << "}" << nl; *cs << "//assign the newly reallocated buffer" << nl; *cs << "this->buffer_ = tmp;" << nl; *cs << "this->release_ = 1; //after reallocation, we own it" << nl; - if (this->managed_type () != be_sequence::MNG_NONE) - { - *cs << "this->mgr_ = tmp_mgr_;" << nl; - } *cs << "this->maximum_ = length;\n"; cs->decr_indent (); *cs << "}" << nl;; @@ -979,6 +842,44 @@ be_sequence::gen_client_stubs (void) cs->decr_indent (); *cs << "}\n\n"; + // freebuf method + cs->indent (); + *cs << "void" << nl; + *cs << this->name () << "::freebuf ("; + if (s->gen_code (bt, this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_sequence::" + "gen_client_inline - " + "state based codegen failed\n"), + -1); + } + + *cs << " *seq, CORBA::ULong nelems)" << nl; + *cs << "{\n"; + cs->incr_indent (); + *cs << "if (!seq) return; // null sequence" << nl; + // the managed types must be individually freed. The others will have + // their destructors called. + switch (this->managed_type ()) + { + case be_sequence::MNG_OBJREF: + { + *cs << "for (CORBA::ULong i=0; i < nelems; i++)" << nl; + *cs << "\tCORBA::release (seq[i]);" << nl; + } + break; + case be_sequence::MNG_STRING: + { + *cs << "for (CORBA::ULong i=0; i < nelems; i++)" << nl; + *cs << "\tCORBA::string_free (seq[i]);" << nl; + } + break; + } + *cs << this->name () << "::freebuf (seq);"; + cs->decr_indent (); + *cs << "}\n\n"; + // generate the typecode information here cs->indent (); // start from current indentation level *cs << "static const CORBA::Long _oc_" << this->flatname () << "[] =" << @@ -1063,6 +964,11 @@ be_sequence::gen_client_inline (void) -1); } + *ci << "// *************************************************************" + << nl; + *ci << "// class " << this->name () << nl; + *ci << "// *************************************************************\n\n"; + // generate the ifdefined macro for type ci->gen_ifdef_macro (this->flatname ()); @@ -1107,10 +1013,6 @@ be_sequence::gen_client_inline (void) this->max_size () << "))," << nl; *ci << "\t release_ (1) // owns" << nl; } - if (this->managed_type () != be_sequence::MNG_NONE) - { - *ci << "\t, mgr_ (0)" << nl; - } *ci << "{}\n\n"; // the maximum method @@ -1158,15 +1060,23 @@ be_sequence::gen_client_inline (void) -1); } - *ci << " &" << nl; *ci << this->name () << "::operator[] (CORBA::ULong index) // read/write" << nl; *ci << "{\n"; ci->incr_indent (); - if (this->managed_type () != be_sequence::MNG_NONE) - *ci << "return this->mgr_[index];\n"; - else - *ci << "return this->buffer_[index];\n"; + switch (this->managed_type ()) + { + case be_sequence::MNG_OBJREF: + *ci << "return " << this->name () << "::TAO_ObjRefMngType (" << + "&this->buffer_[index], this->release_);\n"; + break; + case be_sequence::MNG_STRING: + *ci << "return " << this->name () << "::TAO_StrMngType (" << + "&this->buffer_[index], this->release_);\n"; + break; + default: + *ci << "return this->buffer_[index];\n"; + } ci->decr_indent (); *ci << "}\n\n"; @@ -1181,15 +1091,23 @@ be_sequence::gen_client_inline (void) -1); } - *ci << " &" << nl; *ci << this->name () << "::operator[] (CORBA::ULong index) const // read" << nl; *ci << "{\n"; ci->incr_indent (); - if (this->managed_type () != be_sequence::MNG_NONE) - *ci << "return this->mgr_[index];\n"; - else - *ci << "return this->buffer_[index];\n"; + switch (this->managed_type ()) + { + case be_sequence::MNG_OBJREF: + *ci << "return " << this->name () << "::TAO_ObjRefMngType (" << + "&this->buffer_[index], this->release_);\n"; + break; + case be_sequence::MNG_STRING: + *ci << "return " << this->name () << "::TAO_StrMngType (" << + "&this->buffer_[index], this->release_);\n"; + break; + default: + *ci << "return this->buffer_[index];\n"; + } ci->decr_indent (); *ci << "}\n\n"; cg->pop (); @@ -1258,6 +1176,7 @@ be_sequence::gen_var_defn (void) char namebuf [NAMEBUFSIZE]; // names be_state *s; // code gen state be_type *bt; // base type + be_decl *scope; // our enclosing scope ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); @@ -1288,6 +1207,11 @@ be_sequence::gen_var_defn (void) // retrieve base type bt = be_type::narrow_from_decl (this->base_type ()); + if (this->defined_in ()) + scope = be_scope::narrow_from_scope (this->defined_in ())->decl (); + else + scope = 0; + // generate the var definition (always in the client header). // Depending upon the data type, there are some differences which we account // for over here. @@ -1330,10 +1254,26 @@ be_sequence::gen_var_defn (void) switch (this->managed_type ()) { case be_sequence::MNG_STRING: - *ch << "ACE_NESTED_CLASS (" << this->name () << ", TAO_StrMngType)"; + if (scope) + { + *ch << "ACE_NESTED_CLASS (" << scope->name () << "," << + this->local_name () << "::TAO_StrMngType) "; + } + else + { + *ch << this->local_name () << "::TAO_StrMngType "; + } break; case be_sequence::MNG_OBJREF: - *ch << "ACE_NESTED_CLASS (" << this->name () << ", TAO_ObjRefMngType)"; + if (scope) + { + *ch << "ACE_NESTED_CLASS (" << scope->name () << "," << + this->local_name () << "::TAO_ObjRefMngType) "; + } + else + { + *ch << this->local_name () << "::TAO_ObjRefMngType "; + } break; default: // gen code for base return type @@ -1345,9 +1285,10 @@ be_sequence::gen_var_defn (void) "state based codegen failed\n"), -1); } + *ch << " &"; } - *ch << " &operator[] (CORBA::ULong index);" << nl; + *ch << "operator[] (CORBA::ULong index);" << nl; *ch << "// in, inout, out, _retn " << nl; // the return types of in, out, inout, and _retn are based on the parameter @@ -1542,10 +1483,10 @@ be_sequence::gen_var_impl (void) switch (this->managed_type ()) { case be_sequence::MNG_STRING: - *ci << this->name () << "::TAO_StrMngType"; + *ci << this->name () << "::TAO_StrMngType "; break; case be_sequence::MNG_OBJREF: - *ci << this->name () << "::TAO_ObjRefMngType"; + *ci << this->name () << "::TAO_ObjRefMngType "; break; default: // gen code for base return type @@ -1557,9 +1498,9 @@ be_sequence::gen_var_impl (void) "state based codegen failed\n"), -1); } + *ci << " &"; } - *ci << "&" << nl; *ci << fname << "::operator[] (CORBA::ULong index)" << nl; *ci << "{\n"; ci->incr_indent (); @@ -1633,6 +1574,7 @@ be_sequence::gen_out_defn (void) char namebuf [NAMEBUFSIZE]; // to hold the _out name be_state *s; // code gen state be_type *bt; // base type + be_decl *scope; // our enclosing scope ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); ACE_OS::sprintf (namebuf, "%s_out", this->local_name ()->get_string ()); @@ -1653,6 +1595,11 @@ be_sequence::gen_out_defn (void) // retrieve base type bt = be_type::narrow_from_decl (this->base_type ()); + if (this->defined_in ()) + scope = be_scope::narrow_from_scope (this->defined_in ())->decl (); + else + scope = 0; + // generate the out definition (always in the client header) ch->indent (); // start with whatever was our current indent level @@ -1688,10 +1635,26 @@ be_sequence::gen_out_defn (void) switch (this->managed_type ()) { case be_sequence::MNG_STRING: - *ch << "ACE_NESTED_CLASS (" << this->name () << ", TAO_StrMngType)"; + if (scope) + { + *ch << "ACE_NESTED_CLASS (" << scope->name () << "," << + this->local_name () << "::TAO_StrMngType) "; + } + else + { + *ch << this->local_name () << "::TAO_StrMngType "; + } break; case be_sequence::MNG_OBJREF: - *ch << "ACE_NESTED_CLASS (" << this->name () << ", TAO_ObjRefMngType)"; + if (scope) + { + *ch << "ACE_NESTED_CLASS (" << scope->name () << "," << + this->local_name () << "::TAO_ObjRefMngType) "; + } + else + { + *ch << this->local_name () << "::TAO_ObjRefMngType "; + } break; default: // gen code for base return type @@ -1703,9 +1666,10 @@ be_sequence::gen_out_defn (void) "state based codegen failed\n"), -1); } + *ch << " &"; } - *ch << " &operator[] (CORBA::ULong index);" << nl; + *ch << "operator[] (CORBA::ULong index);" << nl; *ch << "\n"; ch->decr_indent (); *ch << "private:\n"; @@ -1860,10 +1824,10 @@ be_sequence::gen_out_impl (void) switch (this->managed_type ()) { case be_sequence::MNG_STRING: - *ci << this->name () << "::TAO_StrMngType"; + *ci << this->name () << "::TAO_StrMngType "; break; case be_sequence::MNG_OBJREF: - *ci << this->name () << "::TAO_ObjRefMngType"; + *ci << this->name () << "::TAO_ObjRefMngType "; break; default: // gen code for base return type @@ -1875,9 +1839,9 @@ be_sequence::gen_out_impl (void) "state based codegen failed\n"), -1); } + *ci << " &"; } - *ci << "& " << nl; *ci << fname << "::operator[] (CORBA::ULong index)" << nl; *ci << "{\n"; ci->incr_indent (); @@ -1947,16 +1911,25 @@ be_sequence::gen_managed_type_ch (void) ch->indent (); // start with whatever was our current indent level *ch << "class " << namebuf << nl; *ch << "{" << nl; - *ch << "protected:\n"; + *ch << "public:\n"; ch->incr_indent (); // generate the friend instruction *ch << "friend " << this->local_name () << ";" << nl; // default constr is protected as this managed type is not available // outside. Only this sequence can play with it. - *ch << namebuf << " (void); // default constructor\n"; - ch->decr_indent (); - *ch << "public:\n"; - ch->incr_indent (); + //*ch << namebuf << " (void); // default constructor" << nl; + // copy constructor + *ch << namebuf << "(const " << namebuf << " &); // copy ctor " << nl; + // the constructor that will be used + if (this->managed_type () == be_sequence::MNG_STRING) + { + *ch << namebuf << "(char **buffer, CORBA::Boolean release);" << nl; + } + else + { + *ch << namebuf << "(" << bt->nested_type_name (this, "_ptr*") << + ", CORBA::Boolean release);" << nl; + } // destructor *ch << "~" << namebuf << " (void); // destructor" << nl; *ch << nl; @@ -2006,9 +1979,7 @@ be_sequence::gen_managed_type_ch (void) // generate the private section *ch << "private:\n"; ch->incr_indent (); - // copy constructor not allowed - *ch << namebuf << " (const " << namebuf << " &);" << - "// copy constructor not allowed" << nl; + // *ch << namebuf << "(const " << namebuf << " &); // copy ctor " << nl; *ch << typebuf << " *ptr_;" << nl; *ch << "CORBA::Boolean release_;\n"; ch->decr_indent (); @@ -2086,13 +2057,10 @@ be_sequence::gen_managed_type_ci (void) *ci << "// Inline operations for class " << fnamebuf << nl; *ci << "// *************************************************************\n\n"; - // default constr + // destructor ci->indent (); - *ci << "ACE_INLINE" << nl; - *ci << fnamebuf << "::" << lnamebuf << - " (void) // default constructor" << nl; - *ci << "\t: ptr_ (0)," << nl; - *ci << "\t release_ (0)" << nl; + *ci << "ACE_INLINE " << nl; + *ci << fnamebuf << "::~" << lnamebuf << " (void) // destructor" << nl; *ci << "{}\n\n"; // copy constructor not allowed @@ -2100,6 +2068,15 @@ be_sequence::gen_managed_type_ci (void) // operators if (this->managed_type () == be_sequence::MNG_STRING) { + // constructor that will be used + ci->indent (); + *ci << "ACE_INLINE " << nl; + *ci << fnamebuf << "::" << lnamebuf << + "(char **buffer, CORBA::Boolean release)" << nl; + *ci << "\t: ptr_ (buffer)," << nl; + *ci << "\t release_ (release)" << nl; + *ci << "{}\n\n"; + // other extra methods - cast operator () ci->indent (); *ci << "ACE_INLINE " << nl; @@ -2143,6 +2120,15 @@ be_sequence::gen_managed_type_ci (void) } else if (this->managed_type () == be_sequence::MNG_OBJREF) { + // constructor that will be used + ci->indent (); + *ci << "ACE_INLINE " << nl; + *ci << fnamebuf << "::" << lnamebuf << "(" << bt->name () << + "_ptr* buffer, CORBA::Boolean release)" << nl; + *ci << "\t: ptr_ (buffer)," << nl; + *ci << "\t release_ (release)" << nl; + *ci << "{}\n\n"; + // other extra methods - cast operator () ci->indent (); *ci << "ACE_INLINE " << nl; @@ -2195,8 +2181,7 @@ be_sequence::gen_managed_type_ci (void) return 0; } -// implementation of the _var class. All of these get generated in the inline -// file +// implementation of the managed types int be_sequence::gen_managed_type_cs (void) { @@ -2260,13 +2245,31 @@ be_sequence::gen_managed_type_cs (void) { case be_sequence::MNG_OBJREF: { - // destructor + // copy ctro cs->indent (); - *cs << fnamebuf << "::~" << lnamebuf << " (void) // destructor" << nl; + *cs << fnamebuf << "::" << lnamebuf << "(const " << fnamebuf << + " &_tao_mng_type)" << nl; *cs << "{\n"; cs->incr_indent (); - *cs << "if (this->release_)" << nl; - *cs << " CORBA::release (*this->ptr_);\n"; + *cs << "*this->ptr_ = " << bt->name () << + "::_duplicate (*_tao_mng_type.ptr_);" << nl; + *cs << "this->release_ = _tao_mng_type.release_;\n"; + cs->decr_indent (); + *cs << "}\n\n"; + + // assignment operator + cs->indent (); + *cs << fnamebuf << "&" << nl; + *cs << fnamebuf << "::operator= (const " << fnamebuf << + " &_tao_mng_type)" << nl; + *cs << "{\n"; + cs->incr_indent (); + *cs << "if (this == &_tao_mng_type) return *this;" << nl; + *cs << "if (this->release_) // need to free old one" << nl; + *cs << " CORBA::release (*this->ptr_);" << nl; + *cs << "*this->ptr_ = " << bt->name () << + "::_duplicate (*_tao_mng_type.ptr_);" << nl; + *cs << "return *this;\n"; cs->decr_indent (); *cs << "}\n\n"; @@ -2311,13 +2314,29 @@ be_sequence::gen_managed_type_cs (void) break; case be_sequence::MNG_STRING: { - // destructor + // copy constructor cs->indent (); - *cs << fnamebuf << "::~" << lnamebuf << " (void) // destructor" << nl; + *cs << fnamebuf << "::" << lnamebuf << "(const " << fnamebuf << + " &_tao_mng_type)" << nl; *cs << "{\n"; cs->incr_indent (); - *cs << "if (this->release_)" << nl; - *cs << " CORBA::string_free (*this->ptr_);\n"; + *cs << "*this->ptr_ = CORBA::string_dup (*_tao_mng_type.ptr_);" << nl; + *cs << "this->release_ = _tao_mng_type.release_;\n"; + cs->decr_indent (); + *cs << "}\n\n"; + + // assignment operator (does not change the release flag) + cs->indent (); + *cs << fnamebuf << "&" << nl; + *cs << fnamebuf << "::operator= (const " << fnamebuf << + " &_tao_mng_type)" << nl; + *cs << "{\n"; + cs->incr_indent (); + *cs << "if (this == &_tao_mng_type) return *this;" << nl; + *cs << "if (this->release_) // need to free old one" << nl; + *cs << " CORBA::string_free (*this->ptr_);" << nl; + *cs << "*this->ptr_ = CORBA::string_dup (*_tao_mng_type.ptr_);" << nl; + *cs << "return *this;\n"; cs->decr_indent (); *cs << "}\n\n"; @@ -2397,7 +2416,7 @@ be_sequence::gen_typecode (void) cs->indent (); // start from whatever indentation level we were at *cs << "CORBA::tk_sequence, // typecode kind" << nl; - *cs << this->tc_size () << ", // encapsulation length\n"; + *cs << this->tc_encap_len () << ", // encapsulation length\n"; // now emit the encapsulation return this->gen_encapsulation (); } @@ -2417,9 +2436,9 @@ be_sequence::gen_encapsulation (void) be_type *bt; // base type os = cg->client_stubs (); - os->indent (); // start from the current indentation level + os->incr_indent (); - *os << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl; + *os << "TAO_ENCAP_BYTE_ORDER, // byte order\n"; // emit typecode of element type bt = be_type::narrow_from_decl (this->base_type ()); @@ -2430,7 +2449,7 @@ be_sequence::gen_encapsulation (void) } // emit the length - os->indent (); + os->decr_indent (); *os << this->max_size () << ",\n"; return 0; } diff --git a/TAO/TAO_IDL/be/be_state_argument.cpp b/TAO/TAO_IDL/be/be_state_argument.cpp index ecb9e335389..ed428d30a66 100644 --- a/TAO/TAO_IDL/be/be_state_argument.cpp +++ b/TAO/TAO_IDL/be/be_state_argument.cpp @@ -1761,6 +1761,7 @@ be_state_argument::gen_code (be_type *bt, be_decl *d, be_type *type) break; case TAO_CodeGen::TAO_ARGUMENT_POST_DOCALL_CS: { +#if 0 // if we are sequence, call init manager if (type->node_type () == AST_Decl::NT_sequence) { @@ -1776,6 +1777,7 @@ be_state_argument::gen_code (be_type *bt, be_decl *d, be_type *type) break; } } +#endif } break; case TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS: @@ -1892,6 +1894,7 @@ be_state_argument::gen_code (be_type *bt, be_decl *d, be_type *type) break; case TAO_CodeGen::TAO_ARGUMENT_POST_DOCALL_CS: { +#if 0 // if we are sequence, call init manager if (type->node_type () == AST_Decl::NT_sequence) { @@ -1908,6 +1911,7 @@ be_state_argument::gen_code (be_type *bt, be_decl *d, be_type *type) break; } } +#endif if (bt->size_type () == be_decl::VARIABLE) { *os << arg->local_name () << " = _tao_base_" << diff --git a/TAO/TAO_IDL/be/be_state_attribute.cpp b/TAO/TAO_IDL/be/be_state_attribute.cpp index dcae2b3a306..315503929cf 100644 --- a/TAO/TAO_IDL/be/be_state_attribute.cpp +++ b/TAO/TAO_IDL/be/be_state_attribute.cpp @@ -944,6 +944,7 @@ be_state_attribute::gen_code (be_type *bt, be_decl *d, be_type *type) break; case TAO_CodeGen::TAO_ATTRIBUTE_RETVAL_RETURN_CS: { +#if 0 if (type->node_type () == AST_Decl::NT_sequence) { be_sequence *seq = be_sequence::narrow_from_decl (type); @@ -958,6 +959,7 @@ be_state_attribute::gen_code (be_type *bt, be_decl *d, be_type *type) break; } } +#endif *os << "return retval;" << nl; } break; diff --git a/TAO/TAO_IDL/be/be_state_operation.cpp b/TAO/TAO_IDL/be/be_state_operation.cpp index 40ca8b792e2..895334e6cf8 100644 --- a/TAO/TAO_IDL/be/be_state_operation.cpp +++ b/TAO/TAO_IDL/be/be_state_operation.cpp @@ -473,6 +473,7 @@ be_state_operation::gen_code (be_type *bt, be_decl *d, be_type *type) break; case TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS: { +#if 0 be_sequence *seq = be_sequence::narrow_from_decl (type); // init_mgr method for managed types switch (seq->managed_type ()) @@ -484,6 +485,7 @@ be_state_operation::gen_code (be_type *bt, be_decl *d, be_type *type) default: break; } +#endif // if we are sequence, call init manager *os << "return retval;" << nl; } diff --git a/TAO/TAO_IDL/be/be_state_sequence.cpp b/TAO/TAO_IDL/be/be_state_sequence.cpp index 8bdc66137f9..5e51a878de3 100644 --- a/TAO/TAO_IDL/be/be_state_sequence.cpp +++ b/TAO/TAO_IDL/be/be_state_sequence.cpp @@ -127,13 +127,27 @@ be_state_sequence::gen_code (be_type *bt, be_decl *d, be_type *type) if ((type->node_type () == AST_Decl::NT_interface) || (type->node_type () == AST_Decl::NT_interface_fwd)) { - *os << "ACE_NESTED_CLASS (" << seq->local_name () << - ", TAO_ObjRefMngType)"; + if (scope) + { + *os << "ACE_NESTED_CLASS (" << scope->name () << "," << + seq->local_name () << "::TAO_ObjRefMngType) "; + } + else + { + *os << seq->local_name () << "::TAO_ObjRefMngType "; + } } else // must be a string { - *os << "ACE_NESTED_CLASS (" << seq->local_name () << - ", TAO_StrMngType)"; + if (scope) + { + *os << "ACE_NESTED_CLASS (" << scope->name () << "," << + seq->local_name () << "::TAO_StrMngType) "; + } + else + { + *os << seq->local_name () << "::TAO_StrMngType "; + } } } break; @@ -143,11 +157,11 @@ be_state_sequence::gen_code (be_type *bt, be_decl *d, be_type *type) if ((type->node_type () == AST_Decl::NT_interface) || (type->node_type () == AST_Decl::NT_interface_fwd)) { - *os << seq->name () << "::TAO_ObjRefMngType"; + *os << seq->name () << "::TAO_ObjRefMngType "; } else // must be a string { - *os << seq->name () << "::TAO_StrMngType"; + *os << seq->name () << "::TAO_StrMngType "; } } break; @@ -241,14 +255,21 @@ be_state_sequence::gen_code (be_type *bt, be_decl *d, be_type *type) case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH: // managed type returned by // operator [] { - *os << "ACE_NESTED_CLASS (" << seq->local_name () << - ", TAO_ObjRefMngType)"; + if (scope) + { + *os << "ACE_NESTED_CLASS (" << scope->name () << "," << + seq->local_name () << "::TAO_ObjRefMngType ) "; + } + else + { + *os << seq->local_name () << "::TAO_ObjRefMngType "; + } } break; case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI: case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CS: { - *os << seq->name () << "::TAO_ObjRefMngType"; + *os << seq->name () << "::TAO_ObjRefMngType "; } break; default: @@ -272,13 +293,13 @@ be_state_sequence::gen_code (be_type *bt, be_decl *d, be_type *type) break; case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH: case TAO_CodeGen::TAO_SEQUENCE_BODY_CH: - *os << bt->nested_type_name (scope, ""); + *os << bt->nested_type_name (scope, " &"); break; case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI: case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CS: case TAO_CodeGen::TAO_SEQUENCE_BODY_CS: case TAO_CodeGen::TAO_SEQUENCE_BODY_CI: - *os << bt->name (); + *os << bt->name () << " &"; break; default: { @@ -306,13 +327,13 @@ be_state_sequence::gen_code (be_type *bt, be_decl *d, be_type *type) break; case TAO_CodeGen::TAO_SEQUENCE_BODY_CH: case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH: - *os << bt->nested_type_name (scope, ""); + *os << bt->nested_type_name (scope, " &"); break; case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CS: case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI: case TAO_CodeGen::TAO_SEQUENCE_BODY_CS: case TAO_CodeGen::TAO_SEQUENCE_BODY_CI: - *os << bt->name (); + *os << bt->name () << " &"; break; default: { @@ -366,13 +387,13 @@ be_state_sequence::gen_code (be_type *bt, be_decl *d, be_type *type) break; case TAO_CodeGen::TAO_SEQUENCE_BODY_CH: case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH: - *os << bt->nested_type_name (scope, ""); + *os << bt->nested_type_name (scope, " &"); break; case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CS: case TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI: case TAO_CodeGen::TAO_SEQUENCE_BODY_CS: case TAO_CodeGen::TAO_SEQUENCE_BODY_CI: - *os << bt->name (); + *os << bt->name () << " &"; break; default: { diff --git a/TAO/TAO_IDL/be/be_string.cpp b/TAO/TAO_IDL/be/be_string.cpp index 228da5a5a43..18917d3decf 100644 --- a/TAO/TAO_IDL/be/be_string.cpp +++ b/TAO/TAO_IDL/be/be_string.cpp @@ -129,7 +129,7 @@ be_string::gen_typecode (void) cs->indent (); // start from the current indentation level // emit the enumeration *cs << "CORBA::tk_string, " << nl; - *cs << this->max_size () << ", // string length" << nl; + *cs << this->max_size () << ", // string length\n"; return 0; } diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp index f522c5948bf..191110bc2e0 100644 --- a/TAO/tao/decode.cpp +++ b/TAO/tao/decode.cpp @@ -1125,7 +1125,6 @@ TAO_Marshal_Sequence::decode (CORBA::TypeCode_ptr tc, case CORBA::tk_objref: case CORBA::tk_string: case CORBA::tk_wstring: - ACE_OS::memset ((char*)data+16, 0, 4); case CORBA::tk_any: case CORBA::tk_TypeCode: case CORBA::tk_Principal: diff --git a/TAO/tao/invoke.cpp b/TAO/tao/invoke.cpp index b5b645b375c..a3775ec03d1 100644 --- a/TAO/tao/invoke.cpp +++ b/TAO/tao/invoke.cpp @@ -241,18 +241,6 @@ IIOP_Object::do_call (CORBA::Environment &env, // exception reporting } } -// helper method to retrieve the base typecode -CORBA::TypeCode_ptr -tao_base_typecode (CORBA::TypeCode_ptr tc) -{ - CORBA::Environment env; - while (tc->kind (env) == CORBA::tk_alias) - { - tc = tc->content_type (env); - } - return tc; -} - // DII analogue of the above. Differs in how the vararg calling // convention is implemented -- DII doesn't use the normal call stack // with its implicit typing, but iinstead uses heap-based arguments @@ -346,28 +334,7 @@ IIOP_Object::do_dynamic_call (const char *opname, // operation name if (size != 0) { - void *ptr; - CORBA::TypeCode_ptr baseTC = tao_base_typecode (tcp); - if (baseTC->kind (env) == CORBA::tk_sequence) - { - CORBA::TypeCode_ptr content = tao_base_typecode - (baseTC->content_type (env)); - switch (content->kind (env)) - { - case CORBA::tk_string: - case CORBA::tk_wstring: - case CORBA::tk_objref: - ptr = new CORBA::Octet [size+4]; // +4 for - // the - // managed - // type pointer - break; - default: - ptr = new CORBA::Octet [size]; - } - } - else - ptr = new CORBA::Octet [size]; + void *ptr = new CORBA::Octet [size]; tcp->AddRef (); result->value ()->replace (tcp, ptr, @@ -400,28 +367,7 @@ IIOP_Object::do_dynamic_call (const char *opname, // operation name if (size != 0) { - void *ptr; - CORBA::TypeCode_ptr baseTC = tao_base_typecode (tcp); - if (baseTC->kind (env) == CORBA::tk_sequence) - { - CORBA::TypeCode_ptr content = tao_base_typecode - (baseTC->content_type (env)); - switch (content->kind (env)) - { - case CORBA::tk_string: - case CORBA::tk_wstring: - case CORBA::tk_objref: - ptr = new CORBA::Octet [size+4]; // +4 for - // the - // managed - // type pointer - break; - default: - ptr = new CORBA::Octet [size]; - } - } - else - ptr = new CORBA::Octet [size]; + void *ptr = new CORBA::Octet [size]; tcp->AddRef (); value->value ()->replace (tcp, ptr, diff --git a/TAO/tao/nvlist.cpp b/TAO/tao/nvlist.cpp index 0e0959ff8e8..ba75258cb72 100644 --- a/TAO/tao/nvlist.cpp +++ b/TAO/tao/nvlist.cpp @@ -278,10 +278,10 @@ CORBA_NVList::add_item_consume (char *name, // add a value. If necessary, increment the list CORBA::NamedValue_ptr -CORBA_NVList::add_value_consume (char *name, - CORBA::Any *value, - CORBA::Flags flags, - CORBA::Environment &env) +CORBA_NVList::add_value_consume (char * /*name*/, + CORBA::Any */*value*/, + CORBA::Flags /*flags*/, + CORBA::Environment &/*env*/) { // not implemented because we need to see how we can consume the value // One soln is to make the any_ member of NamedValue to be a Any_ptr or @@ -292,7 +292,7 @@ CORBA_NVList::add_value_consume (char *name, //CORBA::Status void -CORBA_NVList::remove (CORBA::ULong n, CORBA::Environment &env) +CORBA_NVList::remove (CORBA::ULong /*n*/, CORBA::Environment &/*env*/) { // not implemented // XXXASG - TODO diff --git a/TAO/tests/Param_Test/Makefile b/TAO/tests/Param_Test/Makefile index cdeda2db29b..5e13dddc4ab 100644 --- a/TAO/tests/Param_Test/Makefile +++ b/TAO/tests/Param_Test/Makefile @@ -10,6 +10,7 @@ LDLIBS = -lTAO +IDL_HDR = param_testC.h param_testS.h IDL_SRC = param_testC.cpp param_testS.cpp PROG_SRCS = $(IDL_SRC) server.cpp client.cpp param_test_i.cpp helper.cpp \ driver.cpp options.cpp results.cpp tests.cpp @@ -44,7 +45,7 @@ DCFLAGS = -g LDFLAGS += -L$(TAO_ROOT)/tao CPPFLAGS += -I$(TAO_ROOT) -I$(TAO_ROOT)/tao/compat $(TSS_ORB_FLAG)#-H -$(IDL_SRC): param_test.idl +$(IDL_HDR) $(IDL_SRC): param_test.idl $(TAO_ROOT)/TAO_IDL/tao_idl param_test.idl server: $(addprefix $(VDIR),$(PARAM_TEST_SVR_OBJS)) @@ -58,6 +59,7 @@ clean: realclean: clean -/bin/rm -rf param_testC.* param_testS.* + # DO NOT DELETE THIS LINE -- g++dep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. @@ -211,6 +213,7 @@ param_testC.o: param_testC.cpp param_testC.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -378,6 +381,7 @@ param_testS.o: param_testS.cpp param_testS.h param_testC.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -546,6 +550,7 @@ server.o: server.cpp \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -713,6 +718,7 @@ client.o: client.cpp options.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -885,6 +891,7 @@ param_test_i.o: param_test_i.cpp \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -1053,6 +1060,7 @@ helper.o: helper.cpp helper.h param_testC.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -1220,6 +1228,7 @@ driver.o: driver.cpp options.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -1392,6 +1401,7 @@ options.o: options.cpp options.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -1562,6 +1572,7 @@ results.o: results.cpp results.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ @@ -1728,6 +1739,7 @@ tests.o: tests.cpp helper.h param_testC.h \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/corbacom.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/sequence.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/typecode.i \ + /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/nvlist.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/any.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/stub.i \ /project/doc/gokhale/packages/ACE_wrappers/build/SunCC/TAO/tao/object.i \ diff --git a/TAO/tests/Param_Test/README b/TAO/tests/Param_Test/README index 40a206077b1..f8dbee65279 100644 --- a/TAO/tests/Param_Test/README +++ b/TAO/tests/Param_Test/README @@ -1,3 +1,4 @@ + // $Id$ // ============================================================================ @@ -52,3 +53,5 @@ To run the client, type short for shorts ubstring for unbounded string fixed_struct for fixed sized structs + var_struct for variable structs + nested_struct for nested structs diff --git a/TAO/tests/Param_Test/driver.cpp b/TAO/tests/Param_Test/driver.cpp index a4b0f35a3fe..846265da1cd 100644 --- a/TAO/tests/Param_Test/driver.cpp +++ b/TAO/tests/Param_Test/driver.cpp @@ -1,4 +1,4 @@ -// $Id: +// $Id // ============================================================================ // @@ -179,6 +179,32 @@ Driver::run (void) delete client; } break; + case Options::TEST_VAR_STRUCT: + { + Param_Test_Client<Test_Var_Struct> *client = new + Param_Test_Client<Test_Var_Struct> (this->orb_ptr_, + this->objref_, + new Test_Var_Struct); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; + case Options::TEST_NESTED_STRUCT: + { + Param_Test_Client<Test_Nested_Struct> *client = new + Param_Test_Client<Test_Nested_Struct> (this->orb_ptr_, + this->objref_, + new Test_Nested_Struct); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; default: break; } @@ -191,10 +217,14 @@ template class Param_Test_Client<Test_Short>; template class Param_Test_Client<Test_Unbounded_String>; template class Param_Test_Client<Test_Fixed_Struct>; template class Param_Test_Client<Test_String_Sequence>; +template class Param_Test_Client<Test_Var_Struct>; +template class Param_Test_Client<Test_Nested_Struct>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Singleton<Driver, ACE_SYNCH_RECURSIVE_MUTEX> #pragma instantiate Param_Test_Client<Test_Short> #pragma instantiate Param_Test_Client<Test_Unbounded_String> #pragma instantiate Param_Test_Client<Test_Fixed_Struct> #pragma instantiate Param_Test_Client<Test_String_Sequence> +#pragma instantiate Param_Test_Client<Test_Var_Struct> +#pragma instantiate Param_Test_Client<Test_Nested_Struct> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tests/Param_Test/options.cpp b/TAO/tests/Param_Test/options.cpp index 19f221d71d8..a58d3977db0 100644 --- a/TAO/tests/Param_Test/options.cpp +++ b/TAO/tests/Param_Test/options.cpp @@ -80,6 +80,10 @@ Options::parse_args (int argc, char **argv) this->test_type_ = Options::TEST_FIXED_STRUCT; else if (!ACE_OS::strcmp (get_opts.optarg, "strseq")) this->test_type_ = Options::TEST_STRING_SEQUENCE; + else if (!ACE_OS::strcmp (get_opts.optarg, "var_struct")) + this->test_type_ = Options::TEST_VAR_STRUCT; + else if (!ACE_OS::strcmp (get_opts.optarg, "nested_struct")) + this->test_type_ = Options::TEST_NESTED_STRUCT; break; case '?': default: diff --git a/TAO/tests/Param_Test/options.h b/TAO/tests/Param_Test/options.h index fb1527285dd..f86d08966d0 100644 --- a/TAO/tests/Param_Test/options.h +++ b/TAO/tests/Param_Test/options.h @@ -31,7 +31,9 @@ public: TEST_SHORT, TEST_UNBOUNDED_STRING, TEST_FIXED_STRUCT, - TEST_STRING_SEQUENCE + TEST_STRING_SEQUENCE, + TEST_VAR_STRUCT, + TEST_NESTED_STRUCT }; enum INVOKE_TYPE diff --git a/TAO/tests/Param_Test/param_test.idl b/TAO/tests/Param_Test/param_test.idl index fc84aef5aea..23a02353cb0 100644 --- a/TAO/tests/Param_Test/param_test.idl +++ b/TAO/tests/Param_Test/param_test.idl @@ -68,6 +68,26 @@ interface Param_Test out StrSeq s3); + // variable structures + struct Var_Struct + { + StrSeq seq; // this field makes the structure variable + }; + + Var_Struct test_var_struct (in Var_Struct s1, + inout Var_Struct s2, + out Var_Struct s3); + + // nested structs (We reuse the var_struct defn above to make a very + // complicated nested structure) + struct Nested_Struct + { + Var_Struct vs; + }; + + Nested_Struct test_nested_struct (in Nested_Struct s1, + inout Nested_Struct s2, + out Nested_Struct s3); /* // object references Coffee make_coffee (); // make a Coffee object @@ -100,20 +120,6 @@ interface Param_Test out MYSTRING s3); - // structures (variable) - struct var_struct - { - Coffee o; - string s; - sequence<octet> ObjectKey; - sequence<octet> bogus; - }; - var_struct test_vstruct (in var_struct s1, - inout var_struct s2, - out var_struct s3); - - // nested structs (we use a combination of fixed and var sized) - // arrays (fixed) // arrays (variable) diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index 8f06c49e86d..a2edd5883a0 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -94,3 +94,45 @@ Param_Test_i::test_strseq (const Param_Test::StrSeq &s1, s3 = out; return ret; } + +// test for variable structs +Param_Test::Var_Struct * +Param_Test_i::test_var_struct (const Param_Test::Var_Struct &s1, + Param_Test::Var_Struct &s2, + Param_Test::Var_Struct_out s3, + CORBA::Environment &env) +{ + // we copy the "in" sequences into all the inout, out and return sequences. + + Param_Test::Var_Struct + *ret = new Param_Test::Var_Struct, + *out = new Param_Test::Var_Struct; + + // now copy all elements of s1 into the others + s2 = s1; + *out = s1; + *ret = s1; + s3 = out; + return ret; +} + +// test for nested structs +Param_Test::Nested_Struct * +Param_Test_i::test_nested_struct (const Param_Test::Nested_Struct &s1, + Param_Test::Nested_Struct &s2, + Param_Test::Nested_Struct_out s3, + CORBA::Environment &env) +{ + // we copy the "in" sequences into all the inout, out and return sequences. + + Param_Test::Nested_Struct + *ret = new Param_Test::Nested_Struct, + *out = new Param_Test::Nested_Struct; + + // now copy all elements of s1 into the others + s2 = s1; + *out = s1; + *ret = s1; + s3 = out; + return ret; +} diff --git a/TAO/tests/Param_Test/param_test_i.h b/TAO/tests/Param_Test/param_test_i.h index 82f00956ee0..50c19abf7b3 100644 --- a/TAO/tests/Param_Test/param_test_i.h +++ b/TAO/tests/Param_Test/param_test_i.h @@ -56,6 +56,20 @@ public: Param_Test::StrSeq_out s3, CORBA::Environment &env); // test for string sequence + + virtual Param_Test::Var_Struct * + test_var_struct (const Param_Test::Var_Struct &s1, + Param_Test::Var_Struct &s2, + Param_Test::Var_Struct_out s3, + CORBA::Environment &env); + // test for variable structs + + virtual Param_Test::Nested_Struct * + test_nested_struct (const Param_Test::Nested_Struct &s1, + Param_Test::Nested_Struct &s2, + Param_Test::Nested_Struct_out s3, + CORBA::Environment &env); + // test for nested structs }; #endif /* PARAM_TEST_I_H */ diff --git a/TAO/tests/Param_Test/tests.cpp b/TAO/tests/Param_Test/tests.cpp index 29f173b4ad4..bfd5435d309 100644 --- a/TAO/tests/Param_Test/tests.cpp +++ b/TAO/tests/Param_Test/tests.cpp @@ -593,3 +593,293 @@ Test_String_Sequence::print_values (void) (this->ret_->length ()? (char *)this->ret_[i]:"<nul>"))); } } + +// ************************************************************************ +// Test_Var_Struct +// ************************************************************************ + +Test_Var_Struct::Test_Var_Struct (void) + : opname_ (CORBA::string_dup ("test_var_struct")), + inout_ (new Param_Test::Var_Struct), + out_ (0), + ret_ (0) +{ +} + +Test_Var_Struct::~Test_Var_Struct (void) +{ + CORBA::string_free (this->opname_); + // the other data members will be freed as they are "_var"s and objects + // (rather than pointers to objects) +} + +const char * +Test_Var_Struct::opname (void) const +{ + return this->opname_; +} + +void +Test_Var_Struct::init_parameters (void) +{ + Generator *gen = GENERATOR::instance (); // value generator + + // get some sequence length (not more than 10) + CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 10) + 1; + + // set the length of the sequence + this->in_.seq.length (len); + // now set each individual element + for (CORBA::ULong i=0; i < this->in_.seq.length (); i++) + { + // generate some arbitrary string to be filled into the ith location in + // the sequence + char *str = gen->gen_string (); + this->in_.seq[i] = str; + } +} + +void +Test_Var_Struct::reset_parameters (void) +{ + this->inout_ = new Param_Test::Var_Struct; // delete the previous one + this->out_ = 0; + this->ret_ = 0; +} + +int +Test_Var_Struct::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env) +{ + Param_Test::Var_Struct_out out (this->out_.out ()); + this->ret_ = objref->test_var_struct (this->in_, + this->inout_.inout (), + out, + env); + return (env.exception () ? -1:0); +} + +int +Test_Var_Struct::add_args (CORBA::NVList_ptr ¶m_list, + CORBA::NVList_ptr &retval, + CORBA::Environment &env) +{ + CORBA::Any in_arg (Param_Test::_tc_StrSeq, (void *) &this->in_, 0); + CORBA::Any inout_arg (Param_Test::_tc_StrSeq, &this->inout_.inout (), 0); + CORBA::Any out_arg (Param_Test::_tc_StrSeq, this->out_.out (), 0); + + // add parameters + (void)param_list->add_value ("s1", in_arg, CORBA::ARG_IN, env); + (void)param_list->add_value ("s2", inout_arg, CORBA::ARG_INOUT, env); + (void)param_list->add_value ("s3", out_arg, CORBA::ARG_OUT, env); + + // add return value + (void)retval->item (0, env)->value ()->replace (Param_Test::_tc_Var_Struct, + &this->ret_, + 0, // does not own + env); + return 0; +} + +CORBA::Boolean +Test_Var_Struct::check_validity (void) +{ + CORBA::Boolean flag = 0; + if ((this->in_.seq.length () == this->inout_->seq.length ()) && + (this->in_.seq.length () == this->out_->seq.length ()) && + (this->in_.seq.length () == this->ret_->seq.length ())) + { + flag = 1; // assume all are equal + // lengths are same. Now compare the contents + for (CORBA::ULong i=0; i < this->in_.seq.length () && flag; i++) + { + if (ACE_OS::strcmp (this->in_.seq[i], this->inout_->seq[i]) || + ACE_OS::strcmp (this->in_.seq[i], this->out_->seq[i]) || + ACE_OS::strcmp (this->in_.seq[i], this->ret_->seq[i])) + // not equal + flag = 0; + } + } + return flag; +} + +CORBA::Boolean +Test_Var_Struct::check_validity (CORBA::Request_ptr req) +{ + CORBA::Environment env; + this->inout_ = new Param_Test::Var_Struct (*(Param_Test::Var_Struct *) req->arguments + ()->item (1, env)->value ()->value ()); + this->out_ = new Param_Test::Var_Struct (*(Param_Test::Var_Struct *) req->arguments + ()->item (2, env)->value ()->value ()); + this->ret_ = new Param_Test::Var_Struct (*(Param_Test::Var_Struct *)req->result + ()->value ()->value ()); + return this->check_validity (); +} + +void +Test_Var_Struct::print_values (void) +{ + for (CORBA::ULong i=0; i < this->in_.seq.length (); i++) + { + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*=*=*=*=*=*=\n" + "Element # %d\n" + "in (len = %d): %s\n" + "inout (len = %d): %s\n" + "out (len = %d): %s\n" + "ret (len = %d): %s\n", + this->in_.seq.length (), + (this->in_.seq.length ()? (char *)this->in_.seq[i]:"<nul>"), + this->inout_->seq.length (), + (this->inout_->seq.length ()? (char *)this->inout_->seq[i]:"<nul>"), + this->out_->seq.length (), + (this->out_->seq.length ()? (char *)this->out_->seq[i]:"<nul>"), + this->ret_->seq.length (), + (this->ret_->seq.length ()? (char *)this->ret_->seq[i]:"<nul>"))); + } +} + +// ************************************************************************ +// Test_Nested_Struct +// ************************************************************************ + +Test_Nested_Struct::Test_Nested_Struct (void) + : opname_ (CORBA::string_dup ("test_nested_struct")), + inout_ (new Param_Test::Nested_Struct), + out_ (0), + ret_ (0) +{ +} + +Test_Nested_Struct::~Test_Nested_Struct (void) +{ + CORBA::string_free (this->opname_); + // the other data members will be freed as they are "_var"s and objects + // (rather than pointers to objects) +} + +const char * +Test_Nested_Struct::opname (void) const +{ + return this->opname_; +} + +void +Test_Nested_Struct::init_parameters (void) +{ + Generator *gen = GENERATOR::instance (); // value generator + + // get some sequence length (not more than 10) + CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 10) + 1; + + // set the length of the sequence + this->in_.vs.seq.length (len); + // now set each individual element + for (CORBA::ULong i=0; i < this->in_.vs.seq.length (); i++) + { + // generate some arbitrary string to be filled into the ith location in + // the sequence + char *str = gen->gen_string (); + this->in_.vs.seq[i] = str; + } +} + +void +Test_Nested_Struct::reset_parameters (void) +{ + this->inout_ = new Param_Test::Nested_Struct; // delete the previous one + this->out_ = 0; + this->ret_ = 0; +} + +int +Test_Nested_Struct::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env) +{ + Param_Test::Nested_Struct_out out (this->out_.out ()); + this->ret_ = objref->test_nested_struct (this->in_, + this->inout_.inout (), + out, + env); + return (env.exception () ? -1:0); +} + +int +Test_Nested_Struct::add_args (CORBA::NVList_ptr ¶m_list, + CORBA::NVList_ptr &retval, + CORBA::Environment &env) +{ + CORBA::Any in_arg (Param_Test::_tc_StrSeq, (void *) &this->in_, 0); + CORBA::Any inout_arg (Param_Test::_tc_StrSeq, &this->inout_.inout (), 0); + CORBA::Any out_arg (Param_Test::_tc_StrSeq, this->out_.out (), 0); + + // add parameters + (void)param_list->add_value ("s1", in_arg, CORBA::ARG_IN, env); + (void)param_list->add_value ("s2", inout_arg, CORBA::ARG_INOUT, env); + (void)param_list->add_value ("s3", out_arg, CORBA::ARG_OUT, env); + + // add return value + (void)retval->item (0, env)->value ()->replace (Param_Test::_tc_Nested_Struct, + &this->ret_, + 0, // does not own + env); + return 0; +} + +CORBA::Boolean +Test_Nested_Struct::check_validity (void) +{ + CORBA::Boolean flag = 0; + if ((this->in_.vs.seq.length () == this->inout_->vs.seq.length ()) && + (this->in_.vs.seq.length () == this->out_->vs.seq.length ()) && + (this->in_.vs.seq.length () == this->ret_->vs.seq.length ())) + { + flag = 1; // assume all are equal + // lengths are same. Now compare the contents + for (CORBA::ULong i=0; i < this->in_.vs.seq.length () && flag; i++) + { + if (ACE_OS::strcmp (this->in_.vs.seq[i], this->inout_->vs.seq[i]) || + ACE_OS::strcmp (this->in_.vs.seq[i], this->out_->vs.seq[i]) || + ACE_OS::strcmp (this->in_.vs.seq[i], this->ret_->vs.seq[i])) + // not equal + flag = 0; + } + } + return flag; +} + +CORBA::Boolean +Test_Nested_Struct::check_validity (CORBA::Request_ptr req) +{ + CORBA::Environment env; + this->inout_ = new Param_Test::Nested_Struct (*(Param_Test::Nested_Struct *) req->arguments + ()->item (1, env)->value ()->value ()); + this->out_ = new Param_Test::Nested_Struct (*(Param_Test::Nested_Struct *) req->arguments + ()->item (2, env)->value ()->value ()); + this->ret_ = new Param_Test::Nested_Struct (*(Param_Test::Nested_Struct *)req->result + ()->value ()->value ()); + return this->check_validity (); +} + +void +Test_Nested_Struct::print_values (void) +{ + for (CORBA::ULong i=0; i < this->in_.vs.seq.length (); i++) + { + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*=*=*=*=*=*=\n" + "Element # %d\n" + "in (len = %d): %s\n" + "inout (len = %d): %s\n" + "out (len = %d): %s\n" + "ret (len = %d): %s\n", + this->in_.vs.seq.length (), + (this->in_.vs.seq.length ()? (char *)this->in_.vs.seq[i]:"<nul>"), + this->inout_->vs.seq.length (), + (this->inout_->vs.seq.length ()? (char *)this->inout_->vs.seq[i]:"<nul>"), + this->out_->vs.seq.length (), + (this->out_->vs.seq.length ()? (char *)this->out_->vs.seq[i]:"<nul>"), + this->ret_->vs.seq.length (), + (this->ret_->vs.seq.length ()? (char *)this->ret_->vs.seq[i]:"<nul>"))); + } +} diff --git a/TAO/tests/Param_Test/tests.h b/TAO/tests/Param_Test/tests.h index 8f74de788e3..e45e7322d7c 100644 --- a/TAO/tests/Param_Test/tests.h +++ b/TAO/tests/Param_Test/tests.h @@ -247,4 +247,120 @@ private: // return value }; +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test variable sized structs +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_Var_Struct +{ +public: + Test_Var_Struct (void); + // ctor + + ~Test_Var_Struct (void); + // dtor + + int run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env); + // run the SII test + + int add_args (CORBA::NVList_ptr &nvlist, + CORBA::NVList_ptr &retval, + CORBA::Environment &env); + // add args to NVList for DII + + const char *opname (void) const; + // return operation name + + void init_parameters (void); + // set values for parameters + + void reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + CORBA::Boolean check_validity (CORBA::Request_ptr req); + // check if results are valid. This is used for DII results + + void print_values (void); + // print all the values + +private: + char *opname_; + // operation name + + Param_Test::Var_Struct in_; + // in parameter + + // these need memory management + Param_Test::Var_Struct_var inout_; + // inout parameter + + Param_Test::Var_Struct_var out_; + // out parameter + + Param_Test::Var_Struct_var ret_; + // return value +}; + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test nested structs +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_Nested_Struct +{ +public: + Test_Nested_Struct (void); + // ctor + + ~Test_Nested_Struct (void); + // dtor + + int run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env); + // run the SII test + + int add_args (CORBA::NVList_ptr &nvlist, + CORBA::NVList_ptr &retval, + CORBA::Environment &env); + // add args to NVList for DII + + const char *opname (void) const; + // return operation name + + void init_parameters (void); + // set values for parameters + + void reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + CORBA::Boolean check_validity (CORBA::Request_ptr req); + // check if results are valid. This is used for DII results + + void print_values (void); + // print all the values + +private: + char *opname_; + // operation name + + Param_Test::Nested_Struct in_; + // in parameter + + // these need memory management + Param_Test::Nested_Struct_var inout_; + // inout parameter + + Param_Test::Nested_Struct_var out_; + // out parameter + + Param_Test::Nested_Struct_var ret_; + // return value +}; + #endif /* if !defined */ |