From 2508c98f73a6f4798b2d27fe8a95aeb42c233574 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Sat, 22 Aug 2026 12:30:25 +1000 Subject: [PATCH] emc: cut the nml_intf dependency on tooldata EMC_TOOL_STAT::operator= has no caller; deleting it builds the tree in both the default and --enable-toolnml configurations, and its stated reason, array members, never applied since implicit copy assignment copies those anyway. The default state of an entry moves next to the type as CANON_TOOL_TABLE_INIT, so the constructor no longer borrows tooldata_entry_init(). Default member initializers would read better but make the struct non-POD, which clang rejects for tooldata_entry_init(), declared extern "C" and returning it by value. --- src/emc/nml_intf/emc_nml.hh | 2 +- src/emc/nml_intf/emcops.cc | 36 +++-------------------------- src/emc/nml_intf/emctool.h | 4 ++++ src/emc/tooldata/tooldata_common.cc | 11 +-------- 4 files changed, 9 insertions(+), 44 deletions(-) diff --git a/src/emc/nml_intf/emc_nml.hh b/src/emc/nml_intf/emc_nml.hh index d502bca759a..5cede52b09f 100644 --- a/src/emc/nml_intf/emc_nml.hh +++ b/src/emc/nml_intf/emc_nml.hh @@ -1638,7 +1638,7 @@ class EMC_TOOL_STAT:public EMC_TOOL_STAT_MSG { // Sub-class update() calls base-class update() // cppcheck-suppress duplInheritedMember void update(CMS * cms); - EMC_TOOL_STAT& operator =(const EMC_TOOL_STAT &s); // need this for [] members + EMC_TOOL_STAT& operator =(const EMC_TOOL_STAT &) = delete; // No copy assignment int pocketPrepped; // idx ready for loading from int toolInSpindle; // tool loaded, 0 is no tool diff --git a/src/emc/nml_intf/emcops.cc b/src/emc/nml_intf/emcops.cc index 320e8805bd7..916e3e3e49a 100644 --- a/src/emc/nml_intf/emcops.cc +++ b/src/emc/nml_intf/emcops.cc @@ -15,10 +15,8 @@ * Last change: ********************************************************************/ -#include "libnml/rcs/rcs_print.hh" #include "emc.hh" #include "emc_nml.hh" -#include "tooldata/tooldata.hh" EMC_AXIS_STAT::EMC_AXIS_STAT() : EMC_AXIS_STAT_MSG(EMC_AXIS_STAT_TYPE, sizeof(EMC_AXIS_STAT)), @@ -159,13 +157,14 @@ EMC_TOOL_STAT::EMC_TOOL_STAT() toolInSpindle(0), // toolno toolFromPocket(0) // tool_from_pocket #ifndef TOOL_NML // { - , toolTableCurrent(tooldata_entry_init()) + , toolTableCurrent CANON_TOOL_TABLE_INIT #endif { #ifdef TOOL_NML //{ + const struct CANON_TOOL_TABLE tdata = CANON_TOOL_TABLE_INIT; int idx; for (idx = 0; idx < CANON_POCKETS_MAX; idx++) { - toolTable[idx] = tooldata_entry_init(); + toolTable[idx] = tdata; } #endif //} } @@ -201,35 +200,6 @@ EMC_COOLANT_STAT::EMC_COOLANT_STAT() { } -// overload = , since class has array elements -EMC_TOOL_STAT& EMC_TOOL_STAT::operator =(const EMC_TOOL_STAT& s) -{ - pocketPrepped = s.pocketPrepped; // idx - toolInSpindle = s.toolInSpindle; // toolno - toolFromPocket = s.toolFromPocket; // tool_from_pocket - -#ifdef TOOL_NML //{ - int idx; - for (idx = 0; idx < CANON_POCKETS_MAX; idx++) { - toolTable[idx].toolno = s.toolTable[idx].toolno; - toolTable[idx].pocketno = s.toolTable[idx].pocketno; - toolTable[idx].offset = s.toolTable[idx].offset; - toolTable[idx].diameter = s.toolTable[idx].diameter; - toolTable[idx].frontangle = s.toolTable[idx].frontangle; - toolTable[idx].backangle = s.toolTable[idx].backangle; - toolTable[idx].orientation = s.toolTable[idx].orientation; - } -#else //}{ - struct CANON_TOOL_TABLE tdata; - if (tooldata_get(&tdata,0) != IDX_OK) { - rcs_print_error("UNEXPECTED idx %s %d\n",__FILE__,__LINE__); - } - toolTableCurrent = tdata; -#endif //} - - return *this; -} - EMC_STAT::EMC_STAT() : EMC_STAT_MSG(EMC_STAT_TYPE, sizeof(EMC_STAT)), debug(0) diff --git a/src/emc/nml_intf/emctool.h b/src/emc/nml_intf/emctool.h index b8775910fe4..39353685028 100644 --- a/src/emc/nml_intf/emctool.h +++ b/src/emc/nml_intf/emctool.h @@ -37,4 +37,8 @@ struct CANON_TOOL_TABLE { char comment[CANON_TOOL_COMMENT_SIZE]; }; +/* default state of an entry: no tool, no pocket, zero geometry */ +#define CANON_TOOL_TABLE_INIT \ + { -1, -1, { { 0, 0, 0 }, 0, 0, 0, 0, 0, 0 }, 0, 0, 0, 0, { 0 } } + #endif diff --git a/src/emc/tooldata/tooldata_common.cc b/src/emc/tooldata/tooldata_common.cc index 040ff7ad807..44a9769784e 100644 --- a/src/emc/tooldata/tooldata_common.cc +++ b/src/emc/tooldata/tooldata_common.cc @@ -40,16 +40,7 @@ void tooldata_init(bool random_toolchanger) struct CANON_TOOL_TABLE tooldata_entry_init() { - struct CANON_TOOL_TABLE tdata; - tdata.toolno = -1; - tdata.pocketno = -1; - tdata.diameter = 0; - tdata.frontangle = 0; - tdata.backangle = 0; - tdata.orientation = 0; - ZERO_EMC_POSE(tdata.offset); - tdata.comment[0] = 0; - + struct CANON_TOOL_TABLE tdata = CANON_TOOL_TABLE_INIT; return tdata; } // tooldata_entry_init()