Skip to content

Commit

Permalink
cosmetics.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Dec 1, 2023
1 parent 4c4b91d commit 97d43f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/codegen/codegen_naming.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ inline constexpr char NRN_PRIVATE_DESTRUCTOR_METHOD[] = "nrn_private_destructor"
/// nrn_alloc method in generated code
static constexpr char NRN_ALLOC_METHOD[] = "nrn_alloc";

/// nrn_jacob method in generated code
static constexpr char NRN_JACOB_METHOD[] = "nrn_jacob";

/// nrn_state method in generated code
static constexpr char NRN_STATE_METHOD[] = "nrn_state";

Expand Down
32 changes: 18 additions & 14 deletions src/codegen/codegen_neuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <regex>

#include "ast/all.hpp"
#include "codegen/codegen_naming.hpp"
#include "codegen/codegen_utils.hpp"
#include "config/config.h"
#include "utils/string_utils.hpp"
Expand Down Expand Up @@ -454,14 +455,15 @@ void CodegenNeuronCppVisitor::print_global_function_common_code(BlockType type,
}

void CodegenNeuronCppVisitor::print_nrn_init() {
printer->add_line(
"void nrn_init(_nrn_model_sorted_token const&, NrnThread*, Memb_list*, int) {}");
printer->fmt_line("void {}(_nrn_model_sorted_token const&, NrnThread*, Memb_list*, int) {{}}",
method_name(naming::NRN_INIT_METHOD));
}

void CodegenNeuronCppVisitor::print_nrn_jacob() {
printer->add_line(
"void nrn_jacob(_nrn_model_sorted_token const&, NrnThread* _nt, Memb_list* _ml_arg, int "
"_type) {}");
printer->fmt_line(
"void {}(_nrn_model_sorted_token const&, NrnThread* _nt, Memb_list* _ml_arg, int "
"_type) {{}}",
method_name(naming::NRN_JACOB_METHOD));
}

/// TODO: Edit for NEURON
Expand All @@ -478,8 +480,7 @@ void CodegenNeuronCppVisitor::print_nrn_destructor() {

/// TODO: Print the equivalent of `nrn_alloc_<mech_name>`
void CodegenNeuronCppVisitor::print_nrn_alloc() {
printer->add_line("void nrn_alloc(Prop*) {}");
return;
printer->fmt_line("void {}(Prop*) {{}}", method_name(naming::NRN_ALLOC_METHOD));
}


Expand All @@ -495,9 +496,11 @@ void CodegenNeuronCppVisitor::print_nrn_state() {
}
codegen = true;

printer->add_line(
"void nrn_state(_nrn_model_sorted_token const& sorted_token, NrnThread* nt, Memb_list* ml, "
"int type) {}");
printer->fmt_line(
"static void {}(_nrn_model_sorted_token const& _sorted_token, NrnThread* nt, Memb_list* "
"ml, int type) {{}}",
method_name(naming::NRN_STATE_METHOD));

/// TODO: Fill in

codegen = false;
Expand Down Expand Up @@ -548,8 +551,9 @@ void CodegenNeuronCppVisitor::print_nrn_cur() {
codegen = true;

printer->add_line(
"void nrn_cur(_nrn_model_sorted_token const& sorted_token, NrnThread* nt, Memb_list* ml, "
"int type) {}");
"void {}(_nrn_model_sorted_token const& sorted_token, NrnThread* nt, Memb_list* ml, "
"int type) {{}}",
method_name(naming::NRN_CUR_METHOD));
/// TODO: Fill in

codegen = false;
Expand Down Expand Up @@ -656,8 +660,6 @@ void CodegenNeuronCppVisitor::print_g_unused() const {

/// TODO: Edit for NEURON
void CodegenNeuronCppVisitor::print_compute_functions() {
print_nrn_init();
print_nrn_alloc();
print_nrn_cur();
print_nrn_state();
print_nrn_jacob();
Expand All @@ -676,6 +678,8 @@ void CodegenNeuronCppVisitor::print_codegen_routines() {
print_mechanism_info();
print_data_structures(true);
print_global_variables_for_hoc();
print_nrn_init();
print_nrn_alloc();
print_compute_functions(); // only nrn_cur and nrn_state
print_mechanism_register();
print_namespace_end();
Expand Down

0 comments on commit 97d43f6

Please sign in to comment.