From ebce34fa3b0efc76fb55555e6bcdbb49084e79d7 Mon Sep 17 00:00:00 2001 From: gokhale Date: Thu, 16 Apr 1998 21:04:32 +0000 Subject: *** empty log message *** --- TAO/ChangeLog-98c | 19 +++++-- TAO/tao/decode.cpp | 7 ++- TAO/tao/encode.cpp | 3 +- TAO/tests/Param_Test/driver.cpp | 15 ++++++ TAO/tests/Param_Test/options.cpp | 4 +- TAO/tests/Param_Test/options.h | 1 + TAO/tests/Param_Test/param_test.idl | 13 ++--- TAO/tests/Param_Test/param_test_i.cpp | 14 +++++ TAO/tests/Param_Test/param_test_i.h | 9 +++- TAO/tests/Param_Test/tests.cpp | 99 +++++++++++++++++++++++++++++++++++ TAO/tests/Param_Test/tests.h | 57 ++++++++++++++++++++ 11 files changed, 227 insertions(+), 14 deletions(-) (limited to 'TAO') diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 5e92812051a..1b562650b29 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,13 +1,26 @@ +Thu Apr 16 16:00:35 1998 Aniruddha Gokhale + + * tao/decode.cpp: In TypeCode::decode, for the case of bounded + strings, we were passing a null pointer to the typecode + constructor. + + * tao/encode.cpp: In TypeCode::In encode, for strings, we were + encoding the typecode's buffer length rather than the bounds of + the string. + + * tests/Param_Test: Added code to test TypeCodes. Most of the + files in this suite are modified. + Thu Apr 16 13:28:59 1998 Carlos O'Ryan - * tao/decode.cpp: + * tao/decode.cpp: An exception was raised if a nil object reference was decoded. - * tao/POA.cpp: + * tao/POA.cpp: For debugging purposes we print a message when an exception is raised on the server side. - * TAO_IDL/be/be_visitor_interface.cpp: + * TAO_IDL/be/be_visitor_interface.cpp: Use ACE_NESTED_CLASS macro for collocated classes, this makes the generated code portable between NT and other platforms. diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp index 3b941dba6fd..459e8e4256e 100644 --- a/TAO/tao/decode.cpp +++ b/TAO/tao/decode.cpp @@ -254,10 +254,13 @@ TAO_Marshal_TypeCode::decode (CORBA::TypeCode_ptr, } else { + CORBA::Long _oc_bounded_string [2] = + {TAO_ENCAP_BYTE_ORDER, 0}; + _oc_bounded_string [1] = (CORBA::Long) bound; // Bounded string. Save the bounds *tcp = new CORBA::TypeCode ((CORBA::TCKind) kind, - bound, 0, CORBA::B_FALSE, - parent); + bound, (char *) &_oc_bounded_string, + CORBA::B_FALSE, parent); } } } diff --git a/TAO/tao/encode.cpp b/TAO/tao/encode.cpp index 5f609268cc9..84c0be6350b 100644 --- a/TAO/tao/encode.cpp +++ b/TAO/tao/encode.cpp @@ -171,7 +171,7 @@ TAO_Marshal_TypeCode::encode (CORBA::TypeCode_ptr, // A few have "simple" parameter lists case CORBA::tk_string: case CORBA::tk_wstring: - continue_encoding = stream->write_ulong (tc2->length_); + continue_encoding = stream->write_ulong (tc2->length (env)); break; // Indirected typecodes can't occur at "top level" like @@ -193,6 +193,7 @@ TAO_Marshal_TypeCode::encode (CORBA::TypeCode_ptr, case CORBA::tk_alias: case CORBA::tk_except: { + // simply encode the encapsulation continue_encoding = stream->write_ulong (tc2->length_); continue_encoding = continue_encoding && stream->write_octet_array ((CORBA::Octet*)tc2->buffer_, tc2->length_); diff --git a/TAO/tests/Param_Test/driver.cpp b/TAO/tests/Param_Test/driver.cpp index f4ea0b14d75..6226d305378 100644 --- a/TAO/tests/Param_Test/driver.cpp +++ b/TAO/tests/Param_Test/driver.cpp @@ -224,6 +224,19 @@ Driver::run (void) delete client; } break; + case Options::TEST_TYPECODE: + { + Param_Test_Client *client = new + Param_Test_Client (this->orb_ptr_, + this->objref_.in(), + new Test_TypeCode); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; case Options::TEST_ANY: { Param_Test_Client *client = new @@ -253,6 +266,7 @@ template class Param_Test_Client; template class Param_Test_Client; template class Param_Test_Client; template class Param_Test_Client; +template class Param_Test_Client; template class Param_Test_Client; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Singleton @@ -264,5 +278,6 @@ template class Param_Test_Client; #pragma instantiate Param_Test_Client #pragma instantiate Param_Test_Client #pragma instantiate Param_Test_Client +#pragma instantiate Param_Test_Client #pragma instantiate Param_Test_Client #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tests/Param_Test/options.cpp b/TAO/tests/Param_Test/options.cpp index 1802cab69d5..d0b3c47a103 100644 --- a/TAO/tests/Param_Test/options.cpp +++ b/TAO/tests/Param_Test/options.cpp @@ -19,7 +19,7 @@ #include "options.h" // @@ Naga, can you please generalize this so we don't use a fixed -// sized constant?! +// sized constant?! #define MAX_IOR_SIZE 512 // Constructor.p @@ -99,6 +99,8 @@ Options::parse_args (int argc, char **argv) this->test_type_ = Options::TEST_STRUCT_SEQUENCE; else if (!ACE_OS::strcmp (get_opts.optarg, "objref")) this->test_type_ = Options::TEST_OBJREF; + else if (!ACE_OS::strcmp (get_opts.optarg, "typecode")) + this->test_type_ = Options::TEST_TYPECODE; else if (!ACE_OS::strcmp (get_opts.optarg, "any")) this->test_type_ = Options::TEST_ANY; break; diff --git a/TAO/tests/Param_Test/options.h b/TAO/tests/Param_Test/options.h index b34830f4e4b..c8ed12be068 100644 --- a/TAO/tests/Param_Test/options.h +++ b/TAO/tests/Param_Test/options.h @@ -37,6 +37,7 @@ public: TEST_NESTED_STRUCT, TEST_STRUCT_SEQUENCE, TEST_OBJREF, + TEST_TYPECODE, TEST_ANY }; diff --git a/TAO/tests/Param_Test/param_test.idl b/TAO/tests/Param_Test/param_test.idl index ef58954d4d4..1f447016259 100644 --- a/TAO/tests/Param_Test/param_test.idl +++ b/TAO/tests/Param_Test/param_test.idl @@ -134,18 +134,19 @@ interface Param_Test // test the parameter passing conventions for ObjRefs Coffee test_objref (in Coffee o1, inout Coffee o2, out Coffee o3); + // test typecodes + TypeCode test_typecode (in TypeCode t1, inout TypeCode t2, out TypeCode t3); + // Anys. We try to pump in all kinds of data types thru these Anys any test_any (in any a1, inout any a2, out any a3); - // test simple objects - // Object test_object (in Object o1, inout Object o2, out Object o3); - - // test typecodes - // TypeCode test_typecode (in TypeCode t1, inout TypeCode t2, out TypeCode t3); - // sequence of typecodes // typedef sequence TypeCodeSeq; // TypeCodeSeq test_tcseq (in TypeCodeSeq t1, inout TypeCodeSeq t2, out TypeCodeSeq t3); + + // test simple objects + // Object test_object (in Object o1, inout Object o2, out Object o3); + /* long test_long (in long l1, inout long l2, diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index f6b02cdb701..9d144d1cbb2 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -360,6 +360,20 @@ Param_Test_i::test_objref (Coffee_ptr o1, return ret; } +// test for typecodes +CORBA::TypeCode_ptr +Param_Test_i::test_typecode (CORBA::TypeCode_ptr t1, + CORBA::TypeCode_ptr &t2, + CORBA::TypeCode_out t3, + CORBA::Environment &env) +{ + // we simply assign t1 to the others + CORBA::TypeCode_ptr retval = CORBA::TypeCode::_duplicate (t1); + t2 = CORBA::TypeCode::_duplicate (t1); + t3 = CORBA::TypeCode::_duplicate (t1); + return retval; +} + // test for Anys CORBA::Any * Param_Test_i::test_any (const CORBA::Any &a1, diff --git a/TAO/tests/Param_Test/param_test_i.h b/TAO/tests/Param_Test/param_test_i.h index 53f035e3d3e..f3a6cf2615d 100644 --- a/TAO/tests/Param_Test/param_test_i.h +++ b/TAO/tests/Param_Test/param_test_i.h @@ -126,7 +126,7 @@ public: Param_Test::Bounded_Coffee_Mix_out s3, CORBA::Environment &env ); - // = End of sequences tests.... + // = End of sequences tests.... virtual Param_Test::Var_Struct * test_var_struct (const Param_Test::Var_Struct &s1, @@ -153,6 +153,13 @@ public: CORBA::Environment &env); // test for object references + virtual CORBA::TypeCode_ptr + test_typecode (CORBA::TypeCode_ptr t1, + CORBA::TypeCode_ptr &o2, + CORBA::TypeCode_out o3, + CORBA::Environment &env); + // test for typecodes + virtual CORBA::Any * test_any (const CORBA::Any &a1, CORBA::Any &a2, diff --git a/TAO/tests/Param_Test/tests.cpp b/TAO/tests/Param_Test/tests.cpp index d57911b3665..6bff84d5ff1 100644 --- a/TAO/tests/Param_Test/tests.cpp +++ b/TAO/tests/Param_Test/tests.cpp @@ -1450,6 +1450,105 @@ Test_ObjRef::print_values (void) ret)); } +// ************************************************************************ +// Test_TypeCode +// ************************************************************************ + +Test_TypeCode::Test_TypeCode (void) + : opname_ (CORBA::string_dup ("test_typecode")) +{ +} + +Test_TypeCode::~Test_TypeCode (void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; +} + +const char * +Test_TypeCode::opname (void) const +{ + return this->opname_; +} + +static const CORBA::TypeCode_ptr tc_table [] = { + // primitive parameterless typecodes + CORBA::_tc_short, + // typecode with a simple parameter + CORBA::_tc_string, + // complex typecodes + CORBA::_tc_Object, + _tc_Param_Test, + Param_Test::_tc_StructSeq, + Param_Test::_tc_Nested_Struct +}; + +int +Test_TypeCode::init_parameters (Param_Test_ptr objref, + CORBA::Environment &env) +{ + Generator *gen = GENERATOR::instance (); // value generator + CORBA::ULong index = (CORBA::ULong) (gen->gen_long () % 6); + + this->in_ = CORBA::TypeCode::_duplicate (tc_table [index]); + this->inout_ = CORBA::TypeCode::_duplicate (CORBA::_tc_null); + + return 0; +} + +int +Test_TypeCode::reset_parameters (void) +{ + Generator *gen = GENERATOR::instance (); // value generator + CORBA::ULong index = (CORBA::ULong) (gen->gen_long () % 6); + this->in_ = CORBA::TypeCode::_duplicate (tc_table [index]); + this->inout_ = CORBA::TypeCode::_duplicate (CORBA::_tc_null); + return 0; +} + +int +Test_TypeCode::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env) +{ + CORBA::TypeCode_out out (this->out_.out ()); + this->ret_ = objref->test_typecode (this->in_.in (), + this->inout_.inout (), + out, + env); + return (env.exception () ? -1:0); +} + +int +Test_TypeCode::add_args (CORBA::NVList_ptr ¶m_list, + CORBA::NVList_ptr &retval, + CORBA::Environment &env) +{ + return 0; +} + +CORBA::Boolean +Test_TypeCode::check_validity (void) +{ + CORBA::Environment env; + if (this->in_->equal (this->inout_.in (), env) && + this->in_->equal (this->out_.in (), env) && + this->in_->equal (this->ret_.in (), env)) + return 1; + else + return 0; +} + +CORBA::Boolean +Test_TypeCode::check_validity (CORBA::Request_ptr req) +{ + return this->check_validity (); +} + +void +Test_TypeCode::print_values (void) +{ +} + // ************************************************************************ // Test_Any // ************************************************************************ diff --git a/TAO/tests/Param_Test/tests.h b/TAO/tests/Param_Test/tests.h index 1dab45fed8a..c5af51ff5dc 100644 --- a/TAO/tests/Param_Test/tests.h +++ b/TAO/tests/Param_Test/tests.h @@ -492,6 +492,63 @@ private: // return value }; +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test TypeCodes +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +class Test_TypeCode +{ +public: + Test_TypeCode (void); + // ctor + + ~Test_TypeCode (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 + + int init_parameters (Param_Test_ptr objref, + CORBA::Environment &env); + // set values for parameters + + int 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 + + CORBA::TypeCode_var in_; + // in parameter + + CORBA::TypeCode_var inout_; + // inout parameter + + CORBA::TypeCode_var out_; + // out parameter + + CORBA::TypeCode_var ret_; + // return value +}; + // =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // test Anys // =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -- cgit v1.2.1