Skip to content

Commit

Permalink
interp: Rename has_user_mcode() to is_any_m_code_remapped()
Browse files Browse the repository at this point in the history
This commit also makes the function private and change loop to be
ranged.
  • Loading branch information
havardAasen committed Mar 17, 2024
1 parent cb4926f commit 657e576
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/emc/rs274ngc/interp_check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int Interp::check_other_codes(block_pointer block) //!< pointer to a block
return INTERP_OK;
}
// bypass ALL checks, argspec takes care of that
if (has_user_mcode(&(_setup),block)) {
if (is_any_m_code_remapped(block, &(_setup))) {
return INTERP_OK;
}
if (block->a_flag) {
Expand Down
12 changes: 5 additions & 7 deletions src/emc/rs274ngc/interp_remap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ bool Interp::is_m_code_remappable(int m_code)
m_code == 68);
}

bool Interp::has_user_mcode(setup_pointer settings,block_pointer block)
bool Interp::is_any_m_code_remapped(block_pointer block, setup_pointer settings)
{
unsigned i;
for(i = 0; i < sizeof(block->m_modes)/sizeof(int); i++) {
if (block->m_modes[i] == -1)
continue;
if (is_m_code_remappable(block->m_modes[i]) &&
settings->m_remapped[block->m_modes[i]])
for (const int m_mode : block->m_modes) {
if (m_mode == -1)
continue;
if (is_m_code_remappable(m_mode) && settings->m_remapped[m_mode])
return true;
}
return false;
Expand Down
5 changes: 2 additions & 3 deletions src/emc/rs274ngc/rs274ngc_interp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,6 @@ int read_inputs(setup_pointer settings);
int init_named_parameters();
int init_python_predef_parameter(const char *name);

bool has_user_mcode(setup_pointer settings,block_pointer block);

bool remap_in_progress(const char *code);
int convert_remapped_code(block_pointer block,
setup_pointer settings,
Expand Down Expand Up @@ -682,9 +680,10 @@ int read_inputs(setup_pointer settings);
private:
[[nodiscard]] static bool is_parameter_readonly(int index);

[[nodiscard]] static bool is_m_code_remappable(int m_code);
[[nodiscard]] static bool is_any_m_code_remapped(block_pointer block, setup_pointer settings);
[[nodiscard]] static bool is_user_defined_m_code(block_pointer block, setup_pointer settings,
int m_group);
[[nodiscard]] static bool is_m_code_remappable(int m_code);
[[nodiscard]] static bool is_g_code_remappable(int g_code);
[[nodiscard]] bool is_user_defined_g_code(int g_code);

Expand Down

0 comments on commit 657e576

Please sign in to comment.