From e20d1eb081dee5b50983bd2a7c2c4c8714240b5b Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 20 Dec 2017 17:56:14 +0900 Subject: [PATCH] Add basic structure for generators Change-Id: If2b4639096a52c53aaebc61aa34ffeaffcdb534f Signed-off-by: Junghoon Park --- idlc/CMakeLists.txt | 4 ++++ idlc/c_gen/c_gen_base.cc | 26 ++++++++++++++++++++++++ idlc/c_gen/c_gen_base.h | 38 +++++++++++++++++++++++++++++++++++ idlc/c_gen/c_proxy_body_gen.cc | 30 +++++++++++++++++++++++++++ idlc/c_gen/c_proxy_body_gen.h | 39 ++++++++++++++++++++++++++++++++++++ idlc/c_gen/c_proxy_header_gen.cc | 30 +++++++++++++++++++++++++++ idlc/c_gen/c_proxy_header_gen.h | 38 +++++++++++++++++++++++++++++++++++ idlc/c_gen/c_stub_body_gen .cc | 29 +++++++++++++++++++++++++++ idlc/c_gen/c_stub_body_gen.h | 38 +++++++++++++++++++++++++++++++++++ idlc/c_gen/c_stub_header_gen.cc | 29 +++++++++++++++++++++++++++ idlc/c_gen/c_stub_header_gen.h | 38 +++++++++++++++++++++++++++++++++++ idlc/cpp_gen/cpp_gen_base.cc | 26 ++++++++++++++++++++++++ idlc/cpp_gen/cpp_gen_base.h | 38 +++++++++++++++++++++++++++++++++++ idlc/cpp_gen/cpp_proxy_body_gen.cc | 30 +++++++++++++++++++++++++++ idlc/cpp_gen/cpp_proxy_body_gen.h | 39 ++++++++++++++++++++++++++++++++++++ idlc/cpp_gen/cpp_proxy_header_gen.cc | 30 +++++++++++++++++++++++++++ idlc/cpp_gen/cpp_proxy_header_gen.h | 38 +++++++++++++++++++++++++++++++++++ idlc/cpp_gen/cpp_stub_body_gen .cc | 29 +++++++++++++++++++++++++++ idlc/cpp_gen/cpp_stub_body_gen.h | 38 +++++++++++++++++++++++++++++++++++ idlc/cpp_gen/cpp_stub_header_gen.cc | 29 +++++++++++++++++++++++++++ idlc/cpp_gen/cpp_stub_header_gen.h | 38 +++++++++++++++++++++++++++++++++++ idlc/main.cc | 30 ++++++++++++++++++++++----- 22 files changed, 699 insertions(+), 5 deletions(-) create mode 100644 idlc/c_gen/c_gen_base.cc create mode 100644 idlc/c_gen/c_gen_base.h create mode 100644 idlc/c_gen/c_proxy_body_gen.cc create mode 100644 idlc/c_gen/c_proxy_body_gen.h create mode 100644 idlc/c_gen/c_proxy_header_gen.cc create mode 100644 idlc/c_gen/c_proxy_header_gen.h create mode 100644 idlc/c_gen/c_stub_body_gen .cc create mode 100644 idlc/c_gen/c_stub_body_gen.h create mode 100644 idlc/c_gen/c_stub_header_gen.cc create mode 100644 idlc/c_gen/c_stub_header_gen.h create mode 100644 idlc/cpp_gen/cpp_gen_base.cc create mode 100644 idlc/cpp_gen/cpp_gen_base.h create mode 100644 idlc/cpp_gen/cpp_proxy_body_gen.cc create mode 100644 idlc/cpp_gen/cpp_proxy_body_gen.h create mode 100644 idlc/cpp_gen/cpp_proxy_header_gen.cc create mode 100644 idlc/cpp_gen/cpp_proxy_header_gen.h create mode 100644 idlc/cpp_gen/cpp_stub_body_gen .cc create mode 100644 idlc/cpp_gen/cpp_stub_body_gen.h create mode 100644 idlc/cpp_gen/cpp_stub_header_gen.cc create mode 100644 idlc/cpp_gen/cpp_stub_header_gen.h diff --git a/idlc/CMakeLists.txt b/idlc/CMakeLists.txt index 7425340..9c321ef 100644 --- a/idlc/CMakeLists.txt +++ b/idlc/CMakeLists.txt @@ -21,6 +21,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/cs_gen CS_GEN_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/c_gen C_GEN_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/cpp_gen CPP_GEN_SOURCES) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) @@ -33,6 +35,8 @@ ADD_EXECUTABLE(tidlc ${BISON_TIDLC_OUTPUTS} ${FLEX_TIDLC_OUTPUTS} ${CS_GEN_SOURCES} + ${C_GEN_SOURCES} + ${CPP_GEN_SOURCES} ${SOURCES} ) TARGET_LINK_LIBRARIES(tidlc ${LIBPKGS_LDFLAGS}) diff --git a/idlc/c_gen/c_gen_base.cc b/idlc/c_gen/c_gen_base.cc new file mode 100644 index 0000000..5d2780e --- /dev/null +++ b/idlc/c_gen/c_gen_base.cc @@ -0,0 +1,26 @@ +/* + * 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 + +#include "idlc/c_gen/c_gen_base.h" + +namespace tidl { + +CGeneratorBase::CGeneratorBase(std::shared_ptr doc) + : Generator(doc) {} + +} // namespace tidl diff --git a/idlc/c_gen/c_gen_base.h b/idlc/c_gen/c_gen_base.h new file mode 100644 index 0000000..f894138 --- /dev/null +++ b/idlc/c_gen/c_gen_base.h @@ -0,0 +1,38 @@ +/* + * 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_C_GEN_C_GEN_BASE_H_ +#define IDLC_C_GEN_C_GEN_BASE_H_ + +#include +#include +#include + +#include "idlc/type.h" +#include "idlc/structure.h" +#include "idlc/generator.h" + +namespace tidl { + +class CGeneratorBase : public Generator { + public: + explicit CGeneratorBase(std::shared_ptr doc); + virtual ~CGeneratorBase() = default; +}; + +} // namespace tidl + +#endif // IDLC_C_GEN_C_GEN_BASE_H_ diff --git a/idlc/c_gen/c_proxy_body_gen.cc b/idlc/c_gen/c_proxy_body_gen.cc new file mode 100644 index 0000000..0aa1715 --- /dev/null +++ b/idlc/c_gen/c_proxy_body_gen.cc @@ -0,0 +1,30 @@ +/* + * 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 "idlc/c_gen/c_proxy_body_gen.h" + +namespace tidl { + +CProxyBodyGen::CProxyBodyGen(std::shared_ptr doc) + : CGeneratorBase(doc) {} + +void CProxyBodyGen::OnInitGen(std::ofstream& stream) { +} + +void CProxyBodyGen::OnFiniGen(std::ofstream& stream) { +} + +} // namespace tidl diff --git a/idlc/c_gen/c_proxy_body_gen.h b/idlc/c_gen/c_proxy_body_gen.h new file mode 100644 index 0000000..07937eb --- /dev/null +++ b/idlc/c_gen/c_proxy_body_gen.h @@ -0,0 +1,39 @@ +/* + * 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_C_GEN_C_PROXY_BODY_GEN_H_ +#define IDLC_C_GEN_C_PROXY_BODY_GEN_H_ + +#include +#include + +#include "idlc/c_gen/c_gen_base.h" + +namespace tidl { + +class CProxyBodyGen : public CGeneratorBase { + public: + explicit CProxyBodyGen(std::shared_ptr doc); + virtual ~CProxyBodyGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; + +}; + +} // namespace tidl + +#endif // IDLC_C_GEN_C_PROXY_BODY_GEN_H_ diff --git a/idlc/c_gen/c_proxy_header_gen.cc b/idlc/c_gen/c_proxy_header_gen.cc new file mode 100644 index 0000000..b4c5be2 --- /dev/null +++ b/idlc/c_gen/c_proxy_header_gen.cc @@ -0,0 +1,30 @@ +/* + * 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 "idlc/c_gen/c_proxy_header_gen.h" + +namespace tidl { + +CProxyHeaderGen::CProxyHeaderGen(std::shared_ptr doc) + : CGeneratorBase(doc) {} + +void CProxyHeaderGen::OnInitGen(std::ofstream& stream) { +} + +void CProxyHeaderGen::OnFiniGen(std::ofstream& stream) { +} + +} // namespace tidl diff --git a/idlc/c_gen/c_proxy_header_gen.h b/idlc/c_gen/c_proxy_header_gen.h new file mode 100644 index 0000000..9be5d6e --- /dev/null +++ b/idlc/c_gen/c_proxy_header_gen.h @@ -0,0 +1,38 @@ +/* + * 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_C_GEN_C_PROXY_HEADER_GEN_H_ +#define IDLC_C_GEN_C_PROXY_HEADER_GEN_H_ + +#include +#include + +#include "idlc/c_gen/c_gen_base.h" + +namespace tidl { + +class CProxyHeaderGen : public CGeneratorBase { + public: + explicit CProxyHeaderGen(std::shared_ptr doc); + virtual ~CProxyHeaderGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; +}; + +} // namespace tidl + +#endif // IDLC_C_GEN_C_PROXY_HEADER_GEN_H_ diff --git a/idlc/c_gen/c_stub_body_gen .cc b/idlc/c_gen/c_stub_body_gen .cc new file mode 100644 index 0000000..de9578b --- /dev/null +++ b/idlc/c_gen/c_stub_body_gen .cc @@ -0,0 +1,29 @@ +/* + * 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 "idlc/c_gen/c_stub_body_gen.h" + +namespace tidl { + +CStubBodyGen::CStubBodyGen(std::shared_ptr doc) + : CGeneratorBase(doc) {} + +void CStubBodyGen::OnInitGen(std::ofstream& stream) { +} + +void CStubBodyGen::OnFiniGen(std::ofstream& stream) {} + +} // namespace tidl diff --git a/idlc/c_gen/c_stub_body_gen.h b/idlc/c_gen/c_stub_body_gen.h new file mode 100644 index 0000000..695f5d2 --- /dev/null +++ b/idlc/c_gen/c_stub_body_gen.h @@ -0,0 +1,38 @@ +/* + * 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_C_GEN_STUB_BODY_GEN_H_ +#define IDLC_C_GEN_STUB_BODY_GEN_H_ + +#include +#include + +#include "idlc/c_gen/c_gen_base.h" + +namespace tidl { + +class CStubBodyGen : public CGeneratorBase { + public: + explicit CStubBodyGen(std::shared_ptr doc); + virtual ~CStubBodyGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; +}; + +} // namespace tidl + +#endif // IDLC_C_GEN_STUB_BODY_GEN_H_ diff --git a/idlc/c_gen/c_stub_header_gen.cc b/idlc/c_gen/c_stub_header_gen.cc new file mode 100644 index 0000000..49db44e --- /dev/null +++ b/idlc/c_gen/c_stub_header_gen.cc @@ -0,0 +1,29 @@ +/* + * 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 "idlc/c_gen/c_stub_header_gen.h" + +namespace tidl { + +CStubHeaderGen::CStubHeaderGen(std::shared_ptr doc) + : CGeneratorBase(doc) {} + +void CStubHeaderGen::OnInitGen(std::ofstream& stream) { +} + +void CStubHeaderGen::OnFiniGen(std::ofstream& stream) {} + +} // namespace tidl diff --git a/idlc/c_gen/c_stub_header_gen.h b/idlc/c_gen/c_stub_header_gen.h new file mode 100644 index 0000000..361d568 --- /dev/null +++ b/idlc/c_gen/c_stub_header_gen.h @@ -0,0 +1,38 @@ +/* + * 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_C_GEN_C_STUB_HEADER_GEN_H_ +#define IDLC_C_GEN_C_STUB_HEADER_GEN_H_ + +#include +#include + +#include "idlc/c_gen/c_gen_base.h" + +namespace tidl { + +class CStubHeaderGen : public CGeneratorBase { + public: + explicit CStubHeaderGen(std::shared_ptr doc); + virtual ~CStubHeaderGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; +}; + +} // namespace tidl + +#endif // IDLC_C_GEN_C_STUB_HEADER_GEN_H_ diff --git a/idlc/cpp_gen/cpp_gen_base.cc b/idlc/cpp_gen/cpp_gen_base.cc new file mode 100644 index 0000000..887c523 --- /dev/null +++ b/idlc/cpp_gen/cpp_gen_base.cc @@ -0,0 +1,26 @@ +/* + * 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 + +#include "idlc/cpp_gen/cpp_gen_base.h" + +namespace tidl { + +CppGeneratorBase::CppGeneratorBase(std::shared_ptr doc) + : Generator(doc) {} + +} // namespace tidl diff --git a/idlc/cpp_gen/cpp_gen_base.h b/idlc/cpp_gen/cpp_gen_base.h new file mode 100644 index 0000000..fa92ddf --- /dev/null +++ b/idlc/cpp_gen/cpp_gen_base.h @@ -0,0 +1,38 @@ +/* + * 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_CPP_GEN_CPP_GEN_BASE_H_ +#define IDLC_CPP_GEN_CPP_GEN_BASE_H_ + +#include +#include +#include + +#include "idlc/type.h" +#include "idlc/structure.h" +#include "idlc/generator.h" + +namespace tidl { + +class CppGeneratorBase : public Generator { + public: + explicit CppGeneratorBase(std::shared_ptr doc); + virtual ~CppGeneratorBase() = default; +}; + +} // namespace tidl + +#endif // IDLC_CPP_GEN_CPP_GEN_BASE_H_ diff --git a/idlc/cpp_gen/cpp_proxy_body_gen.cc b/idlc/cpp_gen/cpp_proxy_body_gen.cc new file mode 100644 index 0000000..4472a76 --- /dev/null +++ b/idlc/cpp_gen/cpp_proxy_body_gen.cc @@ -0,0 +1,30 @@ +/* + * 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 "idlc/cpp_gen/cpp_proxy_body_gen.h" + +namespace tidl { + +CppProxyBodyGen::CppProxyBodyGen(std::shared_ptr doc) + : CppGeneratorBase(doc) {} + +void CppProxyBodyGen::OnInitGen(std::ofstream& stream) { +} + +void CppProxyBodyGen::OnFiniGen(std::ofstream& stream) { +} + +} // namespace tidl diff --git a/idlc/cpp_gen/cpp_proxy_body_gen.h b/idlc/cpp_gen/cpp_proxy_body_gen.h new file mode 100644 index 0000000..d02e035 --- /dev/null +++ b/idlc/cpp_gen/cpp_proxy_body_gen.h @@ -0,0 +1,39 @@ +/* + * 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_CPP_GEN_CPP_PROXY_BODY_GEN_H_ +#define IDLC_CPP_GEN_CPP_PROXY_BODY_GEN_H_ + +#include +#include + +#include "idlc/cpp_gen/cpp_gen_base.h" + +namespace tidl { + +class CppProxyBodyGen : public CppGeneratorBase { + public: + explicit CppProxyBodyGen(std::shared_ptr doc); + virtual ~CppProxyBodyGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; + +}; + +} // namespace tidl + +#endif // IDLC_CPP_GEN_CPP_PROXY_BODY_GEN_H_ diff --git a/idlc/cpp_gen/cpp_proxy_header_gen.cc b/idlc/cpp_gen/cpp_proxy_header_gen.cc new file mode 100644 index 0000000..da27c03 --- /dev/null +++ b/idlc/cpp_gen/cpp_proxy_header_gen.cc @@ -0,0 +1,30 @@ +/* + * 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 "idlc/cpp_gen/cpp_proxy_header_gen.h" + +namespace tidl { + +CppProxyHeaderGen::CppProxyHeaderGen(std::shared_ptr doc) + : CppGeneratorBase(doc) {} + +void CppProxyHeaderGen::OnInitGen(std::ofstream& stream) { +} + +void CppProxyHeaderGen::OnFiniGen(std::ofstream& stream) { +} + +} // namespace tidl diff --git a/idlc/cpp_gen/cpp_proxy_header_gen.h b/idlc/cpp_gen/cpp_proxy_header_gen.h new file mode 100644 index 0000000..927cbcd --- /dev/null +++ b/idlc/cpp_gen/cpp_proxy_header_gen.h @@ -0,0 +1,38 @@ +/* + * 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_CPP_GEN_CPP_PROXY_HEADER_GEN_H_ +#define IDLC_CPP_GEN_CPP_PROXY_HEADER_GEN_H_ + +#include +#include + +#include "idlc/cpp_gen/cpp_gen_base.h" + +namespace tidl { + +class CppProxyHeaderGen : public CppGeneratorBase { + public: + explicit CppProxyHeaderGen(std::shared_ptr doc); + virtual ~CppProxyHeaderGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; +}; + +} // namespace tidl + +#endif // IDLC_CPP_GEN_CPP_PROXY_HEADER_GEN_H_ diff --git a/idlc/cpp_gen/cpp_stub_body_gen .cc b/idlc/cpp_gen/cpp_stub_body_gen .cc new file mode 100644 index 0000000..a2e89e3 --- /dev/null +++ b/idlc/cpp_gen/cpp_stub_body_gen .cc @@ -0,0 +1,29 @@ +/* + * 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 "idlc/cpp_gen/cpp_stub_body_gen.h" + +namespace tidl { + +CppStubBodyGen::CppStubBodyGen(std::shared_ptr doc) + : CppGeneratorBase(doc) {} + +void CppStubBodyGen::OnInitGen(std::ofstream& stream) { +} + +void CppStubBodyGen::OnFiniGen(std::ofstream& stream) {} + +} // namespace tidl diff --git a/idlc/cpp_gen/cpp_stub_body_gen.h b/idlc/cpp_gen/cpp_stub_body_gen.h new file mode 100644 index 0000000..5195efb --- /dev/null +++ b/idlc/cpp_gen/cpp_stub_body_gen.h @@ -0,0 +1,38 @@ +/* + * 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_CPP_GEN_CPP_STUB_BODY_GEN_H_ +#define IDLC_CPP_GEN_CPP_STUB_BODY_GEN_H_ + +#include +#include + +#include "idlc/cpp_gen/cpp_gen_base.h" + +namespace tidl { + +class CppStubBodyGen : public CppGeneratorBase { + public: + explicit CppStubBodyGen(std::shared_ptr doc); + virtual ~CppStubBodyGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; +}; + +} // namespace tidl + +#endif // IDLC_CPP_GEN_CPP_STUB_BODY_GEN_H_ diff --git a/idlc/cpp_gen/cpp_stub_header_gen.cc b/idlc/cpp_gen/cpp_stub_header_gen.cc new file mode 100644 index 0000000..47a8d1c --- /dev/null +++ b/idlc/cpp_gen/cpp_stub_header_gen.cc @@ -0,0 +1,29 @@ +/* + * 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 "idlc/cpp_gen/cpp_stub_header_gen.h" + +namespace tidl { + +CppStubHeaderGen::CppStubHeaderGen(std::shared_ptr doc) + : CppGeneratorBase(doc) {} + +void CppStubHeaderGen::OnInitGen(std::ofstream& stream) { +} + +void CppStubHeaderGen::OnFiniGen(std::ofstream& stream) {} + +} // namespace tidl diff --git a/idlc/cpp_gen/cpp_stub_header_gen.h b/idlc/cpp_gen/cpp_stub_header_gen.h new file mode 100644 index 0000000..7ad6674 --- /dev/null +++ b/idlc/cpp_gen/cpp_stub_header_gen.h @@ -0,0 +1,38 @@ +/* + * 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_CPP_GEN_CPP_STUB_HEADER_GEN_H_ +#define IDLC_CPP_GEN_CPP_STUB_HEADER_GEN_H_ + +#include +#include + +#include "idlc/cpp_gen/cpp_gen_base.h" + +namespace tidl { + +class CppStubHeaderGen : public CppGeneratorBase { + public: + explicit CppStubHeaderGen(std::shared_ptr doc); + virtual ~CppStubHeaderGen() = default; + + void OnInitGen(std::ofstream& stream) override; + void OnFiniGen(std::ofstream& stream) override; +}; + +} // namespace tidl + +#endif // IDLC_CPP_GEN_CPP_STUB_HEADER_GEN_H_ diff --git a/idlc/main.cc b/idlc/main.cc index eb698c4..4931b4f 100644 --- a/idlc/main.cc +++ b/idlc/main.cc @@ -23,6 +23,14 @@ #include "idlc/parser.h" #include "idlc/cs_gen/cs_proxy_gen.h" #include "idlc/cs_gen/cs_stub_gen.h" +#include "idlc/c_gen/c_proxy_header_gen.h" +#include "idlc/c_gen/c_proxy_body_gen.h" +#include "idlc/c_gen/c_stub_header_gen.h" +#include "idlc/c_gen/c_stub_body_gen.h" +#include "idlc/cpp_gen/cpp_proxy_header_gen.h" +#include "idlc/cpp_gen/cpp_proxy_body_gen.h" +#include "idlc/cpp_gen/cpp_stub_header_gen.h" +#include "idlc/cpp_gen/cpp_stub_body_gen.h" namespace { @@ -148,20 +156,32 @@ int main(int argc, char** argv) { if (options->IsProxy()) { if (options->GetLanguage() == "C#") { tidl::CsProxyGen proxy(ps.GetDoc()); - proxy.Run(options->GetOutput()); + proxy.Run(options->GetOutput() + ".cs"); } else if (options->GetLanguage() == "C++") { - //TODO + tidl::CppProxyHeaderGen proxy_header(ps.GetDoc()); + proxy_header.Run(options->GetOutput() + ".h"); + tidl::CppProxyBodyGen proxy_body(ps.GetDoc()); + proxy_body.Run(options->GetOutput() + ".cc"); } else if (options->GetLanguage() == "C") { - //TODO + tidl::CProxyHeaderGen proxy_header(ps.GetDoc()); + proxy_header.Run(options->GetOutput() + ".h"); + tidl::CProxyBodyGen proxy_body(ps.GetDoc()); + proxy_body.Run(options->GetOutput() + ".c"); } } else { if (options->GetLanguage() == "C#") { tidl::CsStubGen stub(ps.GetDoc()); stub.Run(options->GetOutput()); } else if (options->GetLanguage() == "C++") { - //TODO + tidl::CppStubHeaderGen stub_header(ps.GetDoc()); + stub_header.Run(options->GetOutput() + ".h"); + tidl::CppStubBodyGen stub_body(ps.GetDoc()); + stub_body.Run(options->GetOutput() + ".cc"); } else if (options->GetLanguage() == "C") { - //TODO + tidl::CStubHeaderGen stub_header(ps.GetDoc()); + stub_header.Run(options->GetOutput() + ".h"); + tidl::CStubBodyGen stub_body(ps.GetDoc()); + stub_body.Run(options->GetOutput() + ".c"); } } -- 2.7.4