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" \
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);
* limitations under the License.
*/
+#include <ctime>
#include <vector>
#include <utility>
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
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);
}
)__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";
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)
: 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)
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)
: 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)
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";
}
-
namespace {
-const char* cs_cb_interop =
+const char cs_cb_interop[] =
R"__cs_cb(
internal static partial class Interop
{
namespace {
-const char* cs_cb_proxy_interop =
+const char cs_cb_proxy_interop[] =
R"__cs_cb(
internal static partial class Proxy
{
namespace {
-const char* cs_cb_stub_interop =
+const char cs_cb_stub_interop[] =
R"__cs_cb(
internal static partial class Stub
{
* 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 {
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
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);
*/
#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"
: 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)
*/
#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"
: 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)
${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)