From 15c846683496b2351a4a62f2dea4239746baa986 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 8 Jul 2022 13:53:09 +0900 Subject: [PATCH] Add options for aitt Change-Id: Icaed487ff809222553cfb521837039f3ed104706 Signed-off-by: Sangyoon Jang --- idlc/ast/parser.cc | 10 ++++++++-- idlc/ast/parser.h | 5 ++++- idlc/main.cc | 28 ++++++++++++++++++++++++++++ idlc/options.cc | 29 ++++++++++++++++++++--------- idlc/options.h | 2 ++ 5 files changed, 62 insertions(+), 12 deletions(-) diff --git a/idlc/ast/parser.cc b/idlc/ast/parser.cc index d2b6aa6..27c4d81 100644 --- a/idlc/ast/parser.cc +++ b/idlc/ast/parser.cc @@ -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_; } diff --git a/idlc/ast/parser.h b/idlc/ast/parser.h index 69476eb..b52af3f 100644 --- a/idlc/ast/parser.h +++ b/idlc/ast/parser.h @@ -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_; }; diff --git a/idlc/main.cc b/idlc/main.cc index a170a54..adb9801 100644 --- a/idlc/main.cc +++ b/idlc/main.cc @@ -111,6 +111,15 @@ void GenerateStubCodes(std::shared_ptr 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 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 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()); diff --git a/idlc/options.cc b/idlc/options.cc index ce44e6c..51523e4 100644 --- a/idlc/options.cc +++ b/idlc/options.cc @@ -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::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::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::Parse(int argc, char** argv) { return std::shared_ptr(nullptr); } + if (options->isCion_ && options->isAitt_) { + std::cerr << "Only one of cion and aitt is allowed." << std::endl; + return std::shared_ptr(nullptr); + } switch (static_cast(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(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(nullptr); } @@ -198,13 +208,14 @@ std::shared_ptr Options::Parse(int argc, char** argv) { switch (static_cast(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(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(nullptr); } diff --git a/idlc/options.h b/idlc/options.h index 951c0e0..079a90f 100644 --- a/idlc/options.h +++ b/idlc/options.h @@ -44,6 +44,7 @@ class Options { static std::shared_ptr 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_; -- 2.7.4