Fix build error 75/291675/1
authorjusung son <jusung07.son@samsung.com>
Thu, 20 Apr 2023 06:44:29 +0000 (15:44 +0900)
committerjusung son <jusung07.son@samsung.com>
Thu, 20 Apr 2023 06:44:29 +0000 (15:44 +0900)
 - Separate the implementations of Protocol 2.

Change-Id: I95bd68b768c40053d23c6bab4fc5054447816ea3
Signed-off-by: jusung son <jusung07.son@samsung.com>
idlc/ast/tidlc.yy

index 4069761..d20bdd1 100644 (file)
@@ -232,8 +232,13 @@ enums: enum {
 ;
 
 enum: T_ENUM T_ID T_BRACE_OPEN fields T_BRACE_CLOSE {
-    $$ = new tidl::Enum($2->ToString(), $4, $1->GetComments(),
-        @1.begin.line);
+    if (ps->GetVersion() < 2) {
+      ps->ReportError("syntax error. \"enum is supported from protocol version 2\".", @1.begin.line);
+      ps->ReportError("try to use protocol version 2.", @1.begin.line);
+    } else {
+      $$ = new tidl::Enum($2->ToString(), $4, $1->GetComments(),
+          @1.begin.line);
+    }
     delete $2;
   }
 ;
@@ -676,46 +681,50 @@ raw_type: container_type {
       delete $1;
     }
     | T_ID {
-      bool found = false;
-      tidl::BaseType::UserType type;
-      if (currentInterfaceEnums) {
-        for (auto& e : *currentInterfaceEnums) {
-          if (e->GetID() == $1->ToString()) {
-            type = tidl::BaseType::UserType::ENUM;
-            found = true;
-            break;
+      if (ps->GetVersion() < 2) {
+        $$ = new tidl::BaseType($1->ToString(), $1->GetComments(), true);
+      } else {
+        bool found = false;
+        tidl::BaseType::UserType type;
+        if (currentInterfaceEnums) {
+          for (auto& e : *currentInterfaceEnums) {
+            if (e->GetID() == $1->ToString()) {
+              type = tidl::BaseType::UserType::ENUM;
+              found = true;
+              break;
+            }
           }
         }
-      }
 
-      if (!found && document) {
-        for (auto& b : document->GetBlocks()) {
-          if (b->GetType() == tidl::Block::TYPE_STRUCTURE
-              && b->GetID() == $1->ToString()) {
-            type = tidl::BaseType::UserType::STRUCTURE;
-            found = true;
-            break;
+        if (!found && document) {
+          for (auto& b : document->GetBlocks()) {
+            if (b->GetType() == tidl::Block::TYPE_STRUCTURE
+                && b->GetID() == $1->ToString()) {
+              type = tidl::BaseType::UserType::STRUCTURE;
+              found = true;
+              break;
+            }
           }
         }
-      }
 
-      if(!found && currentDeclarations) {
-        for (auto& d : *currentDeclarations) {
-          if (d->GetMethodType() == tidl::Declaration::MethodType::DELEGATE) {
-            if (d->GetID() == $1->ToString()) {
-              type = tidl::BaseType::UserType::DELEGATE;
-              found = true;
-              break;
+        if(!found && currentDeclarations) {
+          for (auto& d : *currentDeclarations) {
+            if (d->GetMethodType() == tidl::Declaration::MethodType::DELEGATE) {
+              if (d->GetID() == $1->ToString()) {
+                type = tidl::BaseType::UserType::DELEGATE;
+                found = true;
+                break;
+              }
             }
           }
         }
-      }
 
-      if (found) {
-        $$ = new tidl::BaseType($1->ToString(), $1->GetComments(), type);
-      } else {
-        ps->ReportError("Unknown type : " + $1->ToString(), @1.begin.line);
-        $$ = NULL;
+        if (found) {
+          $$ = new tidl::BaseType($1->ToString(), $1->GetComments(), type);
+        } else {
+          ps->ReportError("Unknown type : " + $1->ToString(), @1.begin.line);
+          $$ = NULL;
+        }
       }
       delete $1;
     }