--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+ADD_SUBDIRECTORY(idlc)
--- /dev/null
+Copyright (c) 2000 - 2017 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(TIDLC CXX)
+
+FIND_PACKAGE(BISON REQUIRED)
+FIND_PACKAGE(FLEX REQUIRED)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wno-unused-function -Wno-sign-compare")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(SOURCES
+ src/parser.cc
+ src/document.cc
+ src/declaration.cc
+ src/interface.cc
+ src/type.cc
+ src/parameter.cc
+ src/generator.cc
+ src/proxy_gen.cc
+ src/stub_gen.cc
+ src/main.cc
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/inc)
+
+flex_target(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/tidlc.ll tidlc_l.cpp)
+bison_target(TIDLC ${CMAKE_CURRENT_SOURCE_DIR}/tidlc.yy tidlc_y.cpp)
+
+SET(TILDC_deps ${FLEX_TIDLC_OUTPUTS})
+
+ADD_EXECUTABLE(tidlc ${BISON_TIDLC_OUTPUTS} ${FLEX_TIDLC_OUTPUTS} ${SOURCES})
+INSTALL(TARGETS tidlc DESTINATION bin)
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_INTERFACE_H_
+#define IDLC_INC_INTERFACE_H_
+
+#include <string>
+#include <memory>
+
+#include "declaration.h"
+
+namespace tidl {
+
+class Interface {
+ public:
+ Interface(const std::string& id, Declarations* decls);
+
+ const std::string& GetID() const;
+ const Declarations& GetDeclarations() const;
+
+ private:
+ std::string id_;
+ std::unique_ptr<Declarations> decls_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_INTERFACE_H_
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_DECLARATION_H_
+#define IDLC_INC_DECLARATION_H_
+
+#include <string>
+#include <list>
+#include <memory>
+
+#include "type.h"
+#include "parameter.h"
+
+namespace tidl {
+
+class Declaration {
+ public:
+ Declaration(const std::string& id, Type* ret_type, Parameters* params,
+ bool async = false);
+
+ const std::string& GetID() const;
+ const Type& GetType() const;
+ const Parameters& GetParameters() const;
+ bool IsAsync() const;
+
+ private:
+ std::string id_;
+ std::unique_ptr<Type> ret_type_;
+ std::unique_ptr<Parameters> params_;
+ bool async_;
+};
+
+class Declarations {
+ public:
+ void Add(Declaration* decl);
+ const std::list<std::unique_ptr<Declaration>>& GetDecls() const;
+
+ private:
+ std::list<std::unique_ptr<Declaration>> decls_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_DECLARATION_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_DOCUMENT_H_
+#define IDLC_INC_DOCUMENT_H_
+
+#include <list>
+#include <memory>
+
+#include "interface.h"
+
+namespace tidl {
+
+class Document {
+ public:
+ void AddInterface(Interface* interface);
+ const std::list<std::unique_ptr<Interface>>& GetInterfaces() const;
+
+ private:
+ std::list<std::unique_ptr<Interface>> interfaces_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_DOCUMENT_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_GENERATOR_H_
+#define IDLC_INC_GENERATOR_H_
+
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <memory>
+
+#include "document.h"
+#include "parameter.h"
+#include "type.h"
+
+namespace tidl {
+
+class Generator {
+ public:
+ explicit Generator(std::shared_ptr<Document> doc);
+ 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 OnDeclartionGen(std::ofstream& stream, const std::string& id,
+ const Parameters& args, const Type& ret) = 0;
+ virtual void OnInitGen(std::ofstream& stream) = 0;
+ virtual void OnFiniGen(std::ofstream& stream) = 0;
+
+ protected:
+ std::string FileName;
+
+ private:
+ std::shared_ptr<Document> doc_;
+ std::ofstream out_file_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_GENERATOR_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_INTERFACE_H_
+#define IDLC_INC_INTERFACE_H_
+
+#include <string>
+#include <memory>
+
+#include "declaration.h"
+
+namespace tidl {
+
+class Interface {
+ public:
+ Interface(const std::string& id, Declarations* decls);
+
+ const std::string& GetID() const;
+ const Declarations& GetDeclarations() const;
+
+ private:
+ std::string id_;
+ std::unique_ptr<Declarations> decls_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_INTERFACE_H_
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_PARAMETER_H_
+#define IDLC_INC_PARAMETER_H_
+
+#include <string>
+#include <list>
+#include <memory>
+
+#include "type.h"
+
+namespace tidl {
+
+class Parameter {
+ public:
+ Parameter();
+ Parameter(const std::string& id, Type* type);
+
+ const std::string& GetID() const;
+ const Type& GetType() const;
+
+ private:
+ std::unique_ptr<Type> type_;
+ std::string id_;
+};
+
+class Parameters {
+ public:
+ void Add(Parameter* param);
+ const std::list<std::unique_ptr<Parameter>>& GetParams() const;
+
+ private:
+ std::list<std::unique_ptr<Parameter>> params_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_PARAMETER_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_PARSER_H_
+#define IDLC_INC_PARSER_H_
+
+#include <memory>
+#include <string>
+
+#include "document.h"
+
+namespace tidl {
+
+class Parser {
+ public:
+ Parser();
+ ~Parser();
+
+ void* Scanner() const { return scanner_; }
+ bool Parse(const std::string& input);
+ bool ParseFromFile(const std::string& path);
+ void AttachDoc(Document* doc);
+ std::shared_ptr<Document> DetachDoc();
+
+ private:
+ void* scanner_;
+ std::shared_ptr<Document> doc_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_PARSER_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_PROXY_GEN_H_
+#define IDLC_INC_PROXY_GEN_H_
+
+#include <memory>
+#include <string>
+
+#include "generator.h"
+
+namespace tidl {
+
+class ProxyGen : public Generator {
+ public:
+ explicit ProxyGen(std::shared_ptr<Document> doc);
+ virtual ~ProxyGen() = default;
+
+ void OnDeclartionGen(std::ofstream& stream, const std::string& id,
+ const Parameters& args, const Type& ret) 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;
+
+ private:
+ std::string ConvertTypeToCType(const Type& type);
+
+ private:
+ std::string interface_name_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_PROXY_GEN_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_STUB_GEN_H_
+#define IDLC_INC_STUB_GEN_H_
+
+#include <memory>
+#include <string>
+
+#include "generator.h"
+
+namespace tidl {
+
+class StubGen : public Generator {
+ public:
+ explicit StubGen(std::shared_ptr<Document> doc);
+ virtual ~StubGen() = default;
+
+ void OnDeclartionGen(std::ofstream& stream, const std::string& id,
+ const Parameters& args, const Type& ret) 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;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_STUB_GEN_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef IDLC_INC_TYPE_H_
+#define IDLC_INC_TYPE_H_
+
+#include <string>
+
+namespace tidl {
+
+class Token {
+ public:
+ explicit Token(const std::string& name);
+
+ const std::string& ToString() const { return name_; }
+
+ private:
+ std::string name_;
+};
+
+class Type : public Token {
+ public:
+ enum class Direction {
+ IN,
+ OUT,
+ REF
+ };
+
+ Type(const std::string& name, const std::string& dir);
+ explicit Type(const std::string& name);
+ Direction GetDirection() const { return dir_; }
+
+ private:
+ Direction dir_;
+};
+
+} // namespace tidl
+
+#endif // IDLC_INC_TYPE_H_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "declaration.h"
+#include "type.h"
+#include "parameter.h"
+
+namespace tidl {
+
+Declaration::Declaration(const std::string& id, Type* ret_type,
+ Parameters* params, bool async)
+ : id_(id),
+ ret_type_(ret_type),
+ params_(params),
+ async_(async) {}
+
+const std::string& Declaration::GetID() const {
+ return id_;
+}
+
+const Type& Declaration::GetType() const {
+ return *ret_type_;
+}
+
+const Parameters& Declaration::GetParameters() const {
+ return *params_;
+}
+
+bool Declaration::IsAsync() const {
+ return async_;
+}
+
+void Declarations::Add(Declaration* decl) {
+ decls_.emplace_back(decl);
+}
+
+const std::list<std::unique_ptr<Declaration>>& Declarations::GetDecls() const {
+ return decls_;
+}
+
+} // namespace tidl
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "document.h"
+#include "interface.h"
+
+namespace tidl {
+
+void Document::AddInterface(Interface* interface) {
+ interfaces_.emplace_back(interface);
+}
+
+const std::list<std::unique_ptr<Interface>>& Document::GetInterfaces() const {
+ return interfaces_;
+}
+
+} // namespace tidl
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "generator.h"
+#include "interface.h"
+#include "declaration.h"
+
+namespace tidl {
+
+Generator::Generator(std::shared_ptr<Document> doc) : doc_(doc) {
+}
+
+void Generator::Run(const std::string& file_name) {
+ FileName = file_name;
+ out_file_.open(FileName);
+
+ OnInitGen(out_file_);
+ for (auto& interface : doc_->GetInterfaces()) {
+ OnInterfaceBegin(interface->GetID());
+ for (auto& decl : interface->GetDeclarations().GetDecls()) {
+ OnDeclartionGen(out_file_, decl->GetID(), decl->GetParameters(),
+ decl->GetType());
+ }
+ OnInterfaceEnd(interface->GetID());
+ }
+
+ OnFiniGen(out_file_);
+ out_file_.close();
+}
+
+} // namespace tidl
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "declaration.h"
+#include "interface.h"
+
+namespace tidl {
+
+Interface::Interface(const std::string& id, Declarations* decls)
+ : id_(id), decls_(decls) {
+}
+
+const std::string& Interface::GetID() const {
+ return id_;
+}
+
+const Declarations& Interface::GetDeclarations() const {
+ return *decls_;
+}
+
+} // namespace tidl
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <iostream>
+#include <cstring>
+
+#include "parser.h"
+#include "proxy_gen.h"
+#include "stub_gen.h"
+
+namespace {
+
+enum class Option {
+ NONE = 0,
+ PROXY,
+ STUB
+};
+
+void PrintUsage() {
+ std::cout << "usage: tidlc <option> <input_file> <output_file>"
+ << std::endl
+ << "options:" << std::endl
+ << " -p generate proxy code" << std::endl
+ << " -s generate stub code" << std::endl;
+}
+
+} // namespace
+
+int main(int argc, char** argv) {
+ if (argc != 4) {
+ ::PrintUsage();
+ exit(1);
+ }
+
+ ::Option opt = ::Option::NONE;
+
+ if (strcmp(argv[1], "-p") == 0)
+ opt = ::Option::PROXY;
+
+ if (strcmp(argv[1], "-s") == 0)
+ opt = ::Option::STUB;
+
+ if (opt == ::Option::NONE) {
+ PrintUsage();
+ exit(1);
+ }
+
+ tidl::Parser ps;
+ std::string path(argv[2]);
+
+ ps.ParseFromFile(path);
+ if (opt == ::Option::PROXY) {
+ tidl::ProxyGen proxy(ps.DetachDoc());
+ proxy.Run(argv[3]);
+ } else {
+ tidl::StubGen stub(ps.DetachDoc());
+ stub.Run(argv[3]);
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "parameter.h"
+#include "type.h"
+
+namespace tidl {
+
+Parameter::Parameter()
+ : type_(new Type("Empty")) {}
+
+Parameter::Parameter(const std::string& id, Type* type)
+ : type_(type), id_(id) {}
+
+const std::string& Parameter::GetID() const {
+ return id_;
+}
+
+const Type& Parameter::GetType() const {
+ return *type_;
+}
+
+void Parameters::Add(Parameter* param) {
+ params_.emplace_back(param);
+}
+
+const std::list<std::unique_ptr<Parameter>>& Parameters::GetParams() const {
+ return params_;
+}
+
+} // namespace tidl
+
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <fstream>
+#include <string>
+
+#include "parser.h"
+#include "document.h"
+#include "declaration.h"
+#include "parameter.h"
+#include "type.h"
+#include "../tidlc_y.hpp"
+
+struct yy_buffer_state;
+yy_buffer_state* yy_scan_buffer(char*, size_t, void*);
+void yylex_init(void**);
+void yylex_destroy(void*);
+
+namespace tidl {
+
+Parser::Parser() : scanner_(nullptr) {
+ yylex_init(&scanner_);
+}
+
+Parser::~Parser() {
+ yylex_destroy(scanner_);
+}
+
+void Parser::AttachDoc(Document* doc) {
+ doc_ = std::shared_ptr<Document>(doc);
+}
+
+std::shared_ptr<Document> Parser::DetachDoc() {
+ return doc_;
+}
+
+bool Parser::Parse(const std::string& input) {
+ printf("Parse : %s\n", input.c_str());
+
+ std::string in = input;
+
+ in.append(2u, '\0');
+ yy_scan_buffer(&in[0], in.size(), scanner_);
+ if (yy::parser(this).parse() != 0) {
+ printf("[Parser error]\n");
+ return false;
+ }
+
+ printf("[OK]\n");
+
+ return true;
+}
+
+bool Parser::ParseFromFile(const std::string& path) {
+ std::ifstream inFile(path);
+ std::string str((std::istreambuf_iterator<char>(inFile)),
+ std::istreambuf_iterator<char>());
+ return Parse(str);
+}
+
+} // namespace tidl
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "proxy_gen.h"
+
+namespace tidl {
+
+ProxyGen::ProxyGen(std::shared_ptr<Document> doc)
+ : Generator(doc) {}
+
+std::string ProxyGen::ConvertTypeToCType(const Type& type) {
+ if (type.ToString() == "string" &&
+ type.GetDirection() == Type::Direction::IN)
+ return "const char*";
+
+ if (type.ToString() == "string" &&
+ type.GetDirection() == Type::Direction::OUT)
+ return "char**";
+
+ if (type.ToString() == "bundle" &&
+ type.GetDirection() == Type::Direction::IN)
+ return "const bundle*";
+
+ if (type.ToString() == "bundle" &&
+ type.GetDirection() == Type::Direction::OUT)
+ return "bundle**";
+
+ if (type.ToString() == "int" &&
+ (type.GetDirection() == Type::Direction::OUT ||
+ type.GetDirection() == Type::Direction::REF))
+ return "int*";
+
+ if (type.ToString() == "char" &&
+ (type.GetDirection() == Type::Direction::OUT ||
+ type.GetDirection() == Type::Direction::REF))
+ return "char*";
+
+ if (type.ToString() == "double" &&
+ (type.GetDirection() == Type::Direction::OUT ||
+ type.GetDirection() == Type::Direction::REF))
+ return "double*";
+
+ if (type.ToString() == "short" &&
+ (type.GetDirection() == Type::Direction::OUT ||
+ type.GetDirection() == Type::Direction::REF))
+ return "short*";
+
+ if (type.ToString() == "long" &&
+ (type.GetDirection() == Type::Direction::OUT ||
+ type.GetDirection() == Type::Direction::REF))
+ return "long*";
+
+ if (type.ToString() == "float" &&
+ (type.GetDirection() == Type::Direction::OUT ||
+ type.GetDirection() == Type::Direction::REF))
+ return "float*";
+
+ return type.ToString();
+}
+
+void ProxyGen::OnDeclartionGen(std::ofstream& stream, const std::string& id,
+ const Parameters& args,
+ const Type& ret) {
+ stream << ConvertTypeToCType(ret) << " " << interface_name_ + "_" + id << "(";
+
+ bool first = true;
+ for (auto& param : args.GetParams()) {
+ if (!first)
+ stream << ", ";
+
+ stream << ConvertTypeToCType(param->GetType()) << " ";
+ stream << param->GetID();
+ first = false;
+ }
+
+ stream << ")" << std::endl;
+ stream << "{" << std::endl;
+ // TODO(jh9216.park) : generate body
+
+ // Temp
+ stream << "\treturn 0;" << std::endl;
+
+ stream << "}" << std::endl;
+ stream << std::endl;
+}
+
+void ProxyGen::OnInitGen(std::ofstream& stream) {
+ // TODO(h.jhun) : Change header file
+ stream << "#include <rpc-port.h>" << std::endl << std::endl;
+}
+
+void ProxyGen::OnFiniGen(std::ofstream& stream) {
+}
+
+void ProxyGen::OnInterfaceBegin(const std::string& id) {
+ interface_name_ = id;
+}
+
+void ProxyGen::OnInterfaceEnd(const std::string& id) {
+ interface_name_ = "";
+}
+
+} // namespace tidl
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "stub_gen.h"
+
+namespace tidl {
+
+StubGen::StubGen(std::shared_ptr<Document> doc)
+ : Generator(doc) {}
+
+void StubGen::OnDeclartionGen(std::ofstream& stream, const std::string& id,
+ const Parameters& args, const Type& ret) {}
+
+void StubGen::OnInitGen(std::ofstream& stream) {}
+
+void StubGen::OnFiniGen(std::ofstream& stream) {}
+
+void StubGen::OnInterfaceBegin(const std::string& id) {}
+
+void StubGen::OnInterfaceEnd(const std::string& id) {}
+
+} // namespace tidl
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "type.h"
+
+namespace tidl {
+
+Token::Token(const std::string& name) : name_(name) {
+}
+
+Type::Type(const std::string& name) : Token(name) {
+ dir_ = Direction::IN;
+}
+
+Type::Type(const std::string& name, const std::string& dir)
+ : Token(name) {
+ if (dir == "in")
+ dir_ = Direction::IN;
+ else if (dir == "out")
+ dir_ = Direction::OUT;
+ else if (dir == "ref")
+ dir_ = Direction::REF;
+ else
+ dir_ = Direction::IN;
+}
+
+} // namespace tidl
--- /dev/null
+%{
+#include <stdio.h>
+
+#include "parser.h"
+#include "document.h"
+#include "declaration.h"
+#include "type.h"
+#include "parameter.h"
+#include "interface.h"
+#include "tidlc_y.hpp"
+
+#define YY_USER_ACTION yylloc->columns(yyleng);
+%}
+
+%option yylineno
+%option noyywrap
+%option reentrant
+%option bison-bridge
+%option bison-locations
+
+%%
+
+[ \t\r\n] ; // ignore all whitespace
+"," {return yy::parser::token::T_COMMA;}
+"{" {return yy::parser::token::T_BRACE_OPEN;}
+"}" {return yy::parser::token::T_BRACE_CLOSE;}
+"(" {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;}
+"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;}
+
+
+[A-Za-z_][A-Za-z0-9_]* {
+ yylval->token = new tidl::Type(yytext);
+ return yy::parser::token::T_ID;
+ }
+
+%%
+
--- /dev/null
+%{
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "parser.h"
+#include "document.h"
+#include "declaration.h"
+#include "type.h"
+#include "parameter.h"
+#include "interface.h"
+#include "tidlc_y.hpp"
+
+int yylex(yy::parser::semantic_type *, yy::parser::location_type *, void *);
+
+#define lex_scanner ps->Scanner()
+
+%}
+
+%parse-param { tidl::Parser* ps }
+%lex-param { void *lex_scanner }
+
+%token T_LEFT T_RIGHT T_ID 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 T_STRING T_IN T_OUT T_REF T_ASYNC T_INTERFACE
+
+
+%start start
+
+%pure-parser
+%skeleton "glr.cc"
+
+%union {
+ tidl::Document* doc;
+ tidl::Interface* interf;
+ tidl::Declaration* decl;
+ tidl::Declarations* decls;
+ tidl::Type* type;
+ tidl::Type* ret_type;
+ tidl::Token* direction;
+ tidl::Parameter* param;
+ tidl::Parameters* params;
+ tidl::Token* token;
+}
+
+%token<token> T_ID
+
+%type<doc> interface_blocks
+%type<interf> interface_block
+%type<decls> declarations
+%type<decl> declaration
+%type<type> type_specifier
+%type<ret_type> ret_type_specifier
+%type<param> parameter
+%type<params> parameter_list
+%type<direction> direction_specifier
+
+%%
+
+start: interface_blocks {
+ ps->AttachDoc($1);
+ }
+;
+
+interface_blocks: interface_block {
+ $$ = new tidl::Document();
+ $$->AddInterface($1);
+ }
+ | interface_blocks interface_block {
+ $$ = $1;
+ $$->AddInterface($2);
+ }
+;
+
+interface_block: T_INTERFACE T_ID T_BRACE_OPEN declarations T_BRACE_CLOSE {
+ $$ = new tidl::Interface($2->ToString(), $4);
+ delete $2;
+ }
+;
+
+declarations: declaration {
+ $$ = new tidl::Declarations();
+ $$->Add($1);
+ }
+ | declarations declaration {
+ $$ = $1;
+ $$->Add($2);
+ }
+;
+
+declaration: ret_type_specifier T_ID T_LEFT parameter_list T_RIGHT T_SEMICOLON {
+ $$ = new tidl::Declaration($2->ToString(), $1, $4);
+ delete $2;
+ }
+ | ret_type_specifier T_ID T_LEFT parameter_list T_RIGHT T_ASYNC T_SEMICOLON {
+ $$ = new tidl::Declaration($2->ToString(), $1, $4, true);
+ delete $2;
+ }
+;
+
+parameter_list: parameter {
+ $$ = new tidl::Parameters();
+ $$->Add($1);
+ }
+ | parameter_list T_COMMA parameter {
+ $$ = $1;
+ $$->Add($3);
+ }
+;
+
+direction_specifier: {
+ $$ = new tidl::Token("in");
+ }
+ | T_IN {
+ $$ = new tidl::Token("in");
+ }
+ | T_OUT {
+ $$ = new tidl::Token("out");
+ }
+ | T_REF {
+ $$ = new tidl::Token("ref");
+ }
+;
+
+parameter: T_VOID {
+ $$ = new tidl::Parameter();
+ }
+ | type_specifier T_ID {
+ $$ = new tidl::Parameter($2->ToString(), $1);
+ delete $2;
+ }
+;
+
+ret_type_specifier: T_VOID { $$ = new tidl::Type("void"); }
+ | T_INT {
+ $$ = new tidl::Type("int");
+ }
+;
+
+type_specifier: T_VOID { $$ = new tidl::Type("void"); }
+ | direction_specifier T_CHAR {
+ $$ = new tidl::Type("char", $1->ToString());
+ delete $1;
+ }
+ | direction_specifier T_SHORT {
+ $$ = new tidl::Type("short", $1->ToString());
+ delete $1;
+ }
+ | direction_specifier T_INT {
+ $$ = new tidl::Type("int", $1->ToString());
+ delete $1;
+ }
+ | direction_specifier T_LONG {
+ $$ = new tidl::Type("long", $1->ToString());
+ delete $1;
+ }
+ | direction_specifier T_FLOAT {
+ $$ = new tidl::Type("float", $1->ToString());
+ delete $1;
+ }
+ | direction_specifier T_DOUBLE {
+ $$ = new tidl::Type("double", $1->ToString());
+ delete $1;
+ }
+ | direction_specifier T_BUNDLE {
+ $$ = new tidl::Type("bundle", $1->ToString());
+ delete $1;
+ }
+ | direction_specifier T_STRING {
+ $$ = new tidl::Type("string", $1->ToString());
+ delete $1;
+ }
+;
+
+%%
+
+#include <ctype.h>
+#include <stdio.h>
+
+void yy::parser::error(const yy::parser::location_type& l,
+ const std::string& errstr) {
+ printf("Parse error: %d\n", l.begin.line);
+}
+
+
--- /dev/null
+#!/bin/bash
+# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if [ ! `which cpplint.py` ]; then
+ echo -e "\nPlease make sure cpplint.py is in your PATH. It is part of depot_tools inside Chromium repository."
+ exit 1
+fi
+
+OLDPWD=$PWD
+BASE=`dirname $0`
+cd $BASE/..
+
+# filters
+FILTERS="-readability/streams,-build/c++11"
+
+cpplint.py --root=src --filter="$FILTERS" $(find . \( -name '*.h' -o -name '*.cc' \) )
+RET=$?
+
+JS_RET_VAL=$?
+cd $OLDPWD
+
+if [ "x$RET" == "x0" ]; then
+ exit 0
+else
+ exit 1
+fi
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: tidl
+Summary: Tizen Interface Definition Language
+Version: 0.1.0
+Release: 1
+Group: Application Framework/Building
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+Source1001: %{name}.manifest
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+BuildRequires: cmake
+BuildRequires: flex
+BuildRequires: bison
+
+%description
+Tizen Interface Definition Language
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake -DFULLVER=%{version} \
+ -DMAJORVER=${MAJORVER} \
+ .
+
+%__make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%preun
+
+%post
+/sbin/ldconfig
+
+%postun
+/sbin/ldconfig
+
+%files
+%license LICENSE
+%manifest %{name}.manifest
+%{_bindir}/tidlc
+