It's not clear what the behavior was prior to that commit, but after every component USERVARS entry is added to the particle struct with the 1-based index of the component instance appended.
For example, the component Monochromator_curved defines two USERVARSncol and nrow which are used to keep-track of the interacting monochromator-array tile for each scattered neutron.
In the test instrument Test_focus.instr there is one Monochromator_curved component instance in the fifth position, so the generated C code has a particle struct containing ncol_5 and nrow_5.
Prior to this PR mccode_antlr mistakenly treated all component USERVAR parameters as-named in the single namespace; and would produce a struct with ncol and nrow. This would then break the component TRACE code which attempts to set the two values by name, e.g. particle_setvar_void(_particle, "ncol_5", &col);.
This PR changes the mccode_antlr behavior to match the McCode-3 code generator, fixing #48
As part of issue #48 a code generator change was noted https://github.com/McStasMcXtrace/McCode/commit/e56bb8dbff1b6d6532bc30ad30eb3777d049caad that modified the behavior of naming component-defined
USERVARS
.It's not clear what the behavior was prior to that commit, but after every component
USERVARS
entry is added to the particle struct with the 1-based index of the component instance appended.For example, the component
Monochromator_curved
defines twoUSERVARS
ncol
andnrow
which are used to keep-track of the interacting monochromator-array tile for each scattered neutron. In the test instrumentTest_focus.instr
there is oneMonochromator_curved
component instance in the fifth position, so the generated C code has a particle struct containingncol_5
andnrow_5
.Prior to this PR
mccode_antlr
mistakenly treated all component USERVAR parameters as-named in the single namespace; and would produce a struct withncol
andnrow
. This would then break the componentTRACE
code which attempts to set the two values by name, e.g.particle_setvar_void(_particle, "ncol_5", &col);
.This PR changes the
mccode_antlr
behavior to match the McCode-3 code generator, fixing #48