diff options
67 files changed, 945 insertions, 287 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 4cd84818e6c..d14dad42e58 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,82 @@ +Fri Jan 9 17:49:55 1998 Carlos O'Ryan <coryan@cs.wustl.edu> + + * tao/Makefile: + * tao/corba.h: + * tao/corbacom.h: + * tao/sequence.cpp: + * tao/sequence.h: + * tao/sequence.i: + * tao/sequence_T.cpp: + * tao/sequence_T.h: + * tao/sequence_T.i: + Added the new TAO_Base_Sequence class and its parametric + children (TAO_Bounded_Sequence and TAO_Unbounded_Sequence). This + classes will be used in the implementation of all the IDL + sequences, thus providing the interpreter with a base class to + manipulate them. + + * orbsvcs/Scheduling_Service/Scheduler.cpp: + Fixed some instantiation problems. + + * TAO_IDL/be/Makefile: + * TAO_IDL/be/be_argument.cpp: + * TAO_IDL/be/be_array.cpp: + * TAO_IDL/be/be_attribute.cpp: + * TAO_IDL/be/be_constant.cpp: + * TAO_IDL/be/be_decl.cpp: + * TAO_IDL/be/be_enum.cpp: + * TAO_IDL/be/be_enum_val.cpp: + * TAO_IDL/be/be_exception.cpp: + * TAO_IDL/be/be_expression.cpp: + * TAO_IDL/be/be_field.cpp: + * TAO_IDL/be/be_interface.cpp: + * TAO_IDL/be/be_interface_fwd.cpp: + * TAO_IDL/be/be_module.cpp: + * TAO_IDL/be/be_native.cpp: + * TAO_IDL/be/be_operation.cpp: + * TAO_IDL/be/be_predefined_type.cpp: + * TAO_IDL/be/be_root.cpp: + * TAO_IDL/be/be_scope.cpp: + * TAO_IDL/be/be_sequence.cpp: + * TAO_IDL/be/be_string.cpp: + * TAO_IDL/be/be_structure.cpp: + * TAO_IDL/be/be_type.cpp: + * TAO_IDL/be/be_union.cpp: + * TAO_IDL/be/be_union_branch.cpp: + * TAO_IDL/be/be_union_label.cpp: + * TAO_IDL/be/be_visitor.cpp: + * TAO_IDL/be/be_visitor_root.cpp: + * TAO_IDL/be_include/be.h: + * TAO_IDL/be_include/be_argument.h: + * TAO_IDL/be_include/be_array.h: + * TAO_IDL/be_include/be_attribute.h: + * TAO_IDL/be_include/be_constant.h: + * TAO_IDL/be_include/be_decl.h: + * TAO_IDL/be_include/be_enum.h: + * TAO_IDL/be_include/be_enum_val.h: + * TAO_IDL/be_include/be_exception.h: + * TAO_IDL/be_include/be_expression.h: + * TAO_IDL/be_include/be_field.h: + * TAO_IDL/be_include/be_interface.h: + * TAO_IDL/be_include/be_interface_fwd.h: + * TAO_IDL/be_include/be_module.h: + * TAO_IDL/be_include/be_native.h: + * TAO_IDL/be_include/be_operation.h: + * TAO_IDL/be_include/be_predefined_type.h: + * TAO_IDL/be_include/be_root.h: + * TAO_IDL/be_include/be_scope.h: + * TAO_IDL/be_include/be_sequence.h: + * TAO_IDL/be_include/be_string.h: + * TAO_IDL/be_include/be_structure.h: + * TAO_IDL/be_include/be_type.h: + * TAO_IDL/be_include/be_typedef.h: + * TAO_IDL/be_include/be_union.h: + * TAO_IDL/be_include/be_union_branch.h: + * TAO_IDL/be_include/be_union_label.h: + * TAO_IDL/be_include/be_visitor.h: + * TAO_IDL/be_include/be_visitor_root.h: + Added visitors from the poa branch into the main trunk. + Fri Jan 9 16:17:37 1998 Chris Cleeland <cleeland@cs.wustl.edu> * tao/orb_core.*: Changed ORB parameters, OA parameters, and the diff --git a/TAO/TAO_IDL/be/Makefile b/TAO/TAO_IDL/be/Makefile index 7443c0d1e4b..25ca9bf7a88 100644 --- a/TAO/TAO_IDL/be/Makefile +++ b/TAO/TAO_IDL/be/Makefile @@ -55,7 +55,9 @@ BE_FILES = \ be_factory \ be_sunsoft \ be_decl \ - be_scope + be_scope \ + be_visitor \ + be_visitor_root \ FILES = $(BE_FILES) diff --git a/TAO/TAO_IDL/be/be_argument.cpp b/TAO/TAO_IDL/be/be_argument.cpp index 5fbd90661be..6b2fd6c167c 100644 --- a/TAO/TAO_IDL/be/be_argument.cpp +++ b/TAO/TAO_IDL/be/be_argument.cpp @@ -147,6 +147,12 @@ be_argument::gen_server_inline (void) return 0; } +int +be_argument::accept (be_visitor *visitor) +{ + return visitor->visit_argument (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_argument, AST_Argument, be_decl) IMPL_NARROW_FROM_DECL (be_argument) diff --git a/TAO/TAO_IDL/be/be_array.cpp b/TAO/TAO_IDL/be/be_array.cpp index 02ba86dde28..8828a3d2b71 100644 --- a/TAO/TAO_IDL/be/be_array.cpp +++ b/TAO/TAO_IDL/be/be_array.cpp @@ -1433,6 +1433,12 @@ be_array::compute_size_type (void) return 0; } +int +be_array::accept (be_visitor *visitor) +{ + return visitor->visit_array (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_array, AST_Array, be_type) IMPL_NARROW_FROM_DECL (be_array) diff --git a/TAO/TAO_IDL/be/be_attribute.cpp b/TAO/TAO_IDL/be/be_attribute.cpp index 575a6029260..db325652c55 100644 --- a/TAO/TAO_IDL/be/be_attribute.cpp +++ b/TAO/TAO_IDL/be/be_attribute.cpp @@ -676,6 +676,12 @@ be_attribute::gen_server_inline (void) return 0; } +int +be_attribute::accept (be_visitor *visitor) +{ + return visitor->visit_attribute (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_attribute, AST_Attribute, be_decl) IMPL_NARROW_FROM_DECL (be_attribute) diff --git a/TAO/TAO_IDL/be/be_constant.cpp b/TAO/TAO_IDL/be/be_constant.cpp index 10dc22066c8..962436a8de3 100644 --- a/TAO/TAO_IDL/be/be_constant.cpp +++ b/TAO/TAO_IDL/be/be_constant.cpp @@ -169,6 +169,12 @@ be_constant::exprtype_to_string (void) return NULL; } +int +be_constant::accept (be_visitor *visitor) +{ + return visitor->visit_constant (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_constant, AST_Constant, be_decl) IMPL_NARROW_FROM_DECL (be_constant) diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index f8ff330b522..9ab80652df1 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -464,6 +464,12 @@ be_decl::scope (void) } } +int +be_decl::accept (be_visitor *visitor) +{ + return visitor->visit_decl (this); +} + // narrowing methods IMPL_NARROW_METHODS1 (be_decl, AST_Decl) IMPL_NARROW_FROM_DECL (be_decl) diff --git a/TAO/TAO_IDL/be/be_enum.cpp b/TAO/TAO_IDL/be/be_enum.cpp index 6493760fc40..6c3dead7f5c 100644 --- a/TAO/TAO_IDL/be/be_enum.cpp +++ b/TAO/TAO_IDL/be/be_enum.cpp @@ -314,7 +314,13 @@ be_enum::tc_encap_len (void) return this->encap_len_; } +int +be_enum::accept (be_visitor *visitor) +{ + return visitor->visit_enum (this); +} + // Narrowing IMPL_NARROW_METHODS3 (be_enum, AST_Enum, be_scope, be_type) - IMPL_NARROW_FROM_DECL (be_enum) - IMPL_NARROW_FROM_SCOPE (be_enum) +IMPL_NARROW_FROM_DECL (be_enum) +IMPL_NARROW_FROM_SCOPE (be_enum) diff --git a/TAO/TAO_IDL/be/be_enum_val.cpp b/TAO/TAO_IDL/be/be_enum_val.cpp index 76fa116ae68..0a63a7fb3cd 100644 --- a/TAO/TAO_IDL/be/be_enum_val.cpp +++ b/TAO/TAO_IDL/be/be_enum_val.cpp @@ -136,6 +136,12 @@ be_enum_val::tc_encap_len (void) return this->encap_len_; } +int +be_enum_val::accept (be_visitor *visitor) +{ + return visitor->visit_enum_val (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_enum_val, AST_EnumVal, be_decl) IMPL_NARROW_FROM_DECL (be_enum_val) diff --git a/TAO/TAO_IDL/be/be_exception.cpp b/TAO/TAO_IDL/be/be_exception.cpp index fa0ea4fd946..09d4446d1eb 100644 --- a/TAO/TAO_IDL/be/be_exception.cpp +++ b/TAO/TAO_IDL/be/be_exception.cpp @@ -504,6 +504,12 @@ be_exception::tc_encap_len (void) return this->encap_len_; } +int +be_exception::accept (be_visitor *visitor) +{ + return visitor->visit_exception (this); +} + // Narrowing IMPL_NARROW_METHODS3 (be_exception, AST_Exception, be_scope, be_type) IMPL_NARROW_FROM_DECL (be_exception) diff --git a/TAO/TAO_IDL/be/be_expression.cpp b/TAO/TAO_IDL/be/be_expression.cpp index 1b95320823a..bc9773030e6 100644 --- a/TAO/TAO_IDL/be/be_expression.cpp +++ b/TAO/TAO_IDL/be/be_expression.cpp @@ -73,5 +73,8 @@ be_expression::be_expression (double d) { } - - +int +be_expression::accept (be_visitor *visitor) +{ + return visitor->visit_expression (this); +} diff --git a/TAO/TAO_IDL/be/be_field.cpp b/TAO/TAO_IDL/be/be_field.cpp index b535f2dbb56..0511fd4c909 100644 --- a/TAO/TAO_IDL/be/be_field.cpp +++ b/TAO/TAO_IDL/be/be_field.cpp @@ -199,6 +199,12 @@ be_field::compute_size_type (void) return 0; } +int +be_field::accept (be_visitor *visitor) +{ + return visitor->visit_field (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_field, AST_Field, be_decl) IMPL_NARROW_FROM_DECL (be_field) diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 0007f056ec2..fc728411856 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -1837,6 +1837,11 @@ be_interface::relative_skel_name (const char *skelname) return macro; } +int +be_interface::accept (be_visitor *visitor) +{ + return visitor->visit_interface (this); +} // Narrowing IMPL_NARROW_METHODS3 (be_interface, AST_Interface, be_scope, be_type) diff --git a/TAO/TAO_IDL/be/be_interface_fwd.cpp b/TAO/TAO_IDL/be/be_interface_fwd.cpp index 68910b7b6de..d9a352eaef6 100644 --- a/TAO/TAO_IDL/be/be_interface_fwd.cpp +++ b/TAO/TAO_IDL/be/be_interface_fwd.cpp @@ -623,6 +623,12 @@ be_interface_fwd::tc_size (void) return 0; } +int +be_interface_fwd::accept (be_visitor *visitor) +{ + return visitor->visit_interface_fwd (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_interface_fwd, AST_InterfaceFwd, be_type) IMPL_NARROW_FROM_DECL (be_interface_fwd) diff --git a/TAO/TAO_IDL/be/be_module.cpp b/TAO/TAO_IDL/be/be_module.cpp index d66a7ace2bb..544b322987e 100644 --- a/TAO/TAO_IDL/be/be_module.cpp +++ b/TAO/TAO_IDL/be/be_module.cpp @@ -205,6 +205,12 @@ be_module::compute_size_type (void) return 0; } +int +be_module::accept (be_visitor *visitor) +{ + return visitor->visit_module (this); +} + // Narrowing IMPL_NARROW_METHODS3 (be_module, AST_Module, be_scope, be_decl) IMPL_NARROW_FROM_DECL (be_module) diff --git a/TAO/TAO_IDL/be/be_native.cpp b/TAO/TAO_IDL/be/be_native.cpp index 5b619dc7fe5..ece9f06bd51 100644 --- a/TAO/TAO_IDL/be/be_native.cpp +++ b/TAO/TAO_IDL/be/be_native.cpp @@ -83,6 +83,12 @@ be_native::tc_size (void) return 0; } +int +be_native::accept (be_visitor *visitor) +{ + return visitor->visit_native (this); +} + // Narrowing IMPL_NARROW_METHODS2(be_native, AST_Native, be_type) IMPL_NARROW_FROM_DECL(be_native) diff --git a/TAO/TAO_IDL/be/be_operation.cpp b/TAO/TAO_IDL/be/be_operation.cpp index d326c64c285..e78b78f784f 100644 --- a/TAO/TAO_IDL/be/be_operation.cpp +++ b/TAO/TAO_IDL/be/be_operation.cpp @@ -828,6 +828,12 @@ be_operation::compute_size_type (void) return 0; } +int +be_operation::accept (be_visitor *visitor) +{ + return visitor->visit_operation (this); +} + // Narrowing IMPL_NARROW_METHODS3 (be_operation, AST_Operation, be_scope, be_decl) IMPL_NARROW_FROM_DECL (be_operation) diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index 8029132e871..d7a191ba065 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -432,6 +432,12 @@ be_predefined_type::compute_size_type (void) return 0; } +int +be_predefined_type::accept (be_visitor *visitor) +{ + return visitor->visit_predefined_type (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_predefined_type, AST_PredefinedType, be_type) IMPL_NARROW_FROM_DECL (be_predefined_type) diff --git a/TAO/TAO_IDL/be/be_root.cpp b/TAO/TAO_IDL/be/be_root.cpp index 4fbe89ebf3a..1489aea04c8 100644 --- a/TAO/TAO_IDL/be/be_root.cpp +++ b/TAO/TAO_IDL/be/be_root.cpp @@ -300,6 +300,12 @@ be_root::fe_add_array (AST_Array *t) return t; } +int +be_root::accept (be_visitor *visitor) +{ + return visitor->visit_root (this); +} + /* * Narrowing methods */ diff --git a/TAO/TAO_IDL/be/be_scope.cpp b/TAO/TAO_IDL/be/be_scope.cpp index e25ddf47fc5..3757103664d 100644 --- a/TAO/TAO_IDL/be/be_scope.cpp +++ b/TAO/TAO_IDL/be/be_scope.cpp @@ -479,6 +479,12 @@ be_scope::decl (void) } } +int +be_scope::accept (be_visitor *visitor) +{ + return visitor->visit_scope (this); +} + // narrowing methods IMPL_NARROW_METHODS1 (be_scope, UTL_Scope) IMPL_NARROW_FROM_SCOPE (be_scope) diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index 69a9c66d84e..0fab3cb8b8c 100644 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ b/TAO/TAO_IDL/be/be_sequence.cpp @@ -2532,6 +2532,12 @@ be_sequence::decl (void) return this; } +int +be_sequence::accept (be_visitor *visitor) +{ + return visitor->visit_sequence (this); +} + // Narrowing IMPL_NARROW_METHODS3 (be_sequence, AST_Sequence, be_scope, be_type) IMPL_NARROW_FROM_DECL (be_sequence) diff --git a/TAO/TAO_IDL/be/be_string.cpp b/TAO/TAO_IDL/be/be_string.cpp index 18917d3decf..d2dcdd37f61 100644 --- a/TAO/TAO_IDL/be/be_string.cpp +++ b/TAO/TAO_IDL/be/be_string.cpp @@ -157,6 +157,12 @@ be_string::tc_encap_len (void) return this->encap_len_; } +int +be_string::accept (be_visitor *visitor) +{ + return visitor->visit_string (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_string, AST_String, be_type) IMPL_NARROW_FROM_DECL (be_string) diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index dc96bde62d8..a040abd4fd7 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -882,6 +882,12 @@ be_structure::compute_size_type (void) return 0; } +int +be_structure::accept (be_visitor *visitor) +{ + return visitor->visit_structure (this); +} + // Narrowing IMPL_NARROW_METHODS3 (be_structure, AST_Structure, be_scope, be_type) IMPL_NARROW_FROM_DECL (be_structure) diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp index bed5710a386..e4241fe2ae0 100644 --- a/TAO/TAO_IDL/be/be_type.cpp +++ b/TAO/TAO_IDL/be/be_type.cpp @@ -249,6 +249,12 @@ be_type::gen_out_impl (void) return 0; } +int +be_type::accept (be_visitor *visitor) +{ + return visitor->visit_type (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_type, AST_Type, be_decl) IMPL_NARROW_FROM_DECL (be_type) diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index b775b25b520..4a1669e9a79 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -1121,6 +1121,12 @@ be_union::tc_encap_len (void) return this->encap_len_; } +int +be_union::accept (be_visitor *visitor) +{ + return visitor->visit_union (this); +} + // Narrowing IMPL_NARROW_METHODS3 (be_union, AST_Union, be_scope, be_type) IMPL_NARROW_FROM_DECL (be_union) diff --git a/TAO/TAO_IDL/be/be_union_branch.cpp b/TAO/TAO_IDL/be/be_union_branch.cpp index 241fffab0e1..a2fa645230d 100644 --- a/TAO/TAO_IDL/be/be_union_branch.cpp +++ b/TAO/TAO_IDL/be/be_union_branch.cpp @@ -184,6 +184,12 @@ be_union_branch::tc_encap_len (void) return this->encap_len_; } +int +be_union_branch::accept (be_visitor *visitor) +{ + return visitor->visit_union_branch (this); +} + // Narrowing IMPL_NARROW_METHODS2 (be_union_branch, AST_UnionBranch, be_decl) IMPL_NARROW_FROM_DECL (be_union_branch) diff --git a/TAO/TAO_IDL/be/be_union_label.cpp b/TAO/TAO_IDL/be/be_union_label.cpp index 54c34769d76..0c4f6af91fc 100644 --- a/TAO/TAO_IDL/be/be_union_label.cpp +++ b/TAO/TAO_IDL/be/be_union_label.cpp @@ -14,3 +14,9 @@ be_union_label::be_union_label(AST_UnionLabel::UnionLabel ul, { } +int +be_union_label::accept (be_visitor *visitor) +{ + return visitor->visit_union_label (this); +} + diff --git a/TAO/TAO_IDL/be/be_visitor.cpp b/TAO/TAO_IDL/be/be_visitor.cpp new file mode 100644 index 00000000000..2dd112861d6 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor.cpp @@ -0,0 +1,162 @@ +// +// $Id$ +// + +#include "idl.h" +#include "be.h" +#include "be_visitor.h" + +be_visitor::~be_visitor (void) +{ +} + +int be_visitor::visit_decl (be_decl *) +{ + return 0; +} + +int be_visitor::visit_scope (be_scope *node) +{ + if (node->nmembers () > 0) + { + UTL_ScopeActiveIterator *si; + ACE_NEW_RETURN (si, + UTL_ScopeActiveIterator (node, + UTL_Scope::IK_decls), + -1); + while (!si->is_done ()) + { + AST_Decl *d = si->item (); + be_decl *bd = be_decl::narrow_from_decl (d); + if (bd == 0 || bd->accept (this) == -1) + { + delete si; + return -1; + } + si->next (); + } + delete si; + } + + return 0; +} + +int be_visitor::visit_type (be_type *) +{ + return 0; +} + +int be_visitor::visit_predefined_type (be_predefined_type *) +{ + return 0; +} + +int be_visitor::visit_module (be_module *) +{ + return 0; +} + +int be_visitor::visit_interface (be_interface *) +{ + return 0; +} + +int be_visitor::visit_interface_fwd (be_interface_fwd *) +{ + return 0; +} + +int be_visitor::visit_structure (be_structure *) +{ + return 0; +} + +int be_visitor::visit_exception (be_exception *) +{ + return 0; +} + +int be_visitor::visit_expression (be_expression *) +{ + return 0; +} + +int be_visitor::visit_enum (be_enum *) +{ + return 0; +} + +int be_visitor::visit_operation (be_operation *) +{ + return 0; +} + +int be_visitor::visit_field (be_field *) +{ + return 0; +} + +int be_visitor::visit_argument (be_argument *) +{ + return 0; +} + +int be_visitor::visit_attribute (be_attribute *) +{ + return 0; +} + +int be_visitor::visit_union (be_union *) +{ + return 0; +} + +int be_visitor::visit_union_branch (be_union_branch *) +{ + return 0; +} + +int be_visitor::visit_union_label (be_union_label *) +{ + return 0; +} + +int be_visitor::visit_constant (be_constant *) +{ + return 0; +} + +int be_visitor::visit_enum_val (be_enum_val *) +{ + return 0; +} + +int be_visitor::visit_array (be_array *) +{ + return 0; +} + +int be_visitor::visit_sequence (be_sequence *) +{ + return 0; +} + +int be_visitor::visit_string (be_string *) +{ + return 0; +} + +int be_visitor::visit_typedef (be_typedef *) +{ + return 0; +} + +int be_visitor::visit_root (be_root *) +{ + return 0; +} + +int be_visitor::visit_native (be_native *) +{ + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_root.cpp b/TAO/TAO_IDL/be/be_visitor_root.cpp new file mode 100644 index 00000000000..9736eba736b --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_root.cpp @@ -0,0 +1,51 @@ +// +// $Id$ +// + +#include "idl.h" +#include "be.h" +#include "be_visitor_root.h" + +be_visitor_root_ch::be_visitor_root_ch (void) +{ +} + +be_visitor_root_ch::~be_visitor_root_ch (void) +{ +} + +int be_visitor_root_ch::visit_sequence (be_sequence *node) +{ + return 0; +} + + + +be_visitor_root_cs::be_visitor_root_cs (void) +{ +} + +be_visitor_root_cs::~be_visitor_root_cs (void) +{ +} + +int be_visitor_root_cs::visit_sequence (be_sequence *node) +{ + return 0; +} + + + +be_visitor_root_ci::be_visitor_root_ci (void) +{ +} + +be_visitor_root_ci::~be_visitor_root_ci (void) +{ +} + +int be_visitor_root_ci::visit_sequence (be_sequence *node) +{ + return 0; +} + diff --git a/TAO/TAO_IDL/be_include/be.h b/TAO/TAO_IDL/be_include/be.h index 7741e92f2df..085ee64af41 100644 --- a/TAO/TAO_IDL/be_include/be.h +++ b/TAO/TAO_IDL/be_include/be.h @@ -118,4 +118,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "be_codegen.h" // code generator #include "be_factory.h" // factory +#include "be_visitor.h" + #endif // _BE_BE_HH diff --git a/TAO/TAO_IDL/be_include/be_argument.h b/TAO/TAO_IDL/be_include/be_argument.h index a20676a1c82..5f417e6e9e4 100644 --- a/TAO/TAO_IDL/be_include/be_argument.h +++ b/TAO/TAO_IDL/be_include/be_argument.h @@ -54,6 +54,9 @@ public: virtual int gen_server_inline (void); // Generates the server-side inlines for the argument + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_argument, AST_Argument, be_decl); DEF_NARROW_FROM_DECL (be_argument); diff --git a/TAO/TAO_IDL/be_include/be_array.h b/TAO/TAO_IDL/be_include/be_array.h index 2e256fe95b8..74dcc38b95d 100644 --- a/TAO/TAO_IDL/be_include/be_array.h +++ b/TAO/TAO_IDL/be_include/be_array.h @@ -89,6 +89,9 @@ public: virtual long tc_encap_len (void); // return length of encapsulation + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_array, AST_Array, be_type); DEF_NARROW_FROM_DECL (be_array); diff --git a/TAO/TAO_IDL/be_include/be_attribute.h b/TAO/TAO_IDL/be_include/be_attribute.h index 2461013a402..c1ad4b8b362 100644 --- a/TAO/TAO_IDL/be_include/be_attribute.h +++ b/TAO/TAO_IDL/be_include/be_attribute.h @@ -53,6 +53,9 @@ public: virtual int gen_server_inline (void); // Generates the server-side inlines for the attribute + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_attribute, AST_Attribute, be_decl); DEF_NARROW_FROM_DECL (be_attribute); diff --git a/TAO/TAO_IDL/be_include/be_constant.h b/TAO/TAO_IDL/be_include/be_constant.h index 0bbc21f1f9f..a5139d8eed9 100644 --- a/TAO/TAO_IDL/be_include/be_constant.h +++ b/TAO/TAO_IDL/be_include/be_constant.h @@ -56,6 +56,9 @@ public: virtual int gen_server_inline (void); // Generates the server-side inlines for the constant + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_constant, AST_Constant, be_decl); DEF_NARROW_FROM_DECL (be_constant); diff --git a/TAO/TAO_IDL/be_include/be_decl.h b/TAO/TAO_IDL/be_include/be_decl.h index cc1c2f317ce..f6b8f8f9578 100644 --- a/TAO/TAO_IDL/be_include/be_decl.h +++ b/TAO/TAO_IDL/be_include/be_decl.h @@ -21,6 +21,7 @@ #define TAO_BE_DECL_H class be_scope; +class be_visitor; /* * BE_Decl @@ -99,6 +100,9 @@ public: virtual be_scope *scope (void); // return the scope created by this node (if one exists) + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS1 (be_decl, AST_Decl); DEF_NARROW_FROM_DECL (be_decl); diff --git a/TAO/TAO_IDL/be_include/be_enum.h b/TAO/TAO_IDL/be_include/be_enum.h index 8929819a793..e7a3637b750 100644 --- a/TAO/TAO_IDL/be_include/be_enum.h +++ b/TAO/TAO_IDL/be_include/be_enum.h @@ -70,6 +70,9 @@ public: virtual int member_count (void); // return the count of members + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_enum, AST_Enum, be_scope, be_type); DEF_NARROW_FROM_DECL (be_enum); diff --git a/TAO/TAO_IDL/be_include/be_enum_val.h b/TAO/TAO_IDL/be_include/be_enum_val.h index 4a52ea0501f..e8671c23275 100644 --- a/TAO/TAO_IDL/be_include/be_enum_val.h +++ b/TAO/TAO_IDL/be_include/be_enum_val.h @@ -60,6 +60,9 @@ public: virtual long tc_encap_len (void); // return length of encapsulation + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_enum_val, AST_EnumVal, be_decl); DEF_NARROW_FROM_DECL (be_enum_val); diff --git a/TAO/TAO_IDL/be_include/be_exception.h b/TAO/TAO_IDL/be_include/be_exception.h index 55391e0bfde..202b9d1df04 100644 --- a/TAO/TAO_IDL/be_include/be_exception.h +++ b/TAO/TAO_IDL/be_include/be_exception.h @@ -52,6 +52,9 @@ public: virtual int member_count (void); // return the count of members + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_exception, AST_Exception, be_scope, be_type); DEF_NARROW_FROM_DECL (be_exception); diff --git a/TAO/TAO_IDL/be_include/be_expression.h b/TAO/TAO_IDL/be_include/be_expression.h index ae3d90d2164..7429a299977 100644 --- a/TAO/TAO_IDL/be_include/be_expression.h +++ b/TAO/TAO_IDL/be_include/be_expression.h @@ -38,6 +38,9 @@ public: be_expression (String *s); be_expression (char c); be_expression (double d); + + // Visiting + virtual int accept (be_visitor *visitor); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_field.h b/TAO/TAO_IDL/be_include/be_field.h index d8af5c0ba61..4fcb1535058 100644 --- a/TAO/TAO_IDL/be_include/be_field.h +++ b/TAO/TAO_IDL/be_include/be_field.h @@ -59,6 +59,9 @@ public: virtual long tc_encap_len (void); // return the total byte length of ourselves represented as an encapsulation + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_field, AST_Field, be_decl); DEF_NARROW_FROM_DECL (be_field); diff --git a/TAO/TAO_IDL/be_include/be_interface.h b/TAO/TAO_IDL/be_include/be_interface.h index 2a07ce23b32..f418864e982 100644 --- a/TAO/TAO_IDL/be_include/be_interface.h +++ b/TAO/TAO_IDL/be_include/be_interface.h @@ -101,6 +101,9 @@ public: char *relative_skel_name (const char *); // relative skeleton name + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_interface, AST_Interface, be_scope, be_type); DEF_NARROW_FROM_DECL (be_interface); diff --git a/TAO/TAO_IDL/be_include/be_interface_fwd.h b/TAO/TAO_IDL/be_include/be_interface_fwd.h index 4bec2a61528..ac97d8f9020 100644 --- a/TAO/TAO_IDL/be_include/be_interface_fwd.h +++ b/TAO/TAO_IDL/be_include/be_interface_fwd.h @@ -76,6 +76,9 @@ public: virtual long tc_size (void); // return typecode size + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_interface_fwd, AST_InterfaceFwd, be_type); DEF_NARROW_FROM_DECL (be_interface_fwd); diff --git a/TAO/TAO_IDL/be_include/be_module.h b/TAO/TAO_IDL/be_include/be_module.h index da1d76aeea2..519c5be9a43 100644 --- a/TAO/TAO_IDL/be_include/be_module.h +++ b/TAO/TAO_IDL/be_include/be_module.h @@ -56,6 +56,9 @@ public: virtual int gen_server_inline (void); // Generates the server-side inlines for the module + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_module, AST_Module, be_scope, be_decl); DEF_NARROW_FROM_DECL (be_module); diff --git a/TAO/TAO_IDL/be_include/be_native.h b/TAO/TAO_IDL/be_include/be_native.h index bf85c9acbff..70dd2254b57 100644 --- a/TAO/TAO_IDL/be_include/be_native.h +++ b/TAO/TAO_IDL/be_include/be_native.h @@ -60,6 +60,9 @@ public: virtual long tc_size (void); // return typecode size + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2(be_native, AST_Native, be_type); DEF_NARROW_FROM_DECL(be_native); diff --git a/TAO/TAO_IDL/be_include/be_operation.h b/TAO/TAO_IDL/be_include/be_operation.h index 75b3cb091a7..dbdd30b9e2e 100644 --- a/TAO/TAO_IDL/be_include/be_operation.h +++ b/TAO/TAO_IDL/be_include/be_operation.h @@ -58,6 +58,9 @@ public: virtual int argument_count (void); // return the count of members + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_operation, AST_Operation, be_scope, be_decl); DEF_NARROW_FROM_DECL (be_operation); diff --git a/TAO/TAO_IDL/be_include/be_predefined_type.h b/TAO/TAO_IDL/be_include/be_predefined_type.h index 7f94b4e3940..9afb62b3ec3 100644 --- a/TAO/TAO_IDL/be_include/be_predefined_type.h +++ b/TAO/TAO_IDL/be_include/be_predefined_type.h @@ -71,6 +71,9 @@ public: virtual long tc_encap_len (void); // return length of encapsulation + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_predefined_type, AST_PredefinedType, be_type); DEF_NARROW_FROM_DECL (be_predefined_type); diff --git a/TAO/TAO_IDL/be_include/be_root.h b/TAO/TAO_IDL/be_include/be_root.h index f1b16b8e22f..9cbe9c8d96d 100644 --- a/TAO/TAO_IDL/be_include/be_root.h +++ b/TAO/TAO_IDL/be_include/be_root.h @@ -65,6 +65,9 @@ public: AST_String *fe_add_string (AST_String *); AST_Array *fe_add_array (AST_Array *); + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_root, AST_Root, be_scope, be_decl); DEF_NARROW_FROM_DECL (be_root); diff --git a/TAO/TAO_IDL/be_include/be_scope.h b/TAO/TAO_IDL/be_include/be_scope.h index bf312c77aad..0a17593a99c 100644 --- a/TAO/TAO_IDL/be_include/be_scope.h +++ b/TAO/TAO_IDL/be_include/be_scope.h @@ -74,6 +74,9 @@ public: virtual be_decl *decl (void); // return the be_decl node corresponding to this scope node + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS1 (be_scope, UTL_Scope); DEF_NARROW_FROM_SCOPE (be_scope); diff --git a/TAO/TAO_IDL/be_include/be_sequence.h b/TAO/TAO_IDL/be_include/be_sequence.h index b179dbadb71..430b34a35c7 100644 --- a/TAO/TAO_IDL/be_include/be_sequence.h +++ b/TAO/TAO_IDL/be_include/be_sequence.h @@ -114,6 +114,9 @@ public: virtual be_decl *decl (void); // overridden method on the be_scope class + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_sequence, AST_Sequence, be_scope, be_type); DEF_NARROW_FROM_DECL (be_sequence); diff --git a/TAO/TAO_IDL/be_include/be_string.h b/TAO/TAO_IDL/be_include/be_string.h index ac89639779b..30f26043b31 100644 --- a/TAO/TAO_IDL/be_include/be_string.h +++ b/TAO/TAO_IDL/be_include/be_string.h @@ -68,6 +68,9 @@ public: virtual long tc_encap_len (void); // return length of encapsulation + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_string, AST_String, be_type); DEF_NARROW_FROM_DECL (be_string); diff --git a/TAO/TAO_IDL/be_include/be_structure.h b/TAO/TAO_IDL/be_include/be_structure.h index c0e131bffac..be9240dfb64 100644 --- a/TAO/TAO_IDL/be_include/be_structure.h +++ b/TAO/TAO_IDL/be_include/be_structure.h @@ -82,6 +82,9 @@ public: virtual int member_count (void); // return the count of members + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_structure, AST_Structure, be_scope, be_type); DEF_NARROW_FROM_DECL (be_structure); diff --git a/TAO/TAO_IDL/be_include/be_type.h b/TAO/TAO_IDL/be_include/be_type.h index a4cc6b5b17c..39834b02b9c 100644 --- a/TAO/TAO_IDL/be_include/be_type.h +++ b/TAO/TAO_IDL/be_include/be_type.h @@ -77,6 +77,9 @@ public: virtual char *nested_type_name (be_decl *d, char *suffix = 0); // type name of a node used when generating declarations + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_type, AST_Type, be_decl); DEF_NARROW_FROM_DECL (be_type); diff --git a/TAO/TAO_IDL/be_include/be_typedef.h b/TAO/TAO_IDL/be_include/be_typedef.h index 7d0e7270914..ce8802dab53 100644 --- a/TAO/TAO_IDL/be_include/be_typedef.h +++ b/TAO/TAO_IDL/be_include/be_typedef.h @@ -69,6 +69,9 @@ public: virtual long tc_encap_len (void); // return length of encapsulation + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_typedef, AST_Typedef, be_type); DEF_NARROW_FROM_DECL (be_typedef); diff --git a/TAO/TAO_IDL/be_include/be_union.h b/TAO/TAO_IDL/be_include/be_union.h index 74bc6d46927..7104b2403c9 100644 --- a/TAO/TAO_IDL/be_include/be_union.h +++ b/TAO/TAO_IDL/be_include/be_union.h @@ -84,6 +84,9 @@ public: virtual int default_index (void); // return the default index used + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS3 (be_union, AST_Union, be_scope, be_type); DEF_NARROW_FROM_DECL(be_union); diff --git a/TAO/TAO_IDL/be_include/be_union_branch.h b/TAO/TAO_IDL/be_include/be_union_branch.h index 81e512af36b..cc63f776d94 100644 --- a/TAO/TAO_IDL/be_include/be_union_branch.h +++ b/TAO/TAO_IDL/be_include/be_union_branch.h @@ -59,6 +59,9 @@ public: virtual long tc_encap_len (void); // return the total byte length of ourselves represented as an encapsulation + // Visiting + virtual int accept (be_visitor *visitor); + // Narrowing DEF_NARROW_METHODS2 (be_union_branch, AST_UnionBranch, be_decl); DEF_NARROW_FROM_DECL (be_union_branch); diff --git a/TAO/TAO_IDL/be_include/be_union_label.h b/TAO/TAO_IDL/be_include/be_union_label.h index d52770af90d..31b9abbba2a 100644 --- a/TAO/TAO_IDL/be_include/be_union_label.h +++ b/TAO/TAO_IDL/be_include/be_union_label.h @@ -9,6 +9,9 @@ public: // Operations be_union_label(); be_union_label(AST_UnionLabel::UnionLabel ul, AST_Expression *v); + + // Visiting + virtual int accept (be_visitor *visitor); }; #endif diff --git a/TAO/TAO_IDL/be_include/be_visitor.h b/TAO/TAO_IDL/be_include/be_visitor.h index a16663623ab..757c4fe38e9 100644 --- a/TAO/TAO_IDL/be_include/be_visitor.h +++ b/TAO/TAO_IDL/be_include/be_visitor.h @@ -91,6 +91,7 @@ public: virtual int visit_string (be_string *node); virtual int visit_typedef (be_typedef *node); virtual int visit_root (be_root *node); + virtual int visit_native (be_native *node); }; #endif // TAO_BE_VISITOR_H diff --git a/TAO/TAO_IDL/be_include/be_visitor_root.h b/TAO/TAO_IDL/be_include/be_visitor_root.h new file mode 100644 index 00000000000..2dca9c77ff2 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_root.h @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +// +// $Id$ +// + +#if !defined (TAO_BE_VISITOR_ROOT_H) +#define TAO_BE_VISITOR_ROOT_H + +#include "be_visitor.h" + +class be_visitor_root_ch +{ + // + // = TITLE + // Main visitor for the generation of the client header file. + // + // = DESCRIPTION + // This is a concrete visitor to generate the client header. + // + // = NOTE + // The current implementation only works for sequences. + // +public: + be_visitor_root_ch (void); + virtual ~be_visitor_root_ch (void); + + virtual int visit_sequence (be_sequence *node); +}; + +class be_visitor_root_cs +{ + // + // = TITLE + // Main visitor for the generation of the client header file. + // + // = DESCRIPTION + // This is a concrete visitor to generate the client header. + // + // = NOTE + // The current implementation only works for sequences. + // +public: + be_visitor_root_cs (void); + virtual ~be_visitor_root_cs (void); + + virtual int visit_sequence (be_sequence *node); +}; + +class be_visitor_root_ci +{ + // + // = TITLE + // Main visitor for the generation of the client header file. + // + // = DESCRIPTION + // This is a concrete visitor to generate the client header. + // + // = NOTE + // The current implementation only works for sequences. + // +public: + be_visitor_root_ci (void); + virtual ~be_visitor_root_ci (void); + + virtual int visit_sequence (be_sequence *node); +}; + +#endif // TAO_BE_VISITOR_ROOT_H diff --git a/TAO/orbsvcs/Scheduling_Service/Scheduler.cpp b/TAO/orbsvcs/Scheduling_Service/Scheduler.cpp index 2e6e1e25f37..d353581d86b 100644 --- a/TAO/orbsvcs/Scheduling_Service/Scheduler.cpp +++ b/TAO/orbsvcs/Scheduling_Service/Scheduler.cpp @@ -246,7 +246,7 @@ void ACE_Scheduler::export(RT_Info& info, FILE* file) #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Lock_Adapter<ACE_NULL_MUTEX>; +template class ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX>; template class ACE_Map_Entry<ACE_CString, ACE_Scheduler::RT_Info **>; template class ACE_Lock_Adapter<ACE_SYNCH_RW_MUTEX>; @@ -265,7 +265,7 @@ template class ACE_Map_Entry<ACE_CString, ACE_Scheduler::RT_Info **>; #elif defined(ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Lock_Adapter<ACE_Null_Mutex> +#pragma instantiate ACE_Lock_Adapter<ACE_SYNCH_NULL_MUTEX> #pragma instantiate ACE_Map_Entry<ACE_CString, ACE_Scheduler::RT_Info **> #pragma instantiate ACE_Lock_Adapter<ACE_SYNCH_RW_MUTEX> diff --git a/TAO/tao/Makefile b/TAO/tao/Makefile index 6848bc55fb6..25aa747d5ef 100644 --- a/TAO/tao/Makefile +++ b/TAO/tao/Makefile @@ -12,7 +12,7 @@ SHLIB = $(LIBNAME).$(SOEXT) # These are components that are only headers and must be installed CORBA_HDRS = orb sequence stub orbconf objtable optable $(CORBA_SRCS) CORBA_SRCS = any corbacom except nvlist object orbobj poa \ - principa request svrrqst typecode + principa request svrrqst typecode sequence # These are components that are only headers and must be installed OTHERS_HDRS = align cdr giop iiopobj iioporb xdr connect params marshal debug \ diff --git a/TAO/tao/corba.h b/TAO/tao/corba.h index ee58c67c9f2..1a2f61fed9b 100644 --- a/TAO/tao/corba.h +++ b/TAO/tao/corba.h @@ -89,6 +89,7 @@ // individual CORBA classes #include "tao/sequence.h" +#include "tao/sequence_T.h" #include "tao/any.h" #include "tao/poa.h" @@ -139,6 +140,7 @@ #include "tao/orb_core.i" #include "tao/corbacom.i" #include "tao/sequence.i" +#include "tao/sequence_T.i" #include "tao/typecode.i" #include "tao/nvlist.i" #include "tao/any.i" diff --git a/TAO/tao/corbacom.h b/TAO/tao/corbacom.h index 095b97151e4..48a4ce1d18b 100644 --- a/TAO/tao/corbacom.h +++ b/TAO/tao/corbacom.h @@ -142,6 +142,9 @@ struct CDR; // enum values defined in nvlist.h, bitwise ORed. typedef u_int CORBA_Flags; +// forward declare sequences. +template <class T> class TAO_Unbounded_Sequence; + template <class T> struct CORBA_SEQUENCE // = TITLE @@ -459,7 +462,7 @@ public: typedef CORBA_UserException UserException; - typedef CORBA_SEQUENCE <TypeCode_ptr> ExceptionList; + typedef CORBA_SEQUENCE<TypeCode_ptr> ExceptionList; typedef ExceptionList *ExceptionList_ptr; typedef CORBA_ImplementationDef *ImplementationDef_ptr; diff --git a/TAO/tao/sequence.cpp b/TAO/tao/sequence.cpp new file mode 100644 index 00000000000..9dd3b519957 --- /dev/null +++ b/TAO/tao/sequence.cpp @@ -0,0 +1,11 @@ +// +// $Id$ +// + +#include "tao/corba.h" + +TAO_Base_Sequence::~TAO_Base_Sequence (void) +{ + if (this->release_) + this->_deallocate_buffer (); +} diff --git a/TAO/tao/sequence.h b/TAO/tao/sequence.h index 3707cf3f75e..e25ee08cbe7 100644 --- a/TAO/tao/sequence.h +++ b/TAO/tao/sequence.h @@ -18,139 +18,82 @@ #if !defined (TAO_SEQUENCE_H) # define TAO_SEQUENCE_H -// unbounded sequences -template <class T> -class TAO_UnboundedSeq +class TAO_Base_Sequence { - // =TITLE - // TAO_UnboundedSeq - // =DESCRIPTION - // parametrized type for unbounded sequences + // = TITLE + // Base class for TAO sequences. + // + // = DESCRIPTION + // This class provides a common interface for all IDL sequences, + // hence the interpreted marshall engine can manipulate them in a + // type safe manner. + // public: + friend class TAO_Marshal_Sequence; + // We give access to TAO_Marshal_Sequence, this allows a safe yet + // small footprint implementation of the marshal engine. - typedef T ElemType; - - // =operations - - TAO_UnboundedSeq (void); - // default constructor - - TAO_UnboundedSeq (CORBA::ULong max); - // constructor using a maximum length value - - TAO_UnboundedSeq (CORBA::ULong max, CORBA::ULong length, T *data, - CORBA::Boolean release=0); - // constructor using the data and memory management flag - - TAO_UnboundedSeq (const TAO_UnboundedSeq<T> &); - // copy constructor - - ~TAO_UnboundedSeq (void); - // destructor - - TAO_UnboundedSeq<T> &operator= (const TAO_UnboundedSeq<T> &); - // assignment operator + virtual ~TAO_Base_Sequence (void); + // destructor. CORBA::ULong maximum (void) const; - // return the max length of the sequence + // return the maximum length of the sequence - void length (CORBA::ULong); + void length (CORBA::ULong length); // set the length CORBA::ULong length (void) const; // return the current length - T &operator[] (CORBA::ULong); - // operator [] - - const T &operator[] (CORBA::ULong) const; - // operator [] - - // =static operations - - static T *allocbuf (CORBA::ULong); - // allocate storage for the sequence - - static void freebuf (T *); - // free the sequence - -private: + virtual void _allocate_buffer (CORBA::ULong length) = 0; + // Ensure that the buffer contains space for at leat <length> + // elements. The constructor must be called for any new elements, + // the old ones (if any) must be copied into the buffer using + // operator= and then their destructors must be called. + // Finally the old buffer must be released. + + virtual void _deallocate_buffer (void) = 0; + // Releases the buffer and call the destructor for all the elements + // in it; remember that there are <maximum> elements in the buffer. + + virtual int _bounded (void) const = 0; + // Retuns 1 if the sequence is bounded (hence it cannot be resized) + // and 0 otherwise. + +protected: + TAO_Base_Sequence (void); + // Default constructor. + + TAO_Base_Sequence (CORBA::ULong maximum, + CORBA::ULong length, + void* buffer, + CORBA::Boolean release = 0); + // Constructor with control of ownership. + + TAO_Base_Sequence (CORBA::ULong maximum, + void* buffer); + // Assume ownership and set length to 0. + + TAO_Base_Sequence (const TAO_Base_Sequence& rhs); + TAO_Base_Sequence& operator=(const TAO_Base_Sequence& rhs); + // Copy constructor and assignment operator are protected, the + // derived classes must provided the right semantics for the buffer + // copy, only the static fields are actually copy. + +protected: CORBA::ULong maximum_; - // maximum length + // The maximum number of elements the buffer can contain. CORBA::ULong length_; - // length + // The current number of elements in the buffer. - T *buffer_; - // buffer + void* buffer_; + // The buffer with all the elements, casting must be done in derived + // classes. CORBA::Boolean release_; - // memory management - -}; - -// bounded sequences -template <class T, CORBA::ULong size> -class TAO_BoundedSeq -{ - // =TITLE - // TAO_BoundedSeq - // =DESCRIPTION - // parametrized type for Bounded sequences -public: - - typedef T ElemType; - - // =operations - - TAO_BoundedSeq (void); - // default constructor - - TAO_BoundedSeq (CORBA::ULong length, T *data, - CORBA::Boolean release=0); - // constructor using the data and memory management flag - - TAO_BoundedSeq (const TAO_BoundedSeq<T,size> &); - // copy constructor - - ~TAO_BoundedSeq (void); - // destructor - - TAO_BoundedSeq<T,size> &operator= (const TAO_BoundedSeq<T,size> &); - // assignment operator - - CORBA::ULong maximum (void) const; - // return the max length of the sequence - - void length (CORBA::ULong); - // set the length - - CORBA::ULong length (void) const; - // return the current length - - T &operator[] (CORBA::ULong); - // operator [] - - const T &operator[] (CORBA::ULong) const; - // operator [] - - // =static operations - - static T *allocbuf (CORBA::ULong); - // allocate storage for the sequence - - static void freebuf (T *); - // free the sequence - -private: - CORBA::ULong length_; - // length - - CORBA::Boolean release_; - // memory management - - T *buffer_; - // buffer + // If true then the sequence should release the buffer when it is + // destroyed. }; #endif /* TAO_SEQUENCE_H */ diff --git a/TAO/tao/sequence.i b/TAO/tao/sequence.i index f4b2b6d5968..45e7bbee81e 100644 --- a/TAO/tao/sequence.i +++ b/TAO/tao/sequence.i @@ -17,8 +17,8 @@ // operations on the unbounded sequence class -template <class T> ACE_INLINE -TAO_UnboundedSeq<T>::TAO_UnboundedSeq (void) +ACE_INLINE +TAO_Base_Sequence::TAO_Base_Sequence (void) : maximum_ (0), length_ (0), release_ (0), @@ -26,188 +26,72 @@ TAO_UnboundedSeq<T>::TAO_UnboundedSeq (void) { } -template <class T> ACE_INLINE -TAO_UnboundedSeq<T>::TAO_UnboundedSeq (CORBA::ULong max) - : maximum_ (max), - length_ (0), - release_ (1) // we own it -{ - buffer_ = TAO_UnboundedSeq<T>::allocbuf (max); -} - -template <class T> ACE_INLINE -TAO_UnboundedSeq<T>::TAO_UnboundedSeq (CORBA::ULong max, CORBA::ULong length, T - *data, CORBA::Boolean release) - : maxium_ (max), +ACE_INLINE +TAO_Base_Sequence::TAO_Base_Sequence (CORBA::ULong maximum, + CORBA::ULong length, + void* buffer, + CORBA::Boolean release) + : maximum_ (maximum), length_ (length), - buffer_ (data), + buffer_ (buffer), release_ (release) { } -template <class T> ACE_INLINE -TAO_UnboundedSeq<T>::TAO_UnboundedSeq (const TAO_UnboundedSeq<T> &seq) - : maximum_ (seq.maximum ()), - length_ (seq.length ()), - release_ (1) // we own this -{ - this->buffer_ = TAO_UnboundedSeq<T>::allocbuf (this->maximum_); - for (CORBA::ULong i=0; i < this->length_; i++) - this->buffer_[i] = seq[i]; -} - -template <class T> ACE_INLINE -TAO_UnboundedSeq<T>::~TAO_UnboundedSeq (void) -{ - if (this->release_) - TAO_UnboundedSeq<T>::freebuf (this->buffer_); - -} - -template <class T> ACE_INLINE TAO_UnboundedSeq<T> & -TAO_UnboundedSeq<T>::operator= (const TAO_UnboundedSeq<T> &seq) -{ - this->maximum_ = seq.maximum_; - this->length_ = seq.length_; - this->release_ = 1; - this->buffer_ = TAO_UnboundedSeq<T>::allocbuf (this->maximum_); - for (CORBA::ULong i=0; i < this->length_; i++) - this->buffer_[i] = seq[i]; -} - -template <class T> ACE_INLINE CORBA::ULong -TAO_UnboundedSeq<T>::maximum (void) const -{ - return this->maximum_; -} - -template <class T> ACE_INLINE void -TAO_UnboundedSeq<T>::length (CORBA::ULong length) -{ - this->length_ = length; -} - -template <class T> ACE_INLINE CORBA::ULong -TAO_UnboundedSeq<T>::length (void) const -{ - return this->length_; -} - -template <class T> ACE_INLINE T & -TAO_UnboundedSeq<T>::operator[] (CORBA::ULong i) -{ - ACE_ASSERT (i < this->length_); - return this->buffer_[i]; -} - -template <class T> ACE_INLINE const T & -TAO_UnboundedSeq<T>::operator[] (CORBA::ULong i) const -{ - ACE_ASSERT (i < this->length_); - return this->buffer_[i]; -} - -template <class T> ACE_INLINE T * -TAO_UnboundedSeq<T>::allocbuf (CORBA::ULong size) -{ - return new T[size]; -} - -template <class T> ACE_INLINE void -TAO_UnboundedSeq<T>::freebuf (T *buffer) -{ - delete [] buffer; -} - - -// operations on the Bounded sequence class - -template <class T, CORBA::ULong size> ACE_INLINE -TAO_BoundedSeq<T,size>::TAO_BoundedSeq (void) - : length_ (0), - release_ (0), - buffer_ (0) -{ -} - -template <class T, CORBA::ULong size> ACE_INLINE -TAO_BoundedSeq<T,size>::TAO_BoundedSeq (CORBA::ULong length, T *data, CORBA::Boolean - release) - : length_ (length), +ACE_INLINE +TAO_Base_Sequence::TAO_Base_Sequence (CORBA::ULong maximum, + void *data) + : maximum_ (maximum), + length_ (0), buffer_ (data), - release_ (release) + release_ (CORBA::B_TRUE) { } -template <class T, CORBA::ULong size> ACE_INLINE -TAO_BoundedSeq<T,size>::TAO_BoundedSeq (const TAO_BoundedSeq<T,size> &seq) - : length_ (seq.length ()), - release_ (1) // we own this +ACE_INLINE +TAO_Base_Sequence::TAO_Base_Sequence (const TAO_Base_Sequence &rhs) + : maximum_ (rhs.maximum_), + length_ (rhs.length_), + release_ (CORBA::B_TRUE) { - this->buffer_ = TAO_BoundedSeq<T,size>::allocbuf (this->length_); - for (CORBA::ULong i=0; i < this->length_; i++) - this->buffer_[i] = seq[i]; } -template <class T, CORBA::ULong size> ACE_INLINE -TAO_BoundedSeq<T,size>::~TAO_BoundedSeq (void) +ACE_INLINE TAO_Base_Sequence & +TAO_Base_Sequence::operator= (const TAO_Base_Sequence &rhs) { - if (this->release_) - TAO_BoundedSeq<T,size>::freebuf (this->buffer_); - + if (this != &rhs) + { + this->maximum_ = rhs.maximum_; + this->length_ = rhs.length_; + this->release_ = CORBA::B_TRUE; + } + return *this; } -template <class T, CORBA::ULong size> ACE_INLINE TAO_BoundedSeq<T,size> & -TAO_BoundedSeq<T,size>::operator= (const TAO_BoundedSeq<T,size> &seq) +ACE_INLINE CORBA::ULong +TAO_Base_Sequence::maximum (void) const { - this->length_ = seq.length_; - this->release_ = 1; - this->buffer_ = TAO_BoundedSeq<T,size>::allocbuf (this->length_); - for (CORBA::ULong i=0; i < this->length_; i++) - this->buffer_[i] = seq[i]; -} - -template <class T, CORBA::ULong size> ACE_INLINE CORBA::ULong -TAO_BoundedSeq<T,size>::maximum (void) const -{ - return this->length_; + return this->maximum_; } -template <class T, CORBA::ULong size> ACE_INLINE void -TAO_BoundedSeq<T,size>::length (CORBA::ULong length) +ACE_INLINE void +TAO_Base_Sequence::length (CORBA::ULong length) { + if (length > this->maximum_) + { + if (this->_bounded ()) + { + // @@ TODO maybe we should throw? + return; + } + this->_allocate_buffer (length); + this->maximum_ = length; + } this->length_ = length; } -template <class T, CORBA::ULong size> ACE_INLINE CORBA::ULong -TAO_BoundedSeq<T,size>::length (void) const +ACE_INLINE CORBA::ULong +TAO_Base_Sequence::length (void) const { return this->length_; } - -template <class T, CORBA::ULong size> ACE_INLINE T & -TAO_BoundedSeq<T,size>::operator[] (CORBA::ULong i) -{ - ACE_ASSERT (i < this->length_); - return this->buffer_[i]; -} - -template <class T, CORBA::ULong size> ACE_INLINE const T & -TAO_BoundedSeq<T,size>::operator[] (CORBA::ULong i) const -{ - ACE_ASSERT (i < this->length_); - return this->buffer_[i]; -} - -template <class T, CORBA::ULong size> ACE_INLINE T * -TAO_BoundedSeq<T,size>::allocbuf (CORBA::ULong size) -{ - return new T[size]; -} - -template <class T, CORBA::ULong size> ACE_INLINE void -TAO_BoundedSeq<T,size>::freebuf (T *buffer) -{ - delete [] buffer; -} - diff --git a/TAO/tao/sequence_T.cpp b/TAO/tao/sequence_T.cpp new file mode 100644 index 00000000000..41858976368 --- /dev/null +++ b/TAO/tao/sequence_T.cpp @@ -0,0 +1,69 @@ +/* -*- C++ -*- */ + +// +// $Id$ +// + +#if !defined (TAO_SEQUENCE_T_C) +#define TAO_SEQUENCE_T_C + +template<class T> +void TAO_Unbounded_Sequence<T>::_allocate_buffer (CORBA::ULong length) +{ + T* tmp; + ACE_NEW (tmp, T[length]); + + if (this->buffer_ != 0) + { + T* old = ACE_reinterpret_cast(T*,this->buffer_); + for (CORBA::ULong i = 0; i < this->length_; ++i) + { + tmp[i] = old[i]; + } + delete[] old; + } + this->buffer_ = tmp; +} + +template<class T> +void TAO_Unbounded_Sequence<T>::_deallocate_buffer (void) +{ + if (this->buffer_ == 0) + return; + T* tmp = ACE_reinterpret_cast (T*,this->buffer_); + delete[] tmp; + this->buffer_ = 0; +} + +template<class T> +int TAO_Unbounded_Sequence<T>::_bounded (void) const +{ + return 0; +} + +template<class T, CORBA::ULong MAX> +void TAO_Bounded_Sequence<T,MAX>::_allocate_buffer (CORBA::ULong) +{ + // For this class memory is never reallocated so the implementation + // is *really* simple. + ACE_NEW (this->buffer_, T[MAX]); + this->maximum_ = MAX; +} + +template<class T, CORBA::ULong MAX> +void TAO_Bounded_Sequence<T,MAX>::_deallocate_buffer (void) +{ + if (this->buffer_ == 0) + return; + T* tmp = ACE_reinterpret_cast (T*,this->buffer_); + delete[] tmp; + this->buffer_ = 0; +} + +template<class T, CORBA::ULong MAX> +int TAO_Bounded_Sequence<T,MAX>::_bounded (void) const +{ + return 0; +} + +#endif /* TAO_SEQUENCE_T_C */ diff --git a/TAO/tao/sequence_T.i b/TAO/tao/sequence_T.i new file mode 100644 index 00000000000..bfbd1c9b0b5 --- /dev/null +++ b/TAO/tao/sequence_T.i @@ -0,0 +1,156 @@ +/* -*- C++ -*- */ + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// sequence.i +// +// = AUTHOR +// Copyright 1994-1995 by Sun Microsystems Inc. +// +// Aniruddha Gokhale +// +// ============================================================================ + +// operations on the unbounded sequence class + +template <class T> ACE_INLINE +TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (void) +{ +} + +template <class T> ACE_INLINE +TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (CORBA::ULong maximum) + : TAO_Base_Sequence (maximum, + TAO_Unbounded_Sequence<T>::allocbuf (maximum)) +{ +} + +template <class T> ACE_INLINE +TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (CORBA::ULong maximum, + CORBA::ULong length, + T *data, + CORBA::Boolean release) + : TAO_Base_Sequence (maximum, length, data, release) +{ +} + +template <class T> ACE_INLINE +TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (const TAO_Unbounded_Sequence<T> &rhs) + : TAO_Base_Sequence (rhs), +{ + this->buffer_ = TAO_Unbounded_Sequence<T>::allocbuf (this->maximum_); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp[i] = rhs[i]; +} + +template <class T> ACE_INLINE TAO_Unbounded_Sequence<T> & +TAO_Unbounded_Sequence<T>::operator= (const TAO_Unbounded_Sequence<T> &rhs) +{ + if (this != &rhs) + { + this->TAO_Base_Sequence::operator= (rhs); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp[i] = rhs[i]; + } + return *this; +} + +template <class T> ACE_INLINE T & +TAO_Unbounded_Sequence<T>::operator[] (CORBA::ULong i) +{ + ACE_ASSERT (i < this->length_); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + return tmp[i]; +} + +template <class T> ACE_INLINE const T & +TAO_Unbounded_Sequence<T>::operator[] (CORBA::ULong i) const +{ + ACE_ASSERT (i < this->length_); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + return tmp[i]; +} + +template <class T> ACE_INLINE T * +TAO_Unbounded_Sequence<T>::allocbuf (CORBA::ULong size) +{ + return new T[size]; +} + +template <class T> ACE_INLINE void +TAO_Unbounded_Sequence<T>::freebuf (T *buffer) +{ + delete [] buffer; +} + +// operations on the Bounded sequence class + +template <class T, CORBA::ULong MAX> ACE_INLINE +TAO_Bounded_Sequence<T,MAX>::TAO_Bounded_Sequence (void) +{ +} + +template <class T, CORBA::ULong MAX> ACE_INLINE +TAO_Bounded_Sequence<T,MAX>::TAO_Bounded_Sequence (CORBA::ULong length, + T *data, + CORBA::Boolean release) + : TAO_Base_Sequence (length, MAX, data, release) +{ +} + +template <class T, CORBA::ULong MAX> ACE_INLINE +TAO_Bounded_Sequence<T,MAX>::TAO_Bounded_Sequence (const TAO_Bounded_Sequence<T,MAX> &rhs) + : TAO_Base_Sequence (rhs) +{ + this->buffer_ = TAO_Bounded_Sequence<T,MAX>::allocbuf (MAX); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp[i] = rhs[i]; +} + +template <class T, CORBA::ULong MAX> ACE_INLINE TAO_Bounded_Sequence<T,MAX> & +TAO_Bounded_Sequence<T,MAX>::operator= (const TAO_Bounded_Sequence<T,MAX> &rhs) +{ + if (this != &rhs) + { + this->TAO_Base_Sequence::operator= (rhs); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + for (CORBA::ULong i = 0; i < this->length_; ++i) + tmp[i] = seq[i]; + } + return *this; +} + +template <class T, CORBA::ULong MAX> ACE_INLINE T & +TAO_Bounded_Sequence<T,MAX>::operator[] (CORBA::ULong i) +{ + ACE_ASSERT (i < this->length_); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + return tmp[i]; +} + +template <class T, CORBA::ULong MAX> ACE_INLINE const T & +TAO_Bounded_Sequence<T,MAX>::operator[] (CORBA::ULong i) const +{ + ACE_ASSERT (i < this->length_); + T* tmp = ACE_reinterpret_cast(T*,this->buffer); + return tmp[i]; +} + +template <class T, CORBA::ULong MAX> ACE_INLINE T * +TAO_Bounded_Sequence<T,MAX>::allocbuf (CORBA::ULong size) +{ + return new T[size]; +} + +template <class T, CORBA::ULong MAX> ACE_INLINE void +TAO_Bounded_Sequence<T,MAX>::freebuf (T *buffer) +{ + delete [] buffer; +} |