From 959d32cafed8ded062eeb2d72d31cf40af2f1194 Mon Sep 17 00:00:00 2001 From: Ioannis Magkanaris Date: Thu, 30 Nov 2023 13:31:43 +0100 Subject: [PATCH] Fix mech_type in NEURON codegen --- src/codegen/codegen_neuron_cpp_visitor.cpp | 5 ++--- test/unit/codegen/codegen_neuron_cpp_visitor.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/codegen/codegen_neuron_cpp_visitor.cpp b/src/codegen/codegen_neuron_cpp_visitor.cpp index 62315f1961..f4b3747ce0 100644 --- a/src/codegen/codegen_neuron_cpp_visitor.cpp +++ b/src/codegen/codegen_neuron_cpp_visitor.cpp @@ -391,12 +391,11 @@ void CodegenNeuronCppVisitor::print_mechanism_register() { printer->fmt_push_block("void _{}_reg()", info.mod_file); print_sdlists_init(true); // type related information - auto suffix = add_escape_quote(info.mod_suffix); printer->add_newline(); - printer->fmt_line("int mech_type = nrn_get_mechtype({});", suffix); + printer->fmt_line("int mech_type = nrn_get_mechtype({}[1]);", get_channel_info_var_name()); // More things to add here - printer->add_line("_nrn_mechanism_register_data_fields(_mechtype,"); + printer->add_line("_nrn_mechanism_register_data_fields(mech_type,"); printer->increase_indent(); const auto codegen_float_variables_size = codegen_float_variables.size(); for (int i = 0; i < codegen_float_variables_size; ++i) { diff --git a/test/unit/codegen/codegen_neuron_cpp_visitor.cpp b/test/unit/codegen/codegen_neuron_cpp_visitor.cpp index a225d91c37..50dbf9ca9c 100644 --- a/test/unit/codegen/codegen_neuron_cpp_visitor.cpp +++ b/test/unit/codegen/codegen_neuron_cpp_visitor.cpp @@ -232,8 +232,8 @@ void _nrn_mechanism_register_data_fields(Args&&... args) { /* Ds */ _dlist1[0] = {7, 0}; - int mech_type = nrn_get_mechtype("pas_test"); - _nrn_mechanism_register_data_fields(_mechtype, + int mech_type = nrn_get_mechtype(mechanism_info[1]); + _nrn_mechanism_register_data_fields(mech_type, _nrn_mechanism_field{"g"} /* 0 */, _nrn_mechanism_field{"e"} /* 1 */, _nrn_mechanism_field{"i"} /* 2 */,