diff --git a/cmake/NeuronFileLists.cmake b/cmake/NeuronFileLists.cmake index 789867c6a3..2c376847e1 100644 --- a/cmake/NeuronFileLists.cmake +++ b/cmake/NeuronFileLists.cmake @@ -35,8 +35,8 @@ set(HEADER_FILES_TO_INSTALL nrnoc/options.h nrnoc/section_fwd.hpp nrnoc/treeset.h + oc/classreg.h oc/hoc.h - oc/hoc_membf.h oc/hocassrt.h oc/hocdec.h oc/hocgetsym.h diff --git a/src/nrnoc/init.cpp b/src/nrnoc/init.cpp index 963736f2b2..5a190ee06f 100644 --- a/src/nrnoc/init.cpp +++ b/src/nrnoc/init.cpp @@ -1021,8 +1021,8 @@ int point_reg_helper(Symbol* s2) { } extern void class2oc_base(const char*, - void* (*cons)(Object*), - void (*destruct)(void*), + ctor_f* cons, + dtor_f* destruct, Member_func*, Member_ret_obj_func*, Member_ret_str_func*); diff --git a/src/nrnoc/nrniv_mf.h b/src/nrnoc/nrniv_mf.h index 1a1c016daa..3d28a0cbec 100644 --- a/src/nrnoc/nrniv_mf.h +++ b/src/nrnoc/nrniv_mf.h @@ -1,5 +1,5 @@ #pragma once -#include "hoc_membf.h" +#include "classreg.h" #include "hocdec.h" #include "membfunc.h" @@ -51,8 +51,8 @@ int point_register_mech(const char**, nrn_init_t, int, int, - void* (*) (Object*), - void (*)(void*), + ctor_f*, + dtor_f*, Member_func*); extern int nrn_get_mechtype(const char*); extern void nrn_writes_conc(int, int); diff --git a/src/nrnoc/seclist.cpp b/src/nrnoc/seclist.cpp index f5562c31ae..d1509e2a00 100644 --- a/src/nrnoc/seclist.cpp +++ b/src/nrnoc/seclist.cpp @@ -6,7 +6,7 @@ #include "parse.hpp" #include "hocparse.h" #include "code.h" -#include "hoc_membf.h" +#include "classreg.h" /* needs trailing '}' */ #define ITERATE_REMOVE(q1, q2, lst) \ @@ -252,15 +252,6 @@ static Member_func members[] = {{"append", append}, {"allroots", allroots}, {nullptr, nullptr}}; - -extern void class2oc(const char*, - void* (*cons)(Object*), - void (*destruct)(void*), - Member_func*, - Member_ret_obj_func*, - Member_ret_str_func*); - - void SectionList_reg(void) { /* printf("SectionList_reg\n");*/ class2oc("SectionList", constructor, destructor, members, nullptr, nullptr); diff --git a/src/nrnoc/secref.cpp b/src/nrnoc/secref.cpp index 38a2ad7277..d835ed4532 100644 --- a/src/nrnoc/secref.cpp +++ b/src/nrnoc/secref.cpp @@ -18,7 +18,7 @@ access s1.sec // soma becomes the default section #include #include "section.h" #include "parse.hpp" -#include "hoc_membf.h" +#include "classreg.h" #include "oc_ansi.h" extern int hoc_return_type_code; @@ -361,15 +361,6 @@ Section* nrn_sectionref_steer(Section* sec, Symbol* sym, int* pnindex) { return s; } - -extern void class2oc(const char*, - void* (*cons)(Object*), - void (*destruct)(void*), - Member_func*, - Member_ret_obj_func*, - Member_ret_str_func*); - - void SectionRef_reg(void) { Symbol *s, *sr; diff --git a/src/oc/classreg.h b/src/oc/classreg.h index 00ee7e9a55..6aaea74528 100644 --- a/src/oc/classreg.h +++ b/src/oc/classreg.h @@ -1,11 +1,27 @@ #pragma once -#include -#include - -extern void class2oc(const char*, - void* (*cons)(Object*), - void (*destruct)(void*), - Member_func*, - Member_ret_obj_func*, - Member_ret_str_func*); +struct Object; + +using ctor_f = void*(Object*); +using dtor_f = void(void*); + +struct Member_func { + const char* name; + double (*member)(void*); +}; + +struct Member_ret_obj_func { + const char* name; + struct Object** (*member)(void*); +}; + +struct Member_ret_str_func { + const char* name; + const char** (*member)(void*); +}; +void class2oc(const char*, + ctor_f* cons, + dtor_f* destruct, + Member_func*, + Member_ret_obj_func*, + Member_ret_str_func*); diff --git a/src/oc/hoc_membf.h b/src/oc/hoc_membf.h deleted file mode 100644 index 9ac37cba06..0000000000 --- a/src/oc/hoc_membf.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -struct Object; - -typedef struct Member_func { - const char* name; - double (*member)(void*); -} Member_func; - -typedef struct Member_ret_obj_func { - const char* name; - struct Object** (*member)(void*); -} Member_ret_obj_func; - -typedef struct Member_ret_str_func { - const char* name; - const char** (*member)(void*); -} Member_ret_str_func; diff --git a/src/oc/hoc_oop.cpp b/src/oc/hoc_oop.cpp index bf485698f1..cca4bd8647 100644 --- a/src/oc/hoc_oop.cpp +++ b/src/oc/hoc_oop.cpp @@ -1581,8 +1581,8 @@ void hoc_endtemplate(Symbol* t) { } void class2oc_base(const char* name, - void* (*cons)(Object*), - void (*destruct)(void*), + ctor_f* cons, + dtor_f* destruct, Member_func* m, Member_ret_obj_func* mobjret, Member_ret_str_func* strret) { @@ -1629,8 +1629,8 @@ void class2oc_base(const char* name, void class2oc(const char* name, - void* (*cons)(Object*), - void (*destruct)(void*), + ctor_f* cons, + dtor_f* destruct, Member_func* m, Member_ret_obj_func* mobjret, Member_ret_str_func* strret) { diff --git a/test/unit_tests/oc/hoc_interpreter.cpp b/test/unit_tests/oc/hoc_interpreter.cpp index 3e334bfcb1..21338018d2 100644 --- a/test/unit_tests/oc/hoc_interpreter.cpp +++ b/test/unit_tests/oc/hoc_interpreter.cpp @@ -5,7 +5,7 @@ #include "classreg.h" #include "code.h" #include "hocdec.h" -#include "hoc_membf.h" +#include "classreg.h" #include "ocfunc.h" #include