Add options for aitt 36/277536/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 8 Jul 2022 04:53:09 +0000 (13:53 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 11 Jul 2022 08:10:39 +0000 (17:10 +0900)
Change-Id: Icaed487ff809222553cfb521837039f3ed104706
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
idlc/ast/parser.cc
idlc/ast/parser.h
idlc/main.cc
idlc/options.cc
idlc/options.h

index d2b6aa6..27c4d81 100644 (file)
@@ -33,9 +33,11 @@ void yylex_destroy(void*);
 
 namespace tidl {
 
-Parser::Parser(bool beta_enable, bool cion_enable, bool group_enable)
+Parser::Parser(bool beta_enable, bool cion_enable, bool aitt_enable,
+    bool group_enable)
     : scanner_(nullptr), error_(false), beta_enable_(beta_enable),
-    cion_enable_(cion_enable), group_enable_(group_enable) {
+    cion_enable_(cion_enable), aitt_enable_(aitt_enable),
+    group_enable_(group_enable) {
   yylex_init(&scanner_);
 }
 
@@ -86,6 +88,10 @@ bool Parser::IsCionEnabled() {
   return cion_enable_;
 }
 
+bool Parser::IsAittEnabled() {
+  return aitt_enable_;
+}
+
 bool Parser::IsGroupEnabled() {
   return group_enable_;
 }
index 69476eb..b52af3f 100644 (file)
@@ -27,7 +27,8 @@ namespace tidl {
 
 class Parser {
  public:
-  Parser(bool beta_enable = false, bool cion_enable = false, bool group_enable = false);
+  Parser(bool beta_enable = false, bool cion_enable = false,
+      bool aitt_enable = false, bool group_enable = false);
   ~Parser();
 
   void* Scanner() const { return scanner_; }
@@ -38,6 +39,7 @@ class Parser {
   void ReportError(const std::string& err, unsigned line);
   bool IsBetaEnabled();
   bool IsCionEnabled();
+  bool IsAittEnabled();
   bool IsGroupEnabled();
 
  private:
@@ -47,6 +49,7 @@ class Parser {
   bool error_;
   bool beta_enable_;
   bool cion_enable_;
+  bool aitt_enable_;
   bool group_enable_;
 };
 
index a170a54..adb9801 100644 (file)
@@ -111,6 +111,15 @@ void GenerateStubCodes(std::shared_ptr<tidl::Options> options,
     default:
       break;
     }
+  } else if (options->IsAitt()) {
+    switch (options->GetLanguage()) {
+      case tidl::Options::LANGUAGE_TYPE_C:
+      case tidl::Options::LANGUAGE_TYPE_CPP:
+      case tidl::Options::LANGUAGE_TYPE_CSHARP:
+      case tidl::Options::LANGUAGE_TYPE_JAVA:
+      default:
+        break;
+    }
   } else {
     switch (options->GetLanguage()) {
     case tidl::Options::LANGUAGE_TYPE_C:
@@ -203,6 +212,15 @@ void GenerateProxyCodes(std::shared_ptr<tidl::Options> options,
     default:
       break;
     }
+  } else if (options->IsAitt()) {
+    switch (options->GetLanguage()) {
+      case tidl::Options::LANGUAGE_TYPE_C:
+      case tidl::Options::LANGUAGE_TYPE_CPP:
+      case tidl::Options::LANGUAGE_TYPE_CSHARP:
+      case tidl::Options::LANGUAGE_TYPE_JAVA:
+      default:
+        break;
+    }
   } else {
     switch (options->GetLanguage()) {
     case tidl::Options::LANGUAGE_TYPE_C:
@@ -295,6 +313,15 @@ void GenerateGroupCodes(std::shared_ptr<tidl::Options> options,
     default:
       break;
     }
+  } else {
+    switch (options->GetLanguage()) {
+      case tidl::Options::LANGUAGE_TYPE_C:
+      case tidl::Options::LANGUAGE_TYPE_CPP:
+      case tidl::Options::LANGUAGE_TYPE_CSHARP:
+      case tidl::Options::LANGUAGE_TYPE_JAVA:
+      default:
+        break;
+    }
   }
 }
 
@@ -321,6 +348,7 @@ int main(int argc, char** argv) {
     exit(1);
 
   tidl::Parser ps(options->IsBetaEnabled(), options->IsCion(),
+    options->IsAitt(),
     options->GetType() == tidl::Options::Type::TYPE_GROUP ? true : false);
   std::string path(options->GetInput());
 
index ce44e6c..51523e4 100644 (file)
@@ -32,7 +32,7 @@ Help Options:
   -h, --help                  Show help options
 
 Additional Options:
-  -l, --language=LANGUAGE     Select generating language (C, C++, C#, Java(CION only)).
+  -l, --language=LANGUAGE     Select generating language (C, C++, C#, Java(CION & AITT only)).
   -i, --input=INPUT           A tidl interface file.
   -o, --output=OUTPUT         The generated interface file.
   -n, --namespace             Add the prefix in the funtion name as output file name (C language only).
@@ -40,11 +40,12 @@ Additional Options:
   -b, --beta                  Use beta version (Support private file sharing).
   -t, --thread                Generate thread code (Stub only).
   -c, --cion                  Generate CION code.
+  -a, --aitt                  Generate AITT code.
 
 Application Options:
   -p, --proxy                 Generate proxy code
   -s, --stub                  Generate stub code
-  -g, --group                 Generate group code (CION only)
+  -g, --group                 Generate group code (CION and AITT only)
   -v, --version               Show version information
 )__option_cb";
 }
@@ -95,11 +96,12 @@ std::shared_ptr<Options> Options::Parse(int argc, char** argv) {
     {"beta", no_argument,    NULL, 'b'},
     {"thread", no_argument,    NULL, 't'},
     {"cion", no_argument,    NULL, 'c'},
+    {"aitt", no_argument, NULL, 'a'},
     {0, 0, 0, 0}
   };
 
   while (true) {
-    int c = getopt_long(argc, argv, "tcbpsgvhl:i:o:nr", long_options,
+    int c = getopt_long(argc, argv, "tcbpsgvhal:i:o:nr", long_options,
         &option_index);
     if (c == -1)
       break;
@@ -162,6 +164,10 @@ std::shared_ptr<Options> Options::Parse(int argc, char** argv) {
         options->isCion_ = true;
         break;
 
+      case 'a':
+        options->isAitt_ = true;
+        break;
+
       default:
         cmd[CMD_HELP] = 1;
     }
@@ -177,16 +183,20 @@ std::shared_ptr<Options> Options::Parse(int argc, char** argv) {
     return std::shared_ptr<Options>(nullptr);
   }
 
+  if (options->isCion_ && options->isAitt_) {
+    std::cerr << "Only one of cion and aitt is allowed." << std::endl;
+    return std::shared_ptr<Options>(nullptr);
+  }
   switch (static_cast<int>(options->type_)) {
   case TYPE_UNKNOWN:
     std::cerr <<
-      "Stub or proxy or group (CION only) must be specified." << std::endl;
+      "Stub or proxy or group (CION & AITT only) must be specified." << std::endl;
     options->PrintSample();
     return std::shared_ptr<Options>(nullptr);
   case TYPE_GROUP:
-    if (!options->isCion_) {
+    if (!options->isCion_ && !options->isAitt_) {
       std::cerr <<
-        "Group is only allowed for the CION codes." << std::endl;
+        "Group is only allowed for the CION and AITT codes." << std::endl;
       options->PrintSample();
       return std::shared_ptr<Options>(nullptr);
     }
@@ -198,13 +208,14 @@ std::shared_ptr<Options> Options::Parse(int argc, char** argv) {
   switch (static_cast<int>(options->language_)) {
   case LANGUAGE_TYPE_UNKNOWN:
     std::cerr <<
-      "Select a language (C, C++, C#, Java(CION only)).." << std::endl;
+      "Select a language (C, C++, C#, Java(CION & AITT only)).." << std::endl;
     options->PrintSample();
     return std::shared_ptr<Options>(nullptr);
   case LANGUAGE_TYPE_JAVA:
-    if (!options->isCion_) {
+    if (!options->isCion_ && !options->isAitt_) {
       std::cerr <<
-        "Java language is only allowed for the CION codes." << std::endl;
+        "Java language is only allowed for the CION and "
+        "AITT codes." << std::endl;
       options->PrintSample();
       return std::shared_ptr<Options>(nullptr);
     }
index 951c0e0..079a90f 100644 (file)
@@ -44,6 +44,7 @@ class Options {
 
   static std::shared_ptr<Options> Parse(int argc, char** argv);
   bool IsCion() const { return isCion_; }
+  bool IsAitt() const { return isAitt_; }
   Type GetType() const { return type_; }
   bool IsBetaEnabled() const { return isBetaEnabled_; }
   bool IsThreadEnabled() const { return isThreadEnabled_; }
@@ -74,6 +75,7 @@ class Options {
 
  private:
   bool isCion_ = false;
+  bool isAitt_ = false;
   LanguageType language_;
   std::string input_;
   std::string output_;