Skip to content

Commit

Permalink
Release v5.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Oct 25, 2022
2 parents 56cf390 + 5651129 commit 8d6d58b
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 41 deletions.
5 changes: 3 additions & 2 deletions app/commsdsl2comms/src/CommsField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ bool CommsField::commsWrite() const
return true;
}

auto& dslObj = m_field.dslObj();
if ((!dslObj.isForceGen()) && (!m_field.isReferenced())) {
if (!m_field.isReferenced()) {
// Not referenced fields do not need to be written
m_field.generator().logger().debug(
"Skipping file generation for non-referenced field \"" + m_field.dslObj().externalRef() + "\".");
return true;
}

Expand Down
11 changes: 9 additions & 2 deletions app/commsdsl2swig/src/SwigBitfieldField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ std::string SwigBitfieldField::swigExtraPublicFuncsCodeImpl() const
auto& gen = SwigGenerator::cast(generator());
for (auto* m : m_swigMembers) {
static const std::string Templ =
"#^#CLASS_NAME#$#& field_#^#ACC_NAME#$#() { return static_cast<#^#CLASS_NAME#$#&>(Base::field_#^#ACC_NAME#$#()); }\n"
"#^#CLASS_NAME#$#& field_#^#ACC_NAME#$#()\n"
"{\n"
" return static_cast<#^#CLASS_NAME#$#&>(Base::field_#^#ACC_NAME#$#());\n"
"}\n"
"const #^#CLASS_NAME#$#& field_#^#ACC_NAME#$#() const\n"
"{\n"
" return static_cast<const #^#CLASS_NAME#$#&>(Base::field_#^#ACC_NAME#$#());\n"
"}\n"
;

util::ReplacementMap repl = {
Expand All @@ -128,7 +135,7 @@ std::string SwigBitfieldField::swigExtraPublicFuncsCodeImpl() const

util::ReplacementMap repl = {
{"VALUE_ACC", std::move(valueAccCode)},
{"MEM_ACC", util::strListToString(accFuncs, "", "")}
{"MEM_ACC", util::strListToString(accFuncs, "\n", "")}
};

return util::processTemplate(Templ, repl);
Expand Down
11 changes: 9 additions & 2 deletions app/commsdsl2swig/src/SwigBundleField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ std::string SwigBundleField::swigExtraPublicFuncsCodeImpl() const
auto& gen = SwigGenerator::cast(generator());
for (auto* m : m_swigMembers) {
static const std::string Templ =
"#^#CLASS_NAME#$#& field_#^#ACC_NAME#$#() { return static_cast<#^#CLASS_NAME#$#&>(Base::field_#^#ACC_NAME#$#()); }\n"
"#^#CLASS_NAME#$#& field_#^#ACC_NAME#$#()\n"
"{\n"
" return static_cast<#^#CLASS_NAME#$#&>(Base::field_#^#ACC_NAME#$#());\n"
"}\n"
"const #^#CLASS_NAME#$#& field_#^#ACC_NAME#$#() const\n"
"{\n"
" return static_cast<const #^#CLASS_NAME#$#&>(Base::field_#^#ACC_NAME#$#());\n"
"}\n"
;

util::ReplacementMap repl = {
Expand All @@ -127,7 +134,7 @@ std::string SwigBundleField::swigExtraPublicFuncsCodeImpl() const

util::ReplacementMap repl = {
{"VALUE_ACC", std::move(valueAccCode)},
{"MEM_ACC", util::strListToString(accFuncs, "", "")}
{"MEM_ACC", util::strListToString(accFuncs, "\n", "")}
};

return util::processTemplate(Templ, repl);
Expand Down
10 changes: 4 additions & 6 deletions app/commsdsl2swig/src/SwigField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ void SwigField::swigAddCodeIncludes(StringsList& list) const
return;
}

auto& dslObj = m_field.dslObj();
if ((!dslObj.isForceGen()) && (!m_field.isReferenced())) {
if (!m_field.isReferenced()) {
// Code for not referenced does not exist
return;
}
Expand All @@ -135,7 +134,7 @@ void SwigField::swigAddCode(StringsList& list) const

m_codeAdded = true;

if (comms::isGlobalField(m_field) && (!m_field.isReferenced()) && (!m_field.dslObj().isForceGen())) {
if (comms::isGlobalField(m_field) && (!m_field.isReferenced())) {
return;
}

Expand All @@ -154,7 +153,7 @@ void SwigField::swigAddDef(StringsList& list) const
swigAddDefImpl(list);

bool global = comms::isGlobalField(m_field);
if (global && (!m_field.dslObj().isForceGen()) && (!m_field.isReferenced())) {
if (global && (!m_field.isReferenced())) {
// Code for not referenced does not exist
return;
}
Expand Down Expand Up @@ -226,8 +225,7 @@ bool SwigField::swigWrite() const
return true;
}

auto& dslObj = m_field.dslObj();
if ((!dslObj.isForceGen()) && (!m_field.isReferenced())) {
if (!m_field.isReferenced()) {
// Code for not referenced does not exist
return true;
}
Expand Down
27 changes: 13 additions & 14 deletions app/commsdsl2tools_qt/src/ToolsQtCmake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ bool ToolsQtCmake::testWriteInternal() const

static const std::string Template =
"cmake_minimum_required (VERSION 3.1)\n"
"project (\"#^#PROT#$#_cc_tools_qt_plugin\")\n\n"
"project (\"#^#MAIN_NS#$#_cc_tools_qt_plugin\")\n\n"
"find_package(LibComms REQUIRED)\n"
"find_package(#^#PROT#$# REQUIRED)\n"
"find_package(#^#MAIN_NS#$# REQUIRED)\n"
"find_package(cc_tools_qt REQUIRED)\n"
"find_package(Qt5Widgets REQUIRED)\n"
"find_package(Qt5Core REQUIRED)\n\n"
"include(${LibComms_DIR}/CC_Compile.cmake)\n"
"cc_compile(WARN_AS_ERR)\n"
"cc_msvc_force_warn_opt(/W4)\n\n"
"include(GNUInstallDirs)\n\n"
"set (CORE_LIB_NAME \"#^#PROT#$#_cc_tools_qt_plugin_core\")\n\n"
"set (CORE_LIB_NAME \"#^#MAIN_NS#$#_cc_tools_qt_plugin_core\")\n\n"
"######################################################################\n\n"
"function (cc_plugin_core)\n"
" set (name ${CORE_LIB_NAME})\n"
" set (src\n"
" #^#CORE_FILES#$#\n"
" )\n\n"
" add_library (${name} STATIC ${src})\n"
" target_link_libraries (${name} PUBLIC cc::#^#PROT#$# cc::comms cc::cc_tools_qt Qt5::Widgets Qt5::Core)\n"
" target_link_libraries (${name} PUBLIC cc::#^#MAIN_NS#$# cc::comms cc::cc_tools_qt Qt5::Widgets Qt5::Core)\n"
" target_include_directories (${name} PUBLIC ${PROJECT_SOURCE_DIR})\n"
" target_compile_options(${name} PRIVATE\n"
" $<$<CXX_COMPILER_ID:MSVC>:/bigobj /wd4127 /wd5054>\n"
Expand All @@ -87,25 +87,25 @@ bool ToolsQtCmake::testWriteInternal() const
"endfunction()\n\n"
"######################################################################\n\n"
"function (cc_plugin protocol has_config_widget)\n"
" set (name \"cc_plugin_${protocol}\")\n\n"
" set (meta_file \"${CMAKE_CURRENT_SOURCE_DIR}/#^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/${protocol}.json\")\n"
" string(TOLOWER \"cc_plugin_${protocol}\" name)\n\n"
" set (meta_file \"${CMAKE_CURRENT_SOURCE_DIR}/#^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/Plugin_${protocol}.json\")\n"
" set (stamp_file \"${CMAKE_CURRENT_BINARY_DIR}/${protocol}_refresh_stamp.txt\")\n\n"
" if ((NOT EXISTS ${stamp_file}) OR (${meta_file} IS_NEWER_THAN ${stamp_file}))\n"
" execute_process(\n"
" COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/#^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/${protocol}Plugin.h)\n\n"
" COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/#^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/Plugin_${protocol}.h)\n\n"
" execute_process(\n"
" COMMAND ${CMAKE_COMMAND} -E touch ${stamp_file})\n"
" endif ()\n\n"
" set (src\n"
" #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/${protocol}Protocol.cpp\n"
" #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/${protocol}Plugin.cpp\n"
" #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/Protocol_${protocol}.cpp\n"
" #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/Plugin_${protocol}.cpp\n"
" )\n\n"
" set (hdr\n"
" #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/${protocol}Plugin.h\n"
" #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/Plugin_${protocol}.h\n"
" )\n\n"
" if (has_config_widget)\n"
" list (APPEND src #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/${protocol}ConfigWidget.cpp)\n"
" list (APPEND hdr #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/${protocol}ConfigWidget.h)\n"
" list (APPEND src #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/ConfigWidget_${protocol}.cpp)\n"
" list (APPEND hdr #^#TOP_NS#$#/#^#MAIN_NS#$#/plugin/ConfigWidget_${protocol}.h)\n"
" endif ()\n\n"
" qt5_wrap_cpp(moc ${hdr})\n\n"
" set(extra_link_opts)\n"
Expand Down Expand Up @@ -143,12 +143,11 @@ bool ToolsQtCmake::testWriteInternal() const
util::StringsList pluginInvokes;
for (auto& p : plugins) {
assert(p);
pluginInvokes.push_back("cc_plugin (\"" + p->toolsClassName() + "\" " + (p->toolsHasConfigWidget() ? "TRUE" : "FALSE") + ")");
pluginInvokes.push_back("cc_plugin (\"" + p->toolsProtocolName() + "\" " + (p->toolsHasConfigWidget() ? "TRUE" : "FALSE") + ")");
}


util::ReplacementMap repl = {
{"PROT", util::strToName(m_generator.protocolSchema().schemaName())},
{"CORE_FILES", util::strListToString(m_generator.toolsSourceFiles(), "\n", "")},
{"PLUGINS_LIST", util::strListToString(pluginInvokes, "\n", "")},
{"TOP_NS", m_generator.getTopNamespace()},
Expand Down
3 changes: 1 addition & 2 deletions app/commsdsl2tools_qt/src/ToolsQtField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ bool ToolsQtField::toolsWrite() const
return true;
}

auto& dslObj = m_field.dslObj();
if ((!dslObj.isForceGen()) && (!m_field.isReferenced())) {
if (!m_field.isReferenced()) {
// Not referenced fields do not need to be written
return true;
}
Expand Down
20 changes: 10 additions & 10 deletions app/commsdsl2tools_qt/src/ToolsQtPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ namespace commsdsl2tools_qt
namespace
{

const std::string ProtSuffix("Protocol");
const std::string PluginSuffix("Plugin");
const std::string WidgetSuffix("ConfigWidget");
const std::string ProtPrefix("Protocol_");
const std::string PluginPrefix("Plugin_");
const std::string WidgetPrefix("ConfigWidget_");

} // namespace

Expand Down Expand Up @@ -70,9 +70,9 @@ bool ToolsQtPlugin::write()
toolsWriteConfigWidgetSrcInternal();
}

std::string ToolsQtPlugin::toolsClassName() const
std::string ToolsQtPlugin::toolsProtocolName() const
{
return comms::className(toolsAdjustedNameInternal());
return util::strToName(toolsAdjustedNameInternal());
}

bool ToolsQtPlugin::toolsWriteProtocolHeaderInternal()
Expand Down Expand Up @@ -632,7 +632,7 @@ bool ToolsQtPlugin::toolsWritePluginConfigInternal()
static_cast<void>(m_generator);
auto filePath =
m_generator.getOutputDir() + '/' +
toolsRelFilePath(comms::className(util::strToName(toolsAdjustedNameInternal()))) + ".cfg";
toolsRelFilePath(toolsProtocolName()) + ".cfg";

m_generator.logger().info("Generating " + filePath);

Expand Down Expand Up @@ -818,24 +818,24 @@ const std::string& ToolsQtPlugin::toolsAdjustedNameInternal() const
{
auto* nameToUse = &m_name;
if (nameToUse->empty()) {
nameToUse = &m_generator.currentSchema().schemaName();
nameToUse = &m_generator.protocolSchema().schemaName();
}
return *nameToUse;
}

std::string ToolsQtPlugin::toolsProtClassNameInternal() const
{
return comms::className(util::strToName(toolsAdjustedNameInternal())) + ProtSuffix;
return ProtPrefix + toolsProtocolName();
}

std::string ToolsQtPlugin::toolsPluginClassNameInternal() const
{
return comms::className(util::strToName(toolsAdjustedNameInternal())) + PluginSuffix;
return PluginPrefix + toolsProtocolName();
}

std::string ToolsQtPlugin::toolsConfigWidgetClassNameInternal() const
{
return comms::className(util::strToName(toolsAdjustedNameInternal())) + WidgetSuffix;
return WidgetPrefix + toolsProtocolName();
}

bool ToolsQtPlugin::toolsHasConfigWidgetInternal() const
Expand Down
2 changes: 1 addition & 1 deletion app/commsdsl2tools_qt/src/ToolsQtPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ToolsQtPlugin
bool prepare();
bool write();

std::string toolsClassName() const;
std::string toolsProtocolName() const;

bool toolsHasConfigWidget() const
{
Expand Down
2 changes: 1 addition & 1 deletion lib/include/commsdsl/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define COMMSDSL_MINOR_VERSION 1U

/// @brief Patch level of the library
#define COMMSDSL_PATCH_VERSION 1U
#define COMMSDSL_PATCH_VERSION 2U

/// @brief Macro to create numeric version as single unsigned number
#define COMMSDSL_MAKE_VERSION(major_, minor_, patch_) \
Expand Down
5 changes: 5 additions & 0 deletions lib/src/gen/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ bool Field::prepare()
if (result) {
m_impl->setPrepared();
}

if (dslObj().isForceGen()) {
setReferenced();
}

return result;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/gen/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,8 @@ bool Generator::createDirectory(const std::string& path) const
return true;
}

if (!std::filesystem::create_directories(path, ec)) {
std::filesystem::create_directories(path, ec);
if (ec) {
logger().error("Failed to create directory \"" + path + "\" with error: " + ec.message());
return false;
}
Expand Down

0 comments on commit 8d6d58b

Please sign in to comment.