From e6afbb0ec5b9a67cb771b2c5a7f050b0017a54cb Mon Sep 17 00:00:00 2001 From: "Robert A. McDougal" Date: Mon, 15 May 2023 15:25:21 -0400 Subject: [PATCH] neuronapi.cpp no longer uses its .h, that is now a header for 3rd party tools --- cmake/NeuronFileLists.cmake | 1 + src/nrniv/neuronapi.cpp | 37 +++++++- src/nrniv/neuronapi.h | 167 +++++++++++++++--------------------- 3 files changed, 108 insertions(+), 97 deletions(-) diff --git a/cmake/NeuronFileLists.cmake b/cmake/NeuronFileLists.cmake index bff5a80bea..0c525403d1 100644 --- a/cmake/NeuronFileLists.cmake +++ b/cmake/NeuronFileLists.cmake @@ -29,6 +29,7 @@ set(HEADER_FILES_TO_INSTALL multicore.h multisplit.h neuron.h + neuronapi.h newton.hpp newton_struct.h newton_thread.hpp diff --git a/src/nrniv/neuronapi.cpp b/src/nrniv/neuronapi.cpp index 5e87213db2..3904ad4ba6 100644 --- a/src/nrniv/neuronapi.cpp +++ b/src/nrniv/neuronapi.cpp @@ -1,4 +1,3 @@ -#include "neuronapi.h" #include "../../nrnconf.h" #include "nrniv_mf.h" #include "nrnmpi.h" @@ -8,6 +7,42 @@ #include "parse.hpp" +#include "hocdec.h" +#include "section.h" + + +// we define these here to allow the API to be independent of internal details +#define STACK_IS_STR 1 +#define STACK_IS_VAR 2 +#define STACK_IS_NUM 3 +#define STACK_IS_OBJVAR 4 +#define STACK_IS_OBJTMP 5 +#define STACK_IS_USERINT 6 +#define STACK_IS_SYM 7 +#define STACK_IS_OBJUNREF 8 +#define STACK_UNKNOWN -1 + +class SectionListIterator { +public: + SectionListIterator(hoc_Item *); + Section *next(void); + int done(void); + +private: + hoc_Item *initial; + hoc_Item *current; +}; + +class SymbolTableIterator { +public: + SymbolTableIterator(Symlist *); + char const *next(void); + int done(void); + +private: + Symbol *current; +}; + /**************************************** * Connections to the rest of NEURON ****************************************/ diff --git a/src/nrniv/neuronapi.h b/src/nrniv/neuronapi.h index 8cfd2c7e4a..a36a20feae 100644 --- a/src/nrniv/neuronapi.h +++ b/src/nrniv/neuronapi.h @@ -1,119 +1,94 @@ #pragma once -#include "hocdec.h" -#include "section.h" - -// we define these here to allow the API to be independent of internal details -#define STACK_IS_STR 1 -#define STACK_IS_VAR 2 -#define STACK_IS_NUM 3 -#define STACK_IS_OBJVAR 4 -#define STACK_IS_OBJTMP 5 -#define STACK_IS_USERINT 6 -#define STACK_IS_SYM 7 -#define STACK_IS_OBJUNREF 8 -#define STACK_UNKNOWN -1 - -class SectionListIterator { -public: - SectionListIterator(hoc_Item *); - Section *next(void); - int done(void); - -private: - hoc_Item *initial; - hoc_Item *current; -}; - -class SymbolTableIterator { -public: - SymbolTableIterator(Symlist *); - char const *next(void); - int done(void); - -private: - Symbol *current; -}; - +#ifdef __cplusplus extern "C" { +#endif +struct Symbol; +struct Object; +struct Section; +struct SectionListIterator; +struct hoc_Item; +struct SymbolTableIterator; +struct Symlist; + /**************************************** * Initialization ****************************************/ -int nrn_init(int argc, const char **argv); -void nrn_redirect_stdout(int (*myprint)(int, char *)); +extern int (*nrn_init)(int argc, const char **argv); +extern void (*nrn_redirect_stdout)(int (*myprint)(int, char *)); /**************************************** * Sections ****************************************/ -Section *nrn_new_section(char const *const name); -void nrn_connect_sections(Section *child_sec, double child_x, - Section *parent_sec, double parent_x); -void nrn_set_section_length(Section *sec, double length); -double nrn_get_section_length(Section *sec); -double nrn_get_section_Ra(Section *sec); -void nrn_set_section_Ra(Section *sec, double val); -char const *nrn_secname(Section *sec); -void nrn_push_section(Section *sec); -void nrn_pop_section(void); -void nrn_insert_mechanism(Section *sec, Symbol *mechanism); -hoc_Item *nrn_get_allsec(void); -hoc_Item *nrn_get_sectionlist_data(Object *obj); +extern Section *(*nrn_new_section)(char const *const name); +extern void (*nrn_connect_sections)(Section *child_sec, double child_x, + Section *parent_sec, double parent_x); +extern void (*nrn_set_section_length)(Section *sec, double length); +extern double (*nrn_get_section_length)(Section *sec); +extern double (*nrn_get_section_Ra)(Section* sec); +extern void (*nrn_set_section_Ra)(Section* sec, double val); +extern char const *(*nrn_secname)(Section *sec); +extern void (*nrn_push_section)(Section *sec); +extern void (*nrn_pop_section)(void); +extern void (*nrn_insert_mechanism)(Section *sec, Symbol *mechanism); +extern hoc_Item* (*nrn_get_allsec)(void); +extern hoc_Item* (*nrn_get_sectionlist_data)(Object* obj); /**************************************** * Segments ****************************************/ -int nrn_get_nseg(Section const *const sec); -void nrn_set_nseg(Section *const sec, const int nseg); -void nrn_set_segment_diam(Section *const sec, const double x, - const double diam); -double *nrn_get_rangevar_ptr(Section *const sec, Symbol *const sym, - double const x); +extern int (*nrn_get_nseg)(Section const * const sec); +extern void (*nrn_set_nseg)(Section* const sec, const int nseg); +extern void (*nrn_set_segment_diam)(Section* const sec, const double x, const double diam); +extern double* (*nrn_get_rangevar_ptr)(Section* const sec, Symbol* const sym, double const x); /**************************************** * Functions, objects, and the stack ****************************************/ -Symbol *nrn_get_symbol(char const *const name); -int nrn_get_symbol_type(Symbol *sym); -// TODO: need a way of mapping type identifiers to meaningful names -double *nrn_get_symbol_ptr(Symbol *sym); -void nrn_push_double(double val); -double nrn_pop_double(void); -void nrn_push_double_ptr(double *addr); -double *nrn_pop_double_ptr(void); -void nrn_push_str(char **str); -char **nrn_pop_str(void); -void nrn_push_int(int i); -int nrn_pop_int(void); -void nrn_push_object(Object *obj); -Object *nrn_pop_object(void); -int nrn_stack_type(void); -char const *const nrn_stack_type_name(int id); -Object *nrn_new_object(Symbol *sym, int narg); -Symbol *nrn_get_method_symbol(Object *obj, char const *const name); -void nrn_call_method(Object *obj, Symbol *method_sym, int narg); -void nrn_call_function(Symbol *sym, int narg); -void nrn_ref_object(Object *obj); -void nrn_unref_object(Object *obj); -char const *nrn_get_class_name(Object *obj); +extern Symbol *(*nrn_get_symbol)(char const *const name); +extern int (*nrn_get_symbol_type)(Symbol *sym); +extern double *(*nrn_get_symbol_ptr)(Symbol *sym); +extern void (*nrn_push_double)(double val); +extern double (*nrn_pop_double)(void); +extern void (*nrn_push_double_ptr)(double *addr); +extern double *(*nrn_pop_double_ptr)(void); +extern void (*nrn_push_str)(char **str); +extern char **(*nrn_pop_str)(void); +extern void (*nrn_push_int)(int i); +extern int (*nrn_pop_int)(void); +extern void (*nrn_push_object)(Object* obj); +extern Object *(*nrn_pop_object)(void); +extern int (*nrn_stack_type)(void); +extern char const *const (*nrn_stack_type_name)(int id); +extern Object *(*nrn_new_object)(Symbol *sym, int narg); +extern Symbol *(*nrn_get_method_symbol)(Object *obj, char const *const name); +extern void (*nrn_call_method)(Object *obj, Symbol *method_sym, int narg); +extern void (*nrn_call_function)(Symbol *sym, int narg); +extern void (*nrn_ref_object)(Object *obj); +extern void (*nrn_unref_object)(Object *obj); +extern char const * (*nrn_get_class_name)(Object* obj); /**************************************** * Miscellaneous ****************************************/ -int nrn_call_hoc(char const *const command); -SectionListIterator *nrn_new_sectionlist_iterator(hoc_Item *my_sectionlist); -void nrn_free_sectionlist_iterator(SectionListIterator *sl); -Section *nrn_sectionlist_iterator_next(SectionListIterator *sl); -int nrn_sectionlist_iterator_done(SectionListIterator *sl); -SymbolTableIterator *nrn_new_symbol_table_iterator(Symlist *my_symbol_table); -void nrn_free_symbol_table_iterator(SymbolTableIterator *st); -char const *nrn_symbol_table_iterator_next(SymbolTableIterator *st); -int nrn_symbol_table_iterator_done(SymbolTableIterator *st); -int nrn_vector_capacity(Object *vec); -double *nrn_vector_data_ptr(Object *vec); -double *nrn_get_pp_property_ptr(Object *pp, const char *name); -double *nrn_get_steered_property_ptr(Object *obj, const char *name); -char const *nrn_get_symbol_name(Symbol *sym); -Symlist *nrn_get_symbol_table(Symbol *sym); -Symlist *nrn_get_global_symbol_table(void); -// TODO: need a way of extracting information from a ShapePlotInterface +extern int (*nrn_call_hoc)(char const *const command); +extern SectionListIterator *(*nrn_new_sectionlist_iterator)(hoc_Item *my_sectionlist); +extern void (*nrn_free_sectionlist_iterator)(SectionListIterator *sl); +extern Section *(*nrn_sectionlist_iterator_next)(SectionListIterator* sl); +extern int (*nrn_sectionlist_iterator_done)(SectionListIterator* sl); +extern SymbolTableIterator *(*nrn_new_symbol_table_iterator)(Symlist *my_symbol_table); +extern void (*nrn_free_symbol_table_iterator)(SymbolTableIterator *st); +extern char const *(*nrn_symbol_table_iterator_next)(SymbolTableIterator *st); +extern int (*nrn_symbol_table_iterator_done)(SymbolTableIterator *st); +extern int (*nrn_vector_capacity)(Object *vec); +extern double *(*nrn_vector_data_ptr)(Object *vec); +extern double* (*nrn_get_pp_property_ptr)(Object* pp, const char* name); +extern double* (*nrn_get_steered_property_ptr)(Object* obj, const char* name); +extern char const * (*nrn_get_symbol_name)(Symbol* sym); +extern Symlist * (*nrn_get_symbol_table)(Symbol* sym); +extern Symlist * (*nrn_get_global_symbol_table)(void); +// TODO: need shapeplot information extraction + +#ifdef __cplusplus } +#endif \ No newline at end of file