diff options
author | Fred Hornsey <hornseyf@objectcomputing.com> | 2021-06-21 20:22:55 -0500 |
---|---|---|
committer | Fred Hornsey <hornseyf@objectcomputing.com> | 2021-06-21 20:22:55 -0500 |
commit | 2ed7fe7c1c6492c7f920581ec3ac8e7ec4278efd (patch) | |
tree | 7580b073445bd321afe9b4e3a0764108595c48c6 | |
parent | b489eefef18d6c538d5498350bb732bc51792f50 (diff) | |
download | ATCD-2ed7fe7c1c6492c7f920581ec3ac8e7ec4278efd.tar.gz |
Support int8/uint8 Sequences and Arrays
26 files changed, 571 insertions, 267 deletions
diff --git a/ACE/ace/CDR_Stream.h b/ACE/ace/CDR_Stream.h index 9ac1f49c55b..4fbe13c3f7e 100644 --- a/ACE/ace/CDR_Stream.h +++ b/ACE/ace/CDR_Stream.h @@ -197,6 +197,18 @@ public: ACE_CDR::WChar val_; }; + struct ACE_Export from_int8 + { + explicit from_int8 (ACE_CDR::Int8 val); + ACE_CDR::Int8 val_; + }; + + struct ACE_Export from_uint8 + { + explicit from_uint8 (ACE_CDR::UInt8 val); + ACE_CDR::UInt8 val_; + }; + struct ACE_Export from_string { from_string (ACE_CDR::Char* s, @@ -795,6 +807,18 @@ public: ACE_CDR::Octet &ref_; }; + struct ACE_Export to_int8 + { + explicit to_int8 (ACE_CDR::Int8 &ref); + ACE_CDR::Int8 &ref_; + }; + + struct ACE_Export to_uint8 + { + explicit to_uint8 (ACE_CDR::UInt8 &ref); + ACE_CDR::UInt8 &ref_; + }; + struct ACE_Export to_string { /** @@ -1392,8 +1416,6 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_CDR::Double x); extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, const ACE_CDR::Fixed &x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_CDR::UInt8 x); -extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_CDR::Int8 x); // CDR output operator from helper classes @@ -1423,6 +1445,8 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, const std::wstring& x); #endif +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_CDR::from_uint8 x); +extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_CDR::from_int8 x); // Not used by CORBA or TAO extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, @@ -1449,8 +1473,6 @@ extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_CDR::Double &x); extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_CDR::Fixed &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &os, ACE_CDR::UInt8 &x); -extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &os, ACE_CDR::Int8 &x); // CDR input operator from helper classes @@ -1480,6 +1502,8 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_InputCDR &os, extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is, std::wstring& x); #endif +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &os, ACE_CDR::to_uint8 x); +extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &os, ACE_CDR::to_int8 x); ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/CDR_Stream.inl b/ACE/ace/CDR_Stream.inl index 9e4380fbde1..5f0a55da680 100644 --- a/ACE/ace/CDR_Stream.inl +++ b/ACE/ace/CDR_Stream.inl @@ -162,6 +162,30 @@ ACE_OutputCDR::from_std_wstring::from_std_wstring (const std::wstring &ws, #endif ACE_INLINE +ACE_InputCDR::to_int8::to_int8 (ACE_CDR::Int8 &ref) + : ref_ (ref) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_int8::from_int8 (ACE_CDR::Int8 val) + : val_ (val) +{ +} + +ACE_INLINE +ACE_InputCDR::to_uint8::to_uint8 (ACE_CDR::UInt8 &ref) + : ref_ (ref) +{ +} + +ACE_INLINE +ACE_OutputCDR::from_uint8::from_uint8 (ACE_CDR::UInt8 val) + : val_ (val) +{ +} + +ACE_INLINE ACE_InputCDR::Transfer_Contents::Transfer_Contents (ACE_InputCDR &rhs) : rhs_ (rhs) { @@ -1374,20 +1398,6 @@ operator<< (ACE_OutputCDR &os, const std::wstring& x) } #endif -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::UInt8 x) -{ - os.write_uint8 (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator<< (ACE_OutputCDR &os, ACE_CDR::Int8 x) -{ - os.write_int8 (x); - return (ACE_CDR::Boolean) os.good_bit (); -} - // The following use the helper classes ACE_INLINE ACE_CDR::Boolean operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_boolean x) @@ -1447,6 +1457,20 @@ operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_wstring x) (ACE_CDR::Boolean) (os.good_bit () && (!x.bound_ || len <= x.bound_)); } +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_uint8 x) +{ + os.write_uint8 (x.val_); + return (ACE_CDR::Boolean) os.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator<< (ACE_OutputCDR &os, ACE_OutputCDR::from_int8 x) +{ + os.write_int8 (x.val_); + return (ACE_CDR::Boolean) os.good_bit (); +} + // **************************************************************** ACE_INLINE ACE_CDR::Boolean @@ -1541,18 +1565,6 @@ operator>> (ACE_InputCDR &is, std::wstring& x) } #endif -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::UInt8 &x) -{ - return is.read_uint8 (x) && is.good_bit (); -} - -ACE_INLINE ACE_CDR::Boolean -operator>> (ACE_InputCDR &is, ACE_CDR::Int8 &x) -{ - return is.read_int8 (x) && is.good_bit (); -} - // The following use the helper classes ACE_INLINE ACE_CDR::Boolean operator>> (ACE_InputCDR &is, ACE_InputCDR::to_boolean x) @@ -1623,6 +1635,19 @@ operator>> (ACE_InputCDR &is, ACE_InputCDR::to_std_wstring x) || static_cast<ACE_CDR::ULong> (x.val_.size ()) <= x.bound_)); } #endif + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_uint8 x) +{ + return is.read_uint8 (x.ref_) && is.good_bit (); +} + +ACE_INLINE ACE_CDR::Boolean +operator>> (ACE_InputCDR &is, ACE_InputCDR::to_int8 x) +{ + return is.read_int8 (x.ref_) && is.good_bit (); +} + // *************************************************************************** // We must define these methods here because they use the "read_*" inlined // methods of the ACE_InputCDR class diff --git a/TAO/TAO_IDL/ast/ast_expression.cpp b/TAO/TAO_IDL/ast/ast_expression.cpp index 36372478e10..d1705399e7f 100644 --- a/TAO/TAO_IDL/ast/ast_expression.cpp +++ b/TAO/TAO_IDL/ast/ast_expression.cpp @@ -768,7 +768,7 @@ coerce_value (AST_Expression::AST_ExprValue *ev, ev->et = AST_Expression::EV_ushort; return ev; case AST_Expression::EV_int8: - if (ev->u.int8val < 0) return 0; + if (ev->u.int8val < 0) return nullptr; ev->u.usval = static_cast<unsigned short> (ev->u.int8val); ev->et = t; return ev; @@ -949,7 +949,7 @@ coerce_value (AST_Expression::AST_ExprValue *ev, ev->et = AST_Expression::EV_ulong; return ev; case AST_Expression::EV_int8: - if (ev->u.int8val < 0) return 0; + if (ev->u.int8val < 0) return nullptr; ev->u.ulval = static_cast<unsigned long> (ev->u.int8val); ev->et = t; return ev; @@ -1119,7 +1119,7 @@ coerce_value (AST_Expression::AST_ExprValue *ev, ev->et = AST_Expression::EV_ulonglong; return ev; case AST_Expression::EV_int8: - if (ev->u.int8val < 0) return 0; + if (ev->u.int8val < 0) return nullptr; ev->u.ullval = static_cast<ACE_UINT64> (ev->u.int8val); ev->et = t; return ev; diff --git a/TAO/TAO_IDL/ast/ast_sequence.cpp b/TAO/TAO_IDL/ast/ast_sequence.cpp index 94dcbd97893..d8b57129573 100644 --- a/TAO/TAO_IDL/ast/ast_sequence.cpp +++ b/TAO/TAO_IDL/ast/ast_sequence.cpp @@ -245,6 +245,19 @@ AST_Sequence::base_type () const return this->pd_base_type; } +AST_Type * +AST_Sequence::primitive_base_type () const +{ + AST_Type *type_node = dynamic_cast<AST_Type *> (base_type ()); + if (type_node && type_node->node_type () == AST_Decl::NT_typedef) + { + AST_Typedef *typedef_node = dynamic_cast<AST_Typedef*> (type_node); + if (typedef_node) return nullptr; + type_node = typedef_node->primitive_base_type (); + } + return type_node; +} + bool AST_Sequence::unbounded () const { diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index 77c2f2490ec..09ac9fcb692 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -110,6 +110,14 @@ be_predefined_type::gen_member_ostream_operator (TAO_OutStream *os, *os << "ACE_OutputCDR::from_wchar (" << instance_name << (accessor ? " ()" : "") << ")"; break; + case AST_PredefinedType::PT_uint8: + *os << "ACE_OutputCDR::from_uint8 (" << instance_name + << (accessor ? " ()" : "") << ")"; + break; + case AST_PredefinedType::PT_int8: + *os << "ACE_OutputCDR::from_int8 (" << instance_name + << (accessor ? " ()" : "") << ")"; + break; case AST_PredefinedType::PT_object: case AST_PredefinedType::PT_abstract: case AST_PredefinedType::PT_pseudo: diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index e59a718ad6d..abb53381d2b 100644 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ b/TAO/TAO_IDL/be/be_sequence.cpp @@ -95,22 +95,10 @@ be_sequence::be_sequence (AST_Expression *v, break; } - AST_Decl::NodeType nt = t->node_type (); - AST_Typedef *td = nullptr; - AST_Type *pbt = nullptr; - - if (nt == AST_Decl::NT_typedef) - { - td = dynamic_cast<AST_Typedef*> (t); - pbt = td->primitive_base_type (); - nt = pbt->node_type (); - } - - if (nt == AST_Decl::NT_pre_defined) + AST_Type *const base_type = primitive_base_type (); + if (base_type && base_type->node_type () == AST_Decl::NT_pre_defined) { - AST_PredefinedType *pdt = - dynamic_cast<AST_PredefinedType*> (pbt ? pbt : t); - + AST_PredefinedType *pdt = dynamic_cast<AST_PredefinedType*> (base_type); switch (pdt->pt ()) { case AST_PredefinedType::PT_octet: @@ -280,31 +268,16 @@ be_sequence::managed_type () if (this->mt_ == be_sequence::MNG_UNKNOWN) // Not calculated yet. { // Base types. - be_type *bt = nullptr; - be_type *prim_type = nullptr; - - bt = dynamic_cast<be_type*> (this->base_type ()); - - if (!bt) + be_type *const base_type = dynamic_cast<be_type*> (primitive_base_type ()); + if (!base_type) ACE_ERROR_RETURN ((LM_ERROR, "TAO_IDL (%N:%l) " "dynamic_cast<be_type*> " "failed\n"), be_sequence::MNG_UNKNOWN); - if (bt->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = dynamic_cast<be_typedef*> (bt); - prim_type = t->primitive_base_type (); - } - else - { - prim_type = bt; - } - // Determine if we need a managed type and which one. - switch (prim_type->node_type ()) + switch (base_type->node_type ()) { case AST_Decl::NT_interface: case AST_Decl::NT_interface_fwd: @@ -329,7 +302,7 @@ be_sequence::managed_type () case AST_Decl::NT_pre_defined: { be_predefined_type * const bpd = - dynamic_cast<be_predefined_type*> (prim_type); + dynamic_cast<be_predefined_type*> (base_type); AST_PredefinedType::PredefinedType pt = bpd->pt (); @@ -426,10 +399,8 @@ be_sequence::instance_name () '\0', NAMEBUFSIZE); - be_type *bt = nullptr; - bt = dynamic_cast<be_type*> (this->base_type ()); - - if (bt == nullptr) + be_type *const prim_type = dynamic_cast<be_type *> (primitive_base_type ()); + if (!prim_type) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -439,18 +410,6 @@ be_sequence::instance_name () return namebuf; } - // Generate the class name. - - // The base type after removing all the aliases. - be_type *prim_type = bt; - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = dynamic_cast<be_typedef*> (bt); - prim_type = t->primitive_base_type (); - } - // Generate the appropriate sequence type. switch (this->managed_type ()) { @@ -621,19 +580,8 @@ be_sequence::gen_base_class_name (TAO_OutStream *os, break; case be_sequence::MNG_STRING: { - be_type *prim_type = nullptr; - if (elem->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = dynamic_cast<be_typedef*> (elem); - prim_type = t->primitive_base_type (); - } - else - { - prim_type = elem; - } - - if (prim_type->node_type () == AST_Decl::NT_string) + be_type *const prim_type = dynamic_cast<be_type *> (primitive_base_type ()); + if (prim_type && prim_type->node_type () == AST_Decl::NT_string) { be_string *str = dynamic_cast<be_string*> (prim_type); @@ -680,19 +628,8 @@ be_sequence::gen_base_class_name (TAO_OutStream *os, break; case be_sequence::MNG_WSTRING: { - be_type *prim_type = nullptr; - if (elem->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = dynamic_cast<be_typedef*> (elem); - prim_type = t->primitive_base_type (); - } - else - { - prim_type = elem; - } - - if (prim_type->node_type () == AST_Decl::NT_wstring) + be_type *const prim_type = dynamic_cast<be_type *> (primitive_base_type ()); + if (prim_type && prim_type->node_type () == AST_Decl::NT_wstring) { be_string *str = dynamic_cast<be_string*> (prim_type); @@ -744,46 +681,59 @@ be_sequence::gen_base_class_name (TAO_OutStream *os, if (this->unbounded ()) { *os << "::TAO::unbounded_array_sequence<" << linebreak - << be_idt << be_idt_nl - << elem->nested_type_name (ctx_scope) << "," << linebreak - << be_nl; - *os << elem->nested_type_name (ctx_scope) << "_slice," - << linebreak << be_nl - << elem->nested_type_name (ctx_scope) << "_tag" - << linebreak << be_uidt_nl - << ">" << be_uidt; + << be_idt << be_idt_nl + << elem->nested_type_name (ctx_scope) << "," << linebreak + << be_nl; + *os << elem->nested_type_name (ctx_scope) << "_slice," + << linebreak << be_nl + << elem->nested_type_name (ctx_scope) << "_tag" + << linebreak << be_uidt_nl + << ">" << be_uidt; } else { *os << "::TAO::bounded_array_sequence<" << linebreak - << be_idt << be_idt_nl - << elem->nested_type_name (ctx_scope) << "," << linebreak - << be_nl; - *os << elem->nested_type_name (ctx_scope) << "_slice," - << linebreak << be_nl - << elem->nested_type_name (ctx_scope) << "_tag," - << linebreak << be_nl - << this->max_size ()->ev ()->u.ulval << linebreak - << be_uidt_nl - << ">" << be_uidt; + << be_idt << be_idt_nl + << elem->nested_type_name (ctx_scope) << "," << linebreak + << be_nl; + *os << elem->nested_type_name (ctx_scope) << "_slice," + << linebreak << be_nl + << elem->nested_type_name (ctx_scope) << "_tag," + << linebreak << be_nl + << this->max_size ()->ev ()->u.ulval << linebreak + << be_uidt_nl + << ">" << be_uidt; } break; default: - if (this->unbounded ()) - { - *os << "::TAO::unbounded_value_sequence< " - << elem->nested_type_name (ctx_scope) - << ">"; - } - else - { - *os << "::TAO::bounded_value_sequence< " - << elem->nested_type_name (ctx_scope) << "," - << this->max_size ()->ev ()->u.ulval - << ">"; - } + { + const char *tag = ""; + be_type *const base_type = dynamic_cast<be_type*> (primitive_base_type ()); + if (base_type && base_type->node_type () == AST_Decl::NT_pre_defined) + { + be_predefined_type *const predefined_type = + dynamic_cast<be_predefined_type*> (base_type); + switch (predefined_type->pt ()) + { + case AST_PredefinedType::PT_uint8: + tag = ", CORBA::IDLv4::UInt8_tag"; + break; + case AST_PredefinedType::PT_int8: + tag = ", CORBA::IDLv4::Int8_tag"; + break; + default: + break; + } + } + *os + << "::TAO::" << (unbounded () ? "un" : "") << "bounded_value_sequence< " + << elem->nested_type_name (ctx_scope); + if (!unbounded ()) + *os << "," << this->max_size ()->ev ()->u.ulval; + *os << tag << ">"; + } break; } diff --git a/TAO/TAO_IDL/be/be_visitor_any_extracted_type_decl.cpp b/TAO/TAO_IDL/be/be_visitor_any_extracted_type_decl.cpp index e9bc800f9a7..440369d0354 100644 --- a/TAO/TAO_IDL/be/be_visitor_any_extracted_type_decl.cpp +++ b/TAO/TAO_IDL/be/be_visitor_any_extracted_type_decl.cpp @@ -108,6 +108,16 @@ be_visitor_any_extracted_type_decl::visit_predefined_type ( << "::CORBA::Any::to_wchar " << var_name_ << " (" << tmp_name_ << ");"; break; + case AST_PredefinedType::PT_uint8: + os_ << tmp_name_ << " = 0;" << be_nl + << "::CORBA::Any::to_uint8 " << var_name_ + << " (" << tmp_name_ << ");"; + break; + case AST_PredefinedType::PT_int8: + os_ << tmp_name_ << " = 0;" << be_nl + << "::CORBA::Any::to_int8 " << var_name_ + << " (" << tmp_name_ << ");"; + break; case AST_PredefinedType::PT_short: case AST_PredefinedType::PT_ushort: case AST_PredefinedType::PT_long: diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp index 160bf640597..c66e3219503 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp @@ -363,6 +363,12 @@ be_visitor_array_cdr_op_cs::visit_predefined_type ( case AST_PredefinedType::PT_boolean: *os << "boolean_array"; break; + case AST_PredefinedType::PT_uint8: + *os << "uint8_array"; + break; + case AST_PredefinedType::PT_int8: + *os << "int8_array"; + break; default: ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_array_cdr_op_cs::" @@ -431,6 +437,12 @@ be_visitor_array_cdr_op_cs::visit_predefined_type ( case AST_PredefinedType::PT_boolean: *os << "ACE_CDR::Boolean"; break; + case AST_PredefinedType::PT_uint8: + *os << "ACE_CDR::UInt8"; + break; + case AST_PredefinedType::PT_int8: + *os << "ACE_CDR::Int8"; + break; default: ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_array_cdr_op_cs::" diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp index 79c2c13aff0..78bdd8dc7cb 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp @@ -500,6 +500,16 @@ be_visitor_field_cdr_op_cs::visit_predefined_type (be_predefined_type *node) *os << "(strm >> ::ACE_InputCDR::to_boolean (_tao_aggregate." << f->local_name () << "))"; } + else if (pt == AST_PredefinedType::PT_uint8) + { + *os << "(strm >> ::ACE_InputCDR::to_uint8 (_tao_aggregate." + << f->local_name () << "))"; + } + else if (pt == AST_PredefinedType::PT_int8) + { + *os << "(strm >> ::ACE_InputCDR::to_int8 (_tao_aggregate." + << f->local_name () << "))"; + } else { *os << "(strm >> _tao_aggregate." << f->local_name () << ")"; @@ -531,6 +541,16 @@ be_visitor_field_cdr_op_cs::visit_predefined_type (be_predefined_type *node) *os << "(strm << ::ACE_OutputCDR::from_boolean (_tao_aggregate." << f->local_name () << "))"; } + else if (pt == AST_PredefinedType::PT_uint8) + { + *os << "(strm << ::ACE_OutputCDR::from_uint8 (_tao_aggregate." + << f->local_name () << "))"; + } + else if (pt == AST_PredefinedType::PT_int8) + { + *os << "(strm << ::ACE_OutputCDR::from_int8 (_tao_aggregate." + << f->local_name () << "))"; + } else { *os << "(strm << _tao_aggregate." << f->local_name () << ")"; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 498b403d1da..6727ee57e58 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -529,6 +529,12 @@ be_visitor_operation::gen_arg_template_param_name (AST_Decl *scope, case AST_PredefinedType::PT_wchar: *os << "::ACE_InputCDR::to_wchar"; return; + case AST_PredefinedType::PT_uint8: + *os << "::ACE_InputCDR::to_uint8"; + return; + case AST_PredefinedType::PT_int8: + *os << "::ACE_InputCDR::to_int8"; + return; case AST_PredefinedType::PT_void: break; default: diff --git a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp index f3173b1742b..9072ec9a74b 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp @@ -21,6 +21,49 @@ be_visitor_union_cdr_op_cs::~be_visitor_union_cdr_op_cs () { } +namespace { + void + serialize_disc (TAO_OutStream *os, AST_Expression::ExprType disc_type, bool out) + { + const char* tmp_suffix = nullptr; + switch (disc_type) + { + case AST_Expression::EV_bool: + tmp_suffix = "boolean"; + break; + case AST_Expression::EV_char: + tmp_suffix = "char"; + break; + case AST_Expression::EV_wchar: + tmp_suffix = "wchar"; + break; + case AST_Expression::EV_uint8: + tmp_suffix = "uint8"; + break; + case AST_Expression::EV_int8: + tmp_suffix = "int8"; + break; + default: + break; + } + + const char* val = out ? "_tao_union._d ()" : "_tao_discriminant"; + if (tmp_suffix) + { + *os << (out ? "::ACE_OutputCDR::from_" : "::ACE_InputCDR::to_") + << tmp_suffix << " tmp (" << val << ");" << be_nl; + val = "tmp"; + } + + *os + << "if (!(strm " << (out ? "<<" : ">>") << " " << val << "))" << be_idt_nl + << "{" << be_idt_nl + << "return false;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "::CORBA::Boolean result = true;" << be_nl_2; + } +} + int be_visitor_union_cdr_op_cs::visit_union (be_union *node) { @@ -84,37 +127,9 @@ be_visitor_union_cdr_op_cs::visit_union (be_union *node) << ")" << be_uidt_nl << "{" << be_idt_nl; - bool boolDisc = false; - - switch (node->udisc_type ()) - { - case AST_Expression::EV_bool: - boolDisc = true; - *os << "::ACE_OutputCDR::from_boolean tmp (_tao_union._d ());" << be_nl - << "if ( !(strm << tmp) )" << be_idt_nl; - - break; - case AST_Expression::EV_char: - *os << "::ACE_OutputCDR::from_char tmp (_tao_union._d ());" << be_nl - << "if ( !(strm << tmp) )" << be_idt_nl; - - break; - case AST_Expression::EV_wchar: - *os << "::ACE_OutputCDR::from_wchar tmp (_tao_union._d ());" << be_nl - << "if ( !(strm << tmp) )" << be_idt_nl; - - break; - default: - *os << "if ( !(strm << _tao_union._d ()) )" << be_idt_nl; - - break; - } - - *os << "{" << be_idt_nl - << "return false;" << be_uidt_nl - << "}" << be_uidt_nl << be_nl - << "::CORBA::Boolean result = true;" << be_nl_2; + serialize_disc (os, node->udisc_type (), true /* out */); + const bool boolDisc = node->udisc_type () == AST_Expression::EV_bool; if (!boolDisc) { *os << "switch (_tao_union._d ())" << be_nl @@ -165,33 +180,7 @@ be_visitor_union_cdr_op_cs::visit_union (be_union *node) *os << disc_type->full_name () << " " << "_tao_discriminant;" << be_nl; - switch (node->udisc_type ()) - { - case AST_Expression::EV_bool: - *os << "::ACE_InputCDR::to_boolean tmp (_tao_discriminant);" << be_nl - << "if ( !(strm >> tmp) )" << be_idt_nl; - - break; - case AST_Expression::EV_char: - *os << "::ACE_InputCDR::to_char tmp (_tao_discriminant);" << be_nl - << "if ( !(strm >> tmp) )" << be_idt_nl; - - break; - case AST_Expression::EV_wchar: - *os << "::ACE_InputCDR::to_wchar tmp (_tao_discriminant);" << be_nl - << "if ( !(strm >> tmp) )" << be_idt_nl; - - break; - default: - *os << "if ( !(strm >> _tao_discriminant) )" << be_idt_nl; - - break; - } - - *os << "{" << be_idt_nl - << "return false;" << be_uidt_nl - << "}" << be_uidt_nl << be_nl - << "::CORBA::Boolean result = true;" << be_nl_2; + serialize_disc (os, node->udisc_type (), false /* in */); if (boolDisc) { diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp index 5fb6a632f95..f02c02b38a8 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp @@ -574,6 +574,28 @@ be_visitor_union_branch_cdr_op_cs::visit_predefined_type ( << "_tao_union." << f->local_name () << " (_tao_union_tmp);"; } + else if (pt == AST_PredefinedType::PT_uint8) + { + *os << "::CORBA::UInt8 _tao_union_tmp;" << be_nl + << "::ACE_InputCDR::to_uint8 _tao_union_helper " + << "(_tao_union_tmp);" << be_nl + << "result = strm >> _tao_union_helper;" << be_nl_2 + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + } + else if (pt == AST_PredefinedType::PT_int8) + { + *os << "::CORBA::Int8 _tao_union_tmp;" << be_nl + << "::ACE_InputCDR::to_int8 _tao_union_helper " + << "(_tao_union_tmp);" << be_nl + << "result = strm >> _tao_union_helper;" << be_nl_2 + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + } else { *os << node->name () << " _tao_union_tmp;" << be_nl @@ -619,6 +641,16 @@ be_visitor_union_branch_cdr_op_cs::visit_predefined_type ( *os << "strm << ::ACE_OutputCDR::from_boolean (_tao_union." << f->local_name () << " ());"; } + else if (pt == AST_PredefinedType::PT_uint8) + { + *os << "strm << ::ACE_OutputCDR::from_uint8 (_tao_union." + << f->local_name () << " ());"; + } + else if (pt == AST_PredefinedType::PT_int8) + { + *os << "strm << ::ACE_OutputCDR::from_int8 (_tao_union." + << f->local_name () << " ());"; + } else { *os << "strm << _tao_union." << f->local_name () << " ();"; diff --git a/TAO/TAO_IDL/be/be_visitor_valuebox/valuebox_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuebox/valuebox_cs.cpp index 5dcc239871d..06420943760 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuebox/valuebox_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuebox/valuebox_cs.cpp @@ -204,6 +204,16 @@ be_visitor_valuebox_cs::visit_valuebox (be_valuebox *node) "::ACE_InputCDR::to_octet (vb_object->_pd_value)"; break; + case AST_PredefinedType::PT_uint8: + unmarshal_arg = + "::ACE_InputCDR::to_uint8 (vb_object->_pd_value)"; + break; + + case AST_PredefinedType::PT_int8: + unmarshal_arg = + "::ACE_InputCDR::to_int8 (vb_object->_pd_value)"; + break; + case AST_PredefinedType::PT_any: // We need to help the ">>" operator for "any" because // a conversion operator is not available. @@ -407,6 +417,16 @@ be_visitor_valuebox_cs::visit_predefined_type (be_predefined_type * node) "::ACE_OutputCDR::from_octet (this->_pd_value)"; break; + case AST_PredefinedType::PT_uint8: + marshal_arg = + "::ACE_OutputCDR::from_uint8 (this->_pd_value)"; + break; + + case AST_PredefinedType::PT_int8: + marshal_arg = + "::ACE_OutputCDR::from_int8 (this->_pd_value)"; + break; + case AST_PredefinedType::PT_any: marshal_arg = "this->_pd_value.in ()"; break; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_cs.cpp index 53547d82e7d..f06e8fbcfc4 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_cs.cpp @@ -502,6 +502,16 @@ be_visitor_valuetype_field_cdr_cs::visit_predefined_type (be_predefined_type *no *os << "(strm >> ::ACE_InputCDR::to_boolean (" << this->pre_ << f->local_name () << this->post_ << "))"; } + else if (pt == AST_PredefinedType::PT_uint8) + { + *os << "(strm >> ::ACE_InputCDR::to_uint8 (" + << this->pre_ << f->local_name () << this->post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_int8) + { + *os << "(strm >> ::ACE_InputCDR::to_int8 (" + << this->pre_ << f->local_name () << this->post_ << "))"; + } else { *os << "(strm >> " << this->pre_ << f->local_name () @@ -535,6 +545,16 @@ be_visitor_valuetype_field_cdr_cs::visit_predefined_type (be_predefined_type *no *os << "(strm << ::ACE_OutputCDR::from_boolean (" << this->pre_ << f->local_name () << this->post_ << "))"; } + else if (pt == AST_PredefinedType::PT_uint8) + { + *os << "(strm << ::ACE_OutputCDR::from_uint8 (" + << this->pre_ << f->local_name () << this->post_ << "))"; + } + else if (pt == AST_PredefinedType::PT_int8) + { + *os << "(strm << ::ACE_OutputCDR::from_int8 (" + << this->pre_ << f->local_name () << this->post_ << "))"; + } else { *os << "(strm << " << this->pre_ << f->local_name () diff --git a/TAO/TAO_IDL/include/ast_sequence.h b/TAO/TAO_IDL/include/ast_sequence.h index 0ad62ce18b0..6c9688c7d5a 100644 --- a/TAO/TAO_IDL/include/ast_sequence.h +++ b/TAO/TAO_IDL/include/ast_sequence.h @@ -90,6 +90,12 @@ public: AST_Type *base_type () const; + /** + * Returns the fully dealiased base type if it's a typedef. If it's not a + * typedef, the it returns the same value as as base_type(). + */ + AST_Type *primitive_base_type () const; + virtual bool unbounded () const; // Is this sequence bounded or not. diff --git a/TAO/tao/.gitignore b/TAO/tao/.gitignore index 03471db0e1c..8a019505f28 100644 --- a/TAO/tao/.gitignore +++ b/TAO/tao/.gitignore @@ -1,13 +1,16 @@ +/AnyTypeCode/Int8SeqA.cpp +/AnyTypeCode/Int8SeqA.h +/AnyTypeCode/UInt8SeqA.cpp +/AnyTypeCode/UInt8SeqA.h /BooleanSeqC.cpp /BooleanSeqC.h /BooleanSeqS.h -/CharSeqC.cpp -/CharSeqC.h -/CharSeqS.h -/config.h.in /CONV_FRAMEC.cpp /CONV_FRAMEC.h /CONV_FRAMES.h +/CharSeqC.cpp +/CharSeqC.h +/CharSeqS.h /CurrentC.cpp /CurrentC.h /CurrentS.h @@ -21,15 +24,19 @@ /GIOPC.h /GIOPC.inl /GIOPS.h -/IIOP_EndpointsC.cpp -/IIOP_EndpointsC.h -/IIOP_EndpointsS.h /IIOPC.cpp /IIOPC.h /IIOPS.h +/IIOP_EndpointsC.cpp +/IIOP_EndpointsC.h +/IIOP_EndpointsS.h /IOPC.cpp /IOPC.h /IOPS.h +/Int8Seq.pidl +/Int8SeqC.cpp +/Int8SeqC.h +/Int8SeqS.h /LongDoubleSeqC.cpp /LongDoubleSeqC.h /LongDoubleSeqS.h @@ -51,15 +58,15 @@ /OctetSeqC.cpp /OctetSeqC.h /OctetSeqS.h -/orb_typesC.cpp -/orb_typesC.h -/orb_typesS.h -/ParameterModeC.cpp -/ParameterModeC.h -/ParameterModeS.h /PI_ForwardC.cpp /PI_ForwardC.h /PI_ForwardS.h +/ParameterModeC.cpp +/ParameterModeC.h +/ParameterModeS.h +/PolicyC.cpp +/PolicyC.h +/PolicyC.inl /Policy_CurrentC.cpp /Policy_CurrentC.h /Policy_CurrentS.h @@ -90,6 +97,10 @@ /TimeBaseC.cpp /TimeBaseC.h /TimeBaseS.h +/UInt8Seq.pidl +/UInt8SeqC.cpp +/UInt8SeqC.h +/UInt8SeqS.h /ULongLongSeqC.cpp /ULongLongSeqC.h /ULongLongSeqS.h @@ -105,3 +116,7 @@ /WStringSeqC.cpp /WStringSeqC.h /WStringSeqS.h +/config.h.in +/orb_typesC.cpp +/orb_typesC.h +/orb_typesS.h diff --git a/TAO/tao/Basic_Types.h b/TAO/tao/Basic_Types.h index 538332cdf93..facd7e59348 100644 --- a/TAO/tao/Basic_Types.h +++ b/TAO/tao/Basic_Types.h @@ -75,6 +75,24 @@ namespace CORBA typedef ACE_CDR::WChar WChar; typedef WChar &WChar_out; + + typedef ACE_CDR::Int16 Int16; + typedef Int16 &Int16_out; + + typedef ACE_CDR::UInt16 UInt16; + typedef UInt16 &UInt16_out; + + typedef ACE_CDR::Int32 Int32; + typedef Int32 &Int32_out; + + typedef ACE_CDR::UInt32 UInt32; + typedef UInt32 &UInt32_out; + + typedef ACE_CDR::Int64 Int64; + typedef Int64 &Int64_out; + + typedef ACE_CDR::UInt64 UInt64; + typedef UInt64 &UInt64_out; //@} typedef TAO::String_var<CORBA::Char> String_var; diff --git a/TAO/tao/Basic_Types_IDLv4.h b/TAO/tao/Basic_Types_IDLv4.h index 0b278876e2f..e4966777daa 100644 --- a/TAO/tao/Basic_Types_IDLv4.h +++ b/TAO/tao/Basic_Types_IDLv4.h @@ -26,27 +26,11 @@ namespace CORBA //@{ typedef ACE_CDR::Int8 Int8; typedef Int8 &Int8_out; + struct Int8_tag {}; typedef ACE_CDR::UInt8 UInt8; typedef UInt8 &UInt8_out; - - typedef ACE_CDR::Int16 Int16; - typedef Int16 &Int16_out; - - typedef ACE_CDR::UInt16 UInt16; - typedef UInt16 &UInt16_out; - - typedef ACE_CDR::Int32 Int32; - typedef Int32 &Int32_out; - - typedef ACE_CDR::UInt32 UInt32; - typedef UInt32 &UInt32_out; - - typedef ACE_CDR::Int64 Int64; - typedef Int64 &Int64_out; - - typedef ACE_CDR::UInt64 UInt64; - typedef UInt64 &UInt64_out; + struct UInt8_tag {}; //@} } } diff --git a/TAO/tao/Bounded_Sequence_CDR_T.h b/TAO/tao/Bounded_Sequence_CDR_T.h index 6c673bd1214..f2339ff8bbf 100644 --- a/TAO/tao/Bounded_Sequence_CDR_T.h +++ b/TAO/tao/Bounded_Sequence_CDR_T.h @@ -1,5 +1,5 @@ -#ifndef guard_bounded_sequence_cdr -#define guard_bounded_sequence_cdr +#ifndef TAO_BOUNDED_SEQUENCE_CDR_T_H +#define TAO_BOUNDED_SEQUENCE_CDR_T_H /** * @file * @@ -11,6 +11,7 @@ #include "tao/orbconf.h" #include "tao/SystemException.h" +#include "tao/Basic_Types_IDLv4.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -277,6 +278,48 @@ namespace TAO { return true; } + template <typename stream, CORBA::ULong MAX> + bool demarshal_sequence(stream & strm, + TAO::bounded_value_sequence <CORBA::IDLv4::UInt8, MAX, CORBA::IDLv4::UInt8_tag> & target) { + typedef TAO::bounded_value_sequence <CORBA::IDLv4::UInt8, MAX, CORBA::IDLv4::UInt8_tag> sequence; + ::CORBA::ULong new_length = 0; + if (!(strm >> new_length)) { + return false; + } + if ((new_length > strm.length()) || (new_length > target.maximum ())) { + return false; + } + sequence tmp; + tmp.length(new_length); + typename sequence::value_type * buffer = tmp.get_buffer(); + if (!strm.read_uint8_array (buffer, new_length)) { + return false; + } + tmp.swap(target); + return true; + } + + template <typename stream, CORBA::ULong MAX> + bool demarshal_sequence(stream & strm, + TAO::bounded_value_sequence <CORBA::IDLv4::Int8, MAX, CORBA::IDLv4::Int8_tag> & target) { + typedef TAO::bounded_value_sequence <CORBA::IDLv4::Int8, MAX, CORBA::IDLv4::Int8_tag> sequence; + ::CORBA::ULong new_length = 0; + if (!(strm >> new_length)) { + return false; + } + if ((new_length > strm.length()) || (new_length > target.maximum ())) { + return false; + } + sequence tmp; + tmp.length(new_length); + typename sequence::value_type * buffer = tmp.get_buffer(); + if (!strm.read_int8_array (buffer, new_length)) { + return false; + } + tmp.swap(target); + return true; + } + template <typename stream, typename value_t, CORBA::ULong MAX> bool demarshal_sequence(stream & strm, TAO::bounded_value_sequence <value_t, MAX> & target) { typedef TAO::bounded_value_sequence <value_t, MAX> sequence; @@ -382,9 +425,7 @@ namespace TAO { tmp.swap(target); return true; } -} -namespace TAO { template <typename stream, CORBA::ULong MAX> bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <CORBA::Short, MAX> & source) { ::CORBA::ULong const length = source.length (); @@ -504,6 +545,26 @@ namespace TAO { return strm.write_boolean_array (source.get_buffer (), length); } + template <typename stream, CORBA::ULong MAX> + bool marshal_sequence(stream & strm, + const TAO::bounded_value_sequence <CORBA::IDLv4::UInt8, MAX, CORBA::IDLv4::UInt8_tag> & source) { + ::CORBA::ULong const length = source.length (); + if (length > source.maximum () || !(strm << length)) { + return false; + } + return strm.write_uint8_array (source.get_buffer (), length); + } + + template <typename stream, CORBA::ULong MAX> + bool marshal_sequence(stream & strm, + const TAO::bounded_value_sequence <CORBA::IDLv4::Int8, MAX, CORBA::IDLv4::Int8_tag> & source) { + ::CORBA::ULong const length = source.length (); + if (length > source.maximum () || !(strm << length)) { + return false; + } + return strm.write_int8_array (source.get_buffer (), length); + } + template <typename stream, typename value_t, CORBA::ULong MAX> bool marshal_sequence(stream & strm, const TAO::bounded_value_sequence <value_t, MAX> & source) { ::CORBA::ULong const length = source.length (); @@ -568,4 +629,4 @@ namespace TAO { TAO_END_VERSIONED_NAMESPACE_DECL -#endif /* guard_bounded_sequence_cdr */ +#endif /* TAO_BOUNDED_SEQUENCE_CDR_T_H */ diff --git a/TAO/tao/Bounded_Value_Sequence_T.h b/TAO/tao/Bounded_Value_Sequence_T.h index 8c766e1c1f7..a9e620aa42a 100644 --- a/TAO/tao/Bounded_Value_Sequence_T.h +++ b/TAO/tao/Bounded_Value_Sequence_T.h @@ -18,7 +18,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { -template<class T, CORBA::ULong MAX> +template<class T, CORBA::ULong MAX, class Tag=int> class bounded_value_sequence { public: diff --git a/TAO/tao/CDR.h b/TAO/tao/CDR.h index d2ac02e1a0f..c6b7d64b17f 100644 --- a/TAO/tao/CDR.h +++ b/TAO/tao/CDR.h @@ -499,8 +499,6 @@ TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, ACE_OutputCDR::from_std_wstring x); #endif /* ACE_LACKS_STD_WSTRING */ -TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, CORBA::IDLv4::Int8 x); -TAO_Export CORBA::Boolean operator<< (TAO_OutputCDR &os, CORBA::IDLv4::UInt8 x); // CDR input operators for CORBA types @@ -540,8 +538,6 @@ TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &os, ACE_InputCDR::to_std_wstring x); #endif /* ACE_LACKS_STD_WSTRING */ -TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &is, CORBA::IDLv4::Int8 &x); -TAO_Export CORBA::Boolean operator>> (TAO_InputCDR &is, CORBA::IDLv4::UInt8 &x); TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/CDR.inl b/TAO/tao/CDR.inl index 24952bb8329..89958d671dd 100644 --- a/TAO/tao/CDR.inl +++ b/TAO/tao/CDR.inl @@ -495,19 +495,6 @@ ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, } #endif /* ACE_LACKS_STD_WSTRING */ -ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, CORBA::IDLv4::Int8 x) -{ - return os.fragment_stream (ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE) - && static_cast<ACE_OutputCDR &> (os) << x; -} - -ACE_INLINE CORBA::Boolean operator<< (TAO_OutputCDR &os, CORBA::IDLv4::UInt8 x) -{ - return - os.fragment_stream (ACE_CDR::OCTET_ALIGN, ACE_CDR::OCTET_SIZE) - && static_cast<ACE_OutputCDR &> (os) << x; -} - // **************************************************************** ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, @@ -638,14 +625,4 @@ ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, } #endif /* ACE_LACKS_STD_WSTRING */ -ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, CORBA::IDLv4::Int8 &x) -{ - return static_cast<ACE_InputCDR &> (is) >> x; -} - -ACE_INLINE CORBA::Boolean operator>> (TAO_InputCDR &is, CORBA::IDLv4::UInt8 &x) -{ - return static_cast<ACE_InputCDR &> (is) >> x; -} - TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Unbounded_Sequence_CDR_T.h b/TAO/tao/Unbounded_Sequence_CDR_T.h index 0c8d5308970..ab4fb8aca9e 100644 --- a/TAO/tao/Unbounded_Sequence_CDR_T.h +++ b/TAO/tao/Unbounded_Sequence_CDR_T.h @@ -1,5 +1,5 @@ -#ifndef guard_unbounded_sequence_cdr -#define guard_unbounded_sequence_cdr +#ifndef TAO_UNBOUNDED_SEQUENCE_CDR_T_H +#define TAO_UNBOUNDED_SEQUENCE_CDR_T_H /** * @file * @@ -12,6 +12,7 @@ #include "tao/orbconf.h" #include "tao/CORBA_String.h" #include "tao/SystemException.h" +#include "tao/Basic_Types_IDLv4.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -313,6 +314,48 @@ namespace TAO { return true; } + template <typename stream> + bool demarshal_sequence(stream & strm, + TAO::unbounded_value_sequence <CORBA::IDLv4::UInt8, CORBA::IDLv4::UInt8_tag> & target) { + typedef TAO::unbounded_value_sequence <CORBA::IDLv4::UInt8, CORBA::IDLv4::UInt8_tag> sequence; + ::CORBA::ULong new_length = 0; + if (!(strm >> new_length)) { + return false; + } + if (new_length > strm.length()) { + return false; + } + sequence tmp(new_length); + tmp.length(new_length); + typename sequence::value_type * buffer = tmp.get_buffer(); + if (!strm.read_uint8_array (buffer, new_length)) { + return false; + } + tmp.swap(target); + return true; + } + + template <typename stream> + bool demarshal_sequence(stream & strm, + TAO::unbounded_value_sequence <CORBA::IDLv4::Int8, CORBA::IDLv4::Int8_tag> & target) { + typedef TAO::unbounded_value_sequence <CORBA::IDLv4::Int8, CORBA::IDLv4::Int8_tag> sequence; + ::CORBA::ULong new_length = 0; + if (!(strm >> new_length)) { + return false; + } + if (new_length > strm.length()) { + return false; + } + sequence tmp(new_length); + tmp.length(new_length); + typename sequence::value_type * buffer = tmp.get_buffer(); + if (!strm.read_int8_array (buffer, new_length)) { + return false; + } + tmp.swap(target); + return true; + } + template <typename stream, typename value_t> bool demarshal_sequence(stream & strm, TAO::unbounded_value_sequence <value_t> & target) { typedef TAO::unbounded_value_sequence <value_t> sequence; @@ -418,9 +461,7 @@ namespace TAO { tmp.swap(target); return true; } -} -namespace TAO { template <typename stream> bool marshal_sequence(stream & strm, const TAO::unbounded_value_sequence <CORBA::Short> & source) { ::CORBA::ULong const length = source.length (); @@ -554,6 +595,26 @@ namespace TAO { return strm.write_boolean_array (source.get_buffer (), length); } + template <typename stream> + bool marshal_sequence(stream & strm, + const TAO::unbounded_value_sequence <CORBA::IDLv4::UInt8, CORBA::IDLv4::UInt8_tag> & source) { + ::CORBA::ULong const length = source.length (); + if (!(strm << length)) { + return false; + } + return strm.write_uint8_array (source.get_buffer (), length); + } + + template <typename stream> + bool marshal_sequence(stream & strm, + const TAO::unbounded_value_sequence <CORBA::IDLv4::Int8, CORBA::IDLv4::Int8_tag> & source) { + ::CORBA::ULong const length = source.length (); + if (!(strm << length)) { + return false; + } + return strm.write_int8_array (source.get_buffer (), length); + } + template <typename stream, typename value_t> bool marshal_sequence(stream & strm, const TAO::unbounded_value_sequence <value_t> & source) { ::CORBA::ULong const length = source.length (); @@ -618,4 +679,4 @@ namespace TAO { TAO_END_VERSIONED_NAMESPACE_DECL -#endif /* guard_unbounded_sequence_cdr */ +#endif /* TAO_UNBOUNDED_SEQUENCE_CDR_T_H */ diff --git a/TAO/tao/Unbounded_Value_Sequence_T.h b/TAO/tao/Unbounded_Value_Sequence_T.h index a82aa26e6c4..3d6893254a3 100644 --- a/TAO/tao/Unbounded_Value_Sequence_T.h +++ b/TAO/tao/Unbounded_Value_Sequence_T.h @@ -18,7 +18,7 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL namespace TAO { -template<class T> +template<class T, class Tag=int> class unbounded_value_sequence { public: diff --git a/TAO/tao/tao.mpc b/TAO/tao/tao.mpc index a816e0ce154..fd742ddc17d 100644 --- a/TAO/tao/tao.mpc +++ b/TAO/tao/tao.mpc @@ -61,6 +61,12 @@ project(TAO_Core_idl) : tao_versioning_idl_defaults, gen_ostream, install, pidl_ } IDL_Files { + idlflags += -Sci -Gse -Gata --idl-version 4 + Int8Seq.pidl >> AnyTypeCode/Int8SeqA.h AnyTypeCode/Int8SeqA.cpp + UInt8Seq.pidl >> AnyTypeCode/UInt8SeqA.h AnyTypeCode/UInt8SeqA.cpp + } + + IDL_Files { idlflags += -GT -oS PortableServer -Gd \ -Wb,safe_include=tao/PolicyC.h \ -Wb,skel_export_macro=TAO_PortableServer_Export \ @@ -169,6 +175,7 @@ project(TAO) : acelib, install, tao_output, taodefaults, pidl, extra_core, taoid IIOPC.cpp Incoming_Message_Queue.cpp Incoming_Message_Stack.cpp + Int8SeqC.cpp Invocation_Adapter.cpp Invocation_Base.cpp Invocation_Endpoint_Selectors.cpp @@ -308,6 +315,7 @@ project(TAO) : acelib, install, tao_output, taodefaults, pidl, extra_core, taoid TSS_Resources.cpp TypeCodeFactory_Adapter.cpp Typecode_typesC.cpp + UInt8SeqC.cpp ULongLongSeqC.cpp ULongSeqC.cpp UserException.cpp @@ -453,6 +461,8 @@ project(TAO) : acelib, install, tao_output, taodefaults, pidl, extra_core, taoid IIOP_Transport.h Incoming_Message_Queue.h Incoming_Message_Stack.h + Int8SeqC.h + Int8SeqS.h Invocation_Adapter.h Invocation_Base.h Invocation_Endpoint_Selectors.h @@ -633,6 +643,8 @@ project(TAO) : acelib, install, tao_output, taodefaults, pidl, extra_core, taoid Typecode_typesS.h UB_String_Arguments.h UB_String_Argument_T.h + UInt8SeqC.h + UInt8SeqS.h ULongLongSeqC.h ULongLongSeqS.h ULongSeqC.h diff --git a/TAO/tests/IDLv4/explicit_ints/test.idl b/TAO/tests/IDLv4/explicit_ints/test.idl index eb1e476a80c..5cf247fba6d 100644 --- a/TAO/tests/IDLv4/explicit_ints/test.idl +++ b/TAO/tests/IDLv4/explicit_ints/test.idl @@ -1,3 +1,8 @@ +#include "tao/Int8Seq.pidl" +#include "tao/UInt8Seq.pidl" +#include "tao/OctetSeq.pidl" +#include "tao/CharSeq.pidl" + const uint8 u8_min = 0; const uint8 u8_max = 255; const int8 i8_min = -128; @@ -40,6 +45,15 @@ const int8 i8_e7 = i8_e6 & 7; const int8 i8_e8 = i8_e7 << 4; const int8 i8_e9 = i8_e8 >> 1; +typedef uint8 U8arr[3]; +typedef int8 I8arr[3]; +typedef octet Oarr[3]; +typedef char Carr[3]; +typedef sequence<uint8> U8seq; +typedef sequence<int8> I8seq; +typedef sequence<octet> Oseq; +typedef sequence<char> Cseq; + struct StructWithInts { uint8 u8; int8 i8; @@ -49,6 +63,21 @@ struct StructWithInts { int32 i32; uint64 u64; int64 i64; + + // Make sure there's no conflict between uint8, int8, octet, and char. + uint8 u8_arr[3]; + int8 i8_arr[3]; + sequence<uint8> u8_seq; + sequence<int8> i8_seq; + sequence<octet> o_seq; + sequence<char> c_seq; + + U8arr td_u8_arr; + I8arr td_i8_arr; + U8seq td_u8_seq; + I8seq td_i8_seq; + Oseq td_o_seq; + Cseq td_c_seq; }; union UnionOverU8 switch (uint8) { @@ -56,6 +85,14 @@ case 0: uint8 u8; case 1: int8 i8; +case 2: + uint8 u8arr[3]; +case 3: + int8 i8arr[3]; +case 4: + sequence<uint8> u8seq; +case 5: + sequence<int8> i8seq; }; union UnionOverI8 switch (int8) { @@ -63,4 +100,12 @@ case 0: uint8 u8; case 1: int8 i8; +case 2: + uint8 u8arr[3]; +case 3: + int8 i8arr[3]; +case 4: + sequence<uint8> u8seq; +case 5: + sequence<int8> i8seq; }; |