Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide most functions/global variables. #1520

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
@@ -462,7 +462,7 @@ void CodegenCppVisitor::print_global_var_struct_assertions() const {


void CodegenCppVisitor::print_global_var_struct_decl() {
printer->add_line(global_struct(), ' ', global_struct_instance(), ';');
printer->fmt_line("static {} {};", global_struct(), global_struct_instance());
}


4 changes: 2 additions & 2 deletions src/codegen/codegen_cpp_visitor.hpp
Original file line number Diff line number Diff line change
@@ -1547,8 +1547,8 @@ class CodegenCppVisitor: public visitor::ConstAstVisitor {
template <typename T>
void print_function_declaration(const T& node,
const std::string& name,
const std::unordered_set<CppObjectSpecifier>& = {
CppObjectSpecifier::Inline});
const std::unordered_set<CppObjectSpecifier>& =
{CppObjectSpecifier::Static, CppObjectSpecifier::Inline});

void print_rename_state_vars() const;
};
15 changes: 9 additions & 6 deletions src/codegen/codegen_neuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
@@ -1709,7 +1709,7 @@ void CodegenNeuronCppVisitor::print_global_function_common_code(BlockType type,
{"", "NrnThread*", "", "nt"},
{"", "Memb_list*", "", "_ml_arg"},
{"", "int", "", "_type"}};
printer->fmt_push_block("void {}({})", method, get_parameter_str(args));
printer->fmt_push_block("static void {}({})", method, get_parameter_str(args));
print_entrypoint_setup_code_from_memb_list();
printer->add_line("auto nodecount = _ml_arg->nodecount;");
}
@@ -1780,13 +1780,15 @@ void CodegenNeuronCppVisitor::print_nrn_jacob() {

void CodegenNeuronCppVisitor::print_nrn_constructor_declaration() {
if (info.constructor_node) {
printer->fmt_line("void {}(Prop* prop);", method_name(naming::NRN_CONSTRUCTOR_METHOD));
printer->fmt_line("static void {}(Prop* prop);",
method_name(naming::NRN_CONSTRUCTOR_METHOD));
}
}

void CodegenNeuronCppVisitor::print_nrn_constructor() {
if (info.constructor_node) {
printer->fmt_push_block("void {}(Prop* prop)", method_name(naming::NRN_CONSTRUCTOR_METHOD));
printer->fmt_push_block("static void {}(Prop* prop)",
method_name(naming::NRN_CONSTRUCTOR_METHOD));

print_entrypoint_setup_code_from_prop();

@@ -1799,11 +1801,12 @@ void CodegenNeuronCppVisitor::print_nrn_constructor() {


void CodegenNeuronCppVisitor::print_nrn_destructor_declaration() {
printer->fmt_line("void {}(Prop* prop);", method_name(naming::NRN_DESTRUCTOR_METHOD));
printer->fmt_line("static void {}(Prop* prop);", method_name(naming::NRN_DESTRUCTOR_METHOD));
}

void CodegenNeuronCppVisitor::print_nrn_destructor() {
printer->fmt_push_block("void {}(Prop* prop)", method_name(naming::NRN_DESTRUCTOR_METHOD));
printer->fmt_push_block("static void {}(Prop* prop)",
method_name(naming::NRN_DESTRUCTOR_METHOD));
print_entrypoint_setup_code_from_prop();

for (const auto& rv: info.random_variables) {
@@ -2039,7 +2042,7 @@ void CodegenNeuronCppVisitor::print_nrn_current(const BreakpointBlock& node) {
const auto& args = nrn_current_parameters();
const auto& block = node.get_statement_block();
printer->add_newline(2);
printer->fmt_push_block("inline double nrn_current_{}({})",
printer->fmt_push_block("static inline double nrn_current_{}({})",
info.mod_suffix,
get_parameter_str(args));
printer->add_line("double current = 0.0;");