Add copyright 54/172054/1
authorJunghoon Park <jh9216.park@samsung.com>
Fri, 9 Mar 2018 08:57:02 +0000 (17:57 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Fri, 9 Mar 2018 08:57:02 +0000 (17:57 +0900)
Change-Id: I437109817c426866685e7693c6fad1f4c8b48d94
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
17 files changed:
idlc/c_gen/c_gen_base.cc
idlc/cpp_gen/cpp_gen_base.cc
idlc/cpp_gen/cpp_gen_base.h
idlc/cpp_gen/cpp_gen_base_cb.h
idlc/cpp_gen/cpp_proxy_body_gen.cc
idlc/cpp_gen/cpp_proxy_header_gen.cc
idlc/cpp_gen/cpp_stub_body_gen.cc
idlc/cpp_gen/cpp_stub_header_gen.cc
idlc/cs_gen/cs_cb_copyright.h
idlc/cs_gen/cs_cb_interop.h
idlc/cs_gen/cs_cb_proxy_interop.h
idlc/cs_gen/cs_cb_stub_interop.h
idlc/cs_gen/cs_gen_base.cc
idlc/cs_gen/cs_gen_base.h
idlc/cs_gen/cs_proxy_gen.cc
idlc/cs_gen/cs_stub_gen.cc
unit_tests/CMakeLists.txt

index 5029707..68368ee 100644 (file)
@@ -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);
index 3b67c93..0336cd4 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <ctime>
 #include <vector>
 #include <utility>
 
@@ -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
index 4a5058a..0106d3a 100644 (file)
@@ -32,6 +32,7 @@ class CppGeneratorBase : public Generator {
   explicit CppGeneratorBase(std::shared_ptr<Document> doc);
   virtual ~CppGeneratorBase() = default;
 
+  void GenCopyright(std::ofstream& stream);
   void GenStructuresForHeader(std::ofstream& stream);
   void GenStructuresForBody(std::ofstream& stream);
   void GenSerializer(std::ofstream& stream);
index 995d972..4b42319 100644 (file)
@@ -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";
index b0d6c82..3974fca 100644 (file)
@@ -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 <stdlib.h>" << NLine(1)
          << "#include <assert.h>" << NLine(1)
          <<  NLine(1)
index 2937e7b..224cdbd 100644 (file)
@@ -26,6 +26,8 @@ CppProxyHeaderGen::CppProxyHeaderGen(std::shared_ptr<Document> doc)
     : CppGeneratorBase(doc) {}
 
 void CppProxyHeaderGen::OnInitGen(std::ofstream& stream) {
+  GenCopyright(stream);
+  stream << NLine(1);
   stream << "#pragma once" << NLine(1)
          <<  NLine(1)
          << "#include <bundle.h>" << NLine(1)
index e86efff..74187bb 100644 (file)
@@ -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 <stdlib.h>" << NLine(1)
          << "#include <assert.h>" << NLine(1)
          <<  NLine(1)
index a99a406..4dba3b4 100644 (file)
@@ -26,6 +26,8 @@ CppStubHeaderGen::CppStubHeaderGen(std::shared_ptr<Document> doc)
     : CppGeneratorBase(doc) {}
 
 void CppStubHeaderGen::OnInitGen(std::ofstream& stream) {
+  GenCopyright(stream);
+  stream << NLine(1);
   stream << "#pragma once" << NLine(1)
          <<  NLine(1)
          << "#include <bundle.h>" << NLine(1)
index 01e7704..2aae148 100644 (file)
@@ -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";
 }
-
index 648cb2c..1fcb088 100644 (file)
@@ -1,5 +1,5 @@
 namespace {
-const char* cs_cb_interop =
+const char cs_cb_interop[] =
 R"__cs_cb(
 internal static partial class Interop
 {
index a3ca9e2..42865d4 100644 (file)
@@ -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
         {
index c6f770e..5d3dc98 100644 (file)
@@ -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
         {
index 155721f..2b5d9a3 100644 (file)
  * limitations under the License.
  */
 
+#include <ctime>
 #include <vector>
 
 #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
index 7547853..05e1f4a 100644 (file)
@@ -32,6 +32,7 @@ class CsGeneratorBase : public Generator {
   explicit CsGeneratorBase(std::shared_ptr<Document> 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);
index 755e9fe..92e50c8 100644 (file)
@@ -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<Document> 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)
index 4558f74..6747838 100644 (file)
@@ -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<Document> 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)
index 80132d1..a56a7d2 100644 (file)
@@ -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)