--- /dev/null
+#!/bin/bash
+
+#--------------------------------------------------------#
+# Tizen Interface Definition Langauge Compiler #
+#--------------------------------------------------------#
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+SCRIPT_FILE=$(readlink -f $0)
+SCRIPT_DIR=$(dirname $SCRIPT_FILE)
+BUILD_DIR=build
+
+usage() {
+ echo "Usage: $0 [command]"
+ echo "Commands:"
+ echo " build Build the package"
+ echo " clean Clean all artifacts"
+ echo " clean_build Clean & Build the package"
+}
+
+cmd_build() {
+ echo "[TIDL] Build the package"
+ mkdir -p $SCRIPT_DIR/$BUILD_DIR
+ cd $SCRIPT_DIR/$BUILD_DIR
+ cmake ..
+ make clean
+ make
+}
+
+cmd_clean() {
+ echo "[TIDL] Clean all artifacts"
+ cd $SCRIPT_DIR/$BUILD_DIR
+ make clean
+ cd ..
+ rm -rf $SCRIPT_DIR/$BUILD_DIR
+ rm -rf $SCRIPT_DIR/idlc/location*
+ rm -rf $SCRIPT_DIR/idlc/position*
+}
+
+cmd_clean_build() {
+ cmd_clean
+ cmd_build
+}
+
+cmd=$1; shift;
+case "$cmd" in
+ build|--build|-b) cmd_build $@ ;;
+ clean|--clean|-c) cmd_clean $@ ;;
+ clean_build |--clean_build |-cb) cmd_clean_build $@ ;;
+ *) usage ;;
+
+esac
namespace tidl {
-Attribute::Attribute(const std::string& id, BaseType* type, unsigned line)
- : id_(id), type_(type), line_(line) {}
+Attribute::Attribute(const std::string& id, BaseType* type,
+ const std::string& comments, unsigned line)
+ : id_(id), type_(type), comments_(comments), line_(line) {}
const std::string& Attribute::GetID() const {
return id_;
return line_;
}
+const std::string& Attribute::GetComments() const {
+ return comments_;
+}
+
void Attributes::Add(Attribute* attr) {
attrs_.emplace_back(attr);
}
class Attribute {
public:
- Attribute(const std::string& id, BaseType* type, unsigned line);
+ Attribute(const std::string& id, BaseType* type,
+ const std::string& comments, unsigned line);
const std::string& GetID() const;
const BaseType& GetType() const;
const unsigned GetLine() const;
+ const std::string& GetComments() const;
private:
std::string id_;
std::unique_ptr<BaseType> type_;
+ std::string comments_;
unsigned line_;
};
namespace tidl {
-Block::Block(const std::string& id, Block::Type type, unsigned line)
- : id_(id), type_(type), line_(line) {
+Block::Block(const std::string& id, Block::Type type,
+ const std::string& comments, unsigned line)
+ : id_(id), type_(type), comments_(comments), line_(line) {
}
const std::string& Block::GetID() const {
return line_;
}
+const std::string& Block::GetComments() const {
+ return comments_;
+}
+
} // namespace tidl
TYPE_STRUCTURE,
};
- Block(const std::string& id, Block::Type type, unsigned line);
+ Block(const std::string& id, Block::Type type, const std::string& comments,
+ unsigned line);
virtual ~Block() = default;
const std::string& GetID() const;
const Block::Type& GetType() const;
const unsigned GetLine() const;
+ const std::string& GetComments() const;
private:
std::string id_;
Block::Type type_;
+ std::string comments_;
unsigned line_;
};
namespace tidl {
Declaration::Declaration(const std::string& id, BaseType* ret_type,
- Parameters* params, unsigned line, bool async)
+ Parameters* params, const std::string& comments,
+ unsigned line, bool async)
: id_(id),
ret_type_(ret_type),
params_(params),
+ comments_(comments),
line_(line),
async_(async) {}
return line_;
}
+const std::string& Declaration::GetComments() const {
+ return comments_;
+}
+
void Declarations::Add(Declaration* decl) {
decls_.emplace_back(decl);
}
class Declaration {
public:
Declaration(const std::string& id, BaseType* ret_type, Parameters* params,
- unsigned line, bool async = false);
+ const std::string& comments, unsigned line, bool async = false);
const std::string& GetID() const;
const BaseType& GetType() const;
const Parameters& GetParameters() const;
bool IsAsync() const;
const unsigned GetLine() const;
+ const std::string& GetComments() const;
private:
std::string id_;
std::unique_ptr<BaseType> ret_type_;
std::unique_ptr<Parameters> params_;
+ std::string comments_;
unsigned line_;
bool async_;
};
for (auto& block : doc_->GetBlocks()) {
if (block->GetType() == Block::TYPE_INTERFACE) {
Interface* interface = static_cast<Interface*>(block.get());
- OnInterfaceBegin(interface->GetID());
+ OnInterfaceBegin(out_file_, interface->GetID(), interface->GetComments());
for (auto& decl : interface->GetDeclarations().GetDecls()) {
OnDeclarationGen(out_file_, decl->GetID(), decl->GetParameters(),
- decl->GetType());
+ decl->GetType(), decl->GetComments());
}
- OnInterfaceEnd(interface->GetID());
+ OnInterfaceEnd(out_file_, interface->GetID());
} else if (block->GetType() == Block::TYPE_STRUCTURE) {
Structure* structure = static_cast<Structure*>(block.get());
- OnStructureBegin(out_file_, structure->GetID());
+ OnStructureBegin(out_file_, structure->GetID(), structure->GetComments());
for (auto& attr : structure->GetAttributes().GetAttrs()) {
- OnAttributeGen(out_file_, attr->GetID(), attr->GetType());
+ OnAttributeGen(out_file_, attr->GetID(), attr->GetType(),
+ attr->GetComments());
}
OnStructureEnd(out_file_, structure->GetID());
}
virtual ~Generator() = default;
void Run(const std::string& file_name);
- virtual void OnInterfaceBegin(const std::string& id) = 0;
- virtual void OnInterfaceEnd(const std::string& id) = 0;
+ virtual void OnInterfaceBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) = 0;
+ virtual void OnInterfaceEnd(std::ofstream& stream, const std::string& id) = 0;
virtual void OnDeclarationGen(std::ofstream& stream, const std::string& id,
const Parameters& args,
- const BaseType& ret) = 0;
+ const BaseType& ret,
+ const std::string& comments) = 0;
virtual void OnStructureBegin(std::ofstream& stream,
- const std::string& id) = 0;
+ const std::string& id,
+ const std::string& comments) = 0;
virtual void OnStructureEnd(std::ofstream& stream, const std::string& id) = 0;
virtual void OnAttributeGen(std::ofstream& stream, const std::string& id,
- const BaseType& type) = 0;
+ const BaseType& type,
+ const std::string& comments) = 0;
virtual void OnInitGen(std::ofstream& stream) = 0;
virtual void OnFiniGen(std::ofstream& stream) = 0;
namespace tidl {
-Interface::Interface(const std::string& id, Declarations* decls, unsigned line)
- : Block::Block(id, Block::TYPE_INTERFACE, line), decls_(decls) {
+Interface::Interface(const std::string& id, Declarations* decls,
+ const std::string& comments, unsigned line)
+ : Block::Block(id, Block::TYPE_INTERFACE, comments, line), decls_(decls) {
}
const Declarations& Interface::GetDeclarations() const {
class Interface : public Block {
public:
- Interface(const std::string& id, Declarations* decls, unsigned line);
+ Interface(const std::string& id, Declarations* decls,
+ const std::string& comments, unsigned line);
const Declarations& GetDeclarations() const;
void ProxyGen::OnDeclarationGen(std::ofstream& stream, const std::string& id,
const Parameters& args,
- const BaseType& ret) {
+ const BaseType& ret,
+ const std::string& comments) {
+ if (comments != "")
+ stream << comments;
stream << ret.ToString() << " " << interface_name_ + "_" + id << "(";
bool first = true;
void ProxyGen::OnFiniGen(std::ofstream& stream) {
}
-void ProxyGen::OnInterfaceBegin(const std::string& id) {
+void ProxyGen::OnInterfaceBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) {
+ if (comments != "")
+ stream << comments;
interface_name_ = id;
}
-void ProxyGen::OnInterfaceEnd(const std::string& id) {
+void ProxyGen::OnInterfaceEnd(std::ofstream& stream, const std::string& id) {
interface_name_ = "";
}
void ProxyGen::OnAttributeGen(std::ofstream& stream, const std::string& id,
- const BaseType& type) {
+ const BaseType& type,
+ const std::string& comments) {
+ if (comments != "")
+ stream << "\t" << comments;
stream << "\t" << type.GetFullName() << " " << id << ";" << std::endl;
}
-void ProxyGen::OnStructureBegin(std::ofstream& stream, const std::string& id) {
+void ProxyGen::OnStructureBegin(std::ofstream& stream, const std::string& id,
+ const std::string& comments) {
+ if (comments != "")
+ stream << comments;
stream << "typedef struct" << " " << id + "_t" << " " << "{" << std::endl;
}
virtual ~ProxyGen() = default;
void OnDeclarationGen(std::ofstream& stream, const std::string& id,
- const Parameters& args, const BaseType& ret) override;
+ const Parameters& args, const BaseType& ret,
+ const std::string& comments) override;
void OnInitGen(std::ofstream& stream) override;
void OnFiniGen(std::ofstream& stream) override;
- void OnInterfaceBegin(const std::string& id) override;
- void OnInterfaceEnd(const std::string& id) override;
+ void OnInterfaceBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) override;
+ void OnInterfaceEnd(std::ofstream& stream, const std::string& id) override;
void OnAttributeGen(std::ofstream& stream, const std::string& id,
- const BaseType& type) override;
- void OnStructureBegin(std::ofstream& stream, const std::string& id) override;
+ const BaseType& type,
+ const std::string& comments) override;
+ void OnStructureBegin(std::ofstream& stream, const std::string& id,
+ const std::string& comments) override;
void OnStructureEnd(std::ofstream& stream, const std::string& id) override;
private:
namespace tidl {
-Structure::Structure(const std::string& id, Attributes* attrs, unsigned line)
- : Block::Block(id, Block::TYPE_STRUCTURE, line), attrs_(attrs) {
+Structure::Structure(const std::string& id, Attributes* attrs,
+ const std::string& comments, unsigned line)
+ : Block::Block(id, Block::TYPE_STRUCTURE, comments, line), attrs_(attrs) {
}
const Attributes& Structure::GetAttributes() const {
class Structure : public Block {
public:
- Structure(const std::string& id, Attributes* attrs, unsigned line);
+ Structure(const std::string& id, Attributes* attrs,
+ const std::string& comments, unsigned line);
const Attributes& GetAttributes() const;
: Generator(doc) {}
void StubGen::OnDeclarationGen(std::ofstream& stream, const std::string& id,
- const Parameters& args, const BaseType& ret) {}
+ const Parameters& args, const BaseType& ret,
+ const std::string& comments) {}
void StubGen::OnInitGen(std::ofstream& stream) {}
void StubGen::OnFiniGen(std::ofstream& stream) {}
-void StubGen::OnInterfaceBegin(const std::string& id) {}
+void StubGen::OnInterfaceBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) {}
-void StubGen::OnInterfaceEnd(const std::string& id) {}
+void StubGen::OnInterfaceEnd(std::ofstream& stream, const std::string& id) {}
void StubGen::OnAttributeGen(std::ofstream& stream, const std::string& id,
- const BaseType& type) {}
+ const BaseType& type,
+ const std::string& comments) {}
-void StubGen::OnStructureBegin(std::ofstream& stream, const std::string& id) {}
+void StubGen::OnStructureBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) {}
void StubGen::OnStructureEnd(std::ofstream& stream, const std::string& id) {}
virtual ~StubGen() = default;
void OnDeclarationGen(std::ofstream& stream, const std::string& id,
- const Parameters& args, const BaseType& ret) override;
+ const Parameters& args, const BaseType& ret,
+ const std::string& comments) override;
void OnInitGen(std::ofstream& stream) override;
void OnFiniGen(std::ofstream& stream) override;
- void OnInterfaceBegin(const std::string& id) override;
- void OnInterfaceEnd(const std::string& id) override;
+ void OnInterfaceBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) override;
+ void OnInterfaceEnd(std::ofstream& stream, const std::string& id) override;
void OnAttributeGen(std::ofstream& stream, const std::string& id,
- const BaseType& type) override;
- void OnStructureBegin(std::ofstream& stream, const std::string& id) override;
+ const BaseType& type,
+ const std::string& comments) override;
+ void OnStructureBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) override;
void OnStructureEnd(std::ofstream& stream, const std::string& id) override;
};
%{
#include <stdio.h>
+#include <string>
#include "idlc/parser.h"
#include "idlc/document.h"
#define YY_USER_ACTION yylloc->columns(yyleng);
%}
+%x COMMENT
+
%option yylineno
%option noyywrap
%option reentrant
%option bison-locations
%%
+%{
+ std::string comments;
+%}
+"/*" { comments += yytext; BEGIN(COMMENT); }
+<COMMENT>"*/"+\/ { comments += yytext; yylloc->step(); BEGIN(INITIAL); }
+<COMMENT>"*/" { comments += yytext; comments += "\n"; BEGIN(INITIAL); }
+<COMMENT>"*/"\n+ { comments += yytext; yylloc->step(); BEGIN(INITIAL); }
+<COMMENT>\n+ { comments += yytext; yylloc->lines(yyleng); }
+<COMMENT>([^*]\n)+|. { comments += yytext; yylloc->step(); }
+<COMMENT><<EOF>> { return 0; }
-[\n] { yylloc->lines(yyleng); yylloc->step(); }
+"//".*\n { comments += yytext; yylloc->step(); }
+
+[\n]+ { yylloc->lines(yyleng); yylloc->step(); }
[ \t\r\n] ; // ignore all whitespace
"," { return yy::parser::token::T_COMMA; }
"(" { return yy::parser::token::T_LEFT; }
")" { return yy::parser::token::T_RIGHT; }
";" { return yy::parser::token::T_SEMICOLON; }
-"void" { return yy::parser::token::T_VOID; }
-"char" { return yy::parser::token::T_CHAR; }
-"short" { return yy::parser::token::T_SHORT; }
-"int" { return yy::parser::token::T_INT; }
-"long" { return yy::parser::token::T_LONG; }
-"float" { return yy::parser::token::T_FLOAT; }
-"double" { return yy::parser::token::T_DOUBLE; }
-"bundle" { return yy::parser::token::T_BUNDLE; }
-"string" { return yy::parser::token::T_STRING; }
-"bool" { return yy::parser::token::T_BOOL; }
+"void" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_VOID;
+ }
+"char" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_CHAR;
+ }
+"short" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_SHORT;
+ }
+"int" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_INT;
+ }
+"long" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_LONG;
+ }
+"float" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_FLOAT;
+ }
+"double" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_DOUBLE;
+ }
+"bundle" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_BUNDLE;
+ }
+"string" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_STRING;
+ }
+"bool" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_BOOL;
+ }
"in" { return yy::parser::token::T_IN; }
"out" { return yy::parser::token::T_OUT; }
"ref" { return yy::parser::token::T_REF; }
"async" { return yy::parser::token::T_ASYNC; }
-"interface" { return yy::parser::token::T_INTERFACE; }
"<" { return yy::parser::token::T_META_OPEN; }
">" { return yy::parser::token::T_META_CLOSE; }
-"list" { return yy::parser::token::T_LIST; }
-"struct" { return yy::parser::token::T_STRUCTURE; }
-
+"list" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_LIST;
+ }
+"struct" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_STRUCTURE;
+ }
+"interface" {
+ yylval->token = new tidl::Token(yytext, comments);
+ return yy::parser::token::T_INTERFACE;
+ }
[A-Za-z_][A-Za-z0-9_]* {
- yylval->token = new tidl::Token(yytext);
+ yylval->token = new tidl::Token(yytext, comments);
return yy::parser::token::T_ID;
}
%lex-param { void *lex_scanner }
%token T_LEFT T_RIGHT T_COMMA T_SEMICOLON T_BRACE_OPEN T_BRACE_CLOSE
-%token T_CHAR T_SHORT T_INT T_LONG T_FLOAT T_DOUBLE T_VOID T_BUNDLE
-%token T_STRING T_BOOL
-%token T_IN T_OUT T_REF T_ASYNC T_INTERFACE T_STRUCTURE
-%token T_META_OPEN T_META_CLOSE T_LIST
+%token T_IN T_OUT T_REF T_ASYNC
+%token T_META_OPEN T_META_CLOSE
%start start
}
%token<token> T_ID
+%token<token> T_STRUCTURE
+%token<token> T_INTERFACE
+%token<token> T_CHAR
+%token<token> T_SHORT
+%token<token> T_INT
+%token<token> T_LONG
+%token<token> T_FLOAT
+%token<token> T_DOUBLE
+%token<token> T_VOID
+%token<token> T_BUNDLE
+%token<token> T_STRING
+%token<token> T_BOOL
+%token<token> T_LIST
%type<doc> blocks
%type<blk> block
%type<structure> structure_block
;
structure_block: T_STRUCTURE T_ID T_BRACE_OPEN attributes T_BRACE_CLOSE {
- $$ = new tidl::Structure($2->ToString(), $4, @1.begin.line);
+ $$ = new tidl::Structure($2->ToString(), $4, $1->GetComments(),
+ @1.begin.line);
+ delete $1;
delete $2;
}
| T_STRUCTURE T_BRACE_OPEN attributes T_BRACE_CLOSE {
ps->ReportError("syntax error. \"No identifier\".", @1.begin.line);
$$ = NULL;
+ delete $1;
}
| T_STRUCTURE error T_BRACE_OPEN attributes T_BRACE_CLOSE {
ps->ReportError("syntax error. \"Please check it before an open brace.\"",
@2.begin.line);
$$ = NULL;
+ delete $1;
}
| T_STRUCTURE error T_BRACE_CLOSE {
ps->ReportError("syntax error in structure declaration.", @2.begin.line);
$$ = NULL;
+ delete $1;
}
;
;
attribute: base_type T_ID T_SEMICOLON {
- $$ = new tidl::Attribute($2->ToString(), $1, @1.begin.line);
+ $$ = new tidl::Attribute($2->ToString(), $1, $1->GetComments(),
+ @1.begin.line);
delete $2;
}
| base_type T_SEMICOLON {
;
interface_block: T_INTERFACE T_ID T_BRACE_OPEN declarations T_BRACE_CLOSE {
- $$ = new tidl::Interface($2->ToString(), $4, @1.begin.line);
+ $$ = new tidl::Interface($2->ToString(), $4, $1->GetComments(),
+ @1.begin.line);
+ delete $1;
delete $2;
}
| T_INTERFACE T_BRACE_OPEN declarations T_BRACE_CLOSE {
ps->ReportError("syntax error. \"No identifier\".", @1.begin.line);
$$ = NULL;
+ delete $1;
}
| T_INTERFACE error T_BRACE_OPEN declarations T_BRACE_CLOSE {
ps->ReportError("syntax error in interface declaration.", @2.begin.line);
$$ = NULL;
+ delete $1;
}
| T_INTERFACE error T_BRACE_CLOSE {
ps->ReportError("syntax error in interface declaration.", @2.begin.line);
$$ = NULL;
+ delete $1;
}
;
;
declaration: base_type T_ID T_LEFT parameter_list T_RIGHT T_SEMICOLON {
- $$ = new tidl::Declaration($2->ToString(), $1, $4, @1.begin.line);
+ $$ = new tidl::Declaration($2->ToString(), $1, $4, $1->GetComments(),
+ @1.begin.line);
delete $2;
}
| T_VOID T_ID T_LEFT parameter_list T_RIGHT T_ASYNC T_SEMICOLON {
- $$ = new tidl::Declaration($2->ToString(), new tidl::BaseType("void"), $4,
- @1.begin.line, true);
+ $$ = new tidl::Declaration($2->ToString(),
+ new tidl::BaseType("void", $1->GetComments()), $4,
+ $1->GetComments(), @1.begin.line, true);
+ delete $1;
delete $2;
}
| base_type T_ID T_LEFT parameter_list T_RIGHT T_ASYNC T_SEMICOLON {
;
direction_specifier: T_IN {
- $$ = new tidl::Token("in");
+ $$ = new tidl::Token("in", "");
}
| T_OUT {
- $$ = new tidl::Token("out");
+ $$ = new tidl::Token("out", "");
}
| T_REF {
- $$ = new tidl::Token("ref");
+ $$ = new tidl::Token("ref", "");
}
;
parameter: T_VOID {
$$ = new tidl::Parameter("empty",
- new tidl::ParameterType(new tidl::BaseType("void")), @1.begin.line);
+ new tidl::ParameterType(new tidl::BaseType("void", $1->GetComments())),
+ @1.begin.line);
+ delete $1;
}
| parameter_type T_ID {
$$ = new tidl::Parameter($2->ToString(), $1, @1.begin.line);
$$ = $1;
}
| T_VOID {
- $$ = new tidl::BaseType("void");
+ $$ = new tidl::BaseType("void", $1->GetComments());
+ delete $1;
}
| T_CHAR {
- $$ = new tidl::BaseType("char");
+ $$ = new tidl::BaseType("char", $1->GetComments());
+ delete $1;
}
| T_SHORT {
- $$ = new tidl::BaseType("short");
+ $$ = new tidl::BaseType("short", $1->GetComments());
+ delete $1;
}
| T_INT {
- $$ = new tidl::BaseType("int");
+ $$ = new tidl::BaseType("int", $1->GetComments());
+ delete $1;
}
| T_LONG {
- $$ = new tidl::BaseType("long");
+ $$ = new tidl::BaseType("long", $1->GetComments());
+ delete $1;
}
| T_FLOAT {
- $$ = new tidl::BaseType("float");
+ $$ = new tidl::BaseType("float", $1->GetComments());
+ delete $1;
}
| T_DOUBLE {
- $$ = new tidl::BaseType("double");
+ $$ = new tidl::BaseType("double", $1->GetComments());
+ delete $1;
}
| T_BUNDLE {
- $$ = new tidl::BaseType("bundle");
+ $$ = new tidl::BaseType("bundle", $1->GetComments());
+ delete $1;
}
| T_STRING {
- $$ = new tidl::BaseType("string");
+ $$ = new tidl::BaseType("string", $1->GetComments());
+ delete $1;
}
| T_BOOL {
- $$ = new tidl::BaseType("bool");
+ $$ = new tidl::BaseType("bool", $1->GetComments());
+ delete $1;
}
| T_ID {
- $$ = new tidl::BaseType($1->ToString(), true);
+ $$ = new tidl::BaseType($1->ToString(), $1->GetComments(), true);
delete $1;
}
;
container_type: container_type_name T_META_OPEN base_type T_META_CLOSE {
- $$ = new tidl::BaseType($1->ToString());
+ $$ = new tidl::BaseType($1->ToString(), $1->GetComments());
$$->SetMetaType($3);
+ delete $1;
}
;
container_type_name: T_LIST {
- $$ = new tidl::Token("list");
+ $$ = new tidl::Token("list", $1->GetComments());
+ delete $1;
}
;
* limitations under the License.
*/
+#include <iostream>
#include "idlc/type.h"
namespace tidl {
-Token::Token(const std::string& name) : name_(name) {
+Token::Token(const std::string& name, const std::string& comments)
+ : name_(name), comments_(comments) {
}
-BaseType::BaseType(const std::string& name, bool user_defined)
- : Token(name), user_defined_(user_defined) {
+BaseType::BaseType(const std::string& name, const std::string& comments,
+ bool user_defined)
+ : Token(name, comments), user_defined_(user_defined) {
}
void BaseType::SetMetaType(BaseType* type) {
class Token {
public:
- explicit Token(const std::string& name);
+ Token(const std::string& name, const std::string& comments);
virtual ~Token() = default;
virtual std::string ToString() const { return name_; }
+ virtual std::string GetComments() const { return comments_; }
private:
std::string name_;
+ std::string comments_;
};
class BaseType : public Token {
public:
- explicit BaseType(const std::string& name, bool user_defined = false);
+ explicit BaseType(const std::string& name, const std::string& comments,
+ bool user_defined = false);
void SetMetaType(BaseType* type);
const BaseType& GetMetaType() const {
return *meta_type_;
TEST_F(AttributeTest, Attribute_Contstructor) {
tidl::Attribute* attr = new tidl::Attribute("test",
- new tidl::BaseType("int"), __LINE__);
+ new tidl::BaseType("int", ""), "", __LINE__);
EXPECT_NE(attr, nullptr);
delete attr;
}
TEST_F(AttributeTest, Attribute_GetID) {
tidl::Attribute* attr = new tidl::Attribute("test",
- new tidl::BaseType("int"), __LINE__);
+ new tidl::BaseType("int", ""), "", __LINE__);
EXPECT_NE(attr, nullptr);
EXPECT_EQ(attr->GetID(), "test");
delete attr;
TEST_F(AttributeTest, Attribute_GetType) {
tidl::Attribute* attr = new tidl::Attribute("test",
- new tidl::BaseType("int"), __LINE__);
+ new tidl::BaseType("int", ""), "", __LINE__);
EXPECT_NE(attr, nullptr);
EXPECT_EQ(attr->GetType().ToString(), "int");
delete attr;
TEST_F(AttributeTest, Attribute_GetLine) {
unsigned line = __LINE__;
tidl::Attribute* attr = new tidl::Attribute("test",
- new tidl::BaseType("int"), line);
+ new tidl::BaseType("int", ""), "", line);
EXPECT_NE(attr, nullptr);
EXPECT_EQ(attr->GetLine(), line);
delete attr;
}
+TEST_F(AttributeTest, Attribute_GetComments) {
+ std::string comments = "Test comments";
+ tidl::Attribute* attr = new tidl::Attribute("test",
+ new tidl::BaseType("int", ""), comments, __LINE__);
+ EXPECT_NE(attr, nullptr);
+ EXPECT_EQ(attr->GetComments(), comments);
+ delete attr;
+}
+
class AttributesTest : public testing::Test {
public:
virtual void SetUp() {}
TEST_F(AttributesTest, Attributes_Add) {
tidl::Attribute* attr = new tidl::Attribute("test",
- new tidl::BaseType("int"), __LINE__);
+ new tidl::BaseType("int", ""), "", __LINE__);
EXPECT_NE(attr, nullptr);
tidl::Attributes* attrs = new tidl::Attributes();
EXPECT_NE(attrs, nullptr);
TEST_F(AttributesTest, Attributes_GetAttrs) {
tidl::Attributes* attrs = new tidl::Attributes();
EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("test1", new tidl::BaseType("int"), __LINE__));
- attrs->Add(new tidl::Attribute("test2", new tidl::BaseType("char *"),
- __LINE__));
+ attrs->Add(new tidl::Attribute("test1", new tidl::BaseType("int", ""),
+ "", __LINE__));
+ attrs->Add(new tidl::Attribute("test2", new tidl::BaseType("char *", ""),
+ "", __LINE__));
int count = 0;
for (auto& attr : attrs->GetAttrs()) {
TEST_F(AttributesTest, Attributes_Exist) {
tidl::Attribute* attr = new tidl::Attribute("test",
- new tidl::BaseType("int"), __LINE__);
+ new tidl::BaseType("int", ""), "", __LINE__);
EXPECT_NE(attr, nullptr);
tidl::Attributes* attrs = new tidl::Attributes();
EXPECT_NE(attrs, nullptr);
attrs->Add(attr);
tidl::Attribute* attr2 = new tidl::Attribute("test",
- new tidl::BaseType("int"), __LINE__);
+ new tidl::BaseType("int", ""), "", __LINE__);
EXPECT_NE(attr, nullptr);
EXPECT_EQ(attrs->Exist(attr2), true);
delete attr2;
tidl::Block* testBlock;
virtual void SetUp() {
- testBlock = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE, 28);
+ testBlock = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE,
+ "", 28);
}
virtual void TearDown() {
delete testBlock;
TEST_F(BlockTest, Block_Constructor) {
tidl::Block* block = new tidl::Block("StructureBlock",
- tidl::Block::TYPE_STRUCTURE, 37);
+ tidl::Block::TYPE_STRUCTURE, "", __LINE__);
EXPECT_NE(block, nullptr);
delete block;
}
TEST_F(BlockTest, Block_GetLine) {
EXPECT_EQ(testBlock->GetLine(), 28);
}
+
+TEST_F(BlockTest, Block_GetComments) {
+ std::string comments = "Test Block";
+ tidl::Block* block = new tidl::Block("StructureBlock",
+ tidl::Block::TYPE_STRUCTURE, comments, __LINE__);
+ EXPECT_NE(block, nullptr);
+ EXPECT_EQ(block->GetComments(), comments);
+ delete block;
+}
params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
params->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
params->Add(new tidl::Parameter("test2",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
}
virtual void TearDown() {}
};
TEST_F(DeclarationTest, Declaration_Constructor) {
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
delete decl;
}
TEST_F(DeclarationTest, Declaration_GetID) {
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
EXPECT_EQ(decl->GetID(), "test");
delete decl;
TEST_F(DeclarationTest, Declaration_GetType) {
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
EXPECT_EQ(decl->GetType().ToString(), "int");
delete decl;
TEST_F(DeclarationTest, Declaration_GetParameters) {
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
int count = 0;
TEST_F(DeclarationTest, Declaration_IsAsync) {
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
EXPECT_EQ(decl->IsAsync(), false);
delete decl;
}
+TEST_F(DeclarationTest, Declaration_GetComments) {
+ std::string comments = "Test Declaration";
+ tidl::Declaration* decl = new tidl::Declaration("test",
+ new tidl::BaseType("int", ""), params, comments, __LINE__);
+ EXPECT_NE(decl, nullptr);
+ EXPECT_EQ(decl->GetComments(), comments);
+ delete decl;
+}
+
TEST_F(DeclarationTest, Declaration_GetLine) {
unsigned line = __LINE__;
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, line);
+ new tidl::BaseType("int", ""), params, "", line);
EXPECT_NE(decl, nullptr);
EXPECT_EQ(decl->GetLine(), line);
delete decl;
tidl::Parameters* params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
params->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
params->Add(new tidl::Parameter("test2",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
}
};
tidl::Parameters* testParams = new tidl::Parameters();
EXPECT_NE(testParams, nullptr);
testParams->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
tidl::Declaration* testDecl = new tidl::Declaration("test",
- new tidl::BaseType("int"), testParams, __LINE__);
+ new tidl::BaseType("int", ""), testParams, "", __LINE__);
EXPECT_NE(testDecl, nullptr);
EXPECT_EQ(decls->Exist(testDecl), true);
delete testDecl;
virtual void SetUp() {
document = new tidl::Document();
- block = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE, __LINE__);
+ block = new tidl::Block("TestBlock", tidl::Block::TYPE_INTERFACE,
+ "", __LINE__);
}
virtual void TearDown() {
}
TEST_F(DocumentTest, Document_ExistBlock) {
document->AddBlock(block);
tidl::Block* testBlock = new tidl::Block("TestBlock",
- tidl::Block::TYPE_INTERFACE, __LINE__);
+ tidl::Block::TYPE_INTERFACE, "", __LINE__);
EXPECT_NE(testBlock, nullptr);
EXPECT_EQ(document->ExistBlock(testBlock), true);
delete testBlock;
class SampleGenerator : public tidl::Generator {
public:
- SampleGenerator(std::shared_ptr<tidl::Document> doc)
+ explicit SampleGenerator(std::shared_ptr<tidl::Document> doc)
: tidl::Generator(doc), count_(0) {}
~SampleGenerator() {}
- void OnInterfaceBegin(const std::string& id) override {
+ void OnInterfaceBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) override {
interfaceID_ = id;
count_++;
}
- void OnInterfaceEnd(const std::string& id) override {
+ void OnInterfaceEnd(std::ofstream& stream, const std::string& id) override {
count_++;
}
void OnDeclarationGen(std::ofstream& stream, const std::string& id,
const tidl::Parameters& args,
- const tidl::BaseType& ret) override {
+ const tidl::BaseType& ret,
+ const std::string& comments) override {
count_++;
}
- void OnStructureBegin(std::ofstream& stream, const std::string& id) override {
+ void OnStructureBegin(std::ofstream& stream,
+ const std::string& id,
+ const std::string& comments) override {
structureID_ = id;
count_++;
}
count_++;
}
void OnAttributeGen(std::ofstream& stream, const std::string& id,
- const tidl::BaseType& type) override {
+ const tidl::BaseType& type,
+ const std::string& comments) override {
count_++;
}
void OnInitGen(std::ofstream& stream) override {
tidl::Parameters* params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
params->Add(new tidl::Parameter("test",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
tidl::Declarations* decls = new tidl::Declarations();
tidl::Attributes* attrs = new tidl::Attributes();
EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("test", new tidl::BaseType("int"),
- __LINE__));
+ attrs->Add(new tidl::Attribute("test", new tidl::BaseType("int", ""),
+ "", __LINE__));
doc = new tidl::Document();
EXPECT_NE(doc, nullptr);
- doc->AddBlock(new tidl::Interface("TestInterface", decls, __LINE__));
- doc->AddBlock(new tidl::Structure("TestStructure", attrs, __LINE__));
+ doc->AddBlock(new tidl::Interface("TestInterface", decls, "", __LINE__));
+ doc->AddBlock(new tidl::Structure("TestStructure", attrs, "", __LINE__));
}
virtual void TearDown() {}
};
tidl::Parameters* params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
params->Add(new tidl::Parameter("test1",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
params->Add(new tidl::Parameter("test2",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
decls = new tidl::Declarations();
EXPECT_NE(decls, nullptr);
TEST_F(InterfaceTest, Interface_Constructor) {
tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(interface, nullptr);
delete interface;
}
TEST_F(InterfaceTest, Interface_GetDeclrations) {
tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(interface, nullptr);
bool flag = false;
TEST_F(InterfaceTest, Interface_GetID) {
tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(interface, nullptr);
EXPECT_EQ(interface->GetID(), "TestInterface");
delete interface;
TEST_F(InterfaceTest, Interface_GetType) {
tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(interface, nullptr);
EXPECT_EQ(interface->GetType(), tidl::Interface::TYPE_INTERFACE);
delete interface;
TEST_F(InterfaceTest, Interface_GetLine) {
unsigned line = __LINE__;
tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
- line);
+ "", line);
EXPECT_NE(interface, nullptr);
EXPECT_EQ(interface->GetLine(), line);
delete interface;
}
+
+TEST_F(InterfaceTest, Interface_GetComments) {
+ std::string comments = "Test Interface";
+ tidl::Interface* interface = new tidl::Interface("TestInterface", decls,
+ comments, __LINE__);
+ EXPECT_NE(interface, nullptr);
+ EXPECT_EQ(interface->GetComments(), comments);
+ delete interface;
+}
+
tidl::Parameters* params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
params->Add(new tidl::Parameter("test",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
tidl::Declarations* decls = new tidl::Declarations();
tidl::Attributes* attrs = new tidl::Attributes();
EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("test", new tidl::BaseType("int"),
- __LINE__));
+ attrs->Add(new tidl::Attribute("test", new tidl::BaseType("int", ""),
+ "", __LINE__));
doc = new tidl::Document();
EXPECT_NE(doc, nullptr);
- doc->AddBlock(new tidl::Interface("TestInterface", decls, __LINE__));
- doc->AddBlock(new tidl::Structure("TestStructure", attrs, __LINE__));
+ doc->AddBlock(new tidl::Interface("TestInterface", decls, "", __LINE__));
+ doc->AddBlock(new tidl::Structure("TestStructure", attrs, "", __LINE__));
}
virtual void TearDown() {}
virtual void SetUp() {
attrs = new tidl::Attributes();
EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("test1", new tidl::BaseType("int"),
- __LINE__));
- attrs->Add(new tidl::Attribute("test2", new tidl::BaseType("char *"),
- __LINE__));
+ attrs->Add(new tidl::Attribute("test1", new tidl::BaseType("int", ""),
+ "", __LINE__));
+ attrs->Add(new tidl::Attribute("test2", new tidl::BaseType("char *", ""),
+ "", __LINE__));
}
virtual void TearDown() {}
};
TEST_F(StructureTest, Structure_Constructor) {
tidl::Structure* structure = new tidl::Structure("TestStructure", attrs,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(structure, nullptr);
delete structure;
}
TEST_F(StructureTest, Structure_GetAttributes) {
tidl::Structure* structure = new tidl::Structure("TestStructure", attrs,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(structure, nullptr);
int count = 0;
TEST_F(StructureTest, Structure_GetID) {
tidl::Structure* structure = new tidl::Structure("TestStructure", attrs,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(structure, nullptr);
EXPECT_EQ(structure->GetID(), "TestStructure");
delete structure;
TEST_F(StructureTest, Structure_GetType) {
tidl::Structure* structure = new tidl::Structure("TestStructure", attrs,
- __LINE__);
+ "", __LINE__);
EXPECT_NE(structure, nullptr);
EXPECT_EQ(structure->GetType(), tidl::Structure::TYPE_STRUCTURE);
delete structure;
TEST_F(StructureTest, Structure_GetLine) {
unsigned line = __LINE__;
tidl::Structure* structure = new tidl::Structure("TestStructure", attrs,
- line);
+ "", line);
EXPECT_NE(structure, nullptr);
EXPECT_EQ(structure->GetLine(), line);
delete structure;
}
+
+TEST_F(StructureTest, Structure_GetComments) {
+ std::string comments = "Test Structure";
+ tidl::Structure* structure = new tidl::Structure("TestStructure", attrs,
+ comments, __LINE__);
+ EXPECT_NE(structure, nullptr);
+ EXPECT_EQ(structure->GetComments(), comments);
+ delete structure;
+}
tidl::Parameters* params = new tidl::Parameters();
EXPECT_NE(params, nullptr);
params->Add(new tidl::Parameter("test",
- new tidl::ParameterType(new tidl::BaseType("int")), __LINE__));
+ new tidl::ParameterType(new tidl::BaseType("int", "")), __LINE__));
tidl::Declaration* decl = new tidl::Declaration("test",
- new tidl::BaseType("int"), params, __LINE__);
+ new tidl::BaseType("int", ""), params, "", __LINE__);
EXPECT_NE(decl, nullptr);
tidl::Declarations* decls = new tidl::Declarations();
tidl::Attributes* attrs = new tidl::Attributes();
EXPECT_NE(attrs, nullptr);
- attrs->Add(new tidl::Attribute("test", new tidl::BaseType("int"),
- __LINE__));
+ attrs->Add(new tidl::Attribute("test", new tidl::BaseType("int", ""),
+ "", __LINE__));
doc = new tidl::Document();
EXPECT_NE(doc, nullptr);
- doc->AddBlock(new tidl::Interface("TestInterface", decls, __LINE__));
- doc->AddBlock(new tidl::Structure("TestStructure", attrs, __LINE__));
+ doc->AddBlock(new tidl::Interface("TestInterface", decls, "", __LINE__));
+ doc->AddBlock(new tidl::Structure("TestStructure", attrs, "", __LINE__));
}
virtual void TearDown() {}
};
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
struct Student {
string name;
int num;
bundle data;
}
+// Annotation Test!!
+// Structure Class
struct Class {
+ /* string name attr */
string name;
list<Student> students;
}
+/* Interface School! */
interface School {
+ /* Method section */
+ /* Method AddClass */
int AddClass(in Class cls);
+ /* Method GetStudent */
int GetStudent(in string c_name, in string s_name, out Student student);
}
tidl::Token* testToken;
virtual void SetUp() {
- testToken = new tidl::Token("TestToken");
+ testToken = new tidl::Token("TestToken", "Test Token");
}
virtual void TearDown() {
delete testToken;
};
TEST_F(TokenTest, Token_Constructor) {
- tidl::Token* token = new tidl::Token("TestToken");
+ tidl::Token* token = new tidl::Token("TestToken", "");
EXPECT_NE(token, nullptr);
delete token;
}
EXPECT_EQ(testToken->ToString(), "TestToken");
}
+TEST_F(TokenTest, Token_GetComments) {
+ EXPECT_EQ(testToken->GetComments(), "Test Token");
+}
+
class BaseTypeTest : public testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(BaseTypeTest, BaseType_Constructor) {
- tidl::BaseType* baseType = new tidl::BaseType("BaseType");
+ tidl::BaseType* baseType = new tidl::BaseType("BaseType", "");
EXPECT_NE(baseType, nullptr);
delete baseType;
}
TEST_F(BaseTypeTest, BaseType_SetMetaType) {
- tidl::BaseType* customType = new tidl::BaseType("CustomType", true);
- customType->SetMetaType(new tidl::BaseType("int"));
+ tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
+ customType->SetMetaType(new tidl::BaseType("int", ""));
EXPECT_EQ(customType->GetMetaType().ToString(), "int");
delete customType;
}
TEST_F(BaseTypeTest, BaseType_GetMetaType) {
- tidl::BaseType* customType = new tidl::BaseType("CustomType", true);
- customType->SetMetaType(new tidl::BaseType("string"));
+ tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
+ customType->SetMetaType(new tidl::BaseType("string", ""));
EXPECT_EQ(customType->GetMetaType().ToString(), "string");
delete customType;
}
TEST_F(BaseTypeTest, BaseType_GetFullName) {
- tidl::BaseType* customType = new tidl::BaseType("CustomType", true);
- customType->SetMetaType(new tidl::BaseType("string"));
+ tidl::BaseType* customType = new tidl::BaseType("CustomType", "", true);
+ customType->SetMetaType(new tidl::BaseType("string", ""));
EXPECT_EQ(customType->GetFullName(), "CustomType<string>");
delete customType;
}
TEST_F(BaseTypeTest, BaseType_IsUserDefinedType) {
- tidl::BaseType* testType = new tidl::BaseType("TestType", true);
+ tidl::BaseType* testType = new tidl::BaseType("TestType", "", true);
EXPECT_EQ(testType->IsUserDefinedType(), true);
delete testType;
}
+TEST_F(BaseTypeTest, BaseType_GetComments) {
+ std::string comments = "Test BaseType";
+ tidl::BaseType* testType = new tidl::BaseType("TestType", comments, true);
+ EXPECT_NE(testType, nullptr);
+ EXPECT_EQ(testType->GetComments(), comments);
+ delete testType;
+}
+
class ParameterTypeTest : public testing::Test {
public:
virtual void SetUp() {}
TEST_F(ParameterTypeTest, ParameterType_Constructor) {
tidl::ParameterType *parameterType = new tidl::ParameterType(
- new tidl::BaseType("int"));
+ new tidl::BaseType("int", ""));
EXPECT_NE(parameterType, nullptr);
delete parameterType;
}
TEST_F(ParameterTypeTest, ParameterType_Constructor_With_Direction) {
tidl::ParameterType *parameterType = new tidl::ParameterType(
- new tidl::BaseType("int"), "in");
+ new tidl::BaseType("int", ""), "in");
EXPECT_NE(parameterType, nullptr);
delete parameterType;
}
TEST_F(ParameterTypeTest, ParameterType_GetDirection) {
tidl::ParameterType *parameterType = new tidl::ParameterType(
- new tidl::BaseType("int"), "out");
+ new tidl::BaseType("int", ""), "out");
EXPECT_NE(parameterType, nullptr);
EXPECT_EQ(parameterType->GetDirection(), tidl::ParameterType::Direction::OUT);
delete parameterType;
}
TEST_F(ParameterTypeTest, ParameterType_GetBaseType) {
- tidl::ParameterType *parameterType = new tidl::ParameterType(
- new tidl::BaseType("string"), "ref");
+ tidl::ParameterType *parameterType = new tidl::ParameterType(
+ new tidl::BaseType("string", ""), "ref");
EXPECT_NE(parameterType, nullptr);
EXPECT_EQ(parameterType->GetBaseType().ToString(),
"string");