diff options
Diffstat (limited to 'TAO/TAO_IDL/be')
19 files changed, 388 insertions, 178 deletions
diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index 88d11c7699f..b94578fc1a9 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -2445,8 +2445,19 @@ TAO_CodeGen::gen_stub_hdr_includes () this->client_header_ ); + const bool idl4 = idl_global->idl_version_ >= IDL_VERSION_4; this->gen_standard_include (this->client_header_, - "tao/Basic_Types.h"); + idl4 ? "tao/Basic_Types_IDLv4.h" : "tao/Basic_Types.h"); + if (idl4) + { + *client_header_ << + BE_GlobalData::core_versioned_ns_begin << "\n" + "namespace CORBA\n" + "{\n" + " using namespace IDLv4;\n" + "}\n" << + BE_GlobalData::core_versioned_ns_end; + } // May need ORB_Constants if users check SystemException minor // codes. diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp index 2aeaa3f633b..b29c9a85154 100644 --- a/TAO/TAO_IDL/be/be_global.cpp +++ b/TAO/TAO_IDL/be/be_global.cpp @@ -32,6 +32,11 @@ TAO_IDL_BE_Export BE_GlobalData *be_global = nullptr; +const char *const BE_GlobalData::core_versioned_ns_begin = + "\nTAO_BEGIN_VERSIONED_NAMESPACE_DECL\n"; +const char *const BE_GlobalData::core_versioned_ns_end = + "\nTAO_END_VERSIONED_NAMESPACE_DECL\n"; + BE_GlobalData::BE_GlobalData () : changing_standard_include_files_ (1), skel_export_macro_ (nullptr), @@ -55,8 +60,8 @@ BE_GlobalData::BE_GlobalData () safe_include_ (nullptr), unique_include_ (nullptr), stripped_filename_ (nullptr), - core_versioning_begin_ ("\nTAO_BEGIN_VERSIONED_NAMESPACE_DECL\n"), - core_versioning_end_ ("\nTAO_END_VERSIONED_NAMESPACE_DECL\n"), + core_versioning_begin_ (core_versioned_ns_begin), + core_versioning_end_ (core_versioned_ns_end), versioning_begin_ (), versioning_end_ (), versioning_include_ (), @@ -1144,7 +1149,7 @@ BE_GlobalData::versioning_end (const char * s) this->core_versioning_begin_ = this->versioning_end_ + // Yes, "end". - "\nTAO_BEGIN_VERSIONED_NAMESPACE_DECL\n"; + core_versioned_ns_begin; } void @@ -1156,7 +1161,7 @@ BE_GlobalData::versioning_begin (const char * s) + ACE_CString ("\n\n"); this->core_versioning_end_ = - "\nTAO_END_VERSIONED_NAMESPACE_DECL\n" + core_versioned_ns_end + this->versioning_begin_; // Yes, "begin". // Yes, "begin". diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp index 356a5500b5f..5070581c201 100644 --- a/TAO/TAO_IDL/be/be_helper.cpp +++ b/TAO/TAO_IDL/be/be_helper.cpp @@ -529,8 +529,23 @@ TAO_OutStream::print (AST_Expression *expr) break; case AST_Expression::EV_longlong: this->TAO_OutStream::print ("ACE_INT64_LITERAL ("); - this->TAO_OutStream::print (ACE_INT64_FORMAT_SPECIFIER_ASCII, - ev->u.llval); + { + ACE_CDR::LongLong value = ev->u.llval; + /* + * It seems that in C/C++ the minus sign and the bare number are parsed + * separately for negative integer literals. This can cause compilers + * to complain when using the minimum value of a signed integer because + * the number without the minus sign is 1 past the max signed value. + * + * https://stackoverflow.com/questions/65007935 + * + * Apparently the workaround is to write it as `VALUE_PLUS_ONE - 1`. + */ + const bool min_value = value == ACE_INT64_MIN; + if (min_value) ++value; + TAO_OutStream::print (ACE_INT64_FORMAT_SPECIFIER_ASCII, value); + if (min_value) TAO_OutStream::print (" - 1"); + } this->TAO_OutStream::print (")"); break; case AST_Expression::EV_ulonglong: @@ -596,7 +611,7 @@ TAO_OutStream::print (AST_Expression *expr) this->TAO_OutStream::print ("L'%lc'", ev->u.wcval); break; case AST_Expression::EV_octet: - this->TAO_OutStream::print ("%d", ev->u.oval); + this->TAO_OutStream::print ("0x%02x", ev->u.oval); break; case AST_Expression::EV_bool: this->TAO_OutStream::print ("%s", ev->u.bval ? "true" : "false"); @@ -610,6 +625,12 @@ TAO_OutStream::print (AST_Expression *expr) case AST_Expression::EV_enum: this->print (expr->n ()); break; + case AST_Expression::EV_int8: + this->TAO_OutStream::print ("%d", ev->u.int8val); + break; + case AST_Expression::EV_uint8: + this->TAO_OutStream::print ("%uu", ev->u.uint8val); + break; default: break; } diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index 7aa8a813c9b..09ac9fcb692 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -14,9 +14,12 @@ #include "be_predefined_type.h" #include "be_visitor.h" #include "be_helper.h" -#include "utl_identifier.h" + #include "global_extern.h" +#include "utl_identifier.h" +#include "utl_err.h" + #include "ace/Log_Msg.h" #include "ace/ACE.h" #include "ace/OS_NS_stdio.h" @@ -107,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: @@ -198,19 +209,19 @@ be_predefined_type::compute_tc_name () case AST_PredefinedType::PT_any: ACE_NEW (id, Identifier ("_tc_any")); - break; + break; case AST_PredefinedType::PT_object: ACE_NEW (id, Identifier ("_tc_Object")); - break; + break; case AST_PredefinedType::PT_value: ACE_NEW (id, Identifier ("_tc_ValueBase")); - break; + break; case AST_PredefinedType::PT_abstract: ACE_NEW (id, Identifier ("_tc_AbstractBase")); - break; + break; case AST_PredefinedType::PT_pseudo: { char tcname [100]; @@ -222,9 +233,17 @@ be_predefined_type::compute_tc_name () Identifier (tcname)); break; } - default: - ACE_ERROR ((LM_WARNING, "Unknown or invalid predefined type")); + case AST_PredefinedType::PT_uint8: + ACE_NEW (id, Identifier ("_tc_uint8")); + break; + case AST_PredefinedType::PT_int8: + ACE_NEW (id, Identifier ("_tc_int8")); break; + default: + idl_global->err ()->misc_error ( + "be_predefined_type::compute_tc_name: Unknown or invalid predefined type", this); + // Nothing else to do. We will segfault if we continue, return, or throw Bailout + ACE_OS::abort (); } ACE_NEW (conc_name, diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index e59a718ad6d..64de99f0e02 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: @@ -130,6 +118,19 @@ be_sequence::base_type () const this->AST_Sequence::base_type ()); } +be_type * +be_sequence::primitive_base_type () const +{ + be_type *type_node = base_type (); + if (type_node && type_node->node_type () == AST_Decl::NT_typedef) + { + be_typedef *const typedef_node = dynamic_cast<be_typedef *> (type_node); + if (!typedef_node) return nullptr; + type_node = typedef_node->primitive_base_type (); + } + return type_node; +} + // Helper to create_name. char * be_sequence::gen_name () @@ -280,31 +281,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 = 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 +315,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 +412,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 = primitive_base_type (); + if (!prim_type) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -439,18 +423,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,18 +593,15 @@ 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 + be_type *const prim_type = primitive_base_type (); + if (!prim_type) { - prim_type = elem; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_sequence::" + "gen_base_class_name - " + "Bad element type\n"), + -1); } - if (prim_type->node_type () == AST_Decl::NT_string) { be_string *str = @@ -680,18 +649,15 @@ 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 + be_type *const prim_type = primitive_base_type (); + if (!prim_type) { - prim_type = elem; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_sequence::" + "gen_base_class_name - " + "Bad element type\n"), + -1); } - if (prim_type->node_type () == AST_Decl::NT_wstring) { be_string *str = @@ -744,46 +710,68 @@ 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 - << ">"; - } + { + be_type *const base_type = primitive_base_type (); + if (!base_type) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_sequence::" + "gen_base_class_name - " + "Bad element type\n"), + -1); + } + const char *tag = ""; + if (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_union_branch.cpp b/TAO/TAO_IDL/be/be_union_branch.cpp index 217857d51bf..de59bd44cfb 100644 --- a/TAO/TAO_IDL/be/be_union_branch.cpp +++ b/TAO/TAO_IDL/be/be_union_branch.cpp @@ -118,9 +118,11 @@ be_union_branch::gen_default_label_value (TAO_OutStream *os, switch (bu->udisc_type ()) { case AST_Expression::EV_short: + case AST_Expression::EV_int8: *os << dv.u.short_val; break; case AST_Expression::EV_ushort: + case AST_Expression::EV_uint8: *os << dv.u.ushort_val; break; case AST_Expression::EV_long: @@ -129,6 +131,7 @@ be_union_branch::gen_default_label_value (TAO_OutStream *os, case AST_Expression::EV_ulong: *os << dv.u.ulong_val; break; + case AST_Expression::EV_octet: case AST_Expression::EV_char: os->print ("'\\%o'", dv.u.char_val); 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 94ad4554f72..aabe94ec294 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 @@ -362,6 +362,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::" @@ -430,6 +436,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_constant/constant.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant.cpp new file mode 100644 index 00000000000..f339edfc8c4 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant.cpp @@ -0,0 +1,50 @@ +#include "constant.h" + +const char *exprtype_to_cpp_corba_type (AST_Expression::ExprType et) +{ + switch (et) + { + case AST_Expression::EV_short: + return "CORBA::Short"; + case AST_Expression::EV_ushort: + return "CORBA::UShort"; + case AST_Expression::EV_long: + return "CORBA::Long"; + case AST_Expression::EV_ulong: + return "CORBA::ULong"; + case AST_Expression::EV_float: + return "CORBA::Float"; + case AST_Expression::EV_double: + return "CORBA::Double"; + case AST_Expression::EV_char: + return "CORBA::Char"; + case AST_Expression::EV_octet: + return "CORBA::Octet"; + case AST_Expression::EV_bool: + return "CORBA::Boolean"; + case AST_Expression::EV_string: + return "char *const"; + case AST_Expression::EV_void: + return "void"; + case AST_Expression::EV_none: + return "none"; + case AST_Expression::EV_longlong: + return "CORBA::LongLong"; + case AST_Expression::EV_ulonglong: + return "CORBA::ULongLong"; + case AST_Expression::EV_wchar: + return "CORBA::WChar"; + case AST_Expression::EV_wstring: + return "CORBA::WChar *const"; + case AST_Expression::EV_fixed: + return "Fixed"; + case AST_Expression::EV_int8: + return "CORBA::Int8"; + case AST_Expression::EV_uint8: + return "CORBA::UInt8"; + default: + return 0; + } + + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant.h b/TAO/TAO_IDL/be/be_visitor_constant/constant.h index e4c2ba425ce..50da10f172e 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant.h +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant.h @@ -15,8 +15,9 @@ #include "be_extern.h" #include "be_typedef.h" #include "utl_identifier.h" +#include "ast_expression.h" #include "be_visitor_constant.h" #include "be_visitor_context.h" - +const char *exprtype_to_cpp_corba_type (AST_Expression::ExprType et); diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp index 091a149ef13..89701c0a0de 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant_ch.cpp @@ -66,7 +66,7 @@ be_visitor_constant_ch::visit_constant (be_constant *node) } else { - *os << node->exprtype_to_string (); + *os << exprtype_to_cpp_corba_type (node->et ()); } *os << " " << node->local_name (); @@ -93,7 +93,7 @@ be_visitor_constant_ch::visit_constant (be_constant *node) { if (bnt == AST_Decl::NT_string || bnt == AST_Decl::NT_wstring) { - *os << node->exprtype_to_string (); + *os << exprtype_to_cpp_corba_type (node->et ()); } else { @@ -102,7 +102,7 @@ be_visitor_constant_ch::visit_constant (be_constant *node) } else { - *os << node->exprtype_to_string (); + *os << exprtype_to_cpp_corba_type (node->et ()); } *os << " " << node->local_name (); diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp index d8d063c3aa0..cefc77ce40c 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp @@ -62,7 +62,7 @@ be_visitor_constant_cs::visit_constant (be_constant *node) } else { - *os << node->exprtype_to_string (); + *os << exprtype_to_cpp_corba_type (node->et ()); } *os << " " << node->name (); 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/discriminant_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp index ce1b7ca49e6..639e19918ed 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp @@ -159,9 +159,11 @@ be_visitor_union_discriminant_ci::visit_predefined_type ( switch (bu->udisc_type ()) { case AST_Expression::EV_short: + case AST_Expression::EV_int8: *os << dv.u.short_val; break; case AST_Expression::EV_ushort: + case AST_Expression::EV_uint8: *os << dv.u.ushort_val; break; case AST_Expression::EV_long: @@ -171,6 +173,7 @@ be_visitor_union_discriminant_ci::visit_predefined_type ( *os << dv.u.ulong_val; break; case AST_Expression::EV_char: + case AST_Expression::EV_octet: os->print ("'\\%o'", dv.u.char_val); break; case AST_Expression::EV_bool: 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 6b89889b4cf..91d897f3cd4 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuebox/valuebox_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuebox/valuebox_cs.cpp @@ -199,6 +199,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. @@ -402,6 +412,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 () |