diff --git a/cmake/NeuronFileLists.cmake b/cmake/NeuronFileLists.cmake index 9809bf8f88..ca4fbcdbfa 100644 --- a/cmake/NeuronFileLists.cmake +++ b/cmake/NeuronFileLists.cmake @@ -149,7 +149,6 @@ set(IVOC_FILE_LIST axis.cpp bndedval.cpp cbwidget.cpp - checkpnt.cpp epsprint.cpp fourier.cpp gifimage.cpp diff --git a/docs/guide/hoc_chapter_11_old_reference.rst b/docs/guide/hoc_chapter_11_old_reference.rst index aeeb70bbf0..790d095e8f 100644 --- a/docs/guide/hoc_chapter_11_old_reference.rst +++ b/docs/guide/hoc_chapter_11_old_reference.rst @@ -310,7 +310,7 @@ Keywords string_dialog doEvents doNotify numarg hoc_pointer_ execute execute1 load_proc load_func load_template machine_name saveaudit retrieveaudit coredump_on_error - checkpoint quit object_push object_pop pwman_place + quit object_push object_pop pwman_place show_errmess_always numprocs myproc psync settext secname diff --git a/docs/hoc/simctrl/programmatic.rst b/docs/hoc/simctrl/programmatic.rst index 3cec92a87b..4f3d46e59e 100644 --- a/docs/hoc/simctrl/programmatic.rst +++ b/docs/hoc/simctrl/programmatic.rst @@ -346,37 +346,6 @@ Functions ---- -.. hoc:function:: checkpoint - - Syntax: - :samp:`checkpoint("{filename}")` - - Description: - saves the current state of the system in a portable file to - allow one to take up where you left off -- possibly on another - machine. Returning to this state is accomplished by running the - program with the checkpoint file as the first argument. - If the checkpoint file is inconsistent with the executable the - program prints an error message and exits. - - At this time many portions of the computer state are left out of the - checkpoint file, i.e. it is not as complete as a core dump. - Some things that ARE included are: - all interpreter symbols with definitions and values, - all hoc instructions, - all neuron state/parameters with mechanisms. - Many aspects of the GUI are not included. - - .. warning:: - There is not enough implementation at this time to make this - facility useful. Use the :hoc:class:`SaveState` class instead. - - - - ----- - - .. _hoc_finithnd: diff --git a/docs/python/simctrl/programmatic.rst b/docs/python/simctrl/programmatic.rst index ce082d8498..1f4646da54 100755 --- a/docs/python/simctrl/programmatic.rst +++ b/docs/python/simctrl/programmatic.rst @@ -345,36 +345,6 @@ Functions It is cleared at the beginning of a run or when continuing a run. ----- - -.. function:: checkpoint - - Syntax: - :samp:`h.checkpoint("{filename}")` - - Description: - saves the current state of the system in a portable file to - allow one to take up where you left off -- possibly on another - machine. Returning to this state is accomplished by running the - program with the checkpoint file as the first argument. - If the checkpoint file is inconsistent with the executable the - program prints an error message and exits. - - At this time many portions of the computer state are left out of the - checkpoint file, i.e. it is not as complete as a core dump. - Some things that ARE included are: - all interpreter symbols with definitions and values, - all hoc instructions, - all neuron state/parameters with mechanisms. - Many aspects of the GUI are not included. - - .. warning:: - There is not enough implementation at this time to make this - facility useful. Use the :class:`SaveState` class instead. - - - - ---- .. _finithnd: diff --git a/share/lib/helpdict b/share/lib/helpdict index fbfaf1a699..aa978a7a17 100755 --- a/share/lib/helpdict +++ b/share/lib/helpdict @@ -80,7 +80,6 @@ Changeparmfromlist Extras RunFitter StandardRunTools GUI Reference 449 neuron/st ChangeText Graph LookAndFeel GUI Reference 18 neuron/agui/gui.html#ChangeText Channels ModelDescriptionIssues CVode classes neuron neuron.exe Reference 258 neuron/neuron/classes/cvode.html#Channels chdir functions general neuron.exe Reference 177 neuron/general/function/0fun.html#chdir -checkpoint functions general neuron.exe Reference 179 neuron/general/function/checkpnt.html#checkpoint child SectionRef classes neuron neuron.exe Reference 320 neuron/neuron/classes/secref.html#child children SectionList classes neuron neuron.exe Reference 317 neuron/neuron/classes/seclist.html#children chooser File classes general neuron.exe Reference 32 neuron/general/classes/file.html#chooser diff --git a/src/ivoc/checkpnt.cpp b/src/ivoc/checkpnt.cpp deleted file mode 100644 index 77006fa5e4..0000000000 --- a/src/ivoc/checkpnt.cpp +++ /dev/null @@ -1,1265 +0,0 @@ -#include <../../nrnconf.h> -#if HAVE_IV // to end of file -#include -#include - -/* - -strategy: - -symbols - hoc_built_in_symlist - hoc_top_level_symlist - symlists for each template - object data -linked-function pointers - -procedures - symbol pointers and linked function pointers used here - -nrnoc - mostly data but also pointers in the dparam. - because of setpointer (eg, pre-synaptic potential, these can - be pointers to any object data or nrnoc data. - - -bottom line: - extremely important to have generic method for pointers to any - location of an allocated block. - -two pass: - allocate all blocks - make pointer map - fill pointers - -two kinds of pointers - ownership -- responsible for allocating the space - observer -map - key address size type - -This was my initial thought. The incremental implementation has -evolved considerably with many ad hoc aspects and false starts. - -assume usage of compatible executeable. This means the same hoc_built_in_symlist -for writing and reading the checkpoint. For now we save this symlist in the -checkpoint and on reading check to make sure it is the same as the one -in memory. If so I think we have prima facie evidence that the instruction -list is consistent. ie add() -inst_table-> int ---> int -hoc_inst[]-> add(). -the hoc_inst[] contains the signature of an instruction that tells what -(if anything)is expected on the execution list. -All other built-in functions are accessed through their symbols. -In fact all symbols are transmitted via - sym -stable_-> int -----> int -symplist[]-> sym - -Here is the format of the checkpoint file (no leading blanks in file): - -total number of symbols -hoc_built-in-symlist (in recursive symbol and table format) -hoc_top_level_symlist (in recursive symbol and table format) -instructions for all FUNC/PROC symbols --1 -Objectdata (VAR with NOTUSER subtype, OBJECTVAR, STRING) and local data --1 -ivoc,nrnoc, nrniv stuff (to be implemented) - - -The recursive symbol and table format is -symtable size -symbolinteger type subtype -symbolname - if the symbol is of a type that itself has a symbol table then we recurse - -instructions for all ... is a -1 terminated list of -symbolinteger -size -instructionintegers mingled with - signature info consisting of symbolinteger, integer, etc - -Objectdata etc is -1 terminated list of -symbolinteger -data depending on type. eg for VAR && NOTUSER it is - arrayinfo - values for all elements in the array - and for OBJECTVAR it is - arrayinfo - Objectdata recursion for all elements in the array - objectref to the objects for all elements in the array - -*/ - -#include -#include -#include "oc2iv.h" -#include "ocfunc.h" -#include "checkpnt.h" - -#include "hoclist.h" -#include "parse.hpp" -#include "code.h" -#include "equation.h" -int hoc_readcheckpoint(char*); -extern int hoc_resize_toplevel(int); - -static struct HocInst { - Pfrv pi; - const char* signature; -} hoc_inst_[] = {{0, 0}, // 0 - {hoc_nopop, 0}, - {hoc_eval, 0}, - {hoc_add, 0}, - {hoc_sub, 0}, - {hoc_mul, 0}, - {hoc_div, 0}, - {hoc_negate, nullptr}, - {hoc_power, 0}, - {hoc_assign, nullptr}, - {hoc_bltin, "s"}, // requires change - {hoc_varpush, "s"}, // 10 - {hoc_constpush, "s"}, - {hoc_pushzero, 0}, - {hoc_print, 0}, - {hoc_varread, "s"}, - {hoc_prexpr, 0}, - {hoc_prstr, 0}, - {hoc_gt, 0}, - {hoc_lt, nullptr}, - {hoc_eq, nullptr}, // 20 - {hoc_ge, 0}, - {hoc_le, 0}, - {hoc_ne, 0}, - {hoc_and, 0}, - {hoc_or, 0}, - {hoc_not, 0}, - {hoc_ifcode, "iii"}, - {hoc_forcode, "iii"}, - {hoc_shortfor, "ii"}, - {hoc_call, "si"}, // 30 - {hoc_arg, "i"}, - {hoc_argassign, "i"}, - {hoc_funcret, 0}, - {hoc_procret, 0}, - {hoc_stringarg, "i"}, - {hoc_push_string, "s"}, - {hoc_Break, 0}, - {hoc_Continue, 0}, - {hoc_Stop, 0}, - {hoc_assstr, 0}, // 40 - {hoc_evalpointer, 0}, - {hoc_newline, 0}, - {hoc_delete_symbol, "s"}, - {hoc_cyclic, 0}, - {hoc_dep_make, 0}, - {hoc_eqn_name, 0}, - {hoc_eqn_init, 0}, - {hoc_eqn_lhs, 0}, // 50 - {hoc_eqn_rhs, 0}, - {hoc_objectvar, "s"}, - {hoc_object_component, "siis"}, - {hoc_object_eval, 0}, - {hoc_object_asgn, 0}, - {hoc_objvardecl, "si"}, - {hoc_cmp_otype, "i"}, - {hoc_newobj, "si"}, - {hoc_asgn_obj_to_str, 0}, - {hoc_known_type, "i"}, // 60 - {hoc_push_string, "s"}, - {hoc_objectarg, "i"}, - {hoc_ob_pointer, 0}, - {connectsection, 0}, - {simpleconnectsection, 0}, - {connectpointer, "s"}, - {add_section, "si"}, - {range_const, "s"}, - {range_interpolate, "s"}, - {range_interpolate_single, "s"}, // 70 - {rangevareval, "s"}, - {rangepoint, "s"}, - {sec_access, "s"}, - {ob_sec_access, 0}, - {mech_access, "s"}, - {for_segment, "ii"}, - {sec_access_push, "s"}, - {sec_access_pop, 0}, - {forall_section, "ii"}, - {hoc_ifsec, "ii"}, // 80 - {hoc_ifseclist, "ii"}, - {forall_sectionlist, "ii"}, - {connect_point_process_pointer, 0}, - {nrn_cppp, 0}, - {rangevarevalpointer, "s"}, - {sec_access_object, 0}, - {mech_uninsert, "s"}, - {hoc_arayinstal, "i"}, - {0, 0}}; - -#define VPfri void* -static std::map* inst_table_; - -class OcCheckpoint { - public: - OcCheckpoint(); - virtual ~OcCheckpoint() = default; - - bool write(const char*); - - private: - friend class Checkpoint; - bool pass1(); - bool pass2(); - bool make_sym_table(); - bool build_map(); - - bool func(Symbol*); - - bool sym_count(Symbol*); - bool sym_table_install(Symbol*); - bool sym_out(Symbol*); - bool sym_instructions(Symbol*); - bool sym_values(Symbol*); - bool objects(Symbol*); - - bool symlist(Symlist*); - bool symbol(Symbol*); - bool proc(Proc*); - bool instlist(unsigned long, Inst*); - bool datum(Datum*); - bool ctemplate(Symbol*); - bool object(); - bool objectdata(Objectdata*); - long arrayinfo(Symbol* s, Objectdata*); - bool xdr(int&); - bool xdr(long&); - bool xdr(char*&, int); - bool xdr(short&); - bool xdr(unsigned int&); - bool xdr(unsigned long&); - bool xdr(double&); - bool xdr(Object*&); - - private: - int cnt_; - int nobj_; - std::unique_ptr> otable_{}; - bool (OcCheckpoint::*func_)(Symbol*) = nullptr; - std::unique_ptr> stable_{}; - Objectdata* objectdata_; -}; - -class OcReadChkPnt { - public: - OcReadChkPnt(); - virtual ~OcReadChkPnt(); - - bool read(); - - private: - friend class Checkpoint; - bool symbols(); - bool symtable(); - bool symbol(); - bool instructions(); - bool objects(); - bool objectdata(); - - long arrayinfo(Symbol* s, Objectdata*); - - bool get(int&); - bool get(long&); - bool get(char*&); - bool get(double&); - bool get(Object*&); - - private: - bool lookup_; - int builtin_size_; - int lineno_; - int id_; - int nsym_; - Symbol** psym_; - long nobj_; - Object** pobj_; - Symlist* symtable_; -}; - -static bool out_; -static FILE* f_; -static OcCheckpoint* cp_; -static OcReadChkPnt* rdckpt_; -static Checkpoint* ckpt_; - -Checkpoint* Checkpoint::instance() { - if (!ckpt_) { - ckpt_ = new Checkpoint(); - } - return ckpt_; -} - -Checkpoint::Checkpoint() {} -Checkpoint::~Checkpoint() {} -bool Checkpoint::out() { - return out_; -} -bool Checkpoint::xdr(long& i) { - if (out()) { - return cp_->xdr(i); - } else { - return rdckpt_->get(i); - } -} -bool Checkpoint::xdr(Object*& o) { - if (out()) { - return cp_->xdr(o); - } else { - return rdckpt_->get(o); - } -} - -void hoc_checkpoint() { - if (!cp_) { - cp_ = new OcCheckpoint(); - } - bool b; - b = cp_->write(gargstr(1)); - hoc_ret(); - hoc_pushx(double(b)); -} - -int hoc_readcheckpoint(char* fname) { - f_ = fopen(fname, "r"); - if (!f_) { - return 0; - } - char buf[256]; - if (fgets(buf, 256, f_) == 0) { - printf("checkpoint read from file %s failed.\n", fname); - return 2; - } - if (strcmp(buf, "NEURON Checkpoint\n") != 0) { - fclose(f_); - return 0; - } - rdckpt_ = new OcReadChkPnt(); - bool b; - b = rdckpt_->read(); - int rval = 1; - if (!b) { - printf("checkpoint read from file %s failed.\n", fname); - rval = 2; - } - delete rdckpt_; - rdckpt_ = NULL; - return rval; -} - -OcCheckpoint::OcCheckpoint() { - if (!inst_table_) { - inst_table_ = new std::map{}; - for (int i = 1; hoc_inst_[i].pi; ++i) { - inst_table_->emplace((VPfri) hoc_inst_[i].pi, i); - } - } -} - -bool OcCheckpoint::write(const char* fname) { - bool b; - int i; - out_ = 1; - f_ = fopen(fname, "w"); - if (!f_) { - return false; - } - fprintf(f_, "NEURON Checkpoint\n"); - b = make_sym_table(); - func_ = &OcCheckpoint::sym_out; - b = (b && pass1()); - func_ = &OcCheckpoint::sym_instructions; - b = (b && pass1()); - i = -1; - b = (b && xdr(i)); - - // printf("nobj_ = %d\n", nobj_); - b = b && object(); - - func_ = &OcCheckpoint::sym_values; - objectdata_ = hoc_top_level_data; - int size = hoc_resize_toplevel(0); - b = b && xdr(size); - i = 0; - b = b && xdr(i); - b = b && pass1(); - i = -1; - b = (b && xdr(i)); - fclose(f_); - return b; -} - -bool OcCheckpoint::make_sym_table() { - bool b; - cnt_ = 1; - nobj_ = 0; - func_ = &OcCheckpoint::sym_count; - b = pass1(); - if (!b) { - printf("make_sym_table failed on first pass1\n"); - } - fprintf(f_, "#symbols=%d\n", cnt_); - b = (b && xdr(cnt_)); - stable_ = std::make_unique>(); - cnt_ = 1; - func_ = &OcCheckpoint::sym_table_install; - if (!b) { - printf("make_sym_table failed before second pass1\n"); - } - b = (b && pass1()); - if (!b) { - printf("make_sym_table failed on second pass1\n"); - } - func_ = NULL; - return b; -} - -bool OcCheckpoint::sym_count(Symbol* s) { - ++cnt_; - if (s->type == TEMPLATE) { - nobj_ += s->u.ctemplate->count; - } - return true; -} - -bool OcCheckpoint::sym_table_install(Symbol* s) { - stable_->emplace(s, cnt_); - ++cnt_; - return true; -} -bool OcCheckpoint::sym_out(Symbol* s) { - auto it = stable_->find(s); - int val = it != stable_->end() ? it->second : 0; - fprintf(f_, "%d %s %d %d\n", val, s->name, s->type, s->subtype); - int l1 = strlen(s->name); - bool b = xdr(val) && xdr(s->name, l1) && xdr(s->type) && xdr(s->subtype) && xdr(s->cpublic) && - xdr(s->s_varn) && xdr(s->defined_on_the_fly); - switch (s->type) { - case VAR: - if (s->subtype == NOTUSER) { - b = b && xdr(s->u.oboff); - } - arrayinfo(s, NULL); - break; - case STRING: - case OBJECTVAR: - b = b && xdr(s->u.oboff); - arrayinfo(s, NULL); - break; - case TEMPLATE: { - cTemplate* t = s->u.ctemplate; - if (!t->constructor) { - b = b && xdr(t->dataspace_size) && xdr(t->id); - } - break; - } - case NUMBER: - b = b && xdr(*s->u.pnum); - break; - case CSTRING: - b = b && xdr(s->u.cstr, strlen(s->u.cstr)); - break; - } - if (!b) { - printf("failed in sym_table_install\n"); - } - return b; -} - -bool OcCheckpoint::pass1() { - return symlist(hoc_built_in_symlist) && symlist(hoc_top_level_symlist); -} -bool OcCheckpoint::pass2() { - return false; -} -bool OcCheckpoint::build_map() { - return false; -} -bool OcCheckpoint::func(Symbol* s) { - if (func_) { - return (this->*func_)(s); - } - return true; -} -bool OcCheckpoint::symlist(Symlist* sl) { - if (func_ == &OcCheckpoint::sym_out) { - int i = 0; - if (sl) - for (Symbol* s = sl->first; s; s = s->next) { - ++i; - } - fprintf(f_, "symboltable size %d\n", i); - if (!xdr(i)) { - return false; - } - } - if (sl) - for (Symbol* s = sl->first; s; s = s->next) { - if (!symbol(s)) { - printf("symlist failed\n"); - return false; - } - } - return true; -} -bool OcCheckpoint::symbol(Symbol* s) { - if (!func(s)) { - return false; - } - bool b = true; - switch (s->type) { - case TEMPLATE: - b = ctemplate(s); - break; - case FUNCTION: - case PROCEDURE: - b = symlist(s->u.u_proc->list); - break; - } - if (!b) - printf("symbol failed\n"); - return b; -} -bool OcCheckpoint::sym_instructions(Symbol* s) { - Proc* p = s->u.u_proc; - if (s->type == FUNCTION || s->type == PROCEDURE) { - auto it = stable_->find(s); - if (it == stable_->end()) { - printf("couldn't find %s in table\n", s->name); - return false; - } - int val = it->second; - if (p->size) { - fprintf(f_, "instructions for %d |%s|\n", val, s->name); - fprintf(f_, "size %lu\n", p->size); - bool b = xdr(val) && xdr(p->size); - if (!b) { - printf("failed in sym_intructions\n"); - return false; - } - b = instlist(p->size, p->defn.in); - if (!b) { - printf("instlist failed for %s\n", s->name); - } - return b; - } - } - return true; -} -bool OcCheckpoint::instlist(unsigned long size, Inst* in) { - for (unsigned long i = 0; i < size; ++i) { - if (in[i].in == STOP) { - fprintf(f_, " STOP\n"); - int sval = 0; - if (!xdr(sval)) { - printf("instlist failed 1\n"); - return false; - } - continue; - } - if (auto it = inst_table_->find((VPfri) in[i].pf); it != inst_table_->end()) { - auto val = it->second; - fprintf(f_, " %d\n", val); - if (!xdr(val)) { - printf("instlist failed 2\n"); - return false; - } - const char* s = hoc_inst_[val].signature; - for (int j = 0; s && s[j]; ++j) { - ++i; - switch (s[j]) { - case 's': - if (in[i].sym) { - auto it = stable_->find(in[i].sym); - if (it == stable_->end()) { - printf("couldn't find |%s| in table at instruction index %ld\n", - in[i].sym->name, - i); - return false; - } - auto sval = it->second; - // fprintf(f_, " %d |%s|\n", sval, in[i].sym->name); - if (!xdr(sval)) { - printf("instlist failed 3\n"); - return false; - } - } else { - fprintf(f_, " 0 SYMBOL0\n"); - int sval = 0; - if (!xdr(sval)) { - printf("instlist failed 4\n"); - return false; - } - } - break; - case 'i': - fprintf(f_, " %i\n", in[i].i); - if (!xdr(in[i].i)) { - printf("instlist failed 5\n"); - return false; - } - break; - } - } - } else { - printf("OcCheckpoint::instlist failed at i = %lu\n", i); - return false; - } - } - return true; -} -bool OcCheckpoint::datum(Datum*) { - return false; -} -bool OcCheckpoint::ctemplate(Symbol* s) { - cTemplate* t = s->u.ctemplate; - if (func_ == &OcCheckpoint::sym_values) { - Objectdata* saveod = objectdata_; - auto it = stable_->find(s); - bool b = it != stable_->end(); - auto ti = b ? it->second : 0; - fprintf(f_, "%d %d %s\n", ti, t->count, s->name); - b = b && xdr(ti); - // b = b && xdr(t->count); - hoc_Item* q; - ITERATE(q, t->olist) { - Object* ob = OBJ(q); - auto it = otable_->find(ob); - bool found = it != otable_->end(); - b = b && found; - int oid = found ? it->second : 0; - b = b && xdr(oid); - if (t->constructor) { - if (t->checkpoint) { - b = b && (t->checkpoint)(&ob->u.this_pointer); - } else { - printf("No checkpoint available for %s\n", hoc_object_name(ob)); - b = false; - } - } else { - objectdata_ = ob->u.dataspace; - b = b && symlist(t->symtable); - } - if (!b) { - break; - } - } - objectdata_ = saveod; - return b; - } else { - return symlist(t->symtable); - } -} -bool OcCheckpoint::object() { - bool b = xdr(nobj_); - otable_ = std::make_unique>(); - nobj_ = 0; - func_ = &OcCheckpoint::objects; - b = pass1(); - int i = -1; - b = b && xdr(i); - return b; -} -bool OcCheckpoint::objects(Symbol* s) { - if (s->type != TEMPLATE) { - return true; - } - - auto it = stable_->find(s); - bool b = it != stable_->end(); - int sid = b ? it->second : 0; - b = b && xdr(sid); - cTemplate* t = s->u.ctemplate; -#undef init - if (t->init) { - auto it2 = stable_->find(t->init); - bool b2 = it2 != stable_->end(); - b = b && b2; - sid = b2 ? it2->second : sid; - } else { - sid = 0; - } - b = b && xdr(sid); - b = b && xdr(t->index) && xdr(t->count) && xdr(t->id); - hoc_Item* q; - ITERATE(q, t->olist) { - Object* ob = OBJ(q); - ++nobj_; - otable_->emplace(ob, nobj_); // 0 is null object - b = b && xdr(nobj_) && xdr(ob->refcount) && xdr(ob->index); - } - return b; -} - -bool OcCheckpoint::objectdata(Objectdata*) { - return false; -} -#undef sub -long OcCheckpoint::arrayinfo(Symbol* s, Objectdata* od) { - Arrayinfo* ao; - Arrayinfo* as; - - as = s->arayinfo; - if (od) { - ao = od[s->u.oboff + 1].arayinfo; - } else { - ao = as; - } - long n = long(hoc_total_array_data(s, od)); - if (!as) { // not an array - fprintf(f_, "0\n"); - int i = 0; - xdr(i); - } else if (od && as == ao) { // same as original - fprintf(f_, "-1\n"); - int i = -1; - xdr(i); - } else { - int v = ao->a_varn ? 1 : 0; - fprintf(f_, "%d %d %d", ao->nsub, ao->refcount, v); - if (v) { - printf("checkpoint of equation array vars not implemented: %s\n", s->name); - return -1; - } - xdr(ao->nsub); - // xdr(ao->refcount); - // xdr(v); - for (int i = 0; i < ao->nsub; ++i) { - fprintf(f_, " %d", ao->sub[i]); - xdr(ao->sub[i]); - } - fprintf(f_, "\n"); - } - return n; -} - -bool OcCheckpoint::proc(Proc*) { - return false; -} - -bool OcCheckpoint::sym_values(Symbol* s) { - bool b; - auto it = stable_->find(s); - int sp = it != stable_->end() ? it->second : 0; - - if ((s->type == VAR && s->subtype == NOTUSER) || s->type == OBJECTVAR || s->type == STRING || - s->type == SECTION) { - fprintf(f_, "%d %s\n", sp, s->name); - b = xdr(sp); - long n = arrayinfo(s, objectdata_); - if (n == -1) { - return false; - } - // fprintf(f_, " %ld\n", n); - // b = b && xdr(n); - for (long i = 0; i < n; ++i) { - Objectdata od = objectdata_[s->u.oboff]; - if (s->type == VAR) { - double d = od.pval[i]; - fprintf(f_, " %g\n", d); - b = b && xdr(d); - } else if (s->type == OBJECTVAR) { - Object* ob = od.pobj[i]; - if (ob == NULL) { - fprintf(f_, " 0\n"); - int i = 0; - b = b && xdr(i); - } else { - auto it = otable_->find(ob); - bool found = it != otable_->end(); - int oid = found ? it->second : 0; - b = b && found; - b = b && xdr(oid); - } - } else if (s->type == STRING) { - char* cp = od.ppstr[i]; - fprintf(f_, " |%s|\n", cp); - b = b && xdr(cp, strlen(cp)); - // }else if (s->type == SECTION) { - } - } - } - return true; -} - -bool OcCheckpoint::xdr(int& i) { - fprintf(f_, "%d\n", i); - return true; -} -bool OcCheckpoint::xdr(long& i) { - fprintf(f_, "%ld\n", i); - return true; -} -bool OcCheckpoint::xdr(char*& s, int) { - fprintf(f_, "%s\n", s); - return true; -} -bool OcCheckpoint::xdr(short& i) { - int j = i; - fprintf(f_, "%d\n", j); - return true; -} -bool OcCheckpoint::xdr(unsigned int& i) { - int j = i; - fprintf(f_, "%d\n", j); - return true; -} -bool OcCheckpoint::xdr(unsigned long& i) { - long j = i; - fprintf(f_, "%ld\n", j); - return true; -} -bool OcCheckpoint::xdr(double& i) { - fprintf(f_, "%g\n", i); - return true; -} - -bool OcCheckpoint::xdr(Object*& o) { - auto it = otable_->find(o); - bool b = it != otable_->end(); - int i = b ? it->second : 0; - return b && xdr(i); -} - -#undef Chk -#define Chk(arg1, arg2) \ - if (!(arg1)) { \ - printf("%s line %d\n", arg2, lineno_); \ - return false; \ - } -#undef Get -#define Get(arg) \ - if (!get(arg)) { \ - return false; \ - } - -OcReadChkPnt::OcReadChkPnt() { - builtin_size_ = hoc_resize_toplevel(0); -} - -OcReadChkPnt::~OcReadChkPnt() { - delete[] psym_; - delete[] pobj_; -} - -bool OcReadChkPnt::read() { - int size; - out_ = 0; - lineno_ = 1; - id_ = 1; - Chk(symbols(), "OcReadChkPnt::symbols() read failure"); - printf("finished with symbols at lineno = %d\n", lineno_); - Chk(instructions(), "OcReadChkPnt::instructions() read failure"); - printf("finished with instructions at lineno = %d\n", lineno_); - Chk(objects(), "OcReadChkPnt::objects() read failure"); - printf("finished with objects at lineno = %d\n", lineno_); - Get(size); - if (size != hoc_resize_toplevel(size - builtin_size_)) { - printf("top_level_data not right size\n"); - return false; - } - Chk(objectdata(), "OcReadChkPnt::objectdata() read failure"); - printf("finished with objectdata at lineno = %d\n", lineno_); - return true; -} - -bool OcReadChkPnt::symbols() { - Get(nsym_); - psym_ = new Symbol*[nsym_]; - for (int i = 0; i < nsym_; ++i) { - psym_[i] = 0; - } - lookup_ = true; - symtable_ = hoc_built_in_symlist; - Chk(symtable(), "built_in_symlist failure"); - lookup_ = false; - symtable_ = hoc_top_level_symlist; - if (symtable_->first != NULL) { - printf("Some user symbols are already defined at the top level\n"); - return false; - } - Chk(symtable(), "top_level_symlist failure"); - return true; -} -bool OcReadChkPnt::symtable() { - int size; - Get(size); - for (int i = 0; i < size; ++i) { - Chk(symbol(), "symbol read failure"); - } - return true; -} -bool OcReadChkPnt::symbol() { - int id, type, subtype, i; - char buf[2048], *name = buf; - - Get(id); - if (id != id_) { - printf("expected symbol id = %d but file id was %d\n", id_, id); - return false; - } - ++id_; - Get(name); - Get(type); - Get(subtype); - - Symbol* sym; - if (lookup_) { - sym = hoc_table_lookup(name, symtable_); - if (!sym || sym->type != type || sym->subtype != subtype) { - printf("%s not a built-in\n", name); - return false; - } - } else { - sym = hoc_install(name, (type == VAR) ? UNDEF : type, 0.0, &symtable_); - sym->type = type; - sym->subtype = subtype; - } - - psym_[id] = sym; - Get(i); - sym->cpublic = i; - Get(i); - sym->s_varn = i; - Get(i); - sym->defined_on_the_fly = i; - switch (type) { - case VAR: { - if (subtype == NOTUSER) { - Get(i); - if (lookup_ && i != sym->u.oboff) { - printf("bad u.oboff field for built-in VAR\n"); - return false; - } else { - sym->u.oboff = i; - } - } - arrayinfo(sym, NULL); - } break; - case OBJECTVAR: - case STRING: - Get(i); - sym->u.oboff = i; - arrayinfo(sym, NULL); - break; - case CSTRING: - sym->u.cstr = NULL; - Get(sym->u.cstr); - break; - case NUMBER: - sym->u.pnum = new double; - Get(*sym->u.pnum); - break; - case TEMPLATE: { - cTemplate* t; - int dsize, id; - Symlist* slsave = symtable_; - if (!lookup_) { - Get(dsize); - Get(id); - t = new cTemplate; - sym->u.ctemplate = t; - t->sym = sym; - t->dataspace_size = dsize; - t->constructor = 0; - t->destructor = 0; - t->steer = 0; - t->id = id; - symtable_ = NULL; - Chk(symtable(), ""); - t->symtable = symtable_; - } else { - // these don't have a dataspace - t = sym->u.ctemplate; - symtable_ = t->symtable; - Chk(symtable(), ""); - } - symtable_ = slsave; - } break; - case FUNCTION: - case PROCEDURE: { - Symlist* slsave = symtable_; - symtable_ = sym->u.u_proc->list; - Chk(symtable(), ""); - sym->u.u_proc->list = symtable_; - symtable_ = slsave; - } break; - } - return true; -} -bool OcReadChkPnt::instructions() { - int sid, size, i, iid; - Symbol* sym; - const char* signature; - for (;;) { - Get(sid); - if (sid == -1) { - break; - } - sym = psym_[sid]; - if (!sym || (sym->type != FUNCTION && sym->type != PROCEDURE)) { - printf("not a PROC or FUNC\n"); - return false; - } - Get(size); - sym->u.u_proc->size = size; - Inst* lin; - sym->u.u_proc->defn.in = lin = new Inst[size]; - for (i = 0; i < size;) { - Get(iid); - lin[i++].pf = hoc_inst_[iid].pi; - signature = hoc_inst_[iid].signature; - if (signature) - for (const char* cp = signature; *cp; ++cp) { - Get(iid); - switch (*cp) { - case 's': - lin[i++].sym = psym_[iid]; - break; - case 'i': - lin[i++].i = iid; - break; - } - } - } - } - - return true; -} -bool OcReadChkPnt::objects() { - int sid; - long i, n, iob = 0; - Symbol* sym; - Get(nobj_); - pobj_ = new Object*[nobj_ + 1]; - pobj_[0] = NULL; - for (;;) { - Get(sid); - if (sid == -1) { - break; - } - sym = psym_[sid]; - if (sym->type != TEMPLATE) { - printf("not a template\n"); - return false; - } - cTemplate* t = sym->u.ctemplate; - Get(sid); -#undef init - t->init = psym_[sid]; - Get(t->index); - Get(n); - t->count = int(n); - if (t->constructor && !t->checkpoint && t->count > 0) { - printf("Objects for a built-in template without checkpoint: %s\n", sym->name); - return false; - } - t->olist = hoc_l_newlist(); - Get(t->id); - for (i = 0; i < n; ++i) { - int fiob; // not really needed - Get(fiob); - Object* pob = new Object; - pobj_[++iob] = pob; - if (fiob != iob) { - printf("object indexes out of sync\n"); - } - pob->itm_me = hoc_l_lappendobj(t->olist, pob); - pob->ctemplate = t; - Get(pob->refcount); - Get(pob->index); - if (t->constructor) { - // have to set this up later - pob->u.this_pointer = NULL; - } else { - pob->u.dataspace = new Objectdata[t->dataspace_size]; - } - } - } - if (iob != nobj_) { - printf("objects read != objects expected\n"); - return false; - } - return true; -} -bool OcReadChkPnt::objectdata() { - int sid; - long n, i; - Symbol* sym; - double d; - int oid; - Objectdata *od, *odp; - Get(oid); - if (oid == 0) { - od = hoc_top_level_data; - } else if (oid == -1) { - return true; - } else { - od = pobj_[oid]->u.dataspace; - } - for (;;) { - Get(sid); - if (sid == -1) { - break; - } - sym = psym_[sid]; - switch (sym->type) { - case VAR: - n = arrayinfo(sym, od); - odp = od + sym->u.oboff; - if (od != hoc_top_level_data || builtin_size_ <= sym->u.oboff) { - odp->pval = new double[n]; - } - for (i = 0; i < n; ++i) { - Get(d); - odp->pval[i] = d; - } - break; - case OBJECTVAR: - n = arrayinfo(sym, od); - odp = od + sym->u.oboff; - odp->pobj = new Object*[n]; - for (i = 0; i < n; ++i) { - int iob; - Get(iob); - odp->pobj[i] = pobj_[iob]; - } - break; - case STRING: - n = arrayinfo(sym, od); - od[sym->u.oboff].ppstr = new char*[n]; - for (i = 0; i < n; ++i) { - od[sym->u.oboff].ppstr[i] = NULL; - Get(od[sym->u.oboff].ppstr[i]); - } - break; - case TEMPLATE: { - cTemplate* t = sym->u.ctemplate; - if (t->constructor) { - for (long j = 0; j < t->count; ++j) { - int iob; - Object* ob; - Get(iob); - ob = pobj_[iob]; - if (!(*t->checkpoint)(&ob->u.this_pointer)) { - printf("failed reading data for %s\n", hoc_object_name(ob)); - return false; - } - } - } else { - for (long j = 0; j < t->count; ++j) { - objectdata(); - } - } - } break; - default: - return false; - } - } - return true; -} -long OcReadChkPnt::arrayinfo(Symbol* s, Objectdata* od) { - int nsub; - Get(nsub); - if (lookup_) { - int i; - for (i = 0; i < nsub; ++i) { - Get(i); - } - } - Arrayinfo** ap; - if (od == NULL) { - ap = &s->arayinfo; - } else { - ap = &od[s->u.oboff + 1].arayinfo; - } - if (nsub == 0) { - *ap = NULL; - return 1; - } - if (nsub == -1) { - *ap = s->arayinfo; - if (*ap) { - (*ap)->refcount++; - } - return long(hoc_total_array_data(s, NULL)); - } - Arrayinfo* a = (Arrayinfo*) hoc_Emalloc(sizeof(Arrayinfo) + nsub * sizeof(int)); - if (!a) { - return -1; - } - *ap = a; - a->refcount = 1; - a->a_varn = NULL; - a->nsub = nsub; - - long n = 1; - for (int i = 0; i < nsub; ++i) { - int sub; - Get(sub); - a->sub[i] = sub; - n *= sub; - } - return n; -} -bool OcReadChkPnt::get(int& i) { - ++lineno_; - char buf[200]; - if (!fgets(buf, 200, f_) || (sscanf(buf, "%d", &i) != 1)) { - printf("error reading integer at line %d\n", lineno_); - return false; - } - - return true; -} -bool OcReadChkPnt::get(double& i) { - ++lineno_; - char buf[200]; - if (!fgets(buf, 200, f_) || (sscanf(buf, "%lf", &i) != 1)) { - printf("error reading double at line %d\n", lineno_); - return false; - } - - return true; -} -bool OcReadChkPnt::get(long& i) { - int j; - Get(j); - i = j; - return true; -} - -bool OcReadChkPnt::get(char*& s) { - ++lineno_; - if (s) { - if (!fgets(s, 2048, f_)) { - printf("error reading string at line %d\n", lineno_); - return false; - } - s[strlen(s) - 1] = '\0'; - } else { - char buf[256]; - if (!fgets(buf, 256, f_)) { - printf("error reading string at line %d\n", lineno_); - return false; - } - buf[strlen(buf) - 1] = '\0'; - s = new char[strlen(buf) + 1]; - strcpy(s, buf); - } - return true; -} - - -bool OcReadChkPnt::get(Object*& o) { - long i; - Get(i); - o = pobj_[i]; - return true; -} -#endif diff --git a/src/ivoc/checkpnt.h b/src/ivoc/checkpnt.h deleted file mode 100644 index 224e2d05e4..0000000000 --- a/src/ivoc/checkpnt.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#define CKPT(arg1, arg2) \ - if (!arg1.xdr(arg2)) { \ - return false; \ - } - -class Checkpoint { - public: - Checkpoint(); - virtual ~Checkpoint(); - - static Checkpoint* instance(); - - bool out(); // true means to file, false means from file - bool xdr(long&); - bool xdr(Object*&); -}; diff --git a/src/ivoc/graph.cpp b/src/ivoc/graph.cpp index 86a7f38973..aef2b933d9 100644 --- a/src/ivoc/graph.cpp +++ b/src/ivoc/graph.cpp @@ -1226,7 +1226,7 @@ static void gr_destruct(void* v) { } void Graph_reg() { // printf("Graph_reg\n"); - class2oc("Graph", gr_cons, gr_destruct, gr_members, NULL, NULL, NULL); + class2oc("Graph", gr_cons, gr_destruct, gr_members, NULL, NULL); #if HAVE_IV if (hoc_usegui) { colors = new ColorPalette(); diff --git a/src/ivoc/grglyph.cpp b/src/ivoc/grglyph.cpp index d505958115..2c5bc94e6d 100644 --- a/src/ivoc/grglyph.cpp +++ b/src/ivoc/grglyph.cpp @@ -213,7 +213,7 @@ static void destruct(void* v) { } void GrGlyph_reg() { - class2oc("Glyph", cons, destruct, members, NULL, objmembers, NULL); + class2oc("Glyph", cons, destruct, members, objmembers, NULL); sggl_ = hoc_lookup("Glyph"); } diff --git a/src/ivoc/ivocrand.cpp b/src/ivoc/ivocrand.cpp index f250049299..183fb5d72c 100644 --- a/src/ivoc/ivocrand.cpp +++ b/src/ivoc/ivocrand.cpp @@ -511,7 +511,7 @@ static Member_func r_members[] = {{"ACG", r_ACG}, {nullptr, nullptr}}; void Random_reg() { - class2oc("Random", r_cons, r_destruct, r_members, NULL, NULL, NULL); + class2oc("Random", r_cons, r_destruct, r_members, NULL, NULL); random_play_list_ = new RandomPlayList; } diff --git a/src/ivoc/ivocvect.cpp b/src/ivoc/ivocvect.cpp index 1ffb1eba95..9681a6b270 100644 --- a/src/ivoc/ivocvect.cpp +++ b/src/ivoc/ivocvect.cpp @@ -3843,7 +3843,7 @@ static void steer_x(void* v) { } void Vector_reg() { - class2oc("Vector", v_cons, v_destruct, v_members, NULL, v_retobj_members, v_retstr_members); + class2oc("Vector", v_cons, v_destruct, v_members, v_retobj_members, v_retstr_members); svec_ = hoc_lookup("Vector"); // now make the x variable an actual double Symbol* sv = hoc_lookup("Vector"); diff --git a/src/ivoc/matrix.cpp b/src/ivoc/matrix.cpp index 90b0aeef1e..8fa098d61d 100644 --- a/src/ivoc/matrix.cpp +++ b/src/ivoc/matrix.cpp @@ -732,7 +732,7 @@ void Matrix_reg(); #endif void Matrix_reg() { - class2oc("Matrix", m_cons, m_destruct, m_members, NULL, m_retobj_members, NULL); + class2oc("Matrix", m_cons, m_destruct, m_members, m_retobj_members, NULL); nrn_matrix_sym = hoc_lookup("Matrix"); // now make the x variable an actual double Symbol* sx = hoc_table_lookup("x", nrn_matrix_sym->u.ctemplate->symtable); diff --git a/src/ivoc/mlinedit.cpp b/src/ivoc/mlinedit.cpp index ae3a555c12..489719af73 100644 --- a/src/ivoc/mlinedit.cpp +++ b/src/ivoc/mlinedit.cpp @@ -141,7 +141,7 @@ static void destruct(void* v) { } void TextEditor_reg() { - class2oc("TextEditor", cons, destruct, members, NULL, NULL, retstr_members); + class2oc("TextEditor", cons, destruct, members, NULL, retstr_members); } #if HAVE_IV diff --git a/src/ivoc/mymath.cpp b/src/ivoc/mymath.cpp index 46180d18a1..13586a43ad 100644 --- a/src/ivoc/mymath.cpp +++ b/src/ivoc/mymath.cpp @@ -73,7 +73,7 @@ static void* cons(Object*) { static void destruct(void*) {} void GUIMath_reg() { - class2oc("GUIMath", cons, destruct, members, NULL, NULL, NULL); + class2oc("GUIMath", cons, destruct, members, NULL, NULL); } double MyMath::anint(double x) { diff --git a/src/ivoc/ocbox.cpp b/src/ivoc/ocbox.cpp index 5ca1d4d572..61a1320a96 100644 --- a/src/ivoc/ocbox.cpp +++ b/src/ivoc/ocbox.cpp @@ -429,11 +429,11 @@ static Member_func members[] = {{"intercept", intercept}, // #if HAVE {0, 0}}; void HBox_reg() { - class2oc("HBox", hcons, destruct, members, NULL, NULL, NULL); + class2oc("HBox", hcons, destruct, members, NULL, NULL); } void VBox_reg() { - class2oc("VBox", vcons, destruct, members, NULL, NULL, NULL); + class2oc("VBox", vcons, destruct, members, NULL, NULL); } #if HAVE_IV OcGlyphContainer::OcGlyphContainer() diff --git a/src/ivoc/ocdeck.cpp b/src/ivoc/ocdeck.cpp index 55b42f3c9f..be5d6f32db 100644 --- a/src/ivoc/ocdeck.cpp +++ b/src/ivoc/ocdeck.cpp @@ -239,7 +239,7 @@ static Member_func members[] = {{"flip_to", flip_to}, {0, 0}}; void OcDeck_reg() { - class2oc("Deck", cons, destruct, members, NULL, NULL, NULL); + class2oc("Deck", cons, destruct, members, NULL, NULL); } #if HAVE_IV OcDeck::OcDeck() diff --git a/src/ivoc/ocfile.cpp b/src/ivoc/ocfile.cpp index fc7c9ae5d2..fcad2b14ff 100644 --- a/src/ivoc/ocfile.cpp +++ b/src/ivoc/ocfile.cpp @@ -299,7 +299,7 @@ Member_func f_members[] = {{"ropen", f_ropen}, static Member_ret_str_func f_retstr_members[] = {{"getname", f_get_name}, {"dir", f_dir}, {0, 0}}; void OcFile_reg() { - class2oc("File", f_cons, f_destruct, f_members, NULL, NULL, f_retstr_members); + class2oc("File", f_cons, f_destruct, f_members, NULL, f_retstr_members); file_class_sym_ = hoc_lookup("File"); } diff --git a/src/ivoc/oclist.cpp b/src/ivoc/oclist.cpp index c8c5b78485..b19e129966 100644 --- a/src/ivoc/oclist.cpp +++ b/src/ivoc/oclist.cpp @@ -11,7 +11,6 @@ #include #include #include "ocglyph.h" -#include "checkpnt.h" #include "apwindow.h" #include "ocbrowsr.h" #include "objcmd.h" @@ -453,38 +452,9 @@ OcList::~OcList() { remove_all(); } -static int l_chkpt(void** vp) { -#if HAVE_IV - OcList* o; - Checkpoint& chk = *Checkpoint::instance(); - if (chk.out()) { - long cnt; - o = (OcList*) (*vp); - cnt = o->count(); - CKPT(chk, cnt); - for (long i = 0; i < cnt; ++i) { - Object* item = o->object(i); - CKPT(chk, item); - } - } else { - long cnt; - CKPT(chk, cnt); - o = new OcList(cnt); - o->ref(); - for (long i = 0; i < cnt; ++i) { - Object* item; - CKPT(chk, item); - o->append(item); - } - *vp = (void*) o; - } -#endif - return 1; -} - void OcList_reg() { // printf("Oclist_reg\n"); - class2oc("List", l_cons, l_destruct, l_members, l_chkpt, l_retobj_members, NULL); + class2oc("List", l_cons, l_destruct, l_members, l_retobj_members, NULL); list_class_sym_ = hoc_lookup("List"); } diff --git a/src/ivoc/ocnoiv1.cpp b/src/ivoc/ocnoiv1.cpp index ccbe2820ed..d3ceae4d2d 100644 --- a/src/ivoc/ocnoiv1.cpp +++ b/src/ivoc/ocnoiv1.cpp @@ -13,9 +13,6 @@ extern "C" void nrn_shape_update(); void ivoc_help(const char*) {} void ivoc_cleanup() {} -int hoc_readcheckpoint(char*) { - return 0; -} void hoc_notify_iv() { nrn_shape_update(); @@ -109,12 +106,6 @@ void hoc_string_dialog() { hoc_pushx(0.); } } -void hoc_checkpoint() { - // not redirecting checkpoint because not a GUI function - // neuron::python::methods.try_gui_helper("checkpoint", nullptr); - hoc_ret(); - hoc_pushx(0.); -} void hoc_pwman_place() { neuron::python::methods.try_gui_helper("pwman_place", nullptr); hoc_ret(); diff --git a/src/ivoc/ocpointer.cpp b/src/ivoc/ocpointer.cpp index a1cc1b04f9..afe3451316 100644 --- a/src/ivoc/ocpointer.cpp +++ b/src/ivoc/ocpointer.cpp @@ -108,7 +108,7 @@ static void steer_val(void* v) { } void OcPointer_reg() { - class2oc("Pointer", cons, destruct, members, NULL, NULL, s_memb); + class2oc("Pointer", cons, destruct, members, NULL, s_memb); // now make the val variable an actual double Symbol* sv = hoc_lookup("Pointer"); Symbol* sx = hoc_table_lookup("val", sv->u.ctemplate->symtable); diff --git a/src/ivoc/ocptrvector.cpp b/src/ivoc/ocptrvector.cpp index a0c991bea3..d624bce5d9 100644 --- a/src/ivoc/ocptrvector.cpp +++ b/src/ivoc/ocptrvector.cpp @@ -222,6 +222,6 @@ static void destruct(void* v) { } void OcPtrVector_reg() { - class2oc("PtrVector", cons, destruct, members, 0, 0, retstr_members); + class2oc("PtrVector", cons, destruct, members, 0, retstr_members); pv_class_sym_ = hoc_lookup("PtrVector"); } diff --git a/src/ivoc/octimer.cpp b/src/ivoc/octimer.cpp index cf506ef125..560394f2a4 100644 --- a/src/ivoc/octimer.cpp +++ b/src/ivoc/octimer.cpp @@ -99,7 +99,7 @@ static void t_destruct(void* v) { Member_func t_members[] = {{"seconds", t_seconds}, {"start", t_start}, {"end", t_stop}, {0, 0}}; void OcTimer_reg() { - class2oc("Timer", t_cons, t_destruct, t_members, NULL, NULL, NULL); + class2oc("Timer", t_cons, t_destruct, t_members, NULL, NULL); } #if HAVE_IV OcTimer::OcTimer(const char* cmd) { diff --git a/src/ivoc/pwman.cpp b/src/ivoc/pwman.cpp index 8489000cb6..29335af77f 100644 --- a/src/ivoc/pwman.cpp +++ b/src/ivoc/pwman.cpp @@ -801,7 +801,7 @@ static Member_ret_obj_func retobj_members[] = {{"group", pwman_group}, {0, 0}}; static Member_ret_str_func s_memb[] = {{"name", pwman_name}, {0, 0}}; void PWManager_reg() { - class2oc("PWManager", pwman_cons, pwman_destruct, members, NULL, retobj_members, s_memb); + class2oc("PWManager", pwman_cons, pwman_destruct, members, retobj_members, s_memb); } #if HAVE_IV // almost to end of file diff --git a/src/ivoc/strfun.cpp b/src/ivoc/strfun.cpp index 21b78dee78..721dae09ec 100644 --- a/src/ivoc/strfun.cpp +++ b/src/ivoc/strfun.cpp @@ -379,7 +379,7 @@ static void* l_cons(Object*) { } void StringFunctions_reg() { - class2oc("StringFunctions", l_cons, nullptr, l_members, nullptr, l_obj_members, nullptr); + class2oc("StringFunctions", l_cons, nullptr, l_members, l_obj_members, nullptr); } diff --git a/src/ivoc/symchoos.cpp b/src/ivoc/symchoos.cpp index e42125502b..f3fe138876 100644 --- a/src/ivoc/symchoos.cpp +++ b/src/ivoc/symchoos.cpp @@ -209,7 +209,7 @@ static double text(void* v) { } static Member_func members[] = {{"run", srun}, {"text", text}, {0, 0}}; void SymChooser_reg() { - class2oc("SymChooser", scons, sdestruct, members, NULL, NULL, NULL); + class2oc("SymChooser", scons, sdestruct, members, NULL, NULL); } #if HAVE_IV diff --git a/src/ivoc/xmenu.cpp b/src/ivoc/xmenu.cpp index 681914436b..9c91e93fd8 100644 --- a/src/ivoc/xmenu.cpp +++ b/src/ivoc/xmenu.cpp @@ -3127,5 +3127,5 @@ static double vfe_default(void* v) { } static Member_func vfe_members[] = {{"default", vfe_default}, {0, 0}}; void ValueFieldEditor_reg() { - class2oc("ValueFieldEditor", vfe_cons, vfe_destruct, vfe_members, NULL, NULL, NULL); + class2oc("ValueFieldEditor", vfe_cons, vfe_destruct, vfe_members, NULL, NULL); } diff --git a/src/nrncvode/cvodeobj.cpp b/src/nrncvode/cvodeobj.cpp index 5c662ec4b7..d7fc1660ed 100644 --- a/src/nrncvode/cvodeobj.cpp +++ b/src/nrncvode/cvodeobj.cpp @@ -653,7 +653,7 @@ static void destruct(void* v) { #endif } void Cvode_reg() { - class2oc("CVode", cons, destruct, members, NULL, omembers, NULL); + class2oc("CVode", cons, destruct, members, omembers, NULL); net_cvode_instance = new NetCvode(1); Daspk::dteps_ = 1e-9; // change with cvode.dae_init_dteps(newval) } diff --git a/src/nrncvode/netcvode.cpp b/src/nrncvode/netcvode.cpp index 27d7e9bbf0..b64feb7494 100644 --- a/src/nrncvode/netcvode.cpp +++ b/src/nrncvode/netcvode.cpp @@ -848,7 +848,7 @@ static void destruct(void* v) { } void NetCon_reg() { - class2oc("NetCon", cons, destruct, members, NULL, omembers, NULL); + class2oc("NetCon", cons, destruct, members, omembers, NULL); Symbol* nc = hoc_lookup("NetCon"); nc->u.ctemplate->steer = steer_val; Symbol* s; diff --git a/src/nrniv/bbsavestate.cpp b/src/nrniv/bbsavestate.cpp index 3274dc0011..0dc6614710 100644 --- a/src/nrniv/bbsavestate.cpp +++ b/src/nrniv/bbsavestate.cpp @@ -1011,7 +1011,7 @@ static Member_func members[] = {{"save", save}, {0, 0}}; void BBSaveState_reg() { - class2oc("BBSaveState", cons, destruct, members, NULL, NULL, NULL); + class2oc("BBSaveState", cons, destruct, members, NULL, NULL); } // from savstate.cpp diff --git a/src/nrniv/finithnd.cpp b/src/nrniv/finithnd.cpp index 0bf58a2e32..d29e0b4864 100644 --- a/src/nrniv/finithnd.cpp +++ b/src/nrniv/finithnd.cpp @@ -89,7 +89,7 @@ static void finithnd_destruct(void* v) { } void FInitializeHandler_reg() { - class2oc("FInitializeHandler", finithnd_cons, finithnd_destruct, members, NULL, NULL, NULL); + class2oc("FInitializeHandler", finithnd_cons, finithnd_destruct, members, NULL, NULL); } std::vector FInitialHandler::fihlist_[4]; diff --git a/src/nrniv/impedanc.cpp b/src/nrniv/impedanc.cpp index d9cbde709d..8d1621a8ec 100644 --- a/src/nrniv/impedanc.cpp +++ b/src/nrniv/impedanc.cpp @@ -147,7 +147,7 @@ static Member_func members[] = {{"compute", compute}, {0, 0}}; void Impedance_reg() { - class2oc("Impedance", cons, destruct, members, nullptr, nullptr, nullptr); + class2oc("Impedance", cons, destruct, members, nullptr, nullptr); } Imp::~Imp() { diff --git a/src/nrniv/kschan.cpp b/src/nrniv/kschan.cpp index adb7906249..a5c8fc8a86 100644 --- a/src/nrniv/kschan.cpp +++ b/src/nrniv/kschan.cpp @@ -799,10 +799,10 @@ static void* kst_cons(Object* o) { static void kst_destruct(void*) {} void KSChan_reg() { - class2oc("KSChan", ks_cons, ks_destruct, ks_dmem, NULL, ks_omem, ks_smem); - class2oc("KSGate", ksg_cons, ksg_destruct, ksg_dmem, NULL, ksg_omem, ksg_smem); - class2oc("KSState", kss_cons, kss_destruct, kss_dmem, NULL, kss_omem, kss_smem); - class2oc("KSTrans", kst_cons, kst_destruct, kst_dmem, NULL, kst_omem, kst_smem); + class2oc("KSChan", ks_cons, ks_destruct, ks_dmem, ks_omem, ks_smem); + class2oc("KSGate", ksg_cons, ksg_destruct, ksg_dmem, ksg_omem, ksg_smem); + class2oc("KSState", kss_cons, kss_destruct, kss_dmem, kss_omem, kss_smem); + class2oc("KSTrans", kst_cons, kst_destruct, kst_dmem, kst_omem, kst_smem); ksstate_sym = hoc_lookup("KSState"); ksgate_sym = hoc_lookup("KSGate"); kstrans_sym = hoc_lookup("KSTrans"); diff --git a/src/nrniv/linmod1.cpp b/src/nrniv/linmod1.cpp index 813299a8e8..2df98917fe 100644 --- a/src/nrniv/linmod1.cpp +++ b/src/nrniv/linmod1.cpp @@ -61,7 +61,7 @@ static void destruct(void* v) { } void LinearMechanism_reg() { - class2oc("LinearMechanism", cons, destruct, members, NULL, NULL, NULL); + class2oc("LinearMechanism", cons, destruct, members, NULL, NULL); } LinearMechanism::LinearMechanism() { diff --git a/src/nrniv/nmodlrandom.cpp b/src/nrniv/nmodlrandom.cpp index 8432c64e78..66be7a9dc1 100644 --- a/src/nrniv/nmodlrandom.cpp +++ b/src/nrniv/nmodlrandom.cpp @@ -104,7 +104,6 @@ void NMODLRandom_reg() { nmodlrandom_cons, nmodlrandom_destruct, members, - nullptr, retobj_members, nullptr); if (!nmodlrandom_sym) { diff --git a/src/nrniv/nrnmenu.cpp b/src/nrniv/nrnmenu.cpp index de66948849..f4103033cb 100644 --- a/src/nrniv/nrnmenu.cpp +++ b/src/nrniv/nrnmenu.cpp @@ -669,7 +669,7 @@ static Member_func ms_members[] = {{"panel", ms_panel}, {0, 0}}; void MechanismStandard_reg() { - class2oc("MechanismStandard", ms_cons, ms_destruct, ms_members, NULL, NULL, NULL); + class2oc("MechanismStandard", ms_cons, ms_destruct, ms_members, NULL, NULL); ms_class_sym_ = hoc_lookup("MechanismStandard"); } @@ -1130,7 +1130,7 @@ static Member_ret_obj_func mt_retobj_members[] = {{"pp_begin", mt_pp_begin}, static Member_ret_str_func mt_retstr_func[] = {{"code", mt_code}, {"file", mt_file}, {0, 0}}; void MechanismType_reg() { class2oc( - "MechanismType", mt_cons, mt_destruct, mt_members, NULL, mt_retobj_members, mt_retstr_func); + "MechanismType", mt_cons, mt_destruct, mt_members, mt_retobj_members, mt_retstr_func); mt_class_sym_ = hoc_lookup("MechanismType"); } diff --git a/src/nrniv/nrnpy.cpp b/src/nrniv/nrnpy.cpp index be8b723df4..9176a63858 100644 --- a/src/nrniv/nrnpy.cpp +++ b/src/nrniv/nrnpy.cpp @@ -251,7 +251,7 @@ void nrnpython_reg() { #endif // Stub implementation of PythonObject if Python support was not enabled, or a nrnpython library // could not be loaded. - class2oc("PythonObject", p_cons, p_destruct, p_members, nullptr, nullptr, nullptr); + class2oc("PythonObject", p_cons, p_destruct, p_members, nullptr, nullptr); } #ifdef NRNPYTHON_DYNAMICLOAD // to end of file diff --git a/src/nrniv/nrnste.cpp b/src/nrniv/nrnste.cpp index 639137a90e..52a30bfaa0 100644 --- a/src/nrniv/nrnste.cpp +++ b/src/nrniv/nrnste.cpp @@ -65,7 +65,7 @@ static void ste_destruct(void* v) { } void StateTransitionEvent_reg() { - class2oc("StateTransitionEvent", ste_cons, ste_destruct, members, NULL, NULL, NULL); + class2oc("StateTransitionEvent", ste_cons, ste_destruct, members, NULL, NULL); } StateTransitionEvent::StateTransitionEvent(int nstate, Point_process* pnt) diff --git a/src/nrniv/ppshape.cpp b/src/nrniv/ppshape.cpp index 1aaee148fe..a87937ed12 100644 --- a/src/nrniv/ppshape.cpp +++ b/src/nrniv/ppshape.cpp @@ -54,7 +54,7 @@ static void pp_destruct(void* v) { void PPShape_reg() { // printf("PPShape_reg\n"); - class2oc("PPShape", pp_cons, pp_destruct, pp_members, NULL, NULL, NULL); + class2oc("PPShape", pp_cons, pp_destruct, pp_members, NULL, NULL); } #if HAVE_IV // to end of file diff --git a/src/nrniv/savstate.cpp b/src/nrniv/savstate.cpp index 50b1175c5d..647e5688e2 100644 --- a/src/nrniv/savstate.cpp +++ b/src/nrniv/savstate.cpp @@ -1277,5 +1277,5 @@ static Member_func members[] = {{"save", save}, {0, 0}}; void SaveState_reg() { - class2oc("SaveState", cons, destruct, members, NULL, NULL, NULL); + class2oc("SaveState", cons, destruct, members, NULL, NULL); } diff --git a/src/nrniv/secbrows.cpp b/src/nrniv/secbrows.cpp index 10516f7884..a74ecfd39e 100644 --- a/src/nrniv/secbrows.cpp +++ b/src/nrniv/secbrows.cpp @@ -96,7 +96,7 @@ static void sb_destruct(void* v) { #endif } void SectionBrowser_reg() { - class2oc("SectionBrowser", sb_cons, sb_destruct, sb_members, NULL, NULL, NULL); + class2oc("SectionBrowser", sb_cons, sb_destruct, sb_members, NULL, NULL); } #if HAVE_IV diff --git a/src/nrniv/shape.cpp b/src/nrniv/shape.cpp index cf6e32851e..96eddef0a9 100644 --- a/src/nrniv/shape.cpp +++ b/src/nrniv/shape.cpp @@ -605,7 +605,7 @@ static void sh_destruct(void* v) { } void Shape_reg() { // printf("Shape_reg\n"); - class2oc("Shape", sh_cons, sh_destruct, sh_members, NULL, retobj_members, NULL); + class2oc("Shape", sh_cons, sh_destruct, sh_members, retobj_members, NULL); } #if HAVE_IV diff --git a/src/nrniv/shapeplt.cpp b/src/nrniv/shapeplt.cpp index 9505a130d8..a35516da96 100644 --- a/src/nrniv/shapeplt.cpp +++ b/src/nrniv/shapeplt.cpp @@ -426,7 +426,7 @@ static void sh_destruct(void* v) { } void PlotShape_reg() { // printf("PlotShape_reg\n"); - class2oc("PlotShape", sh_cons, sh_destruct, sh_members, NULL, retobj_members, NULL); + class2oc("PlotShape", sh_cons, sh_destruct, sh_members, retobj_members, NULL); } void* ShapePlotData::varobj() const { diff --git a/src/nrniv/spaceplt.cpp b/src/nrniv/spaceplt.cpp index e88aac8405..1978cafdfb 100644 --- a/src/nrniv/spaceplt.cpp +++ b/src/nrniv/spaceplt.cpp @@ -291,7 +291,7 @@ static void s_destruct(void* v) { void RangeVarPlot_reg() { // printf("RangeVarPlot_reg\n"); - class2oc("RangeVarPlot", s_cons, s_destruct, s_members, NULL, rvp_retobj_members, NULL); + class2oc("RangeVarPlot", s_cons, s_destruct, s_members, rvp_retobj_members, NULL); } #if HAVE_IV diff --git a/src/nrnoc/init.cpp b/src/nrnoc/init.cpp index f233507f70..267eac5c55 100644 --- a/src/nrnoc/init.cpp +++ b/src/nrnoc/init.cpp @@ -1025,7 +1025,6 @@ extern void class2oc_base(const char*, void* (*cons)(Object*), void (*destruct)(void*), Member_func*, - int (*checkpoint)(void**), Member_ret_obj_func*, Member_ret_str_func*); @@ -1045,7 +1044,7 @@ int point_register_mech(const char** m, Symlist* sl; Symbol *s, *s2; nrn_load_name_check(m[1]); - class2oc_base(m[1], constructor, destructor, fmember, nullptr, nullptr, nullptr); + class2oc_base(m[1], constructor, destructor, fmember, nullptr, nullptr); s = hoc_lookup(m[1]); sl = hoc_symlist; hoc_symlist = s->u.ctemplate->symtable; diff --git a/src/nrnoc/seclist.cpp b/src/nrnoc/seclist.cpp index 2568a5b9cd..584612113f 100644 --- a/src/nrnoc/seclist.cpp +++ b/src/nrnoc/seclist.cpp @@ -259,14 +259,13 @@ extern void class2oc(const char*, void* (*cons)(Object*), void (*destruct)(void*), Member_func*, - int (*checkpoint)(void**), Member_ret_obj_func*, Member_ret_str_func*); void SectionList_reg(void) { /* printf("SectionList_reg\n");*/ - class2oc("SectionList", constructor, destructor, members, nullptr, nullptr, nullptr); + class2oc("SectionList", constructor, destructor, members, nullptr, nullptr); } #define relative(pc) (pc + (pc)->i) diff --git a/src/nrnoc/secref.cpp b/src/nrnoc/secref.cpp index 87071ed2a8..7b1f5dd793 100644 --- a/src/nrnoc/secref.cpp +++ b/src/nrnoc/secref.cpp @@ -366,7 +366,6 @@ extern void class2oc(const char*, void* (*cons)(Object*), void (*destruct)(void*), Member_func*, - int (*checkpoint)(void**), Member_ret_obj_func*, Member_ret_str_func*); @@ -374,7 +373,7 @@ extern void class2oc(const char*, void SectionRef_reg(void) { Symbol *s, *sr; - class2oc("SectionRef", cons, destruct, members, nullptr, nullptr, nullptr); + class2oc("SectionRef", cons, destruct, members, nullptr, nullptr); /* now make the sec variable an actual SECTIONREF */ sr = hoc_lookup("SectionRef"); s = hoc_table_lookup("sec", sr->u.ctemplate->symtable); diff --git a/src/nrnpython/nrnpy_p2h.cpp b/src/nrnpython/nrnpy_p2h.cpp index da2083877a..07ac58daba 100644 --- a/src/nrnpython/nrnpy_p2h.cpp +++ b/src/nrnpython/nrnpy_p2h.cpp @@ -1084,7 +1084,7 @@ void nrnpython_reg_real_nrnpy_hoc_cpp(neuron::python::impl_ptrs* ptrs); */ extern "C" NRN_EXPORT void nrnpython_reg_real(neuron::python::impl_ptrs* ptrs) { assert(ptrs); - class2oc("PythonObject", p_cons, p_destruct, p_members, nullptr, nullptr, nullptr); + class2oc("PythonObject", p_cons, p_destruct, p_members, nullptr, nullptr); nrnpy_pyobj_sym_ = hoc_lookup("PythonObject"); assert(nrnpy_pyobj_sym_); ptrs->callable_with_args = callable_with_args; diff --git a/src/oc/classreg.h b/src/oc/classreg.h index 4a1893c4af..00ee7e9a55 100644 --- a/src/oc/classreg.h +++ b/src/oc/classreg.h @@ -7,6 +7,5 @@ extern void class2oc(const char*, void* (*cons)(Object*), void (*destruct)(void*), Member_func*, - int (*checkpoint)(void**), Member_ret_obj_func*, Member_ret_str_func*); diff --git a/src/oc/hoc.cpp b/src/oc/hoc.cpp index fee82add88..6eded05477 100644 --- a/src/oc/hoc.cpp +++ b/src/oc/hoc.cpp @@ -891,21 +891,6 @@ int hoc_main1(int argc, const char** argv, const char** envp) { gargv += 2; gargc -= 2; } - if (argc > 1 && argv[1][0] != '-') { - /* first file may be a checkpoint file */ - extern int hoc_readcheckpoint(char*); - switch (hoc_readcheckpoint(const_cast(argv[1]))) { - case 1: - ++gargv; - --gargc; - break; - case 2: - nrn_exit(1); - break; - default: - break; - } - } if (gargc == 1) /* fake an argument list */ { diff --git a/src/oc/hoc_init.cpp b/src/oc/hoc_init.cpp index 719d712590..bfcd5a9342 100644 --- a/src/oc/hoc_init.cpp +++ b/src/oc/hoc_init.cpp @@ -170,7 +170,6 @@ static struct { /* Builtin functions with multiple or variable args */ {"saveaudit", hoc_Saveaudit}, {"retrieveaudit", hoc_Retrieveaudit}, {"coredump_on_error", hoc_coredump_on_error}, - {"checkpoint", hoc_checkpoint}, {"quit", hoc_quit}, {"object_push", hoc_object_push}, {"object_pop", hoc_object_pop}, diff --git a/src/oc/hoc_oop.cpp b/src/oc/hoc_oop.cpp index 350b1bbc70..ce2a68b531 100644 --- a/src/oc/hoc_oop.cpp +++ b/src/oc/hoc_oop.cpp @@ -1547,7 +1547,6 @@ void hoc_begintemplate(Symbol* t1) { t->u.ctemplate->destructor = 0; t->u.ctemplate->is_point_ = 0; t->u.ctemplate->steer = 0; - t->u.ctemplate->checkpoint = 0; t->u.ctemplate->id = ++template_id; pushtemplatei(icntobjectdata); pushtemplateodata(hoc_objectdata); @@ -1600,7 +1599,6 @@ void class2oc_base(const char* name, void* (*cons)(Object*), void (*destruct)(void*), Member_func* m, - int (*checkpoint)(void**), Member_ret_obj_func* mobjret, Member_ret_str_func* strret) { extern int hoc_main1_inited_; @@ -1622,7 +1620,6 @@ void class2oc_base(const char* name, t->constructor = cons; t->destructor = destruct; t->steer = 0; - t->checkpoint = checkpoint; if (m) for (i = 0; m[i].name; ++i) { @@ -1650,10 +1647,9 @@ void class2oc(const char* name, void* (*cons)(Object*), void (*destruct)(void*), Member_func* m, - int (*checkpoint)(void**), Member_ret_obj_func* mobjret, Member_ret_str_func* strret) { - class2oc_base(name, cons, destruct, m, checkpoint, mobjret, strret); + class2oc_base(name, cons, destruct, m, mobjret, strret); py_exposed_classes.push_back(name); } diff --git a/src/oc/hocdec.h b/src/oc/hocdec.h index eb328950f0..c0b31ae6af 100644 --- a/src/oc/hocdec.h +++ b/src/oc/hocdec.h @@ -158,7 +158,6 @@ struct cTemplate { void* (*constructor)(struct Object*); void (*destructor)(void*); void (*steer)(void*); /* normally nullptr */ - int (*checkpoint)(void**); }; union Objectdata { diff --git a/src/oc/ocfunc.h b/src/oc/ocfunc.h index dabc840dc0..b30006011a 100644 --- a/src/oc/ocfunc.h +++ b/src/oc/ocfunc.h @@ -25,7 +25,7 @@ extern void hoc_single_event_run(void), hoc_notify_iv(void), nrniv_bind_thread(v extern void hoc_pointer(void), hoc_Numarg(void), hoc_Argtype(void), hoc_exec_cmd(void); extern void hoc_load_proc(void), hoc_load_func(void), hoc_load_template(void), hoc_load_file(void); extern void hoc_xcheckbox(void), hoc_xstatebutton(void), hoc_Symbol_limits(void); -extern void hoc_coredump_on_error(void), hoc_checkpoint(void), hoc_quit(void); +extern void hoc_coredump_on_error(void), hoc_quit(void); extern void hoc_object_push(void), hoc_object_pop(void), hoc_pwman_place(void); extern void hoc_show_errmess_always(void), hoc_execute1(void), hoc_secname(void); extern void hoc_neuronhome(void), hoc_Execerror(void); diff --git a/src/parallel/ocbbs.cpp b/src/parallel/ocbbs.cpp index 36e6e33f29..2091a345e4 100644 --- a/src/parallel/ocbbs.cpp +++ b/src/parallel/ocbbs.cpp @@ -1136,7 +1136,7 @@ static void destruct(void* v) { } void ParallelContext_reg() { - class2oc("ParallelContext", cons, destruct, members, nullptr, retobj_members, retstr_members); + class2oc("ParallelContext", cons, destruct, members, retobj_members, retstr_members); } // A BBS message is something to execute. diff --git a/test/unit_tests/oc/hoc_interpreter.cpp b/test/unit_tests/oc/hoc_interpreter.cpp index 36f03aaaea..3e334bfcb1 100644 --- a/test/unit_tests/oc/hoc_interpreter.cpp +++ b/test/unit_tests/oc/hoc_interpreter.cpp @@ -145,7 +145,6 @@ SCENARIO("Test calling code from HOC that throws exceptions", "[NEURON][hoc_inte throwing_util_constructor, throwing_util_destructor, throwing_util_members, - nullptr /* checkpoint */, throwing_util_ret_obj_members, throwing_util_ret_str_members); registered = true;