From: Junghoon Park Date: Fri, 9 Mar 2018 08:57:02 +0000 (+0900) Subject: Add copyright X-Git-Tag: accepted/tizen/unified/20180315.061327~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F54%2F172054%2F1;p=platform%2Fcore%2Fappfw%2Ftidl.git Add copyright Change-Id: I437109817c426866685e7693c6fad1f4c8b48d94 Signed-off-by: Junghoon Park --- diff --git a/idlc/c_gen/c_gen_base.cc b/idlc/c_gen/c_gen_base.cc index 5029707..68368ee 100644 --- a/idlc/c_gen/c_gen_base.cc +++ b/idlc/c_gen/c_gen_base.cc @@ -219,6 +219,8 @@ std::string CGeneratorBase::Trim(const std::string& str) void CGeneratorBase::GenLicenseDescription(std::ofstream& stream) { const char license[] = "/*\n" \ + " * Generated by tidlc $$.\n" \ + " *\n" \ " * Copyright (c) $$ Samsung Electronics Co., Ltd.\n" \ " *\n" \ " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" \ @@ -236,6 +238,9 @@ void CGeneratorBase::GenLicenseDescription(std::ofstream& stream) { GenTemplate(license, stream, [&]()->std::string { + return FULLVER; + }, + [&]()->std::string { std::time_t t = std::time(NULL); std::tm* local_time = std::localtime(&t); return std::to_string(local_time->tm_year + 1900); diff --git a/idlc/cpp_gen/cpp_gen_base.cc b/idlc/cpp_gen/cpp_gen_base.cc index 3b67c93..0336cd4 100644 --- a/idlc/cpp_gen/cpp_gen_base.cc +++ b/idlc/cpp_gen/cpp_gen_base.cc @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -792,4 +793,17 @@ bool CppGeneratorBase::IsDelegateType(const std::string type_name) { return false; } +void CppGeneratorBase::GenCopyright(std::ofstream& stream) { + GenTemplate(CB_COPYRIGHT, stream, + [&]()->std::string { + return FULLVER; + }, + [&]()->std::string { + std::time_t t = std::time(NULL); + std::tm* local_time = std::localtime(&t); + return std::to_string(local_time->tm_year + 1900); + } + ); +} + } // namespace tidl diff --git a/idlc/cpp_gen/cpp_gen_base.h b/idlc/cpp_gen/cpp_gen_base.h index 4a5058a..0106d3a 100644 --- a/idlc/cpp_gen/cpp_gen_base.h +++ b/idlc/cpp_gen/cpp_gen_base.h @@ -32,6 +32,7 @@ class CppGeneratorBase : public Generator { explicit CppGeneratorBase(std::shared_ptr doc); virtual ~CppGeneratorBase() = default; + void GenCopyright(std::ofstream& stream); void GenStructuresForHeader(std::ofstream& stream); void GenStructuresForBody(std::ofstream& stream); void GenSerializer(std::ofstream& stream); diff --git a/idlc/cpp_gen/cpp_gen_base_cb.h b/idlc/cpp_gen/cpp_gen_base_cb.h index 995d972..4b42319 100644 --- a/idlc/cpp_gen/cpp_gen_base_cb.h +++ b/idlc/cpp_gen/cpp_gen_base_cb.h @@ -88,3 +88,23 @@ rpc_port_parcel_h operator >> (rpc_port_parcel_h h, $$::CallbackBase& cb) { } )__cpp_cb"; + +const char CB_COPYRIGHT[] = +R"__cs_cb(/* + * Generated by tidlc $$. + * + * Copyright (c) $$ 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. + */ +)__cs_cb"; diff --git a/idlc/cpp_gen/cpp_proxy_body_gen.cc b/idlc/cpp_gen/cpp_proxy_body_gen.cc index b0d6c82..3974fca 100644 --- a/idlc/cpp_gen/cpp_proxy_body_gen.cc +++ b/idlc/cpp_gen/cpp_proxy_body_gen.cc @@ -33,6 +33,8 @@ void CppProxyBodyGen::OnInitGen(std::ofstream& stream) { if (found != std::string::npos) header_file.replace(found, key.length(), ".h"); + GenCopyright(stream); + stream << NLine(1); stream << "#include " << NLine(1) << "#include " << NLine(1) << NLine(1) diff --git a/idlc/cpp_gen/cpp_proxy_header_gen.cc b/idlc/cpp_gen/cpp_proxy_header_gen.cc index 2937e7b..224cdbd 100644 --- a/idlc/cpp_gen/cpp_proxy_header_gen.cc +++ b/idlc/cpp_gen/cpp_proxy_header_gen.cc @@ -26,6 +26,8 @@ CppProxyHeaderGen::CppProxyHeaderGen(std::shared_ptr doc) : CppGeneratorBase(doc) {} void CppProxyHeaderGen::OnInitGen(std::ofstream& stream) { + GenCopyright(stream); + stream << NLine(1); stream << "#pragma once" << NLine(1) << NLine(1) << "#include " << NLine(1) diff --git a/idlc/cpp_gen/cpp_stub_body_gen.cc b/idlc/cpp_gen/cpp_stub_body_gen.cc index e86efff..74187bb 100644 --- a/idlc/cpp_gen/cpp_stub_body_gen.cc +++ b/idlc/cpp_gen/cpp_stub_body_gen.cc @@ -33,6 +33,8 @@ void CppStubBodyGen::OnInitGen(std::ofstream& stream) { if (found != std::string::npos) header_file.replace(found, key.length(), ".h"); + GenCopyright(stream); + stream << NLine(1); stream << "#include " << NLine(1) << "#include " << NLine(1) << NLine(1) diff --git a/idlc/cpp_gen/cpp_stub_header_gen.cc b/idlc/cpp_gen/cpp_stub_header_gen.cc index a99a406..4dba3b4 100644 --- a/idlc/cpp_gen/cpp_stub_header_gen.cc +++ b/idlc/cpp_gen/cpp_stub_header_gen.cc @@ -26,6 +26,8 @@ CppStubHeaderGen::CppStubHeaderGen(std::shared_ptr doc) : CppGeneratorBase(doc) {} void CppStubHeaderGen::OnInitGen(std::ofstream& stream) { + GenCopyright(stream); + stream << NLine(1); stream << "#pragma once" << NLine(1) << NLine(1) << "#include " << NLine(1) diff --git a/idlc/cs_gen/cs_cb_copyright.h b/idlc/cs_gen/cs_cb_copyright.h index 01e7704..2aae148 100644 --- a/idlc/cs_gen/cs_cb_copyright.h +++ b/idlc/cs_gen/cs_cb_copyright.h @@ -1,9 +1,21 @@ namespace { -const char* cs_cb_copyright = +const char cs_cb_copyright[] = R"__cs_cb(/* - * This file is generated by tidlc. - * Please do not modify it directly. + * Generated by tidlc $$. + * + * Copyright (c) $$ 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. */ )__cs_cb"; } - diff --git a/idlc/cs_gen/cs_cb_interop.h b/idlc/cs_gen/cs_cb_interop.h index 648cb2c..1fcb088 100644 --- a/idlc/cs_gen/cs_cb_interop.h +++ b/idlc/cs_gen/cs_cb_interop.h @@ -1,5 +1,5 @@ namespace { -const char* cs_cb_interop = +const char cs_cb_interop[] = R"__cs_cb( internal static partial class Interop { diff --git a/idlc/cs_gen/cs_cb_proxy_interop.h b/idlc/cs_gen/cs_cb_proxy_interop.h index a3ca9e2..42865d4 100644 --- a/idlc/cs_gen/cs_cb_proxy_interop.h +++ b/idlc/cs_gen/cs_cb_proxy_interop.h @@ -1,5 +1,5 @@ namespace { -const char* cs_cb_proxy_interop = +const char cs_cb_proxy_interop[] = R"__cs_cb( internal static partial class Proxy { diff --git a/idlc/cs_gen/cs_cb_stub_interop.h b/idlc/cs_gen/cs_cb_stub_interop.h index c6f770e..5d3dc98 100644 --- a/idlc/cs_gen/cs_cb_stub_interop.h +++ b/idlc/cs_gen/cs_cb_stub_interop.h @@ -1,5 +1,5 @@ namespace { -const char* cs_cb_stub_interop = +const char cs_cb_stub_interop[] = R"__cs_cb( internal static partial class Stub { diff --git a/idlc/cs_gen/cs_gen_base.cc b/idlc/cs_gen/cs_gen_base.cc index 155721f..2b5d9a3 100644 --- a/idlc/cs_gen/cs_gen_base.cc +++ b/idlc/cs_gen/cs_gen_base.cc @@ -14,9 +14,11 @@ * limitations under the License. */ +#include #include #include "idlc/cs_gen/cs_gen_base.h" +#include "idlc/cs_gen/cs_cb_copyright.h" namespace tidl { @@ -590,4 +592,18 @@ bool CsGeneratorBase::IsDelegateType(const std::string type_name) { return false; } +void CsGeneratorBase::GenCopyright(std::ofstream& stream) { + GenTemplate(::cs_cb_copyright, stream, + [&]()->std::string { + return FULLVER; + }, + [&]()->std::string { + std::time_t t = std::time(NULL); + std::tm* local_time = std::localtime(&t); + return std::to_string(local_time->tm_year + 1900); + } + ); + stream << NLine(1); +} + } // namespace tidl diff --git a/idlc/cs_gen/cs_gen_base.h b/idlc/cs_gen/cs_gen_base.h index 7547853..05e1f4a 100644 --- a/idlc/cs_gen/cs_gen_base.h +++ b/idlc/cs_gen/cs_gen_base.h @@ -32,6 +32,7 @@ class CsGeneratorBase : public Generator { explicit CsGeneratorBase(std::shared_ptr doc); virtual ~CsGeneratorBase() = default; + void GenCopyright(std::ofstream& stream); void GenStructures(std::ofstream& stream); void GenStructure(std::ofstream& stream, const Structure& st); void GenSerializer(std::ofstream& stream); diff --git a/idlc/cs_gen/cs_proxy_gen.cc b/idlc/cs_gen/cs_proxy_gen.cc index 755e9fe..92e50c8 100644 --- a/idlc/cs_gen/cs_proxy_gen.cc +++ b/idlc/cs_gen/cs_proxy_gen.cc @@ -15,7 +15,6 @@ */ #include "idlc/cs_gen/cs_proxy_gen.h" -#include "idlc/cs_gen/cs_cb_copyright.h" #include "idlc/cs_gen/cs_cb_interop.h" #include "idlc/cs_gen/cs_cb_proxy_interop.h" @@ -25,8 +24,7 @@ CsProxyGen::CsProxyGen(std::shared_ptr doc) : CsGeneratorBase(doc) {} void CsProxyGen::OnInitGen(std::ofstream& stream) { - stream << ::cs_cb_copyright << NLine(1); - stream << NLine(1); + GenCopyright(stream); stream << "using System;" << NLine(1) << "using System.Collections.Generic;" << NLine(1) << "using System.Runtime.InteropServices;" << NLine(1) diff --git a/idlc/cs_gen/cs_stub_gen.cc b/idlc/cs_gen/cs_stub_gen.cc index 4558f74..6747838 100644 --- a/idlc/cs_gen/cs_stub_gen.cc +++ b/idlc/cs_gen/cs_stub_gen.cc @@ -15,7 +15,6 @@ */ #include "idlc/cs_gen/cs_stub_gen.h" -#include "idlc/cs_gen/cs_cb_copyright.h" #include "idlc/cs_gen/cs_cb_interop.h" #include "idlc/cs_gen/cs_cb_stub_interop.h" @@ -25,8 +24,7 @@ CsStubGen::CsStubGen(std::shared_ptr doc) : CsGeneratorBase(doc) {} void CsStubGen::OnInitGen(std::ofstream& stream) { - stream << ::cs_cb_copyright << NLine(1); - stream << NLine(1); + GenCopyright(stream); stream << "using System;" << NLine(1) << "using System.Collections.Generic;" << NLine(1) << "using System.Runtime.InteropServices;" << NLine(1) diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 80132d1..a56a7d2 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -27,6 +27,8 @@ SET(TIDLC_SOURCES ${CMAKE_SOURCE_DIR}/idlc/attribute.cc ) +ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"") + AUX_SOURCE_DIRECTORY(. UNIT_TESTS_SOURCES) AUX_SOURCE_DIRECTORY(cs_gen CS_GEN_UNIT_TESTS_SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/idlc/cs_gen CS_GEN_SOURCES)