Modify supporting enum type 10/297010/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 8 Aug 2023 22:50:11 +0000 (07:50 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 8 Aug 2023 22:54:54 +0000 (07:54 +0900)
To use the enum type of the other structure, the developer should set
the structure name explicitly.

Change-Id: Idc2776cc4f51ef7c05bab5b1e5a83d50f3eb6f43
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/ast/tidlc.yy
idlc/ast/tidlc_y.cpp
tests/build_tests/tidl/Message_v2.tidl

index 2ab28949038e66b3f55651cae43d00a0087cf05e..c0d3b0581fac0ded633f2ef686fe424206796f54 100644 (file)
@@ -810,18 +810,6 @@ raw_type: container_type {
                 type = tidl::BaseType::UserType::STRUCTURE;
                 found = true;
                 break;
-              } else {
-                for (auto& e : b->GetEnums()) {
-                  if (e->GetID() == name) {
-                    type = tidl::BaseType::UserType::ENUM;
-                    name = b->GetID() + "." + name;
-                    found = true;
-                    break;
-                  }
-                }
-
-                if (found)
-                  break;
               }
             }
           }
@@ -839,11 +827,9 @@ raw_type: container_type {
           }
         }
 
-        if (found) {
-          $$ = new tidl::BaseType(name, $1->GetComments(), type);
-        } else {
+        $$ = new tidl::BaseType(name, $1->GetComments(), type);
+        if (!found) {
           ps->ReportError("Unknown type : " + $1->ToString(), @1.begin.line);
-          $$ = NULL;
         }
       }
       delete $1;
index 9cffa0c3467b58e9f781a144daa437f5234f4c8d..cdfa45fab61cad8f5dee4b7c43e38a4691f46c5d 100644 (file)
@@ -397,7 +397,7 @@ static const yytype_int16 yyrline[] =
      635,   640,   644,   648,   652,   656,   662,   670,   681,   687,
      690,   693,   698,   701,   705,   711,   714,   720,   723,   740,
      743,   747,   751,   755,   759,   763,   767,   771,   781,   785,
-     789,   851,   878,   892,   905,   909,   913,   921
+     789,   837,   864,   878,   891,   895,   899,   907
 };
 #endif
 
@@ -2502,18 +2502,6 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
                 type = tidl::BaseType::UserType::STRUCTURE;
                 found = true;
                 break;
-              } else {
-                for (auto& e : b->GetEnums()) {
-                  if (e->GetID() == name) {
-                    type = tidl::BaseType::UserType::ENUM;
-                    name = b->GetID() + "." + name;
-                    found = true;
-                    break;
-                  }
-                }
-
-                if (found)
-                  break;
               }
             }
           }
@@ -2531,20 +2519,18 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
           }
         }
 
-        if (found) {
-          ((*yyvalp).b_type) = new tidl::BaseType(name, (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(), type);
-        } else {
+        ((*yyvalp).b_type) = new tidl::BaseType(name, (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments(), type);
+        if (!found) {
           ps->ReportError("Unknown type : " + (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->ToString(), (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
-          ((*yyvalp).b_type) = NULL;
         }
       }
       delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2544 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2530 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 91:
-#line 851 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 837 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
                       {
       bool found = false;
       if (document) {
@@ -2570,11 +2556,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
       }
       delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.token);
     }
-#line 2574 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2560 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 92:
-#line 878 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 864 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
                                                                        {
       if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token)->ToString() == "map") {
         ps->ReportError("syntax error. The value must be existed.", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yyloc).begin.line);
@@ -2589,11 +2575,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
         delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.token);
       }
     }
-#line 2593 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2579 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 93:
-#line 892 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 878 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
                                                                                {
       if ((YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token)->ToString() != "map") {
         ps->ReportError("syntax error. The container type must be \"map\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yyloc).begin.line);
@@ -2605,29 +2591,29 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
         delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (-5)].yystate.yysemantics.yysval.token);
       }
     }
-#line 2609 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2595 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 94:
-#line 905 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 891 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
                             {
       ((*yyvalp).token) = new tidl::Token("list", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
       delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2618 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2604 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 95:
-#line 909 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 895 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
               {
       ((*yyvalp).token) = new tidl::Token("array", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
       delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2627 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2613 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 96:
-#line 913 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 899 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
             {
       if (ps->GetVersion() < 2) {
         ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
@@ -2636,11 +2622,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
       ((*yyvalp).token) = new tidl::Token("map", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
       delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2640 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2626 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
   case 97:
-#line 921 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 907 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
             {
       if (ps->GetVersion() < 2) {
         ps->ReportError("syntax error. \"No identifier\".", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yyloc).begin.line);
@@ -2649,11 +2635,11 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
       ((*yyvalp).token) = new tidl::Token("set", (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token)->GetComments());
       delete (YY_CAST (yyGLRStackItem const *, yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.token);
     }
-#line 2653 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2639 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
     break;
 
 
-#line 2657 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 2643 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
 
       default: break;
     }
@@ -4115,7 +4101,7 @@ yyparse (yy::parser& yyparser, tidl::Parser* ps)
 
   // User initialization code.
 yylloc.initialize ();
-#line 4119 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 4105 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
 
 
   if (! yyinitGLRStack (yystackp, YYINITDEPTH))
@@ -4403,7 +4389,7 @@ yypdumpstack (yyGLRStack* yystackp)
 
 
 
-#line 931 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
+#line 917 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc.yy"
 
 
 #include <ctype.h>
@@ -4415,7 +4401,7 @@ void yy::parser::error(const yy::parser::location_type& l,
 }
 
 
-#line 4419 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 4405 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
 
 /*------------------.
 | Report an error.  |
@@ -4431,7 +4417,7 @@ yyerror (const yy::parser::location_type *yylocationp, yy::parser& yyparser, tid
 
 
 namespace yy {
-#line 4435 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 4421 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
 
   /// Build a parser object.
   parser::parser (tidl::Parser* ps_yyarg)
@@ -4519,4 +4505,4 @@ namespace yy {
 
 #endif
 } // yy
-#line 4523 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
+#line 4509 "/opt/data/tizen/public/platform/core/appfw/tidl/idlc/ast/tidlc_y.cpp"
index 1dd9bb804c30f4ec7a8f44c7130f3845e4d87339..1db26ca86a40967a7fcb0c47a49e17f692abc7fd 100644 (file)
@@ -13,12 +13,12 @@ struct Envelope {
 }
 
 struct BeginEnvelope : Envelope {
-  peer peer_info;
+  Envelope.peer peer_info;
   string message;
 }
 
 struct EndEnvelope : Envelope {
-  peer peer_info;
+  Envelope.peer peer_info;
   string message;
 }