Skip to content

Commit

Permalink
Merge pull request DOCGroup#2244 from iguessthislldo/igtd/small-idl4-…
Browse files Browse the repository at this point in the history
…features

Minor Additions to IDL4 Support
  • Loading branch information
iguessthislldo committed Jun 12, 2024
2 parents 7d35ea7 + fe02c11 commit 230473b
Show file tree
Hide file tree
Showing 20 changed files with 3,982 additions and 3,916 deletions.
14 changes: 14 additions & 0 deletions TAO/NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
USER VISIBLE CHANGES BETWEEN TAO-4.0.0 and TAO-4.0.1
====================================================

- TAO_IDL:
- Support the following IDL v4 features (may not work everywhere in TAO):
- Empty structs
- `octet` and `wchar` union discriminators
- Allow using `typedef`s of `int8` and `uint8` as union discriminators
- Allow using empty parentheses in annotation applications to
workaround syntax errors when an annotation with no arguments has to
be followed by a complete scoped name:
`@example_annotation() ::ex::ExampleType`
This is a proposed solution to an IDL spec issue.
- Reserve the `bitfield`, `bitmask`, and `bitset` keywords in IDL v4
(these are not implemented yet)
- Allow using `map` as an identifier in IDL v3 again

USER VISIBLE CHANGES BETWEEN TAO-3.1.4 and TAO-4.0.0
====================================================

Expand Down
2 changes: 2 additions & 0 deletions TAO/TAO_IDL/be/be_union.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,12 @@ be_union::gen_empty_default_label ()
return (n_labels < 2);

case AST_PredefinedType::PT_char:
case AST_PredefinedType::PT_octet:
return (n_labels <= ACE_OCTET_MAX);

case AST_PredefinedType::PT_short:
case AST_PredefinedType::PT_ushort:
case AST_PredefinedType::PT_wchar:
return (n_labels <= ACE_UINT16_MAX);

case AST_PredefinedType::PT_long:
Expand Down
1 change: 1 addition & 0 deletions TAO/TAO_IDL/be/be_union_branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ be_union_branch::gen_default_label_value (TAO_OutStream *os,
*os << dv.u.short_val;
break;
case AST_Expression::EV_ushort:
case AST_Expression::EV_wchar:
*os << dv.u.ushort_val;
break;
case AST_Expression::EV_long:
Expand Down
18 changes: 10 additions & 8 deletions TAO/TAO_IDL/be/be_visitor_structure/cdr_op_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ be_visitor_structure_cdr_op_cs::visit_structure (be_structure *node)
// Set the sub state as generating code for the output operator.
this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT);

const bool empty = node->nfields () == 0;
const char *const strm = empty ? "" : "strm";
const char *const tao_aggregate = empty ? "" : "_tao_aggregate";
*os << "::CORBA::Boolean operator<< (" << be_idt << be_idt_nl
<< "TAO_OutputCDR &strm," << be_nl
<< "const " << node->name () << " &_tao_aggregate)" << be_uidt
<< "TAO_OutputCDR &" << strm << "," << be_nl
<< "const " << node->name () << " &" << tao_aggregate << ")" << be_uidt
<< be_uidt_nl
<< "{" << be_idt_nl;

Expand All @@ -81,7 +84,7 @@ be_visitor_structure_cdr_op_cs::visit_structure (be_structure *node)
-1);
}

*os << ";" << be_uidt << be_uidt_nl
*os << "true;" << be_uidt << be_uidt_nl
<< "}" << be_nl_2;

// Set the substate as generating code for the input operator.
Expand All @@ -92,15 +95,15 @@ be_visitor_structure_cdr_op_cs::visit_structure (be_structure *node)

if (! node->is_local ())
{
*os << "strm";
*os << strm;
}

*os << "," << be_nl
<< node->name () << " &";

if (! node->is_local ())
{
*os << "_tao_aggregate";
*os << tao_aggregate;
}

*os << ")" << be_uidt << be_uidt_nl
Expand Down Expand Up @@ -135,7 +138,7 @@ be_visitor_structure_cdr_op_cs::visit_structure (be_structure *node)
-1);
}

*os << ";" << be_uidt << be_uidt;
*os << "true;" << be_uidt << be_uidt;
}

*os << be_uidt_nl << "}" << be_nl;
Expand All @@ -157,8 +160,7 @@ be_visitor_structure_cdr_op_cs::post_process (be_decl *bd)
{
TAO_OutStream *os = this->ctx_->stream ();

if (!this->last_node (bd)
&& bd->node_type () != AST_Decl::NT_enum_val)
if (bd->node_type () != AST_Decl::NT_enum_val)
{
switch (this->ctx_->sub_state ())
{
Expand Down
3 changes: 3 additions & 0 deletions TAO/TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace {
case AST_Expression::EV_int8:
tmp_suffix = "int8";
break;
case AST_Expression::EV_octet:
tmp_suffix = "octet";
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions TAO/TAO_IDL/be/be_visitor_union/discriminant_ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ be_visitor_union_discriminant_ci::visit_predefined_type (
*os << dv.u.short_val;
break;
case AST_Expression::EV_ushort:
case AST_Expression::EV_wchar:
*os << dv.u.ushort_val;
break;
case AST_Expression::EV_long:
Expand Down
2 changes: 1 addition & 1 deletion TAO/TAO_IDL/fe/fe_lookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
unsigned int
TAO_IDL_CPP_Keyword_Table::hash (const char *str, unsigned int len)
{
static const unsigned char asso_values[] =
static constexpr unsigned char asso_values[] =
{
252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
252, 252, 252, 252, 252, 252, 252, 252, 252, 252,
Expand Down
90 changes: 16 additions & 74 deletions TAO/TAO_IDL/fe/idl.ll
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ static AST_Decl * idl_find_node (const char *);
#undef ECHO
#endif

#define IDL4_KEYWORD(TOKEN_NAME) if (idl_global->idl_version_ >= IDL_VERSION_4) return TOKEN_NAME;

%}

/* SO we don't choke on files that use \r\n */
Expand All @@ -138,7 +140,6 @@ enum return IDL_ENUM;
string return IDL_STRING;
wstring return IDL_WSTRING;
sequence return IDL_SEQUENCE;
map return IDL_MAP;
union return IDL_UNION;
fixed return IDL_FIXED;
switch return IDL_SWITCH;
Expand All @@ -158,79 +159,6 @@ native return IDL_NATIVE;
local return IDL_LOCAL;
abstract return IDL_ABSTRACT;

int8 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_INT8;
else
{
REJECT;
}
}
uint8 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_UINT8;
else
{
REJECT;
}
}
int16 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_INT16;
else
{
REJECT;
}
}
uint16 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_UINT16;
else
{
REJECT;
}
}
int32 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_INT32;
else
{
REJECT;
}
}
uint32 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_UINT32;
else
{
REJECT;
}
}
int64 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_INT64;
else
{
REJECT;
}
}
uint64 {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_UINT64;
else
{
REJECT;
}
}
map {
if (idl_global->idl_version_ >= IDL_VERSION_4)
return IDL_MAP;
else
{
REJECT;
}
}

custom return IDL_CUSTOM;
factory return IDL_FACTORY;
private return IDL_PRIVATE;
Expand Down Expand Up @@ -282,6 +210,20 @@ oneway return IDL_ONEWAY;
@annotation[^A-Za-z0-9_] return IDL_ANNOTATION_DECL; // Allow annotation names that start with "annotation"
@ return IDL_ANNOTATION_SYMBOL;

int8 IDL4_KEYWORD(IDL_INT8); REJECT;
uint8 IDL4_KEYWORD(IDL_UINT8); REJECT;
int16 IDL4_KEYWORD(IDL_INT16); REJECT;
uint16 IDL4_KEYWORD(IDL_UINT16); REJECT;
int32 IDL4_KEYWORD(IDL_INT32); REJECT;
uint32 IDL4_KEYWORD(IDL_UINT32); REJECT;
int64 IDL4_KEYWORD(IDL_INT64); REJECT;
uint64 IDL4_KEYWORD(IDL_UINT64); REJECT;

bitfield IDL4_KEYWORD(IDL_BITFIELD); REJECT;
bitmask IDL4_KEYWORD(IDL_BITMASK); REJECT;
bitset IDL4_KEYWORD(IDL_BITSET); REJECT;
map IDL4_KEYWORD(IDL_MAP); REJECT;

[a-ij-rs-zA-IJ-RS-Z_][a-ij-rs-zA-IJ-RS-Z0-9_]* {
// Make sure that this identifier is not a C++ keyword. If it is,
// prepend it with a _cxx_. Lookup in the perfect hash table for C++
Expand Down
Loading

0 comments on commit 230473b

Please sign in to comment.