From 6cfe365eae869dd44380f0cb69b989124c474dd0 Mon Sep 17 00:00:00 2001 From: parsons Date: Mon, 14 Jun 2010 13:48:01 +0000 Subject: ChangeLogTag: Mon Jun 14 13:45:43 UTC 2010 Jeff Parsons --- TAO/ChangeLog | 301 +++++++++++++++++++++ TAO/MPC/config/stl_mapping.mpb | 7 + TAO/TAO_IDL/be/be_codegen.cpp | 31 +++ TAO/TAO_IDL/be/be_global.cpp | 23 ++ TAO/TAO_IDL/be/be_sequence.cpp | 11 +- TAO/TAO_IDL/be/be_visitor_arg_traits.cpp | 21 +- TAO/TAO_IDL/be/be_visitor_argument.cpp | 4 + TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp | 31 ++- TAO/TAO_IDL/be/be_visitor_argument/argument.cpp | 2 +- TAO/TAO_IDL/be/be_visitor_operation/operation.cpp | 31 ++- .../be/be_visitor_operation/operation_ch.cpp | 2 +- TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp | 22 +- TAO/TAO_IDL/be/be_visitor_root/any_op.cpp | 2 +- TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp | 66 +++-- TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp | 108 +++++++- TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp | 41 ++- TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp | 112 ++++++-- TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp | 107 +++++--- TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp | 119 +++++--- TAO/TAO_IDL/be_include/be_global.h | 6 + TAO/tao/AnyTypeCode/Any.cpp | 22 ++ TAO/tao/AnyTypeCode/Any.h | 4 + TAO/tao/AnyTypeCode/Vector_AnyOp_T.h | 103 +++++++ TAO/tao/Array_VarOut_T.h | 1 + TAO/tao/Basic_Arguments.h | 10 + TAO/tao/CDR.h | 6 + TAO/tao/CDR.inl | 15 + TAO/tao/Fixed_Size_Argument_T.h | 2 - TAO/tao/PortableServer/Basic_SArguments.h | 7 + TAO/tao/PortableServer/Vector_SArgument_T.cpp | 117 ++++++++ TAO/tao/PortableServer/Vector_SArgument_T.h | 170 ++++++++++++ TAO/tao/PortableServer/Vector_SArgument_T.inl | 67 +++++ TAO/tao/Vector_Argument_T.cpp | 149 ++++++++++ TAO/tao/Vector_Argument_T.h | 192 +++++++++++++ TAO/tao/Vector_Argument_T.inl | 107 ++++++++ TAO/tao/Vector_CDR_T.h | 223 +++++++++++++++ TAO/tao/tao.mpc | 2 + TAO/tests/AMI/ami_test.idl | 5 + TAO/tests/Alt_Mapping/README | 77 ++++++ TAO/tests/Alt_Mapping/alt_mapping.idl | 30 ++ TAO/tests/Alt_Mapping/alt_mapping.mpc | 70 +++++ TAO/tests/Alt_Mapping/alt_mapping_i.cpp | 63 +++++ TAO/tests/Alt_Mapping/alt_mapping_i.h | 45 +++ TAO/tests/Alt_Mapping/client.cpp | 152 +++++++++++ TAO/tests/Alt_Mapping/client.h | 74 +++++ TAO/tests/Alt_Mapping/driver.cpp | 171 ++++++++++++ TAO/tests/Alt_Mapping/driver.h | 52 ++++ TAO/tests/Alt_Mapping/helper.cpp | 112 ++++++++ TAO/tests/Alt_Mapping/helper.h | 47 ++++ TAO/tests/Alt_Mapping/options.cpp | 176 ++++++++++++ TAO/tests/Alt_Mapping/options.h | 101 +++++++ TAO/tests/Alt_Mapping/results.cpp | 149 ++++++++++ TAO/tests/Alt_Mapping/results.h | 88 ++++++ TAO/tests/Alt_Mapping/run_test.pl | 119 ++++++++ TAO/tests/Alt_Mapping/server.cpp | 155 +++++++++++ TAO/tests/Alt_Mapping/tests.h | 22 ++ TAO/tests/Alt_Mapping/ub_string.cpp | 124 +++++++++ TAO/tests/Alt_Mapping/ub_string.h | 67 +++++ TAO/tests/Alt_Mapping/ub_struct_seq.cpp | 196 ++++++++++++++ TAO/tests/Alt_Mapping/ub_struct_seq.h | 75 +++++ TAO/tests/IDL_Test/reopened_modules.idl | 44 +++ TAO/tests/IDL_Test/repo_id_mod.idl | 3 +- 62 files changed, 4293 insertions(+), 168 deletions(-) create mode 100644 TAO/MPC/config/stl_mapping.mpb create mode 100644 TAO/tao/AnyTypeCode/Vector_AnyOp_T.h create mode 100644 TAO/tao/PortableServer/Vector_SArgument_T.cpp create mode 100644 TAO/tao/PortableServer/Vector_SArgument_T.h create mode 100644 TAO/tao/PortableServer/Vector_SArgument_T.inl create mode 100644 TAO/tao/Vector_Argument_T.cpp create mode 100644 TAO/tao/Vector_Argument_T.h create mode 100644 TAO/tao/Vector_Argument_T.inl create mode 100644 TAO/tao/Vector_CDR_T.h create mode 100644 TAO/tests/Alt_Mapping/README create mode 100644 TAO/tests/Alt_Mapping/alt_mapping.idl create mode 100644 TAO/tests/Alt_Mapping/alt_mapping.mpc create mode 100644 TAO/tests/Alt_Mapping/alt_mapping_i.cpp create mode 100644 TAO/tests/Alt_Mapping/alt_mapping_i.h create mode 100644 TAO/tests/Alt_Mapping/client.cpp create mode 100644 TAO/tests/Alt_Mapping/client.h create mode 100644 TAO/tests/Alt_Mapping/driver.cpp create mode 100644 TAO/tests/Alt_Mapping/driver.h create mode 100644 TAO/tests/Alt_Mapping/helper.cpp create mode 100644 TAO/tests/Alt_Mapping/helper.h create mode 100644 TAO/tests/Alt_Mapping/options.cpp create mode 100644 TAO/tests/Alt_Mapping/options.h create mode 100644 TAO/tests/Alt_Mapping/results.cpp create mode 100644 TAO/tests/Alt_Mapping/results.h create mode 100755 TAO/tests/Alt_Mapping/run_test.pl create mode 100644 TAO/tests/Alt_Mapping/server.cpp create mode 100644 TAO/tests/Alt_Mapping/tests.h create mode 100644 TAO/tests/Alt_Mapping/ub_string.cpp create mode 100644 TAO/tests/Alt_Mapping/ub_string.h create mode 100644 TAO/tests/Alt_Mapping/ub_struct_seq.cpp create mode 100644 TAO/tests/Alt_Mapping/ub_struct_seq.h (limited to 'TAO') diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 8d598bb9ad9..aa91daf8714 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,304 @@ +Mon Jun 14 13:45:43 UTC 2010 Jeff Parsons + + * Merged alt_mapping branch + + Tue May 11 16:16:18 UTC 2010 Jeff Parsons + + * TAO_IDL/be/be_visitor_argument/arglist.cpp: + + Added missing global double colon in generation of enum argument. + + Fri May 7 19:44:31 UTC 2010 Jeff Parsons + + * TAO_IDL/be/be_visitor_operation/operation.cpp: + + Added a check to generate the SArg_Trait parameter for + the repo id arg to _is_a() as char* instead of std::string. + We would have to regenerate ORB code for that to work, + and it may be a choice later on to do that. + + * TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp: + * TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp: + + To set the length of a sequence, changed the call to the + underlying vector from capacity() to resize() - capacity() + wasn't behaving as expected. + + * tests/Alt_Mapping/ub_struct_seq.cpp: + + Cosmetic changes, and other changes in parameter init + and results checking to make debugging easier. + + Mon May 3 22:21:33 UTC 2010 Jeff Parsons + + * tests/Param_Test/param_testC.cpp: + * tests/Param_Test/param_testS.cpp: + * tests/Param_Test/param_testC.h: + * tests/Param_Test/param_testS.h: + * tests/Param_Test/param_testC.inl: + * tests/Param_Test/param_testS.inl: + + Removed these from the repository in this + branch, all hand-crafted hacks have been + removed. + + * tests/Param_Test/ub_string.h: + * tests/Param_Test/param_test_i.cpp: + * tests/Param_Test/Param_Test.mpc: + * tests/Param_Test/ub_string.cpp: + * tests/Param_Test/ub_long_seq.h: + * tests/Param_Test/param_test_i.h: + * tests/Param_Test/README: + * tests/Param_Test/ub_long_seq.cpp: + + Restored these files to head version, the + STL support is now covered in its own test. + + * TAO_IDL/be/be_visitor_operation/operation.cpp: + + Fixed bug in code generation for unbounded + strings, in the logic to decide when to use + "std::string" and when not to. + + Mon May 3 21:39:09 UTC 2010 Jeff Parsons + + * tests/Alt_Mapping/driver.h: + * tests/Alt_Mapping/options.h: + * tests/Alt_Mapping/ub_string.h: + * tests/Alt_Mapping/results.cpp: + * tests/Alt_Mapping/alt_mapping_i.cpp: + * tests/Alt_Mapping/server.cpp: + * tests/Alt_Mapping/results.h: + * tests/Alt_Mapping/tests.h: + * tests/Alt_Mapping/alt_mapping_i.h: + * tests/Alt_Mapping/README: + * tests/Alt_Mapping/client.cpp: + * tests/Alt_Mapping/helper.cpp: + * tests/Alt_Mapping/alt_mapping.idl: + * tests/Alt_Mapping/ub_struct_seq.cpp: + * tests/Alt_Mapping/client.h: + * tests/Alt_Mapping/helper.h: + * tests/Alt_Mapping/ub_struct_seq.h: + * tests/Alt_Mapping/alt_mapping.mpc: + * tests/Alt_Mapping/options.cpp: + * tests/Alt_Mapping/driver.cpp: + * tests/Alt_Mapping/run_test.pl: + * tests/Alt_Mapping/ub_string.cpp: + + New test for alternate C++ mapping support. + Currently supports unbounded strings and + tests unbounded sequence of simple structs. + + * TAO_IDL/be/be_visitor_arg_traits.cpp: + * TAO_IDL/be/be_visitor_argument/arglist.cpp: + * TAO_IDL/be/be_visitor_operation/arglist.cpp: + * TAO_IDL/be/be_visitor_operation/rettype.cpp: + * TAO_IDL/be/be_visitor_operation/operation.cpp: + * TAO_IDL/be/be_visitor_operation/operation_ss.cpp: + * TAO_IDL/be/be_codegen.cpp: + * TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp: + * TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp: + * TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp: + * TAO_IDL/be/be_sequence.cpp: + * tao/Vector_Argument_T.inl: + * tao/AnyTypeCode/Any.cpp: + * tao/PortableServer/Vector_SArgument_T.inl: + * tao/PortableServer/Vector_SArgument_T.cpp: + * tao/PortableServer/Vector_SArgument_T.h: + * tao/Vector_Argument_T.h: + * tao/Fixed_Size_Argument_T.h: + + More tweaks to fully automate the generation of + correct code for the alternate C++ mapping. + + Mon Apr 12 19:30:47 UTC 2010 Jeff Parsons + + * TAO_IDL/be/be_codegen.cpp: + + Added conditional include of vector argument class + header file. + + * TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp: + + Fixed typos in generated code, and added check to + skip bounded sequences for now. + + * tao/Vector_Argument_T.inl: + * tao/Vector_Argument_T.h: + * tao/Vector_Argument_T.cpp: + + Overhauled signatures of most methods. + + Fri Apr 9 20:39:11 UTC 2010 Jeff Parsons + + * MPC/config/stl_mapping.mpb: + + New base project, to help with toggling the + alternate C++ mapping generation for the + entire middleware. + + * tao/Vector_Argument_T.inl: + * tao/PortableServer/Vector_SArgument_T.inl: + * tao/PortableServer/Vector_SArgument_T.cpp: + * tao/PortableServer/Vector_SArgument_T.h: + * tao/Vector_Argument_T.h: + * tao/Vector_Argument_T.cpp: + + New argument template helper classes and + traits, for the std::vector containers + used for unbounded sequences. + + * tao/tao.mpc: + + Added new files to TAO build project. + + * tao/AnyTypeCode/Vector_AnyOp_T.h: + * tao/Vector_CDR_T.h: + + Added 'typename' qualifier to template + traits references to disambiguate them + for the C++ compiler. + + * TAO_IDL/be/be_visitor_arg_traits.cpp: + * TAO_IDL/be/be_visitor_argument/argument.cpp: + * TAO_IDL/be/be_visitor_argument/arglist.cpp: + * TAO_IDL/be/be_visitor_operation/operation_ch.cpp: + * TAO_IDL/be/be_visitor_operation/rettype.cpp: + * TAO_IDL/be/be_visitor_operation/operation.cpp: + + Further removal of hacks from the IDL compiler + to generate the alternate C++ mapping in the + general case. + + * tests/Param_Test/param_test_i.cpp: + * tests/Param_Test/param_test_i.h: + + Update some of the servant methods to use + the new signatures. + + Mon Mar 29 20:28:34 UTC 2010 Jeff Parsons + + * TAO_IDL/be/be_codegen.cpp: + * TAO_IDL/be_visitor_sequence/any_op_cs.cpp: + + Minor mods to codegen for STL includes and STL any + operators. + + Mon Mar 29 18:49:32 UTC 2010 Jeff Parsons + + * TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp: + + Cosmetic changes. + + * TAO_IDL/be/be_codegen.cpp: + + Added generation of includes for CDR and Any operator + template header files. + + * TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp: + * TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp: + + Added code generation for Any insertions and extraction + operators for std::vector<> types representing IDL + sequences. + + * TAO_IDL/be/be_global.cpp: + + Added command line option to trigger code generation for + alternate C++ mapping. + + Mon Mar 29 18:46:20 UTC 2010 Jeff Parsons + + * tao/AnyTypeCode/Any.h: + * tao/AnyTypeCode/Any.cpp: + + Added non-copying Any insertion operator for std::string. + Not yet implemented, still a no-op. + + * tao/tao.mpc: + * tao/Vector_AnyOp_T.h: + + Moved this template file to the AnyTypeCode directory. + + Mon Mar 29 17:13:54 UTC 2010 Jeff Parsons + + * tao/Vector_CDR_T.h: + + Cosmetic changes. + + * tao/Vector_AnyOp_T.h: + + New file defining no-op Any insertion and extraction operators + for std::vector, in various categories of element types. + + * tao/tao.mpc: + + Added above files to the MPC project. + + Tue Mar 2 23:18:32 UTC 2010 Jeff Parsons + + * tests/Param_Test/param_test_i.cpp: + * tests/Param_Test/Param_Test.mpc: + * tests/Param_Test/param_testC.cpp: + * tests/Param_Test/param_testS.cpp: + * tests/Param_Test/param_testC.h: + * tests/Param_Test/param_testS.h: + * tests/Param_Test/param_test_i.h: + * TAO_IDL/be/be_visitor_argument/arglist.cpp: + * TAO_IDL/be/be_codegen.cpp: + * TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp: + * TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp: + * TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp: + * TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp: + * TAO_IDL/be/be_visitor_root/cdr_op.cpp: + * TAO_IDL/be/be_visitor_root/any_op.cpp: + * TAO_IDL/be/be_visitor_argument.cpp: + * TAO_IDL/be/be_global.cpp: + * TAO_IDL/be_include/be_global.h: + * tao/AnyTypeCode/Any.h: + * tao/AnyTypeCode/Any.cpp: + * tao/CDR.inl + * tao/Array_VarOut_T.h: + * tao/CDR.h: + + Progress toward generation of code for alternate mapping + in the general case. + + * tao/Vector_CDR_T.h: + + New file containing template methods for (de)marshaling + std::vector. Includes a general case and special + cases for interfaces and arrays. + + Tue Feb 23 17:06:19 UTC 2010 Jeff Parsons + + * TAO_IDL/be/be_visitor_arg_traits.cpp: + * TAO_IDL/be/be_visitor_argument/arglist.cpp: + * TAO_IDL/be/be_visitor_operation/operation_ch.cpp: + * TAO_IDL/be/be_visitor_operation/rettype.cpp: + * TAO_IDL/be/be_visitor_operation/operation.cpp: + * TAO_IDL/be/be_codegen.cpp: + * TAO_IDL/be/be_visitor_root/cdr_op.cpp: + * TAO_IDL/be/be_visitor_root/any_op.cpp: + + Changes to make the hand-crafted mods to the + Param_Test operations test_unbounded_string() + and test_long_sequence() appear in generated + code. + + Mon Jan 11 19:17:57 UTC 2010 Jeff Parsons + + * tao/Basic_Arguments.h: + * tao/PortableServer/Basic_SArguments.h: + + Added specializations Arg_Traits and + SArg_Traits. + + * tests/Param_Test/param_testC.cpp: + + Removed specializations Arg_Traits + since it is now in the ORB (see above). + Fri Jun 11 19:15:30 UTC 2010 Jeff Parsons * TAO_IDL/be/be_visitor_ccm_pre_proc.cpp(create_equivalent): diff --git a/TAO/MPC/config/stl_mapping.mpb b/TAO/MPC/config/stl_mapping.mpb new file mode 100644 index 00000000000..c960f2a3d94 --- /dev/null +++ b/TAO/MPC/config/stl_mapping.mpb @@ -0,0 +1,7 @@ +// -*- MPC -*- +// $Id$ + +feature(stl_mapping) : taoidldefaults { + requires += stl_mapping + idlflags += -Gstl +} diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index ec38758dd96..68bb74911df 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -255,6 +255,12 @@ TAO_CodeGen::start_client_header (const char *fname) } else { + if (be_global->alt_mapping ()) + { + *this->client_header_ << "#include " + << "\n#include \n"; + } + this->gen_stub_hdr_includes (); size_t const nfiles = idl_global->n_included_idl_files (); @@ -2677,6 +2683,19 @@ TAO_CodeGen::gen_stub_src_includes (void) this->gen_any_file_includes (this->client_stubs_); } + if (be_global->alt_mapping () && idl_global->seq_seen_) + { + this->gen_standard_include (this->client_stubs_, + "tao/Vector_CDR_T.h"); + + if (be_global->any_support ()) + { + this->gen_standard_include ( + this->client_stubs_, + "tao/AnyTypeCode/Vector_AnyOp_T.h"); + } + } + // Includes whatever arg helper template classes that may be needed. this->gen_stub_arg_file_includes (this->client_stubs_); @@ -2988,6 +3007,12 @@ TAO_CodeGen::gen_stub_arg_file_includes (TAO_OutStream * stream) stream ); + this->gen_cond_file_include ( + idl_global->seq_seen_ && be_global->alt_mapping (), + "tao/Vector_Argument_T.h", + stream + ); + this->gen_cond_file_include ( idl_global->any_arg_seen_, "tao/AnyTypeCode/Any_Arg_Traits.h", @@ -3070,6 +3095,12 @@ TAO_CodeGen::gen_skel_arg_file_includes (TAO_OutStream * stream) stream ); + this->gen_cond_file_include ( + idl_global->seq_seen_ && be_global->alt_mapping (), + "tao/PortableServer/Vector_SArgument_T.h", + stream + ); + this->gen_cond_file_include ( idl_global->any_arg_seen_, "tao/PortableServer/Any_SArg_Traits.h", diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp index 474e853f47d..8c6c14c02e4 100644 --- a/TAO/TAO_IDL/be/be_global.cpp +++ b/TAO/TAO_IDL/be/be_global.cpp @@ -2314,6 +2314,18 @@ BE_GlobalData::gen_lem_force_all (bool val) this->gen_lem_force_all_ = val; } +bool +BE_GlobalData::alt_mapping (void) const +{ + return this->alt_mapping_; +} + +void +BE_GlobalData::alt_mapping (bool val) +{ + this->alt_mapping_ = val; +} + unsigned long BE_GlobalData::tab_size (void) const { @@ -2757,6 +2769,12 @@ BE_GlobalData::parse_args (long &i, char **av) // CIAO servant code generation. be_global->gen_ciao_svnt (true); } + else if (av[i][3] == 't' && av[i][4] == 'l') + { + // Generate code using STL types for strings + // and sequences. + be_global->alt_mapping (true); + } else { ACE_ERROR (( @@ -3686,6 +3704,11 @@ BE_GlobalData::usage (void) const LM_DEBUG, ACE_TEXT (" -Gsp\t\t\tGenerate the code for Smart Proxies\n") )); + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT (" -Gstl\t\t\tGenerate the alternate C++ mapping for") + ACE_TEXT (" IDL strings and sequences\n") + )); ACE_DEBUG (( LM_DEBUG, ACE_TEXT (" -Gt\t\t\tenable optimized TypeCode support") diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index b117c0d079f..9b892275822 100644 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ b/TAO/TAO_IDL/be/be_sequence.cpp @@ -20,9 +20,10 @@ #include "be_interface_fwd.h" #include "be_predefined_type.h" #include "be_field.h" +#include "be_string.h" #include "be_visitor.h" #include "be_helper.h" -#include "be_string.h" +#include "be_extern.h" #include "utl_identifier.h" #include "idl_defines.h" @@ -555,6 +556,14 @@ be_sequence::gen_base_class_name (TAO_OutStream *os, AST_Decl *ctx_scope) { be_type *elem = be_type::narrow_from_decl (this->base_type ()); + + if (be_global->alt_mapping () && this->unbounded ()) + { + *os << "std::vector<" << elem->nested_type_name (ctx_scope) + << ">"; + + return 0; + } // Generate the appropriate base class type. switch (this->managed_type ()) diff --git a/TAO/TAO_IDL/be/be_visitor_arg_traits.cpp b/TAO/TAO_IDL/be/be_visitor_arg_traits.cpp index e075fa9027b..1adfd21f049 100644 --- a/TAO/TAO_IDL/be/be_visitor_arg_traits.cpp +++ b/TAO/TAO_IDL/be/be_visitor_arg_traits.cpp @@ -602,6 +602,7 @@ be_visitor_arg_traits::visit_sequence (be_sequence *node) TAO_OutStream *os = this->ctx_->stream (); be_typedef *alias = this->ctx_->alias (); + AST_Type *bt = node->base_type (); *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__; @@ -611,21 +612,27 @@ be_visitor_arg_traits::visit_sequence (be_sequence *node) // This should be generated even for imported nodes. The ifdef // guard prevents multiple declarations. - os->gen_ifdef_macro (alias->flat_name (), guard_suffix.c_str (), false); - + os->gen_ifdef_macro (alias->flat_name (), + guard_suffix.c_str (), + false); + + bool use_vec = (node->unbounded () && be_global->alt_mapping ()); + UTL_ScopedName *sn = alias->name (); + *os << be_nl << be_nl << "template<>" << be_nl - << "class " - << this->S_ << "Arg_Traits<" - << alias->name () << ">" << be_idt_nl + << "class " << this->S_ << "Arg_Traits<" << sn << ">" + << be_idt_nl << ": public" << be_idt << be_idt_nl - << "Var_Size_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl - << alias->name () << "," << be_nl + << (use_vec ? "Vector_" : "Var_Size_") + << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl + << sn << "," << be_nl << this->insert_policy() << be_uidt_nl << ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl << "{" << be_nl << "};"; + os->gen_endif (); this->generated (node, true); diff --git a/TAO/TAO_IDL/be/be_visitor_argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument.cpp index cf4b25d8a3c..f16ad0c0acd 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument.cpp @@ -37,8 +37,12 @@ #include "be_home.h" #include "be_operation.h" #include "be_helper.h" +#include "be_extern.h" + #include "utl_identifier.h" + #include "nr_extern.h" + #include "ace/Log_Msg.h" #include "be_visitor_argument/arglist.cpp" diff --git a/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp index abe198abe8b..d1ba5d33171 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/arglist.cpp @@ -87,7 +87,9 @@ int be_visitor_args_arglist::visit_array (be_array *node) int be_visitor_args_arglist::visit_enum (be_enum *node) { - TAO_OutStream *os = this->ctx_->stream (); // get output stream + TAO_OutStream *os = this->ctx_->stream (); + + *os << "::"; switch (this->direction ()) { @@ -295,7 +297,15 @@ int be_visitor_args_arglist::visit_sequence (be_sequence *node) *os << this->type_name (node) << " &"; break; case AST_Argument::dir_OUT: - *os << this->type_name (node, "_out"); + if (be_global->alt_mapping () && node->unbounded ()) + { + *os << this->type_name (node) << " &"; + } + else + { + *os << this->type_name (node, "_out"); + } + break; } @@ -305,6 +315,23 @@ int be_visitor_args_arglist::visit_sequence (be_sequence *node) int be_visitor_args_arglist::visit_string (be_string *node) { TAO_OutStream *os = this->ctx_->stream (); + ACE_CDR::ULong bound = node->max_size ()->ev ()->u.ulval; + bool wide = (node->width () != (long) sizeof (char)); + + if (!wide && bound == 0 && be_global->alt_mapping ()) + { + switch (this->direction ()) + { + case AST_Argument::dir_IN: + *os << "const std::string"; + break; + default: + *os << "std::string &"; + break; + } + + return 0; + } if (node->width () == (long) sizeof (char)) { diff --git a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp index b20bc5f29b5..cb357cee097 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp @@ -53,7 +53,7 @@ be_visitor_args::type_name (be_type *node, } ACE_OS::sprintf (namebuf, - "::%s", + "%s", bt->full_name ()); if (suffix) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 5c5bebb38b8..48f13b135ce 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -461,11 +461,13 @@ be_visitor_operation::gen_arg_template_param_name (AST_Decl *scope, } AST_Decl::NodeType nt = bt->unaliased_type ()->node_type (); + ACE_CDR::ULong bound = 0; if (nt == AST_Decl::NT_string || nt == AST_Decl::NT_wstring) { - AST_String *s = AST_String::narrow_from_decl (bt->unaliased_type ()); - ACE_CDR::ULong bound = s->max_size ()->ev ()->u.ulval; + AST_String *s = + AST_String::narrow_from_decl (bt->unaliased_type ()); + bound = s->max_size ()->ev ()->u.ulval; // If the (w)string is unbounded, code is generated below by the // last line of this method, whether bt is a typedef or not. @@ -504,7 +506,8 @@ be_visitor_operation::gen_arg_template_param_name (AST_Decl *scope, // type, in order to disambiguate the template parameter. if (nt == AST_Decl::NT_pre_defined) { - AST_PredefinedType *pdt = AST_PredefinedType::narrow_from_decl (ut); + AST_PredefinedType *pdt = + AST_PredefinedType::narrow_from_decl (ut); switch (pdt->pt ()) { @@ -535,9 +538,29 @@ be_visitor_operation::gen_arg_template_param_name (AST_Decl *scope, *os << "::"; } + /// For now, keep a list of system operation or arg names + /// that may not be remapped. May decide later to regnerate + /// ORB code for alt mapping as well. + ACE_CString repo_id (scope->repoID ()); + bool sys_val = (repo_id == "IDL:repository_id:1.0"); + // For types other than the 4 above, don't unalias the type name // in case it is a sequence or array. - *os << bt->name (); + if (nt == AST_Decl::NT_string && bound == 0) + { + if (be_global->alt_mapping () && !sys_val) + { + *os << "std::string"; + } + else + { + *os << "char *"; + } + } + else + { + *os << bt->name (); + } if (nt == AST_Decl::NT_array) { diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp index 47130754f70..c1910e1f343 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp @@ -50,7 +50,7 @@ be_visitor_operation_ch::visit_operation (be_operation *node) ACE_TEXT ("Bad return type\n")), -1); } - + // Grab the right visitor to generate the return type. be_visitor_context ctx (*this->ctx_); be_visitor_operation_rettype or_visitor (&ctx); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp index 6bc0eb7eaf5..5b607d1214f 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype.cpp @@ -132,9 +132,12 @@ int be_visitor_operation_rettype::visit_sequence ( be_sequence *node) { - // We should never directly be here because anonymous - // sequence return types are not allowed. - *os << "::" << this->type_name (node) << " *"; + *os << "::" << this->type_name (node); + + if (!be_global->alt_mapping () || !node->unbounded ()) + { + *os << " *"; + } return 0; } @@ -142,13 +145,20 @@ be_visitor_operation_rettype::visit_sequence ( int be_visitor_operation_rettype::visit_string (be_string *node) { - if (node->width () == (long) sizeof (char)) + ACE_CDR::ULong bound = node->max_size ()->ev ()->u.ulval; + bool wide = (node->width () != (long) sizeof (char)); + + if (wide) { - *os << "char *"; + *os << "::CORBA::WChar *"; + } + else if (bound == 0 && be_global->alt_mapping ()) + { + *os << "std::string"; } else { - *os << "::CORBA::WChar *"; + *os << "char *"; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp b/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp index e0b80b109a1..18443c5f93a 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/any_op.cpp @@ -54,6 +54,6 @@ be_visitor_root_any_op::visit_root (be_root *node) ACE_TEXT ("codegen for scope failed\n")), -1); } - + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp index 1099be78c56..1effa9a6ef6 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_ch.cpp @@ -43,32 +43,56 @@ be_visitor_sequence_any_op_ch::visit_sequence (be_sequence *node) *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + ACE_CString name; + + bool alt = be_global->alt_mapping (); + + if (alt) + { + be_type *bt = + be_type::narrow_from_decl (node->base_type ()); + + name = "std::vector<"; + name += bt->full_name (); + name += ">"; + } + else + { + name = node->full_name (); + } + *os << be_global->core_versioning_begin () << be_nl; // Generate the Any <<= and >>= operators. - *os << macro; - *os << " void" - << " operator<<= ( ::CORBA::Any &, const "; - *os << node->name (); - *os << " &); // copying version" << be_nl; - *os << macro; - *os << " void" - << " operator<<= ( ::CORBA::Any &, "; - *os << node->name (); - *os << "*); // noncopying version" << be_nl; - *os << macro; - *os << " ::CORBA::Boolean" - << " operator>>= (const ::CORBA::Any &, "; - *os << node->name (); - *os << " *&); // deprecated" << be_nl; - *os << macro; - *os << " ::CORBA::Boolean" - << " operator>>= (const ::CORBA::Any &, const "; - *os << node->name (); - *os << " *&);"; + *os << macro + << " void" + << " operator<<= ( ::CORBA::Any &, const " + << name.c_str () + << " &); // copying version" << be_nl; + + if (!alt) + { + *os << macro + << " void" + << " operator<<= ( ::CORBA::Any &, " + << name.c_str () + << "*); // noncopying version" << be_nl; + + *os << macro + << " ::CORBA::Boolean" + << " operator>>= (const ::CORBA::Any &, " + << name.c_str () + << " *&); // deprecated" << be_nl; + } + + *os << macro + << " ::CORBA::Boolean" + << " operator>>= (const ::CORBA::Any &, const " + << name.c_str () + << " *&);"; *os << be_global->core_versioning_end () << be_nl; - node->cli_hdr_any_op_gen (1); + node->cli_hdr_any_op_gen (true); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp index 8d75eae8193..964b0fc01cc 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp @@ -46,6 +46,109 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) *os << be_global->core_versioning_begin () << be_nl; + // These are no-ops for now, so we just generate them and return + if (be_global->alt_mapping () && node->max_size ()->ev ()->u.ulval == 0) + { + be_type *bt = + be_type::narrow_from_decl (node->base_type ()); + + if (bt->node_type () == AST_Decl::NT_typedef) + { + be_typedef *td = be_typedef::narrow_from_decl (bt); + bt = td->primitive_base_type (); + } + + enum type_category + { + ANY_VALUE, + ANY_OBJREF, + ANY_ARRAY + }; + + type_category tc = ANY_VALUE; + + if (bt->node_type () == AST_Decl::NT_array) + { + tc = ANY_ARRAY; + } + else if (be_interface::narrow_from_decl (bt) != 0 + && be_valuetype::narrow_from_decl (bt) == 0) + { + tc = ANY_OBJREF; + } + + *os << be_nl + << "void operator<<= (" << be_idt_nl + << "::CORBA::Any &_tao_any," << be_nl + << "const std::vector<" << bt->full_name () + << "> &_tao_elem)" << be_uidt_nl + << "{" << be_idt_nl + << "TAO::"; + + switch (tc) + { + case ANY_OBJREF: + *os << "insert_objref_vector<" + << bt->full_name () << "_ptr> ("; + + break; + case ANY_ARRAY: + *os << "insert_array_vector<" + << bt->full_name () << "_forany> ("; + + break; + default: + *os << "insert_value_vector<" + << bt->full_name () << "> ("; + + break; + } + + *os << be_idt_nl + << "_tao_any," << be_nl + << "_tao_elem);" << be_uidt << be_uidt_nl + << "}"; + + *os << be_nl << be_nl + << "::CORBA::Boolean operator>>= (" << be_idt_nl + << "const ::CORBA::Any &_tao_any," << be_nl + << "std::vector<" << bt->full_name () + << "> &_tao_elem)" << be_uidt_nl + << "{" << be_idt_nl + << "return" << be_idt_nl + << "TAO::"; + + switch (tc) + { + case ANY_OBJREF: + *os << "extract_objref_vector<" + << bt->full_name () << "_ptr> ("; + + break; + case ANY_ARRAY: + *os << "extract_array_vector<" + << bt->full_name () << "_forany> ("; + + break; + default: + *os << "extract_value_vector<" + << bt->full_name () << "> ("; + + break; + } + + *os << be_idt_nl + << "_tao_any," << be_nl + << "_tao_elem);" << be_uidt << be_uidt << be_uidt_nl + << "}"; + + *os << be_nl + << be_global->core_versioning_end () << be_nl; + + node->cli_stub_any_op_gen (true); + return 0; + } + // Since we don't generate CDR stream operators for types that // explicitly contain a local interface (at some level), we // must override these Any template class methods to avoid @@ -80,7 +183,8 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) be_typedef *td = this->ctx_->tdef (); // Copying insertion. - *os << be_nl << "// Copying insertion." << be_nl + *os << be_nl + << "// Copying insertion." << be_nl << "void operator<<= (" << be_idt << be_idt_nl << "::CORBA::Any &_tao_any," << be_nl << "const " << node->name () << " &_tao_elem" << be_uidt_nl @@ -150,6 +254,6 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) *os << be_global->core_versioning_end () << be_nl; - node->cli_stub_any_op_gen (1); + node->cli_stub_any_op_gen (true); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp index f5b136c5369..e09eecb2157 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_ch.cpp @@ -68,21 +68,44 @@ be_visitor_sequence_cdr_op_ch::visit_sequence (be_sequence *node) << node->flat_name () << "_H_" << "\n#define _TAO_CDR_OP_" << node->flat_name () << "_H_"; } + + bool alt = be_global->alt_mapping (); *os << be_global->core_versioning_begin (); - *os << be_nl + *os << be_nl << be_nl << be_global->stub_export_macro () << " ::CORBA::Boolean" - << " operator<< (" << be_idt_nl + << " operator<< (" << be_idt << be_idt_nl << "TAO_OutputCDR &strm," << be_nl - << "const " << node->name () << " &_tao_sequence);" - << be_uidt; + << "const "; - *os << be_nl << be_nl - << be_global->stub_export_macro () << " ::CORBA::Boolean" - << " operator>> (" << be_idt_nl - << "TAO_InputCDR &strm," << be_nl - << node->name () << " &_tao_sequence);" << be_uidt; + if (alt) + { + *os << "std::vector<" << base_type->name () << ">"; + } + else + { + *os << node->name (); + } + + *os << " &_tao_sequence" << be_uidt_nl + << ");" << be_uidt_nl; + + *os << be_global->stub_export_macro () << " ::CORBA::Boolean" + << " operator>> (" << be_idt << be_idt_nl + << "TAO_InputCDR &strm," << be_nl; + + if (alt) + { + *os << "std::vector<" << base_type->name () << ">"; + } + else + { + *os << node->name (); + } + + *os << " &_tao_sequence" << be_uidt_nl + << ");" << be_uidt; if (be_global->gen_ostream_operators ()) { diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp index 7d8e4edd931..90d74dee51b 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp @@ -97,41 +97,101 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) << node->flat_name () << "_CPP_" << be_nl << "#define _TAO_CDR_OP_" << node->flat_name () << "_CPP_" << be_nl; + + bool alt = be_global->alt_mapping (); *os << be_global->core_versioning_begin () << be_nl; // Set the sub state as generating code for the output operator. this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - - *os << "::CORBA::Boolean operator<< (" << be_idt << be_idt_nl - << "TAO_OutputCDR &strm," << be_nl - << "const " << node->name () - << " &_tao_sequence" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - - *os << "return TAO::marshal_sequence(strm, _tao_sequence);" - << be_uidt_nl; - - *os << "}" << be_nl << be_nl; + + if (alt) + { + *os << "::CORBA::Boolean operator<< (" << be_idt_nl + << "TAO_OutputCDR &strm," << be_nl + << "const std::vector<" << bt->full_name () + << "> &_tao_vector)" + << be_uidt_nl + << "{" << be_idt_nl + << "::CORBA::ULong length = _tao_vector.size ();" + << be_nl + << "strm << length;" << be_nl << be_nl + << "for ( ::CORBA::ULong i = 0UL; i < length; ++i)" + << be_idt_nl + << "{" << be_idt_nl + << "if (! (strm << _tao_vector[i]))" << be_idt_nl + << "{" << be_idt_nl + << "return false;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "return true;" << be_uidt_nl + << "}" << be_nl << be_nl; + } + else + { + *os << "::CORBA::Boolean operator<< (" + << be_idt << be_idt_nl + << "TAO_OutputCDR &strm," << be_nl + << "const " << node->name () << " &_tao_sequence" + << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "return TAO::marshal_sequence(strm, _tao_sequence);" + << be_uidt_nl + << "}" << be_nl << be_nl; + } // Set the sub state as generating code for the input operator. this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); - *os << "::CORBA::Boolean operator>> (" << be_idt << be_idt_nl - << "TAO_InputCDR &strm"; - - *os << "," << be_nl - << node->name () << " &_tao_sequence"; - - *os << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - - *os << "return TAO::demarshal_sequence(strm, _tao_sequence);" - << be_uidt_nl; - - *os << "}" << be_nl; + if (alt) + { + *os << "::CORBA::Boolean operator>> (" << be_idt_nl + << "TAO_InputCDR &strm," << be_nl + << "std::vector<" << bt->full_name () + << "> &_tao_vector)" << be_uidt_nl + << "{" << be_idt_nl + << "::CORBA::ULong length = 0UL;" << be_nl + << bt->full_name (); + + if (bt->size_type () == AST_Type::VARIABLE) + { + *os << " *"; + } + + *os << " tmp;" << be_nl << be_nl + << "if (! (strm >> length))" << be_idt_nl + << "{" << be_idt_nl + << "return false;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "_tao_vector.resize (length);" << be_nl << be_nl + << "for ( ::CORBA::ULong i = 0UL; i < length; ++i)" + << be_idt_nl + << "{" << be_idt_nl + << "if (! (strm >> tmp))" << be_idt_nl + << "{" << be_idt_nl + << "return false;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "_tao_vector[i] = tmp;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "return true;" << be_uidt_nl + << "}" << be_nl; + } + else + { + *os << "::CORBA::Boolean operator>> (" + << be_idt << be_idt_nl + << "TAO_InputCDR &strm" + << "," << be_nl + << node->name () + << " &_tao_sequence" + << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "return TAO::demarshal_sequence(strm, _tao_sequence);" + << be_uidt_nl + << "}" << be_nl; + } if (be_global->gen_ostream_operators ()) { diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp index 4dce0fbe634..e90c8768e91 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp @@ -100,16 +100,21 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) os->gen_ifdef_macro (node->flat_name ()); - if (this->ctx_->tdef () != 0) + /// If we are using std::vector, we won't be using _vars + /// and _outs. They may get redefined and reinstated later. + if (!be_global->alt_mapping () || !node->unbounded ()) { - *os << be_nl << be_nl - << "class " << node->local_name () << ";"; - } + if (this->ctx_->tdef () != 0) + { + *os << be_nl << be_nl + << "class " << node->local_name () << ";"; + } - if (this->ctx_->tdef () != 0) - { - this->gen_varout_typedefs (node, - bt); + if (this->ctx_->tdef () != 0) + { + this->gen_varout_typedefs (node, + bt); + } } *os << be_nl << be_nl @@ -141,51 +146,73 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) << node->local_name () << " ( ::CORBA::ULong max);"; } - *os << be_nl - << node->local_name () << " (" << be_idt; - - if (node->unbounded ()) + /// If we are using std::vector, we can't implement this + /// constructor. + if (!be_global->alt_mapping () || !node->unbounded ()) { *os << be_nl - << "::CORBA::ULong max,"; - } + << node->local_name () << " (" << be_idt; - *os << be_nl - << "::CORBA::ULong length," << be_nl; + if (node->unbounded ()) + { + *os << be_nl + << "::CORBA::ULong max,"; + } - // Generate the base type for the buffer. - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH); - be_visitor_sequence_buffer_type bt_visitor (&ctx); + *os << be_nl + << "::CORBA::ULong length," << be_nl; - if (bt->accept (&bt_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } + // Generate the base type for the buffer. + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH); + be_visitor_sequence_buffer_type bt_visitor (&ctx); + + if (bt->accept (&bt_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_sequence_ch::" + "visit_sequence - " + "buffer type visit failed\n"), + -1); + } - *os << "* buffer, " << be_nl - << "::CORBA::Boolean release = false);" << be_uidt_nl; - *os << node->local_name () << " (const " << node->local_name () + *os << "* buffer, " << be_nl + << "::CORBA::Boolean release = false);" << be_uidt; + } + + *os << be_nl + << node->local_name () << " (const " << node->local_name () << " &);" << be_nl; *os << "virtual ~" << node->local_name () << " (void);"; + if (be_global->alt_mapping () && node->unbounded ()) + { + *os << be_nl << be_nl + << "virtual ::CORBA::ULong length (void) const;" + << be_nl + << "virtual void length ( ::CORBA::ULong);" + << be_nl << be_nl + << "virtual ::CORBA::ULong maximum (void) const;"; + } + if (be_global->any_support () && !node->anonymous ()) { *os << be_nl << be_nl << "static void _tao_any_destructor (void *);"; } - // Generate the _var_type typedef (only if we are not anonymous). - if (this->ctx_->tdef () != 0) + /// If we are using std::vector, we can't implement this + /// constructor. + if (!be_global->alt_mapping () || !node->unbounded ()) { - *os << be_nl << be_nl - << "typedef " << node->local_name () << "_var _var_type;" - << be_nl - << "typedef " << node->local_name () << "_out _out_type;"; + // Generate the _var_type typedef (only if we are not anonymous). + if (this->ctx_->tdef () != 0) + { + *os << be_nl << be_nl + << "typedef " << node->local_name () << "_var _var_type;" + << be_nl + << "typedef " << node->local_name () << "_out _out_type;"; + } } // TAO provides extensions for octet sequences, first find out if @@ -211,8 +238,10 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) } // Now generate the extension... - if (predef != 0 && predef->pt () == AST_PredefinedType::PT_octet - && node->unbounded ()) + if (predef != 0 + && predef->pt () == AST_PredefinedType::PT_octet + && node->unbounded () + && !be_global->alt_mapping ()) { *os << be_nl << be_nl << "\n\n#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp index 178e620be64..a7ef110214f 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp @@ -82,67 +82,72 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) } - *os << be_nl << "(max)" << be_uidt << be_uidt_nl + *os << " (max)" << be_uidt << be_uidt_nl << "{}"; } - // constructor with the buffer - *os << be_nl << be_nl - << node->name () << "::" << node->local_name () << " (" - << be_idt << be_idt_nl; - - if (node->unbounded ()) + /// If we are using std::vector, we can't implement this + /// constructor. + if (!be_global->alt_mapping () || !node->unbounded ()) { - // Unbounded seq takes this extra parameter. - *os << "::CORBA::ULong max," << be_nl; - } + // constructor with the buffer + *os << be_nl << be_nl + << node->name () << "::" << node->local_name () << " (" + << be_idt << be_idt_nl; - *os << "::CORBA::ULong length," << be_nl; + if (node->unbounded ()) + { + // Unbounded seq takes this extra parameter. + *os << "::CORBA::ULong max," << be_nl; + } - // generate the base type for the buffer - be_visitor_context ctx (*this->ctx_); - be_visitor_sequence_buffer_type bt_visitor (&ctx); + *os << "::CORBA::ULong length," << be_nl; - if (bt->accept (&bt_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } + // generate the base type for the buffer + be_visitor_context ctx (*this->ctx_); + be_visitor_sequence_buffer_type bt_visitor (&ctx); - *os << " * buffer," << be_nl - << "::CORBA::Boolean release)" << be_uidt << be_uidt_nl - << " : " << be_idt << be_idt; + if (bt->accept (&bt_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_sequence_cs::" + "visit_sequence - " + "base type visit failed\n"), + -1); + } - // Pass it to the base constructor. - if (node->gen_base_class_name (os, "", this->ctx_->scope ()->decl ()) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "codegen for base sequence class\n"), - -1); - } + *os << " * buffer," << be_nl + << "::CORBA::Boolean release" << be_uidt_nl + << ")" << be_uidt_nl + << " : " << be_idt << be_idt; - *os << be_nl << "("; + // Pass it to the base constructor. + if (node->gen_base_class_name (os, "", this->ctx_->scope ()->decl ()) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_sequence_cs::" + "visit_sequence - " + "codegen for base sequence class\n"), + -1); + } - if (node->unbounded ()) - { - *os << "max, "; - } + *os << be_nl << "("; - *os << "length, buffer, release)" << be_uidt << be_uidt_nl - << "{}"; + if (node->unbounded ()) + { + *os << "max, "; + } + + *os << "length, buffer, release)" << be_uidt << be_uidt_nl + << "{}"; + } // Copy constructor. *os << be_nl << be_nl << node->name () << "::" << node->local_name () - << " (" << be_idt << be_idt_nl + << " (" << be_idt << be_idt << be_idt_nl << "const " << node->local_name () - << " &seq)" << be_uidt - << be_uidt_nl + << " &seq)" << be_uidt << be_uidt_nl << " : " << be_idt << be_idt; // Pass it to the base constructor. @@ -155,7 +160,7 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) -1); } - *os << be_nl << "(seq)" << be_uidt << be_uidt_nl + *os << " (seq)" << be_uidt << be_uidt_nl << "{}"; // Destructor. @@ -164,6 +169,30 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) << " (void)" << be_nl << "{}"; + if (be_global->alt_mapping () && node->unbounded ()) + { + *os << be_nl << be_nl + << "::CORBA::ULong" << be_nl + << node->name () << "::length (void) const" << be_nl + << "{" << be_idt_nl + << "return this->size ();" << be_uidt_nl + << "}"; + + *os << be_nl << be_nl + << "void" << be_nl + << node->name () << "::length ( ::CORBA::ULong length)" + << be_nl + << "{" << be_idt_nl + << "this->resize (length);" << be_uidt_nl + << "}"; + + *os << be_nl << be_nl + << "::CORBA::ULong" << be_nl + << node->name () << "::maximum (void) const" << be_nl + << "{" << be_idt_nl + << "return this->capacity ();" << be_uidt_nl + << "}"; + } if (be_global->any_support () && !node->anonymous ()) { diff --git a/TAO/TAO_IDL/be_include/be_global.h b/TAO/TAO_IDL/be_include/be_global.h index a4f61a16303..c78b5ca60a6 100644 --- a/TAO/TAO_IDL/be_include/be_global.h +++ b/TAO/TAO_IDL/be_include/be_global.h @@ -788,6 +788,9 @@ public: bool gen_lem_force_all (void) const; void gen_lem_force_all (bool val); + + bool alt_mapping (void) const; + void alt_mapping (bool val); unsigned long tab_size (void) const; void tab_size (unsigned long val); @@ -1129,6 +1132,9 @@ private: /// 2 spaces by default, can be set from the command line. unsigned int tab_size_; + + bool alt_mapping_; + // Are we generating STL types? }; #endif /* _BE_GLOBAL_H */ diff --git a/TAO/tao/AnyTypeCode/Any.cpp b/TAO/tao/AnyTypeCode/Any.cpp index bd769921aed..bc967972886 100644 --- a/TAO/tao/AnyTypeCode/Any.cpp +++ b/TAO/tao/AnyTypeCode/Any.cpp @@ -516,6 +516,18 @@ operator<<= (CORBA::Any &any, const CORBA::WChar *ws) 0); } +ACE_INLINE void +operator <<= (CORBA::Any &any, const std::string & str) +{ + any <<= str.c_str (); +} + +ACE_INLINE void +operator <<= (CORBA::Any &any, std::string * str) +{ + // TODO +} + // Extraction: these are safe and hence we have to check that the // typecode of the Any is equal to the one we are trying to extract // into. @@ -721,6 +733,16 @@ operator>>= (const CORBA::Any &any, CORBA::TypeCode_ptr &tc) ); } +CORBA::Boolean +operator >>= (const CORBA::Any &any, std::string &str) +{ + const char *buf = 0; + CORBA::Boolean flag = any >>= buf; + str.assign (buf); + ACE::strdelete (const_cast (buf)); + return flag; +} + // ================================================================ // Any_Impl_T template specializations. diff --git a/TAO/tao/AnyTypeCode/Any.h b/TAO/tao/AnyTypeCode/Any.h index 85184997880..6f6dfe69e7e 100644 --- a/TAO/tao/AnyTypeCode/Any.h +++ b/TAO/tao/AnyTypeCode/Any.h @@ -301,6 +301,8 @@ TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::TypeCode_ptr); TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::TypeCode_ptr *); TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const CORBA::Object_ptr); TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, CORBA::Object_ptr *); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, const std::string &); +TAO_AnyTypeCode_Export void operator<<= (CORBA::Any &, std::string *); /// Typesafe extraction. @@ -330,6 +332,8 @@ TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::Char *&); TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, const CORBA::WChar *&); +TAO_AnyTypeCode_Export CORBA::Boolean operator>>= (const CORBA::Any &, + std::string &); TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/AnyTypeCode/Vector_AnyOp_T.h b/TAO/tao/AnyTypeCode/Vector_AnyOp_T.h new file mode 100644 index 00000000000..20b44708ac0 --- /dev/null +++ b/TAO/tao/AnyTypeCode/Vector_AnyOp_T.h @@ -0,0 +1,103 @@ +#ifndef guard_vector_anyop +#define guard_vector_anyop +/** + * @file + * + * @brief CORBA::Any insertion/extraction for std::vector + * + * $Id$ + * + * @author Jeff Parsons + */ + +#include + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /// Copying + template + void + insert_value_vector ( + CORBA::Any &, + const std::vector &) + { + } + + /// Non-copying + template + void + insert_value_vector ( + CORBA::Any &, + std::vector *) + { + } + + template + bool + extract_value_vector ( + const CORBA::Any &, + std::vector &) + { + return true; + } + + /// Copying + template + void + insert_objref_vector ( + CORBA::Any &, + const std::vector &) + { + } + + /// Non-copying + template + void + insert_objref_vector ( + CORBA::Any &, + std::vector *) + { + } + + template + bool + extract_objref_vector ( + const CORBA::Any &, + std::vector &) + { + return true; + } + + /// Copying + template + void + insert_array_vector ( + CORBA::Any &, + const std::vector &) + { + } + + /// Non-copying + template + void + insert_array_vector ( + CORBA::Any &, + std::vector *) + { + } + + template + bool + extract_array_vector ( + const CORBA::Any &, + std::vector &) + { + return true; + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif // guard_vector_anyop diff --git a/TAO/tao/Array_VarOut_T.h b/TAO/tao/Array_VarOut_T.h index e638ee402f6..d1b386ce72b 100644 --- a/TAO/tao/Array_VarOut_T.h +++ b/TAO/tao/Array_VarOut_T.h @@ -51,6 +51,7 @@ class TAO_Array_Forany_T public: typedef T _array_type; typedef T_slice _slice_type; + typedef TAG _tag_type; TAO_Array_Forany_T (void); TAO_Array_Forany_T (_slice_type *, CORBA::Boolean nocopy = false); diff --git a/TAO/tao/Basic_Arguments.h b/TAO/tao/Basic_Arguments.h index 28465bfda85..175754ed15e 100644 --- a/TAO/tao/Basic_Arguments.h +++ b/TAO/tao/Basic_Arguments.h @@ -114,6 +114,16 @@ namespace TAO TAO::Any_Insert_Policy_AnyTypeCode_Adapter> { }; + + template<> + class TAO_Export Arg_Traits + : public + Basic_Arg_Traits_T < + std::string, + TAO::Any_Insert_Policy_Stream + > + { + }; } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/CDR.h b/TAO/tao/CDR.h index 5b97e998e02..a0228ac2e03 100644 --- a/TAO/tao/CDR.h +++ b/TAO/tao/CDR.h @@ -62,6 +62,8 @@ #include "ace/Hash_Map_Manager_T.h" #include "ace/Null_Mutex.h" +#include + TAO_BEGIN_VERSIONED_NAMESPACE_DECL class TAO_ORB_Core; @@ -489,6 +491,8 @@ TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, ACE_OutputCDR::from_string x); TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, ACE_OutputCDR::from_wstring x); +TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, + const std::string &x); // CDR input operators for CORBA types @@ -518,6 +522,8 @@ TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, ACE_InputCDR::to_string x); TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, ACE_InputCDR::to_wstring x); +TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, + std::string &x); TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/CDR.inl b/TAO/tao/CDR.inl index 7a4943589fc..204f247c996 100644 --- a/TAO/tao/CDR.inl +++ b/TAO/tao/CDR.inl @@ -455,6 +455,12 @@ ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, return os << x.val_; } +ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, + const std::string &x) +{ + return os << x.c_str (); +} + // **************************************************************** ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, @@ -549,5 +555,14 @@ ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, return marshal_flag; } +ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, + std::string &x) +{ + char *buf = 0; + CORBA::Boolean const marshal_flag = is >> buf; + x.assign (buf); + ACE::strdelete (buf); + return marshal_flag; +} TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Fixed_Size_Argument_T.h b/TAO/tao/Fixed_Size_Argument_T.h index 7ac0ddb249c..82d68da9817 100644 --- a/TAO/tao/Fixed_Size_Argument_T.h +++ b/TAO/tao/Fixed_Size_Argument_T.h @@ -10,7 +10,6 @@ */ //============================================================================= - #ifndef TAO_FIXED_SIZE_ARGUMENT_T_H #define TAO_FIXED_SIZE_ARGUMENT_T_H @@ -113,7 +112,6 @@ namespace TAO S & arg (void); private: - S & x_; }; diff --git a/TAO/tao/PortableServer/Basic_SArguments.h b/TAO/tao/PortableServer/Basic_SArguments.h index eaedf834235..5398b0c2e90 100644 --- a/TAO/tao/PortableServer/Basic_SArguments.h +++ b/TAO/tao/PortableServer/Basic_SArguments.h @@ -106,6 +106,13 @@ namespace TAO { }; + template<> + class TAO_PortableServer_Export SArg_Traits + : public Basic_SArg_Traits_T< + std::string, + TAO::Any_Insert_Policy_Stream > + { + }; } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/PortableServer/Vector_SArgument_T.cpp b/TAO/tao/PortableServer/Vector_SArgument_T.cpp new file mode 100644 index 00000000000..bcc2053fe83 --- /dev/null +++ b/TAO/tao/PortableServer/Vector_SArgument_T.cpp @@ -0,0 +1,117 @@ +// $Id$ + +#ifndef TAO_VECTOR_SARGUMENT_T_CPP +#define TAO_VECTOR_SARGUMENT_T_CPP + +#include "tao/PortableServer/Vector_SArgument_T.h" + +#if !defined (__ACE_INLINE__) +#include "tao/PortableServer/Vector_SArgument_T.inl" +#endif /* __ACE_INLINE__ */ + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template +CORBA::Boolean +TAO::In_Vector_SArgument_T::demarshal (TAO_InputCDR &cdr) +{ + return cdr >> this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::In_Vector_SArgument_T::interceptor_value ( + CORBA::Any *any + ) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +// =========================================================== + +template +CORBA::Boolean +TAO::Inout_Vector_SArgument_T::marshal (TAO_OutputCDR &cdr) +{ + return cdr << this->x_; +} + +template +CORBA::Boolean +TAO::Inout_Vector_SArgument_T::demarshal (TAO_InputCDR & cdr) +{ + return cdr >> this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::Inout_Vector_SArgument_T::interceptor_value ( + CORBA::Any *any + ) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +// ============================================================== + +template +CORBA::Boolean +TAO::Out_Vector_SArgument_T::marshal (TAO_OutputCDR &cdr) +{ + return cdr << this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::Out_Vector_SArgument_T::interceptor_value ( + CORBA::Any *any) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +// ============================================================ + +template +CORBA::Boolean +TAO::Ret_Vector_SArgument_T::marshal (TAO_OutputCDR &cdr) +{ + return cdr << this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::Ret_Vector_SArgument_T::interceptor_value ( + CORBA::Any *any) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_VECTOR_SARGUMENT_T_CPP */ diff --git a/TAO/tao/PortableServer/Vector_SArgument_T.h b/TAO/tao/PortableServer/Vector_SArgument_T.h new file mode 100644 index 00000000000..cf9cabba5d3 --- /dev/null +++ b/TAO/tao/PortableServer/Vector_SArgument_T.h @@ -0,0 +1,170 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Vector_SArgument_T.h + * + * $Id$ + * + * @author Jeff Parsons + */ +//============================================================================= + +#ifndef TAO_VECTOR_SARGUMENT_T_H +#define TAO_VECTOR_SARGUMENT_T_H + +#include /**/ "ace/pre.h" +#include "tao/Argument.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class In_Vector_SArgument_T + * + * @brief Template class for IN skeleton argument of + * unbounded sequence IDL types. + * + */ + template + class In_Vector_SArgument_T : public InArgument + { + public: + virtual CORBA::Boolean demarshal (TAO_InputCDR &); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S const & arg (void) const; + + private: + S x_; + }; + + /** + * @class Inout_Vector_SArgument_T + * + * @brief Template class for INOUT skeleton arg of + * unbounded sequence IDL types. + * + */ + template + class Inout_Vector_SArgument_T : public InoutArgument + { + public: + Inout_Vector_SArgument_T (void); + + virtual CORBA::Boolean marshal (TAO_OutputCDR &cdr); + virtual CORBA::Boolean demarshal (TAO_InputCDR &); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S & arg (void); + + private: + S x_; + }; + + /** + * @class Out_Vector_SArgument_T + * + * @brief Template class for OUT skeleton argument of + * unbounded sequence IDL types. + * + */ + template + class Out_Vector_SArgument_T : public OutArgument + { + public: + Out_Vector_SArgument_T (void); + + virtual CORBA::Boolean marshal (TAO_OutputCDR &cdr); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S & arg (void); + + private: + S x_; + }; + + /** + * @class Ret_Vector_SArgument_T + * + * @brief Template class for return skeleton value of + * unbounded sequence IDL types. + * + */ + template + class Ret_Vector_SArgument_T : public RetArgument + { + public: + Ret_Vector_SArgument_T (void); + + virtual CORBA::Boolean marshal (TAO_OutputCDR &cdr); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S & arg (void); + + private: + S x_; + }; + + /** + * @struct Vector_SArg_Traits_T + * + * @brief Template class for skeleton argument traits of + * sequence IDL types, when the STL mapping is used by + * the IDL compiler. The ret_type and out_type typedefs + * are different from Vector_SArg_Traits_T. + * + */ + template + struct Vector_SArg_Traits_T + { + typedef T ret_type; + typedef const T & in_type; + typedef T & inout_type; + typedef typename T & out_type; + + typedef In_Vector_SArgument_T in_arg_val; + typedef Inout_Vector_SArgument_T inout_arg_val; + typedef Out_Vector_SArgument_T out_arg_val; + typedef Ret_Vector_SArgument_T ret_val; + + // Typedefs corresponding to return value of arg() method in both + // the client and server side argument class templates. + typedef in_type in_arg_type; + typedef inout_type inout_arg_type; + typedef ret_type & out_arg_type; + typedef ret_type & ret_arg_type; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "tao/PortableServer/Vector_SArgument_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/PortableServer/Vector_SArgument_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Vector_SArgument_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_VECTOR_SARGUMENT_T_H */ diff --git a/TAO/tao/PortableServer/Vector_SArgument_T.inl b/TAO/tao/PortableServer/Vector_SArgument_T.inl new file mode 100644 index 00000000000..0f0356302fa --- /dev/null +++ b/TAO/tao/PortableServer/Vector_SArgument_T.inl @@ -0,0 +1,67 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template +S const & +TAO::In_Vector_SArgument_T::arg (void) const +{ + return this->x_; +} + +// ========================================================================== + +template +ACE_INLINE +TAO::Inout_Vector_SArgument_T::Inout_Vector_SArgument_T (void) +{ +} + +template +S & +TAO::Inout_Vector_SArgument_T::arg (void) +{ + return this->x_; +} + +// ========================================================================== + +template +ACE_INLINE +TAO::Out_Vector_SArgument_T::Out_Vector_SArgument_T (void) +{ +} + +template +S & +TAO::Out_Vector_SArgument_T::arg (void) +{ + return this->x_; +} + +// ========================================================================== + +template +ACE_INLINE +TAO::Ret_Vector_SArgument_T::Ret_Vector_SArgument_T (void) +{ +} + +template +ACE_INLINE +S & +TAO::Ret_Vector_SArgument_T::arg (void) +{ + return this->x_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Vector_Argument_T.cpp b/TAO/tao/Vector_Argument_T.cpp new file mode 100644 index 00000000000..c2c76c9b80e --- /dev/null +++ b/TAO/tao/Vector_Argument_T.cpp @@ -0,0 +1,149 @@ +// $Id$ + +#ifndef TAO_VECTOR_ARGUMENT_T_CPP +#define TAO_VECTOR_ARGUMENT_T_CPP + +#include "tao/Vector_Argument_T.h" + +#if !defined (__ACE_INLINE__) +#include "tao/Vector_Argument_T.inl" +#endif /* __ACE_INLINE__ */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template +CORBA::Boolean +TAO::In_Vector_Argument_T::marshal (TAO_OutputCDR &cdr) +{ + return cdr << this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::In_Vector_Argument_T::interceptor_value ( + CORBA::Any *any + ) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +template +TAO::In_Vector_Clonable_Argument_T::~In_Vector_Clonable_Argument_T (void) +{ + if (this->is_clone_) + { + S & tmp = const_cast (this->x_); + delete tmp; + } +} + +template +TAO::Argument* +TAO::In_Vector_Clonable_Argument_T::clone (void) +{ + S* clone_x = new S (this->x_); + In_Vector_Clonable_Argument_T* clone_arg + = new In_Vector_Clonable_Argument_T (*clone_x); + clone_arg->is_clone_ = true; + return clone_arg; +} + +// =========================================================== + +template +CORBA::Boolean +TAO::Inout_Vector_Argument_T::marshal ( + TAO_OutputCDR &cdr + ) +{ + return cdr << this->x_; +} + +template +CORBA::Boolean +TAO::Inout_Vector_Argument_T::demarshal ( + TAO_InputCDR & cdr + ) +{ + return cdr >> this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::Inout_Vector_Argument_T::interceptor_value ( + CORBA::Any *any + ) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +// ============================================================== + +template +CORBA::Boolean +TAO::Out_Vector_Argument_T::demarshal ( + TAO_InputCDR & cdr + ) +{ + return cdr >> this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::Out_Vector_Argument_T::interceptor_value ( + CORBA::Any *any + ) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +// ============================================================ + +template +CORBA::Boolean +TAO::Ret_Vector_Argument_T::demarshal ( + TAO_InputCDR & cdr + ) +{ + return cdr >> this->x_; +} + +#if TAO_HAS_INTERCEPTORS == 1 + +template +void +TAO::Ret_Vector_Argument_T::interceptor_value ( + CORBA::Any *any + ) const +{ + Insert_Policy::any_insert (any, this->x_); +} + +#endif /* TAO_HAS_INTERCEPTORS */ + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif /* TAO_VECTOR_ARGUMENT_T_CPP */ diff --git a/TAO/tao/Vector_Argument_T.h b/TAO/tao/Vector_Argument_T.h new file mode 100644 index 00000000000..cf40240a218 --- /dev/null +++ b/TAO/tao/Vector_Argument_T.h @@ -0,0 +1,192 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file Vector_Argument_T.h + * + * $Id$ + * + * @authors Jeff Parsons + */ +//============================================================================= + +#ifndef TAO_VECTOR_ARGUMENT_T_H +#define TAO_VECTOR_ARGUMENT_T_H + +#include /**/ "ace/pre.h" + +#include "tao/Argument.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + /** + * @class In_Vector_Argument_T + * + * @brief Template class for IN stub argument of + * unbounded sequence IDL types. + * + */ + template + class In_Vector_Argument_T : public InArgument + { + public: + In_Vector_Argument_T (S const & x); + + virtual CORBA::Boolean marshal (TAO_OutputCDR &cdr); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S const & arg (void) const; + + protected: + S const & x_; + }; + + /** + * @class In_Vector_Clonable_Argument_T + * + * @brief Template class for IN stub argument of + * unbounded sequence IDL types. + * + */ + template + class In_Vector_Clonable_Argument_T : + public In_Vector_Argument_T + { + public: + In_Vector_Clonable_Argument_T (S const & x); + virtual ~In_Vector_Clonable_Argument_T (void); + + virtual Argument* clone (void); + + private: + bool is_clone_; + }; + + /** + * @class Inout_Vector_Argument_T + * + * @brief Template class for INOUT stub argument of + * unbounded sequence IDL types. + * + */ + template + class Inout_Vector_Argument_T : public InoutArgument + { + public: + Inout_Vector_Argument_T (S & x); + + virtual CORBA::Boolean marshal (TAO_OutputCDR &cdr); + virtual CORBA::Boolean demarshal (TAO_InputCDR &); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S & arg (void); + + private: + S & x_; + }; + + /** + * @class Out_Vector_Argument_T + * + * @brief Template class for OUT stub argument of + * unbounded sequence IDL types. + * + */ + template + class Out_Vector_Argument_T : public OutArgument + { + public: + Out_Vector_Argument_T (S & x); + + virtual CORBA::Boolean demarshal (TAO_InputCDR &); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S & arg (void); + + private: + S & x_; + }; + + /** + * @class Ret_Vector_Argument_T + * + * @brief Template class for return stub value of fixed size IDL types. + * + */ + template + class Ret_Vector_Argument_T : public RetArgument + { + public: + Ret_Vector_Argument_T (void); + + virtual CORBA::Boolean demarshal (TAO_InputCDR &); +#if TAO_HAS_INTERCEPTORS == 1 + virtual void interceptor_value (CORBA::Any *any) const; +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + S & arg (void); + + S excp (void); + S retn (void); + + protected: + S x_; + }; + + /** + * @struct Vector_Arg_Traits_T + * + * @brief Template class for stub argument traits of + * sequence IDL types, when the STL mapping is used by + * the IDL compiler. The ret_type and out_type typedefs + * are different from Vector_Arg_Traits_T. + * + */ + template + struct Vector_Arg_Traits_T + { + typedef T ret_type; + typedef T const & in_type; + typedef T & inout_type; + typedef typename T & out_type; + + typedef In_Vector_Argument_T in_arg_val; + typedef In_Vector_Clonable_Argument_T + in_clonable_arg_val; + typedef Inout_Vector_Argument_T inout_arg_val; + typedef Out_Vector_Argument_T out_arg_val; + typedef Ret_Vector_Argument_T ret_val; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "tao/Vector_Argument_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "tao/Vector_Argument_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Vector_Argument_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_VECTOR_ARGUMENT_T_H */ diff --git a/TAO/tao/Vector_Argument_T.inl b/TAO/tao/Vector_Argument_T.inl new file mode 100644 index 00000000000..ad052d1a0db --- /dev/null +++ b/TAO/tao/Vector_Argument_T.inl @@ -0,0 +1,107 @@ +// -*- C++ -*- +// +// $Id$ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +template +ACE_INLINE +TAO::In_Vector_Argument_T::In_Vector_Argument_T (S const & x) + : x_ (x) +{ +} + +template +ACE_INLINE +S const & +TAO::In_Vector_Argument_T::arg (void) const +{ + return this->x_; +} + +template +ACE_INLINE +TAO::In_Vector_Clonable_Argument_T::In_Vector_Clonable_Argument_T (S const & x) + : In_Vector_Argument_T (x), + is_clone_ (false) +{} + +// ========================================================================== + +template +ACE_INLINE +TAO::Inout_Vector_Argument_T::Inout_Vector_Argument_T (S & x) + : x_ (x) +{ +} + +template +ACE_INLINE +S & +TAO::Inout_Vector_Argument_T::arg (void) +{ + return this->x_; +} + +// ========================================================================== + +template +ACE_INLINE +TAO::Out_Vector_Argument_T::Out_Vector_Argument_T ( + S & x + ) + : x_ (x) +{} + +template +ACE_INLINE +S & +TAO::Out_Vector_Argument_T::arg (void) +{ + return this->x_; +} + +// ========================================================================== + +template +ACE_INLINE +TAO::Ret_Vector_Argument_T::Ret_Vector_Argument_T (void) +{ +} + +template +ACE_INLINE +S & +TAO::Ret_Vector_Argument_T::arg (void) +{ + return this->x_; +} + +template +ACE_INLINE +S +TAO::Ret_Vector_Argument_T::excp (void) +{ + return this->x_; +} + +template +ACE_INLINE +S +TAO::Ret_Vector_Argument_T::retn (void) +{ + return this->x_; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Vector_CDR_T.h b/TAO/tao/Vector_CDR_T.h new file mode 100644 index 00000000000..3a3b84adcd9 --- /dev/null +++ b/TAO/tao/Vector_CDR_T.h @@ -0,0 +1,223 @@ +#ifndef guard_vector_cdr +#define guard_vector_cdr +/** + * @file + * + * @brief CDR (de)marshaling for std::vector + * + * $Id$ + * + * @author Jeff Parsons + */ + +#include + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + template + bool + marshal_value_vector ( + TAO_OutputCDR &strm, + const std::vector &source) + { + ::CORBA::ULong const length = source.size (); + + if (! (strm << length)) + { + return false; + } + + for (std::vector::const_iterator i = source.begin (); + i != source.end (); + ++i) + { + if (! (strm << *i)) + { + return false; + } + } + + return true; + } + + template + bool + demarshal_value_vector ( + TAO_InputCDR &strm, + std::vector &target) + { + ::CORBA::ULong new_length = 0; + + if (! (strm >> new_length)) + { + return false; + } + + if (new_length > strm.length ()) + { + return false; + } + + std::vector tmp; + tmp.reserve (new_length); + T tmp_elem; + + for ( ::CORBA::ULong i = 0; i < new_length; ++i) + { + if (! (strm >> tmp_elem)) + { + return false; + } + + tmp[i] = tmp_elem; + } + + tmp.swap(target); + return true; + } + + template + bool + marshal_objref_vector ( + TAO_OutputCDR &strm, + const std::vector &source) + { + ::CORBA::ULong const length = source.size (); + + if (! (strm << length)) + { + return false; + } + + for (std::vector::const_iterator i = source.begin (); + i != source.end (); + ++i) + { + if (! (TAO::Objref_Traits::marshal (*i, strm))) + { + return false; + } + } + + return true; + } + + template + bool + demarshal_objref_vector ( + TAO_InputCDR &strm, + std::vector &target) + { + ::CORBA::ULong new_length = 0; + + if (! (strm >> new_length)) + { + return false; + } + + if (new_length > strm.length ()) + { + return false; + } + + std::vector tmp; + tmp.reserve (new_length); + T::_ptr_type tmp_elem = T::_nil (); + + for ( ::CORBA::ULong i = 0; i < new_length; ++i) + { + if (! (strm >> tmp_elem)) + { + return false; + } + + tmp[i] = tmp_elem; + } + + tmp.swap (target); + return true; + } + + template + bool + marshal_array_vector ( + TAO_OutputCDR &strm, + const std::vector &source) + { + typedef TAO_FixedArray_Var_T var_type; + ::CORBA::ULong const length = source.size (); + + if (! (strm << length)) + { + return false; + } + + for (std::vector i = source.begin (); + i != source.end (); + ++i) + { + var_type tmp_array = + TAO::Array_Traits::dup (*i); + T_forany const tmp (tmp_array.inout ()); + + if (! (strm << tmp)) + { + return false; + } + } + + return true; + } + + template + bool + demarshal_array_vector ( + TAO_InputCDR &strm, + const std::vector &source) + { + typedef TAO::Array_Traits array_traits; + ::CORBA::ULong new_length = 0; + + if (! (strm >> new_length)) + { + return false; + } + + if (new_length > strm.length ()) + { + return false; + } + + std::vector tmp_vec; + tmp_vec.reserve (new_length); + + for ( ::CORBA::ULong i = 0; i < new_length; ++i) + { + T_forany tmp_array (array_traits::alloc ()); + bool const _tao_marshal_flag = (strm >> tmp_array); + + if (_tao_marshal_flag) + { + array_traits::copy (tmp_vec[i], tmp_array.in ()); + } + + array_traits::free (tmp_array.inout ()); + + if (!_tao_marshal_flag) + { + return false; + } + } + + tmp_vec.swap (target); + return true; + } +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#endif // guard_vector_cdr diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index 6579659f6bb..57649862ba4 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -629,6 +629,8 @@ project(TAO) : acelib, install, tao_output, taodefaults, pidl, extra_core, taoid varbase.h VarOut_T.h Var_Size_Argument_T.h + Vector_Argument_T.h + Vector_CDR_T.h Version.h Versioned_Namespace.h Wait_On_Leader_Follower.h diff --git a/TAO/tests/AMI/ami_test.idl b/TAO/tests/AMI/ami_test.idl index 135ec21abd2..04005e9531f 100644 --- a/TAO/tests/AMI/ami_test.idl +++ b/TAO/tests/AMI/ami_test.idl @@ -33,4 +33,9 @@ module A void inout_arg_test (inout string str); }; + + interface Test_Child : AMI_Test + { + void child_op (); + }; }; diff --git a/TAO/tests/Alt_Mapping/README b/TAO/tests/Alt_Mapping/README new file mode 100644 index 00000000000..a1aae3b61a1 --- /dev/null +++ b/TAO/tests/Alt_Mapping/README @@ -0,0 +1,77 @@ +// $Id$ + +// ============================================================================ +// This test covers the use of std::string as an alternate C++ mapping for +// CORBA strings, and the use of std::vector as an alternate C++ mapping +// for sequences of type T. The current version of the test uses a struct +// containing several simple date types - more types of sequences will be +// added in the future. +// ============================================================================ + +This directory contains an application that tests all the parameter +passing conventions in CORBA for the supported OMG IDL data types. + +Type "make" to make the application. The server executable is called +"server" and the client executable is called "client". + +You should have the TAO IDL compiler and the TAO library installed +before using this application. + +The -GA options has been added the IDL compiler command line for this +test. This option moves the generation of implementations for type +codes and Any insertion/extraction operators to a separate file with +the extension *A.cpp. Adding this option tests that it is handled +correctly for all the various IDL types used in this test. + +To run the server, type + + server [arguments to ORB_init] [-d] [-o ] + + arguments to ORB_init start with the letters -ORB. Please + see TAO documentattion on all the supported arguments + + -d for debugging. + -o for outputting the servant IOR to a file. + +To run the client, type + + client [arguments to ORB_init] [options for this application] + + Supported options are: + + [-d] debugging + [-n loopcount] number of times to run the test + [-f servant-IOR-file] reads the servant-IOR from the + specified file. + [-k Param_Test-obj-ref-key] object key of Param_Test object + [-i invocation (sii/dii)] default is static invocation + interface. To use DII, type + -i dii + [-t data type] + Data types supported in this version are: + + ubstring for unbounded string + ub_struct_seq for sequences of structs + + + There are 2 options of giving the IOR to the client: + + 1. Using the -f option to read the IOR from a file. + + 2. Using the -k option to read the IOR from the + command line. + +run_test.pl: +----------- + There is a perl script in this directory named run_test.pl to + test all the types. It starts the server first and then runs + the client with the different data type parameters. The + arguments it takes are: + + -n num -- runs the client num times (default is 5) + -d -- runs each in debug mode + -onewin -- keeps all tests in one window on NT + -h -- prints this information + -t type -- runs only one type of param test + -i (dii|sii) -- Changes the type of invocation (default is sii) + (as of 5/3/10 DII is not yet supported) diff --git a/TAO/tests/Alt_Mapping/alt_mapping.idl b/TAO/tests/Alt_Mapping/alt_mapping.idl new file mode 100644 index 00000000000..bd70a846da0 --- /dev/null +++ b/TAO/tests/Alt_Mapping/alt_mapping.idl @@ -0,0 +1,30 @@ +// $Id$ + +interface Alt_Mapping +{ + string test_unbounded_string (in string s1, + inout string s2, + out string s3); + + struct Fixed_Struct + { + long l; + char c; + short s; + octet o; + float f; + boolean b; + double d; + }; + + + typedef sequence StructSeq; + StructSeq test_struct_sequence (in StructSeq s1, + inout StructSeq s2, + out StructSeq s3); + + void shutdown (); + // Shutdown the server: this is useful to check for memory leaks, + // performance results and in general to verify that orderly + // shutdown is possible. +}; diff --git a/TAO/tests/Alt_Mapping/alt_mapping.mpc b/TAO/tests/Alt_Mapping/alt_mapping.mpc new file mode 100644 index 00000000000..302f66953ee --- /dev/null +++ b/TAO/tests/Alt_Mapping/alt_mapping.mpc @@ -0,0 +1,70 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + IDL_Files { + idlflags -= -Sa -St + idlflags += -Gstl + alt_mapping.idl + } + custom_only = 1 +} + +project(*Server): taoserver, codeset, avoids_minimum_corba, avoids_corba_e_compact, avoids_corba_e_micro { + after += *idl + + IDL_Files { + } + + Source_Files { + alt_mappingS.cpp + alt_mappingC.cpp + alt_mapping_i.cpp + server.cpp + } + + Header_Files { + alt_mappingS.h + alt_mappingC.h + alt_mapping_i.h + } + + Inline_Files { + alt_mappingS.inl + alt_mappingC.inl + } +} + +project(*Client): taoserver, codeset, avoids_minimum_corba, avoids_ace_for_tao { + exename = client + after += *idl + + IDL_Files { + } + + Source_Files { + alt_mappingC.cpp + client.cpp + driver.cpp + helper.cpp + options.cpp + results.cpp + ub_string.cpp + ub_struct_seq.cpp + } + + Header_Files { + alt_mappingC.h + driver.h + helper.h + options.h + results.h + ub_string.h + ub_struct_seq.h + } + + Inline_Files { + alt_mappingC.inl + } +} + diff --git a/TAO/tests/Alt_Mapping/alt_mapping_i.cpp b/TAO/tests/Alt_Mapping/alt_mapping_i.cpp new file mode 100644 index 00000000000..f9392cbfda5 --- /dev/null +++ b/TAO/tests/Alt_Mapping/alt_mapping_i.cpp @@ -0,0 +1,63 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// alt_mapping_i.cpp +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "alt_mapping_i.h" + +#include "tao/debug.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_wchar.h" +#include "ace/OS_NS_string.h" + +Alt_Mapping_i::Alt_Mapping_i (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +Alt_Mapping_i::~Alt_Mapping_i (void) +{ +} + +// test unbounded strings. For return and out types, we return duplicates of +// the in string. For the inout, we append the same string to itself and send +// it back +std::string +Alt_Mapping_i::test_unbounded_string (const std::string s1, + std::string &s2, + std::string &s3) +{ + std::string retstr = s1; + s3 = s1; + s2 = s1 + s1; + return retstr; +} + +// test for struct sequences +Alt_Mapping::StructSeq +Alt_Mapping_i::test_struct_sequence ( + const Alt_Mapping::StructSeq & s1, + Alt_Mapping::StructSeq & s2, + Alt_Mapping::StructSeq & s3) +{ + // We copy the "in" sequences into all the inout, out and return sequences. + + // now copy all elements of s1 into the others using the assignment operator + s2 = s1; + s3 = s1; + return s1; +} + +void +Alt_Mapping_i::shutdown (void) +{ + this->orb_->shutdown (); +} + diff --git a/TAO/tests/Alt_Mapping/alt_mapping_i.h b/TAO/tests/Alt_Mapping/alt_mapping_i.h new file mode 100644 index 00000000000..5360f329137 --- /dev/null +++ b/TAO/tests/Alt_Mapping/alt_mapping_i.h @@ -0,0 +1,45 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// alt_mapping_i.h +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#ifndef ALT_MAPPING_I_H +#define ALT_MAPPING_I_H + +#include "alt_mappingS.h" + +class Alt_Mapping_i : public POA_Alt_Mapping +{ + // = TITLE + // Alt_Mapping_i + // = DESCRIPTION + // Implementation of the Alt_Mapping_i test suite. +public: + Alt_Mapping_i (CORBA::ORB_ptr orb); + + ~Alt_Mapping_i (void); + + virtual std::string + test_unbounded_string (const std::string s1, + std::string &s2, + std::string &s3); + + virtual Alt_Mapping::StructSeq test_struct_sequence ( + const Alt_Mapping::StructSeq & s1, + Alt_Mapping::StructSeq & s2, + Alt_Mapping::StructSeq & s3); + + void shutdown (void); + +private: + CORBA::ORB_var orb_; +}; + +#endif /* ALT_MAPPING_I_H */ diff --git a/TAO/tests/Alt_Mapping/client.cpp b/TAO/tests/Alt_Mapping/client.cpp new file mode 100644 index 00000000000..ff7cfae34e7 --- /dev/null +++ b/TAO/tests/Alt_Mapping/client.cpp @@ -0,0 +1,152 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// client.cpp +// +// = DESCRIPTION +// This file contains the implementation of the client-side of the +// Alt_Mapping application. +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#ifndef CLIENT_CPP +#define CLIENT_CPP + +#include "options.h" +#include "results.h" +#include "client.h" + +// Constructor.p +template +Alt_Mapping_Client::Alt_Mapping_Client (CORBA::ORB_ptr orb, + Alt_Mapping_ptr objref, + T *t) + : orb_ (orb), + alt_mapping_test_ (objref), + test_object_ (t) +{ +} + +// destructor +template +Alt_Mapping_Client::~Alt_Mapping_Client (void) +{ + delete this->test_object_; +} + +// All the individual tests. +template int +Alt_Mapping_Client::run_sii_test (void) +{ + CORBA::ULong i = 0; // loop index + Options *opt = OPTIONS::instance (); // get the options + const char *opname = this->test_object_->opname (); // operation + + if (opt->debug ()) + ACE_DEBUG ((LM_DEBUG, + "********** %s SII *********\n", + opname)); + + // Initialize call count and error count. + this->results_.call_count (0); + this->results_.error_count (0); + this->results_.iterations (opt->loop_count ()); + + // Declare the Env + // Initialize parameters for the test. + int check = this->test_object_->init_parameters (this->alt_mapping_test_); + + if (check == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) client.cpp - run_sii_test:" + "init_parameters failed for opname - %s", + opname), + -1); + } + + + // Make the calls in a loop. + for (i = 0; i < opt->loop_count (); i++) + { + try + { + this->results_.call_count (this->results_.call_count () + 1); + if (opt->debug ()) + { + ACE_DEBUG ((LM_DEBUG, "\n****** Before call values *****\n")); + this->test_object_->print_values (); + } + + // start the timing + this->results_.start_timer (); + + // make the call + this->test_object_->run_sii_test (this->alt_mapping_test_); + + // stop the timer. + this->results_.stop_timer (); + + // now check if the values returned are as expected + if (opt->debug ()) + { + ACE_DEBUG ((LM_DEBUG, "\n****** After call values *****\n")); + this->test_object_->print_values (); + } + } + catch (const CORBA::Exception& ex) + { + + this->results_.error_count (this->results_.error_count () + 1); + ex._tao_print_exception (opname); + ACE_ERROR ((LM_ERROR, + "(%N:%l) client.cpp - run_sii_test:" + "run_sii_test exception in iteration %d", + i)); + goto loop_around; + + } + + if (!this->test_object_->check_validity ()) + { + this->results_.error_count (this->results_.error_count () + 1); + ACE_ERROR ((LM_ERROR, + "(%N:%l) client.cpp - run_sii_test: " + "Invalid results in iteration %d\n", + i)); + continue; + } + // reset parameters for the test. + if (this->test_object_->reset_parameters () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) client.cpp - run_sii_test:" + "init_parameters failed for opname - %s", + opname), -1); + loop_around: continue; + } + + // print statistics + this->results_.print_stats (); + + if (this->results_.error_count () != 0) + { + ACE_DEBUG ((LM_DEBUG, + "********** Error running %s SII *********\n", + opname)); + } + else if (opt->debug ()) + { + ACE_DEBUG ((LM_DEBUG, + "********** Finished running %s SII *********\n", + opname)); + } + + return this->results_.error_count ()? -1 : 0; +} + +#endif /* CLIENT_CPP */ diff --git a/TAO/tests/Alt_Mapping/client.h b/TAO/tests/Alt_Mapping/client.h new file mode 100644 index 00000000000..acdb2a18612 --- /dev/null +++ b/TAO/tests/Alt_Mapping/client.h @@ -0,0 +1,74 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Alt_Mapping_Test +// +// = FILENAME +// client.h +// +// = DESCRIPTION +// Header file for the Alt_Mapping_Test client application. +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef ALT_MAPPING_CLIENT_H +#define ALT_MAPPING_CLIENT_H + +#include "tao/Codeset/Codeset.h" +#include "alt_mappingC.h" +#include "results.h" + +template +class Alt_Mapping_Client +{ + // = TITLE + // Alt_Mapping_Client + // + // = DESCRIPTION + // This class declares an interface to run the example client for + // Alt_Mapping CORBA server. All the complexity for initializing + // the client is hidden in the class. Just the run () interface + // is needed. The template class does the specific work of making + // the request of the desired data type +public: + typedef T TEST_OBJECT; + + // = Constructor and destructor. + Alt_Mapping_Client (CORBA::ORB_ptr orb, + Alt_Mapping_ptr objref, + T *); + + ~Alt_Mapping_Client (void); + + int run_sii_test (void); + // run the SII test + +private: + CORBA::ORB_ptr orb_; + // underlying ORB + + Alt_Mapping_ptr alt_mapping_test_; + // alt mapping object reference + + TEST_OBJECT *test_object_; + // object doing the actual work + + Results results_; + // results +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "client.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("client.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ALT_MAPPING_CLIENT_H */ diff --git a/TAO/tests/Alt_Mapping/driver.cpp b/TAO/tests/Alt_Mapping/driver.cpp new file mode 100644 index 00000000000..1a5c6380d8c --- /dev/null +++ b/TAO/tests/Alt_Mapping/driver.cpp @@ -0,0 +1,171 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// driver.cpp +// +// = DESCRIPTION +// Driver program +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#include "client.h" +#include "driver.h" +#include "results.h" +#include "tests.h" +#include "ace/Get_Opt.h" + +// This function runs the test (main program) +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + // get an instance of the driver object + Driver drv; + + // initialize the driver + if (drv.init (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) driver.cpp - " + "Driver initialization failed\n"), + -1); + + // run various tests + if (drv.run () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) driver.cpp - " + "tests failed\n"), + -1); + return 0; +} + +// constructor +Driver::Driver (void) +{ +} + +Driver::~Driver (void) +{ +} + +// initialize the driver +int +Driver::init (int argc, ACE_TCHAR **argv) +{ + // environment to track exceptions + + // retrieve the instance of Options + Options *opt = OPTIONS::instance (); + + char exception_string[256]; + + try + { + ACE_OS::strcpy (exception_string, "ORB Initialization"); + + // Retrieve the underlying ORB + this->orb_ = CORBA::ORB_init (argc, + argv, + "internet"); + + // Parse command line and verify parameters. + if (opt->parse_args (argc, argv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) driver.cpp - " + "parse_args failed\n"), + -1); + // Retrieve a Param_Test object reference + ACE_OS::strcpy (exception_string,"ORB::string_to_object() failed."); + + CORBA::Object_var temp = + this->orb_->string_to_object (opt->param_test_ior ()); + + + if (CORBA::is_nil (temp.in())) + ACE_ERROR_RETURN ((LM_ERROR, + "ORB::string_to_object() returned null object for IOR <%s>\n", + opt->param_test_ior ()), + -1); + + // Get the object reference + ACE_OS::strcpy (exception_string,"Param_Test::_narrow () failed."); + + this->objref_ = Alt_Mapping::_narrow (temp.in()); + + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception (exception_string); + return -1; + } + + return 0; +} + +int +Driver::run (void) +{ + // serves as a factory of Param_Client objects. It is also responsible to + // start the test + + Options *opt = OPTIONS::instance (); // get the options object + int retstatus = -1; + + switch (opt->test_type ()) + { + case Options::TEST_UB_STRING: + { + Alt_Mapping_Client *client = new + Alt_Mapping_Client (this->orb_.in (), + this->objref_.in(), + new Test_Unbounded_String); + retstatus = client->run_sii_test (); + + delete client; + } + break; + case Options::TEST_UB_STRUCT_SEQUENCE: + { + Alt_Mapping_Client *client = new + Alt_Mapping_Client ( + this->orb_.in (), + this->objref_.in(), + new Test_Unbounded_Struct_Sequence); + + retstatus = client->run_sii_test (); + + delete client; + + Alt_Mapping_Client *client2 = new + Alt_Mapping_Client + (this->orb_.in (), + this->objref_.in(), + new Test_Unbounded_Struct_Sequence); + + retstatus = client2->run_sii_test (); + + delete client2; + } + break; + default: + break; + } + + // Get in a new environment variable + try + { + if (opt->shutdown ()) + { + this->objref_->shutdown (); + } + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("during shutdown"); + } + + return retstatus; +} diff --git a/TAO/tests/Alt_Mapping/driver.h b/TAO/tests/Alt_Mapping/driver.h new file mode 100644 index 00000000000..e3f488c1181 --- /dev/null +++ b/TAO/tests/Alt_Mapping/driver.h @@ -0,0 +1,52 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// driver.h +// +// = DESCRIPTION +// Header file for the driver program. The driver is a singleton. +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef DRIVER_H +#define DRIVER_H + +#include "options.h" +#include "Alt_MappingC.h" + +class Driver +{ + // = TITLE + // Driver + // + // = DESCRIPTION + // Driver program for the client +public: + // = Constructor and destructor. + Driver (void); + ~Driver (void); + + int init (int argc, ACE_TCHAR **argv); + // Initialize the driver object + + int run (void); + // Execute client example code. + +private: + CORBA::ORB_var orb_; + // underlying ORB (we do not own it) + + Alt_Mapping_var objref_; + // object reference (we do not own it) +}; + +#endif /* !defined */ diff --git a/TAO/tests/Alt_Mapping/helper.cpp b/TAO/tests/Alt_Mapping/helper.cpp new file mode 100644 index 00000000000..26f38b4ce3a --- /dev/null +++ b/TAO/tests/Alt_Mapping/helper.cpp @@ -0,0 +1,112 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// helper.cpp +// +// = DESCRIPTION +// Defines a helper class that can generate values for the parameters used +// for the Alt_Mapping example +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#include "helper.h" +#include "ace/OS_NS_ctype.h" + +const CORBA::ULong TEST_BUFSIZE = 128; + +Generator::Generator (void) +{ +} + +Generator::~Generator (void) +{ +} + +CORBA::Short +Generator::gen_short (void) +{ + return (CORBA::Short) (ACE_OS::rand () % TEST_BUFSIZE); +} + +CORBA::Long +Generator::gen_long (void) +{ + return ::ACE_OS::rand () % TEST_BUFSIZE; +} + +char * +Generator::gen_string (void) +{ + return gen_string (TEST_BUFSIZE); +} + +char * +Generator::gen_string (int max_length) +{ + CORBA::ULong len = (CORBA::ULong) (::ACE_OS::rand () % max_length); + char *buf = CORBA::string_alloc (len); + CORBA::ULong i = 0; + + while (i < len) + { + int c = ACE_OS::rand () % 128; + if (ACE_OS::ace_isprint (c) && !ACE_OS::ace_isspace (c)) + { + buf [i] = c; + i++; + } + } + + buf[i] = 0; + return buf; +} + +CORBA::WChar * +Generator::gen_wstring (void) +{ + return gen_wstring (TEST_BUFSIZE); +} + +CORBA::WChar * +Generator::gen_wstring (int max_length) +{ + CORBA::ULong len = (CORBA::ULong) (::ACE_OS::rand () % max_length); + CORBA::WChar *buf = CORBA::wstring_alloc (len); + CORBA::ULong i = 0; + CORBA::WChar limit = + ACE_OutputCDR::wchar_maxbytes() == 1 ? ACE_OCTET_MAX : ACE_WCHAR_MAX; + while (i < len) + { + CORBA::WChar wc = ACE_OS::rand () % limit; + if (wc) + { + buf[i] = wc; + i++; + } + } + + buf[i] = 0; + return buf; +} + +const Alt_Mapping::Fixed_Struct +Generator::gen_fixed_struct (void) +{ + this->fixed_struct_.l = ACE_OS::rand (); + this->fixed_struct_.c = ACE_OS::rand () % 128; + this->fixed_struct_.s = (CORBA::Short) ACE_OS::rand (); + this->fixed_struct_.o = ACE_OS::rand () % 128; + this->fixed_struct_.f = (CORBA::Float) (ACE_OS::rand () * 1.0); + this->fixed_struct_.b = (CORBA::Boolean) (ACE_OS::rand () % 2); + this->fixed_struct_.d = (ACE_OS::rand () * 1.0); + return this->fixed_struct_; +} + +#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) +template ACE_Singleton *ACE_Singleton::singleton_; +#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ diff --git a/TAO/tests/Alt_Mapping/helper.h b/TAO/tests/Alt_Mapping/helper.h new file mode 100644 index 00000000000..3165a376941 --- /dev/null +++ b/TAO/tests/Alt_Mapping/helper.h @@ -0,0 +1,47 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// helper.h +// +// = DESCRIPTION +// Defines a helper class that can generate values for the parameters used +// for the Param_Test example +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef HELPER_H +#define HELPER_H + +#include "alt_mappingC.h" +#include "ace/Singleton.h" + +class Generator +{ +public: + Generator (void); + + ~Generator (void); + + CORBA::Short gen_short (void); + CORBA::Long gen_long (void); + char* gen_string (void); + char* gen_string (int maxlength); + CORBA::WChar* gen_wstring (void); + CORBA::WChar* gen_wstring (int maxlength); + const Alt_Mapping::Fixed_Struct gen_fixed_struct (void); + + private: + Alt_Mapping::Fixed_Struct fixed_struct_; +}; + +typedef ACE_Singleton GENERATOR; + +#endif /* HELPER_H */ diff --git a/TAO/tests/Alt_Mapping/options.cpp b/TAO/tests/Alt_Mapping/options.cpp new file mode 100644 index 00000000000..66055e12438 --- /dev/null +++ b/TAO/tests/Alt_Mapping/options.cpp @@ -0,0 +1,176 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// options.cpp +// +// = DESCRIPTION +// Options for the Param_Test application +// +// = AUTHORS +// Jeff Parsonss +// +// ============================================================================ + +#include "options.h" +#include "tao/debug.h" +#include "ace/Read_Buffer.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_fcntl.h" +#include "ace/Log_Msg.h" + +ACE_RCSID (Param_Test, + options, + "$Id$") + +// Constructor.p +Options::Options (void) + : ior_ (CORBA::string_dup ("file://test.ior")), + test_type_ (Options::NO_TEST), + invoke_type_ (Options::SII), + loop_count_ (1), + debug_ (0), + shutdown_ (0) +{ +} + +Options::~Options (void) +{ +} + +// Parses the command line arguments and returns an error status. + +int +Options::parse_args (int argc, ACE_TCHAR **argv) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xdn:f:i:t:k:")); + int c; + int result; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag + TAO_debug_level++; + this->debug_ = 1; + break; + + case 'x': + this->shutdown_ = 1; + break; + + case 'n': // loop count + this->loop_count_ = (CORBA::ULong) ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'f': + result = this->read_ior (get_opts.opt_arg ()); + + if (result < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to read ior from %s : %p\n", + get_opts.opt_arg ()), + -1); + + break; + + case 'k': + this->ior_ = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ())); + break; + + case 'i': // invocation + if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("dii"))) + this->invoke_type_ = Options::DII; + break; + + case 't': // data type + if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("ubstring"))) + this->test_type_ = Options::TEST_UB_STRING; + else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("ub_struct_seq"))) + this->test_type_ = Options::TEST_UB_STRUCT_SEQUENCE; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-n loopcount]" + " [-f servant-IOR-file]" + " [-i invocation (sii/dii)]" + " [-t data type]" + "\n", + argv [0]), + -1); + } + + // Indicates successful parsing of command line. + return 0; +} + +// Get the factory IOR from the file created by the server. +int +Options::read_ior (ACE_TCHAR *filename) +{ + // Open the file for reading. + ACE_HANDLE f_handle = ACE_OS::open (filename, 0); + + if (f_handle == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for writing: %p\n", + filename), + -1); + ACE_Read_Buffer ior_buffer (f_handle, true); + this->ior_ = ior_buffer.read (); + + if (this->ior_.in () == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to allocate memory to read ior: %p\n"), + -1); + return 0; +} + +char const * +Options::param_test_ior (void) const +{ + return this->ior_.in (); +} + +Options::TEST_TYPE +Options::test_type (void) +{ + return this->test_type_; +} + +Options::INVOKE_TYPE +Options::invoke_type (void) +{ + return this->invoke_type_; +} + +CORBA::ULong +Options::loop_count (void) +{ + return this->loop_count_; +} + +CORBA::Boolean +Options::debug (void) const +{ + return this->debug_; +} + +CORBA::Boolean +Options::shutdown (void) const +{ + return this->shutdown_; +} + +#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) +template ACE_Singleton *ACE_Singleton::singleton_; +#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ diff --git a/TAO/tests/Alt_Mapping/options.h b/TAO/tests/Alt_Mapping/options.h new file mode 100644 index 00000000000..c01ecc8e9a4 --- /dev/null +++ b/TAO/tests/Alt_Mapping/options.h @@ -0,0 +1,101 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// options.h +// +// = DESCRIPTION +// Options for the Param_Test application +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef OPTIONS_H +#define OPTIONS_H + +#include "ace/Singleton.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Basic_Types.h" +#include "tao/CORBA_String.h" +#include "tao/orbconf.h" + +class Options +{ +public: + enum TEST_TYPE + { + NO_TEST, + TEST_UB_STRING, + TEST_UB_STRUCT_SEQUENCE, + }; + + enum INVOKE_TYPE + { + SII, + DII + }; + + Options (void); + // constructor + + ~Options (void); + // destructor + + int parse_args (int argc, ACE_TCHAR **argv); + // Parses the arguments passed on the command line. + + char const * param_test_ior (void) const; + // return the IOR for the servant + + TEST_TYPE test_type (void); + // what test to run + + INVOKE_TYPE invoke_type (void); + // whether to use SII or DII + + CORBA::ULong loop_count (void); + // number of times to run the test + + CORBA::Boolean debug (void) const; + // whether debug option is on or not + + CORBA::Boolean shutdown (void) const; + // If we should request the server to shutdown. + +private: + int read_ior (ACE_TCHAR *filename); + // Function to read the servant IOR from a file. + + CORBA::String_var ior_; + // IOR for the servant + + TEST_TYPE test_type_; + // what test to run + + INVOKE_TYPE invoke_type_; + // whether SII or DII + + CORBA::ULong loop_count_; + // Number of times to do the "test_*" operations. + + CORBA::Boolean debug_; + // debugging output values + + CORBA::Boolean shutdown_; + // server shutdown flag. +}; + +typedef ACE_Singleton OPTIONS; + +#endif /* OPTIONS_H */ diff --git a/TAO/tests/Alt_Mapping/results.cpp b/TAO/tests/Alt_Mapping/results.cpp new file mode 100644 index 00000000000..56d38e2a92e --- /dev/null +++ b/TAO/tests/Alt_Mapping/results.cpp @@ -0,0 +1,149 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// results.cpp +// +// = DESCRIPTION +// Printing the results +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#include "results.h" +#include "tao/debug.h" +#include "ace/Log_Msg.h" + +Results::Results (void) +{ +} + +Results::~Results (void) +{ + delete [] this->elapsed_time_; +} + +void +Results::print_stats (void) +{ + double + avg_real_time = 0, + avg_user_time = 0, + avg_system_time = 0, + cps; // calls per sec + + CORBA::ULong i; + + if (TAO_debug_level > 0 && this->error_count_ == 0) + { + //FUZZ: disable check_for_lack_ACE_OS + ACE_DEBUG ((LM_DEBUG, + "Iteration\tReal time (msec)\tUser time (msec)" + "\tSystem time (msec)\n\n")); + //FUZZ: enable check_for_lack_ACE_OS + + for (i = 0; i < this->call_count_; i++) + { + this->elapsed_time_[i].real_time *= ACE_ONE_SECOND_IN_MSECS; + this->elapsed_time_[i].user_time *= ACE_ONE_SECOND_IN_MSECS; + this->elapsed_time_[i].system_time *= ACE_ONE_SECOND_IN_MSECS; + avg_real_time += this->elapsed_time_[i].real_time; + avg_user_time += this->elapsed_time_[i].user_time; + avg_system_time += this->elapsed_time_[i].system_time; + + ACE_DEBUG ((LM_DEBUG, + "%u\t\t%0.06f\t\t%0.06f\t\t%0.06f\n", + i, + (this->elapsed_time_[i].real_time < 0.0? + 0.0:this->elapsed_time_[i].real_time), + (this->elapsed_time_[i].user_time < 0.0? + 0.0:this->elapsed_time_[i].user_time), + (this->elapsed_time_[i].system_time < 0.0? + 0.0:this->elapsed_time_[i].system_time))); + } // end of for loop + + // compute average + avg_real_time /= this->call_count_; + avg_user_time /= this->call_count_; + avg_system_time /= this->call_count_; + cps = 1000 / (avg_real_time < 0.01 ? 0.01 : avg_real_time); + + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*= Average *=*=*=*=*=*=\n" + "\treal_time\t= %0.06f ms,\n" + "\tuser_time\t= %0.06f ms,\n" + "\tsystem_time\t= %0.06f ms\n" + "\t%0.00f calls/second\n" + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\n", + (avg_real_time < 0.0? 0.0:avg_real_time), + (avg_user_time < 0.0? 0.0:avg_user_time), + (avg_system_time < 0.0? 0.0:avg_system_time), + (cps < 0.0? 0.0 : cps))); + + ACE_DEBUG ((LM_DEBUG, + "\t%d calls, %d errors\n" + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\n", + this->call_count_, + this->error_count_)); + } + else if (this->error_count_ != 0) + { + ACE_DEBUG ((LM_DEBUG, + "\tERROR %d faults in %d calls\n" + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\n", + this->error_count_, + this->call_count_)); + } +} + +void +Results::print_exception (const char * /* call_name */) +{ + //ACE_PRINT_EXCEPTION (call_name); +} + +void +Results::start_timer (void) +{ + this->timer_.start (); +} + +void +Results::stop_timer (void) +{ + this->timer_.stop (); + this->timer_.elapsed_time (this->elapsed_time_[this->call_count_-1]); +} + +CORBA::ULong +Results::call_count (void) +{ + return this->call_count_; +} + +void +Results::call_count (CORBA::ULong c) +{ + this->call_count_ = c; +} + +CORBA::ULong +Results::error_count (void) +{ + return this->error_count_; +} + +void +Results::error_count (CORBA::ULong c) +{ + this->error_count_ = c; +} + +void +Results::iterations (CORBA::ULong iters) +{ + this->elapsed_time_ = new ACE_Profile_Timer::ACE_Elapsed_Time [iters]; +} diff --git a/TAO/tests/Alt_Mapping/results.h b/TAO/tests/Alt_Mapping/results.h new file mode 100644 index 00000000000..e04e26e5f3c --- /dev/null +++ b/TAO/tests/Alt_Mapping/results.h @@ -0,0 +1,88 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// results.h +// +// = DESCRIPTION +// Printing the results +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef RESULTS_H +#define RESULTS_H + +#include "tao/Basic_Types.h" + +#include "ace/Profile_Timer.h" +#include "ace/CORBA_macros.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL +namespace CORBA +{ + class Environment; +} +TAO_END_VERSIONED_NAMESPACE_DECL + +class Results +{ +public: + Results (void); + // ctor + + ~Results (void); + // destructor + + void print_stats (void); + // prints the time stats + + void print_exception (const char *call_name); + // print the exception + + void start_timer (void); + // start timing + + void stop_timer (void); + // stop timing + + CORBA::ULong call_count (void); + // return call count + + void call_count (CORBA::ULong); + // set the call count + + CORBA::ULong error_count (void); + // return the error count + + void error_count (CORBA::ULong); + // set error count + + void iterations (CORBA::ULong iters); + // set the number of times the test will be run + +private: + CORBA::ULong call_count_; + // # of calls made to functions + + CORBA::ULong error_count_; + // # of errors incurred in the lifetime of the application. + + ACE_Profile_Timer timer_; + // for timing the test + + ACE_Profile_Timer::ACE_Elapsed_Time *elapsed_time_; + // holds the elapsed time for each iteration +}; + +#endif /* RESULTS_H */ diff --git a/TAO/tests/Alt_Mapping/run_test.pl b/TAO/tests/Alt_Mapping/run_test.pl new file mode 100755 index 00000000000..a39ea895ae8 --- /dev/null +++ b/TAO/tests/Alt_Mapping/run_test.pl @@ -0,0 +1,119 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +my $server = PerlACE::TestTarget::create_target(1) || die "Create target 1 failed\n"; +my $client = PerlACE::TestTarget::create_target(2) || die "Create target 2 failed\n"; + +$iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +$invocation = "sii"; +$num = 5; +$debug = ""; +$status = 0; + +# Parse the arguments + +@types = ("ubstring", "ub_struct_seq"); + + +for ($i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") { + print "Run_Test Perl script for TAO Param Test\n\n"; + print "run_test [-n num] [-d] [-onewin] [-h] [-t type] [-i (dii|sii)] [-chorus ]\n"; + print "\n"; + print "-n num -- runs the client num times\n"; + print "-d -- runs each in debug mode\n"; + print "-h -- prints this information\n"; + print "-t type -- runs only one type of param test\n"; + print "-i (dii|sii) -- Changes the type of invocation\n"; + print "-chorus -- Run tests on chorus target\n"; + exit 0; + } + elsif ($ARGV[$i] eq "-n") { + $num = $ARGV[$i + 1]; + $i++; + } + elsif ($ARGV[$i] eq "-d") { + $debug = $debug." -d"; + } + elsif ($ARGV[$i] eq "-t") { + @types = split (',', $ARGV[$i + 1]); + $i++; + } + elsif ($ARGV[$i] eq "-i") { + $invocation = $ARGV[$i + 1]; + $i++; + } +} + +$SV = $server->CreateProcess ("server", "$debug -o $server_iorfile"); +$CL = $client->CreateProcess ("client"); + +foreach $type (@types) { + $server->DeleteFile($iorbase); # Ignore errors + $client->DeleteFile($iorbase); + + print STDERR "==== Testing $type === wait....\n"; + + $server_status = $SV->Spawn (); + + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; + } else { + if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); + exit 1; + } + + if ($server->GetFile ($iorbase) == -1) { + print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; + } + if ($client->PutFile ($iorbase) == -1) { + print STDERR "ERROR: cannot set file <$client_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; + } + + $CL->Arguments ("$debug -f $client_iorfile -i $invocation -t $type -n $num -x"); + $client_status = $CL->SpawnWaitKill ($server->ProcessStartWaitInterval() + 45); + + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; + $status = 1; + } + + $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); + + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; + } + + $server->GetStderrLog(); + } + + $server->DeleteFile($iorbase); + $client->DeleteFile($iorbase); + + print STDERR "==== Test for $type finished ===\n"; +} + +$server->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/tests/Alt_Mapping/server.cpp b/TAO/tests/Alt_Mapping/server.cpp new file mode 100644 index 00000000000..8d86a2403bb --- /dev/null +++ b/TAO/tests/Alt_Mapping/server.cpp @@ -0,0 +1,155 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// server.cpp +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#include "alt_mapping_i.h" +#include "tao/Codeset/Codeset.h" +#include "tao/debug.h" +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_stdio.h" + +// Parses the command line arguments and returns an error status. +static FILE *ior_output_file = 0; +static const ACE_TCHAR *ior_output_filename = ACE_TEXT("test.ior"); + +static int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("do:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag + TAO_debug_level++; + break; + case 'o': + ior_output_filename = get_opts.opt_arg (); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + "\n", argv [0]), 1); + } + + return 0; // Indicates successful parsing of command line +} + +// Standard command line parsing utilities used. + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + PortableServer::POA_var oa_ptr; + Alt_Mapping_i *svnt = 0; + + try + { + const char *orb_name = ""; + CORBA::ORB_var orb_ptr = + CORBA::ORB_init (argc, argv, orb_name); + + CORBA::Object_var temp; // holder for the myriad of times we get + // an object which we then have to narrow. + + // Get the Root POA + + temp = orb_ptr->resolve_initial_references ("RootPOA"); + + if (CORBA::is_nil (temp.in())) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) Unable to get root poa reference.\n"), + 1); + + oa_ptr = PortableServer::POA::_narrow (temp.in()); + + PortableServer::POAManager_var poa_manager = + oa_ptr->the_POAManager (); + + // Parse remaining command line and verify parameters. + parse_args (argc, argv); + + // initialize a param_test target object and register it with the object + // adapter + + // Create the implementation object + ACE_NEW_RETURN (svnt, + Alt_Mapping_i (orb_ptr.in ()), + -1); + + // Register with GoodPOA with a specific name + PortableServer::ObjectId_var id = + PortableServer::string_to_ObjectId ("alt_mapping"); + oa_ptr->activate_object_with_id (id.in (), + svnt); + + // Stringify the objref we'll be implementing, and print it to + // stdout. Someone will take that string and give it to a + // client. Then release the object. + + temp = oa_ptr->id_to_reference (id.in ()); + + CORBA::String_var str = + orb_ptr->object_to_string (temp.in ()); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) The IOR is <%s>\n", + str.in ())); + } + + ior_output_file = ACE_OS::fopen (ior_output_filename, "w"); + + if (ior_output_file == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for writing: %p\n", + ior_output_filename), + -1); + } + + ACE_OS::fprintf (ior_output_file, + "%s", + str.in ()); + ACE_OS::fclose (ior_output_file); + + + // Make the POAs controlled by this manager active + poa_manager->activate (); + + orb_ptr->run (); + + oa_ptr->destroy (true, true); + } + catch (const CORBA::SystemException& sysex) + { + sysex._tao_print_exception ("System Exception"); + return -1; + } + catch (const CORBA::UserException& userex) + { + userex._tao_print_exception ("User Exception"); + return -1; + } + + /// Free resources. + delete svnt; + + return 0; +} diff --git a/TAO/tests/Alt_Mapping/tests.h b/TAO/tests/Alt_Mapping/tests.h new file mode 100644 index 00000000000..ed6cdb30ef8 --- /dev/null +++ b/TAO/tests/Alt_Mapping/tests.h @@ -0,0 +1,22 @@ +// $Id$ + +// ============================================================================ +// +// = FILENAME +// tests.h +// +// = DESCRIPTION +// All the test objects header files included here +// +// = AUTHORS +// Jeff Parsons +// +// ============================================================================ + +#ifndef TESTS_H +#define TESTS_H + +#include "ub_struct_seq.h" +#include "ub_string.h" + +#endif /* if !defined */ diff --git a/TAO/tests/Alt_Mapping/ub_string.cpp b/TAO/tests/Alt_Mapping/ub_string.cpp new file mode 100644 index 00000000000..cdf3746d71c --- /dev/null +++ b/TAO/tests/Alt_Mapping/ub_string.cpp @@ -0,0 +1,124 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// ub_string.cpp +// +// = DESCRIPTION +// tests unbounded strings +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#include "helper.h" +#include "ub_string.h" + +// ************************************************************************ +// Test_Unbounded_String +// ************************************************************************ + +Test_Unbounded_String::Test_Unbounded_String (void) + : opname_ (CORBA::string_dup ("test_unbounded_string")) +{ +} + +Test_Unbounded_String::~Test_Unbounded_String (void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; +} + +const char * +Test_Unbounded_String::opname (void) const +{ + return this->opname_; +} + +int +Test_Unbounded_String::init_parameters (Alt_Mapping_ptr) +{ + Generator *gen = GENERATOR::instance (); // value generator + + this->in_ = gen->gen_string (); + this->inout_ = this->in_.c_str (); + + return 0; +} + +int +Test_Unbounded_String::reset_parameters (void) +{ + this->inout_ = this->in_.c_str (); + this->out_.clear (); + this->ret_.clear (); + + return 0; +} + +int +Test_Unbounded_String::run_sii_test (Alt_Mapping_ptr objref) +{ + try + { + this->ret_ = objref->test_unbounded_string (this->in_, + this->inout_, + this->out_);//str_out); + + return 0; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Test_Unbounded_String::run_sii_test\n"); + } + + return -1; +} + +CORBA::Boolean +Test_Unbounded_String::check_validity (void) +{ + CORBA::ULong len = this->in_.length (); + + std::string first_half = this->inout_.substr (0, len); + std::string second_half = this->inout_.substr (len, len); + + return (this->in_ == this->out_ + && this->in_ == this->ret_ + && this->inout_.length () == 2 * len + && this->in_ == first_half + && this->in_ == second_half); +} + +CORBA::Boolean +Test_Unbounded_String::check_validity (CORBA::Request_ptr ) +{ + // No need to retrieve anything because, for all the args and + // the return, we provided the memory and we own it. + return this->check_validity (); +} + +void +Test_Unbounded_String::print_values (void) +{ + ACE_DEBUG ((LM_DEBUG, + "\n=*=*=*=*=*=*\n" + "in with len (%d) = %s\n" + "inout with len (%d) = %s\n" + "out with len (%d) = %s\n" + "ret with len (%d) = %s\n" + "\n=*=*=*=*=*=*\n", + this->in_.length (), + this->in_.c_str (), + this->inout_.length (), + this->inout_.c_str (), + this->out_.length (), + this->out_.c_str (), + this->ret_.length (), + this->ret_.c_str ())); +} diff --git a/TAO/tests/Alt_Mapping/ub_string.h b/TAO/tests/Alt_Mapping/ub_string.h new file mode 100644 index 00000000000..b3f4037173b --- /dev/null +++ b/TAO/tests/Alt_Mapping/ub_string.h @@ -0,0 +1,67 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// unbounded_string.h +// +// = DESCRIPTION +// Tests unbounded string +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef PARAM_TEST_UNBOUNDED_STRING_H +#define PARAM_TEST_UNBOUNDED_STRING_H + +#include "Alt_MappingC.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test unbounded strings +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +class Test_Unbounded_String +{ +public: + Test_Unbounded_String (void); + // ctor + + ~Test_Unbounded_String (void); + // dtor + + int run_sii_test (Alt_Mapping_ptr objref); + // run the SII test + + const char *opname (void) const; + // return operation name + + int init_parameters (Alt_Mapping_ptr objref); + // 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 + + std::string in_; + std::string inout_; + std::string out_; + std::string ret_; +}; + +#endif /* PARAM_TEST_UNBOUNDED_STRING_H */ diff --git a/TAO/tests/Alt_Mapping/ub_struct_seq.cpp b/TAO/tests/Alt_Mapping/ub_struct_seq.cpp new file mode 100644 index 00000000000..14d9796aba4 --- /dev/null +++ b/TAO/tests/Alt_Mapping/ub_struct_seq.cpp @@ -0,0 +1,196 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// ub_struct_seq.cpp +// +// = DESCRIPTION +// tests unbounded struct sequences +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#include "helper.h" +#include "ub_struct_seq.h" + +// ************************************************************************ +// Test_Struct_Sequence +// ************************************************************************ + +Test_Unbounded_Struct_Sequence::Test_Unbounded_Struct_Sequence ( + void) + : opname_ (CORBA::string_dup ("test_struct_sequence")) +{ +} + +Test_Unbounded_Struct_Sequence::~Test_Unbounded_Struct_Sequence ( + void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; + // the other data members will be freed as they are "_var"s and objects + // (rather than pointers to objects) +} + +const char * +Test_Unbounded_Struct_Sequence::opname (void) const +{ + return this->opname_; +} + +int +Test_Unbounded_Struct_Sequence::init_parameters (Alt_Mapping_ptr) +{ + 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_.length (len); + this->inout_.length (len); + + // Now set each individual element. + for (CORBA::ULong i = 0; i < this->in_.length (); i++) + { + // Generate some arbitrary struct to be filled into the ith location in + // the sequence. + this->in_[i] = gen->gen_fixed_struct (); + this->inout_[i] = gen->gen_fixed_struct (); + } + + return 0; +} + +int +Test_Unbounded_Struct_Sequence::reset_parameters (void) +{ + this->inout_.clear (); + this->out_.clear (); + this->ret_.clear (); + + return 0; +} + +int +Test_Unbounded_Struct_Sequence::run_sii_test ( + Alt_Mapping_ptr objref) +{ + try + { + this->ret_.swap (objref->test_struct_sequence (this->in_, + this->inout_, + this->out_)); + + return 0; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Test_Struct_Sequence::run_sii_test\n"); + + } + return -1; +} + +CORBA::Boolean +Test_Unbounded_Struct_Sequence::check_validity (void) +{ + return (this->compare (this->in_, this->inout_) + && this->compare (this->in_, this->out_) + && this->compare (this->in_, this->ret_)); +} + +void +Test_Unbounded_Struct_Sequence::print_values (void) +{ + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "IN sequence\n")); + this->print_sequence (this->in_); + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "INOUT sequence\n")); + this->print_sequence (this->inout_); + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "OUT sequence\n")); + this->print_sequence (this->out_); + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "RET sequence\n")); + this->print_sequence (this->ret_); +} + +CORBA::Boolean +Test_Unbounded_Struct_Sequence::compare ( + const Alt_Mapping::StructSeq &s1, + const Alt_Mapping::StructSeq &s2) +{ + ACE_CDR::ULong s1v = s1.maximum (); + ACE_CDR::ULong s2v = s2.maximum (); + + if (s1v != s2v) + { + return false; + } + + s1v = s1.length (); + s2v = s2.length (); + + if (s1v != s2v) + { + return false; + } + + for (CORBA::ULong i=0; i < s1.length (); i++) + { + const Alt_Mapping::Fixed_Struct& vs1 = s1[i]; + const Alt_Mapping::Fixed_Struct& vs2 = s2[i]; + + if (vs1.l != vs2.l + || vs1.c != vs2.c + || vs1.s != vs2.s + || vs1.o != vs2.o + || vs1.f != vs2.f + || vs1.b != vs2.b + || vs1.d != vs2.d ) + return false; + } + + return true; // success +} + +void +Test_Unbounded_Struct_Sequence::print_sequence ( + const Alt_Mapping::StructSeq &s) +{ + ACE_DEBUG ((LM_DEBUG, + "maximum = %d\n" + "length = %d\n", + s.maximum (), + s.length ())); + ACE_DEBUG ((LM_DEBUG, "Elements -\n")); + + for (CORBA::ULong i=0; i < s.length (); i++) + { + const Alt_Mapping::Fixed_Struct& vs = s[i]; + + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "\tl = %d\n" + "\tc = %c\n" + "\ts = %d\n" + "\to = %x\n" + "\tf = %f\n" + "\tb = %d\n" + "\td = %f\n", + i, + vs.l, vs.c, vs.s, vs.o, vs.f, vs.b, vs.d)); + } +} diff --git a/TAO/tests/Alt_Mapping/ub_struct_seq.h b/TAO/tests/Alt_Mapping/ub_struct_seq.h new file mode 100644 index 00000000000..a79a5fcf70a --- /dev/null +++ b/TAO/tests/Alt_Mapping/ub_struct_seq.h @@ -0,0 +1,75 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// ub_struct_seq.h +// +// = DESCRIPTION +// Tests unbounded struct sequence +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef ALT_MAPPING_TEST_UNBOUNED_STRUCT_SEQUENCE_H +#define ALT_MAPPING_TEST_UNBOUNED_STRUCT_SEQUENCE_H + +#include "alt_mappingC.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test unbounded sequence of structs +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_Unbounded_Struct_Sequence +{ +public: + Test_Unbounded_Struct_Sequence (void); + // ctor + + ~Test_Unbounded_Struct_Sequence (void); + // dtor + + int run_sii_test (Alt_Mapping_ptr objref); + // run the SII test + + const char *opname (void) const; + // return operation name + + int init_parameters (Alt_Mapping_ptr objref); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + void print_values (void); + // print all the values + +protected: + CORBA::Boolean compare (const Alt_Mapping::StructSeq &s1, + const Alt_Mapping::StructSeq &s2); + // compare + + void print_sequence (const Alt_Mapping::StructSeq &s); + // print individual sequence + +private: + char *opname_; + + Alt_Mapping::StructSeq in_; + + Alt_Mapping::StructSeq inout_; + + Alt_Mapping::StructSeq out_; + + Alt_Mapping::StructSeq ret_; +}; + +#endif /* ALT_MAPPING_TEST_UNBOUNED_STRUCT_SEQUENCE_H */ diff --git a/TAO/tests/IDL_Test/reopened_modules.idl b/TAO/tests/IDL_Test/reopened_modules.idl index 0c77618fc43..6f4d98931c5 100644 --- a/TAO/tests/IDL_Test/reopened_modules.idl +++ b/TAO/tests/IDL_Test/reopened_modules.idl @@ -309,3 +309,47 @@ module A_mod interface Foo : A_mod::Foo {}; }; }; + +/// Similar to example at the top of this file, +/// but with more openings and deeper nesting. +module m1 +{ + module m2 + { + module m3a + { + module m4a + { + const unsigned short FRED = 123; + }; + }; + }; +}; + +module m1 +{ + module m2 + { + module m3a + { + module m4b + { + const unsigned short JIM = 240; + }; + }; + }; +}; + +module m1 +{ + module m2 + { + module m3b + { + typedef string <::m1::m2::m3a::m4b::JIM> StringJIM; + typedef string StringJIM_0; + typedef string StringJIM_1; + typedef string StringJIM_2; + }; + }; +}; diff --git a/TAO/tests/IDL_Test/repo_id_mod.idl b/TAO/tests/IDL_Test/repo_id_mod.idl index e19a898bb4b..51f50178384 100644 --- a/TAO/tests/IDL_Test/repo_id_mod.idl +++ b/TAO/tests/IDL_Test/repo_id_mod.idl @@ -49,6 +49,7 @@ module gleep // Tests the handling of extra whitespace as well as the version setting. # pragma version gleep::floop::schmendrick 524.23 + local interface schmendrick {}; module verklempt @@ -58,7 +59,7 @@ module gleep // This will override the prefix directive for module floop at the end // of the file. typeprefix floop::verklempt "verklempt_prefix"; - }; + }; }; local interface schmegegging {}; -- cgit v1.2.1