Skip to content

Commit

Permalink
Respond to Review and Fix Typedefs in Union Disc
Browse files Browse the repository at this point in the history
  • Loading branch information
iguessthislldo committed Jun 10, 2024
1 parent f78f458 commit 1d95cca
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 40 deletions.
4 changes: 3 additions & 1 deletion TAO/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ USER VISIBLE CHANGES BETWEEN TAO-4.0.0 and TAO-4.0.1
====================================================

- TAO_IDL:
- Support the following IDL v4 features:
- 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
Expand Down
24 changes: 12 additions & 12 deletions TAO/TAO_IDL/fe/idl.tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5084,7 +5084,7 @@ yyparse (void)
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Annotations are not allowed in IDL3");
"Annotations are not allowed in IDL versions before 4");

Identifier *id = (yyvsp[-1].idval);
UTL_ScopedName name (id, 0);
Expand Down Expand Up @@ -5234,7 +5234,7 @@ yyparse (void)
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Annotations are not allowed in IDL3");
"Annotations are not allowed in IDL versions before 4");

AST_Annotation_Decl *decl = 0;
UTL_ScopedName *name = (yyvsp[0].idlist);
Expand Down Expand Up @@ -6010,7 +6010,7 @@ yyparse (void)
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Empty structs are not allowed in IDL3");
"Empty structs are not allowed in IDL versions before 4");

idl_global->set_parse_state (IDL_GlobalData::PS_StructQsSeen);
}
Expand Down Expand Up @@ -6324,7 +6324,7 @@ yyparse (void)
{
if ((yyvsp[0].etval) == AST_Expression::EV_wchar && idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Using wchar as a union discriminator isn't allowed in IDL3");
"Using wchar as a union discriminator isn't allowed in IDL versions before 4");

(yyval.dcval) = idl_global->scopes ().bottom ()->lookup_primitive_type ((yyvsp[0].etval));
}
Expand All @@ -6336,7 +6336,7 @@ yyparse (void)
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Using octet as a union discriminator isn't allowed in IDL3");
"Using octet as a union discriminator isn't allowed in IDL versions before 4");

(yyval.dcval) = idl_global->scopes ().bottom ()->lookup_primitive_type ((yyvsp[0].etval));
}
Expand Down Expand Up @@ -6366,8 +6366,7 @@ yyparse (void)
* typedef's to arrive at the base type at the end of the
* chain.
*/
d =
s->lookup_by_name ((yyvsp[0].idlist));
d = s->lookup_by_name ((yyvsp[0].idlist));

if (s != 0 && d != 0)
{
Expand All @@ -6392,18 +6391,19 @@ yyparse (void)
case AST_PredefinedType::PT_ulonglong:
case AST_PredefinedType::PT_short:
case AST_PredefinedType::PT_ushort:
case AST_PredefinedType::PT_int8:
case AST_PredefinedType::PT_uint8:
case AST_PredefinedType::PT_char:
case AST_PredefinedType::PT_boolean:
(yyval.dcval) = p;
found = true;
break;
case AST_PredefinedType::PT_wchar:
case AST_PredefinedType::PT_octet:
/* octets and wchars are not allowed */
idl_global->err ()->error0 (
UTL_Error::EIDL_DISC_TYPE
);
(yyval.dcval) = 0;
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Using octet or wchar as a union discriminator isn't allowed in IDL versions before 4");
(yyval.dcval) = p;
found = true;
break;
default:
Expand Down
24 changes: 12 additions & 12 deletions TAO/TAO_IDL/fe/idl.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ annotation_dcl
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Annotations are not allowed in IDL3");
"Annotations are not allowed in IDL versions before 4");

Identifier *id = $2;
UTL_ScopedName name (id, 0);
Expand Down Expand Up @@ -2516,7 +2516,7 @@ annotation_appl
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Annotations are not allowed in IDL3");
"Annotations are not allowed in IDL versions before 4");

AST_Annotation_Decl *decl = 0;
UTL_ScopedName *name = $2;
Expand Down Expand Up @@ -3174,7 +3174,7 @@ struct_body
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Empty structs are not allowed in IDL3");
"Empty structs are not allowed in IDL versions before 4");

idl_global->set_parse_state (IDL_GlobalData::PS_StructQsSeen);
}
Expand Down Expand Up @@ -3436,15 +3436,15 @@ switch_type_spec :
{
if ($1 == AST_Expression::EV_wchar && idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Using wchar as a union discriminator isn't allowed in IDL3");
"Using wchar as a union discriminator isn't allowed in IDL versions before 4");

$$ = idl_global->scopes ().bottom ()->lookup_primitive_type ($1);
}
| octet_type
{
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Using octet as a union discriminator isn't allowed in IDL3");
"Using octet as a union discriminator isn't allowed in IDL versions before 4");

$$ = idl_global->scopes ().bottom ()->lookup_primitive_type ($1);
}
Expand All @@ -3467,8 +3467,7 @@ switch_type_spec :
* typedef's to arrive at the base type at the end of the
* chain.
*/
d =
s->lookup_by_name ($1);
d = s->lookup_by_name ($1);

if (s != 0 && d != 0)
{
Expand All @@ -3493,18 +3492,19 @@ switch_type_spec :
case AST_PredefinedType::PT_ulonglong:
case AST_PredefinedType::PT_short:
case AST_PredefinedType::PT_ushort:
case AST_PredefinedType::PT_int8:
case AST_PredefinedType::PT_uint8:
case AST_PredefinedType::PT_char:
case AST_PredefinedType::PT_boolean:
$$ = p;
found = true;
break;
case AST_PredefinedType::PT_wchar:
case AST_PredefinedType::PT_octet:
/* octets and wchars are not allowed */
idl_global->err ()->error0 (
UTL_Error::EIDL_DISC_TYPE
);
$$ = 0;
if (idl_global->idl_version_ < IDL_VERSION_4)
idl_global->err ()->idl_version_error (
"Using octet or wchar as a union discriminator isn't allowed in IDL versions before 4");
$$ = p;
found = true;
break;
default:
Expand Down
60 changes: 45 additions & 15 deletions TAO/tests/IDLv4/union_disc/test.idl
Original file line number Diff line number Diff line change
@@ -1,21 +1,51 @@
union WcharUnion switch (wchar) {
typedef wchar wchar_t;
const wchar wchar_const = L'u';
union WcharUnion switch (wchar_t) {
/* TODO: https://github.com/DOCGroup/ACE_TAO/issues/1284
case L'\u0':
boolean b;
*/
case L'i':
int32 i32;
case L'u':
case wchar_const:
uint32 u32;
default:
string str;
/* TODO: https://github.com/DOCGroup/ACE_TAO/issues/1284
case L'\uffff':
string s;
*/
};

union OctetUnion switch (octet) {
case 1:
boolean b;
case 8:
int8 i8;
case 16:
int8 i16;
case 32:
int32 i32;
default:
string str;
typedef octet octet_t;
const octet octet_const = 1;
union OctetUnion switch (octet_t) {
case 0:
octet a;
case octet_const:
octet b;
case 255:
octet c;
};

typedef uint8 uint8_t;
const uint8 uint8_const = 1;
union Uint8Union switch (uint8_t) {
case 0:
uint8 a;
case uint8_const:
uint8 b;
case 255:
uint8 c;
};

typedef int8 int8_t;
const int8 int8_const = 1;
union Int8Union switch (int8_t) {
case -128:
int8 a;
case 0:
int8 b;
case int8_const:
int8 c;
case 127:
int8 d;
};

0 comments on commit 1d95cca

Please sign in to comment.