Skip to content

Commit 01cd8b6

Browse files
authored
Changes for '1uc/improve-usecase-func'. (#3)
1 parent 86ea3be commit 01cd8b6

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

func_proc/coreneuron/func_proc.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ namespace coreneuron {
205205
}
206206

207207

208-
inline double get_a_42_test_func_proc(int id, int pnodecount, test_func_proc_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a);
208+
inline double x_plus_a_test_func_proc(int id, int pnodecount, test_func_proc_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a);
209209
inline int set_x_42_test_func_proc(int id, int pnodecount, test_func_proc_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v);
210210
inline int set_x_a_test_func_proc(int id, int pnodecount, test_func_proc_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a);
211211
inline int set_a_x_test_func_proc(int id, int pnodecount, test_func_proc_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v);
@@ -233,10 +233,10 @@ namespace coreneuron {
233233
}
234234

235235

236-
inline double get_a_42_test_func_proc(int id, int pnodecount, test_func_proc_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a) {
237-
double ret_get_a_42 = 0.0;
238-
ret_get_a_42 = a + 42.0;
239-
return ret_get_a_42;
236+
inline double x_plus_a_test_func_proc(int id, int pnodecount, test_func_proc_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a) {
237+
double ret_x_plus_a = 0.0;
238+
ret_x_plus_a = inst->x[id] + a;
239+
return ret_x_plus_a;
240240
}
241241

242242

func_proc/neuron/func_proc.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ namespace neuron {
121121
hoc_retpushx(1.);
122122
}
123123
/* Mechanism procedures and functions */
124-
inline double get_a_42_test_func_proc(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a);
124+
inline double x_plus_a_test_func_proc(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a);
125125
inline int set_x_42_test_func_proc(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt);
126126
inline int set_x_a_test_func_proc(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a);
127127
inline int set_a_x_test_func_proc(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt);
@@ -143,11 +143,11 @@ namespace neuron {
143143
static void _hoc_set_x_42(void);
144144
static void _hoc_set_x_a(void);
145145
static void _hoc_set_a_x(void);
146-
static void _hoc_get_a_42(void);
146+
static void _hoc_x_plus_a(void);
147147
static double _npy_set_x_42(Prop*);
148148
static double _npy_set_x_a(Prop*);
149149
static double _npy_set_a_x(Prop*);
150-
static double _npy_get_a_42(Prop*);
150+
static double _npy_x_plus_a(Prop*);
151151

152152

153153
/* connect user functions to hoc names */
@@ -156,14 +156,14 @@ namespace neuron {
156156
{"set_x_42_test_func_proc", _hoc_set_x_42},
157157
{"set_x_a_test_func_proc", _hoc_set_x_a},
158158
{"set_a_x_test_func_proc", _hoc_set_a_x},
159-
{"get_a_42_test_func_proc", _hoc_get_a_42},
159+
{"x_plus_a_test_func_proc", _hoc_x_plus_a},
160160
{0, 0}
161161
};
162162
static NPyDirectMechFunc npy_direct_func_proc[] = {
163163
{"set_x_42", _npy_set_x_42},
164164
{"set_x_a", _npy_set_x_a},
165165
{"set_a_x", _npy_set_a_x},
166-
{"get_a_42", _npy_get_a_42},
166+
{"x_plus_a", _npy_x_plus_a},
167167
};
168168
static void _hoc_set_x_42(void) {
169169
double _r{};
@@ -267,22 +267,25 @@ namespace neuron {
267267
set_a_x_test_func_proc(_ml, id, _ppvar, _thread, _nt);
268268
return(_r);
269269
}
270-
static void _hoc_get_a_42(void) {
270+
static void _hoc_x_plus_a(void) {
271271
double _r{};
272272
Datum* _ppvar;
273273
Datum* _thread;
274274
NrnThread* _nt;
275-
Prop* _local_prop = _prop_id ? _extcall_prop : nullptr;
275+
if (!_prop_id) {
276+
hoc_execerror("No data for x_plus_a_test_func_proc. Requires prior call to setdata_test_func_proc and that the specified mechanism instance still be in existence.", NULL);
277+
}
278+
Prop* _local_prop = _extcall_prop;
276279
_nrn_mechanism_cache_instance _ml_real{_local_prop};
277280
auto* const _ml = &_ml_real;
278281
size_t const id{};
279282
_ppvar = _local_prop ? _nrn_mechanism_access_dparam(_local_prop) : nullptr;
280283
_thread = _extcall_thread.data();
281284
_nt = nrn_threads;
282-
_r = get_a_42_test_func_proc(_ml, id, _ppvar, _thread, _nt, *getarg(1));
285+
_r = x_plus_a_test_func_proc(_ml, id, _ppvar, _thread, _nt, *getarg(1));
283286
hoc_retpushx(_r);
284287
}
285-
static double _npy_get_a_42(Prop* _prop) {
288+
static double _npy_x_plus_a(Prop* _prop) {
286289
double _r{};
287290
Datum* _ppvar;
288291
Datum* _thread;
@@ -293,7 +296,7 @@ namespace neuron {
293296
_ppvar = _nrn_mechanism_access_dparam(_prop);
294297
_thread = _extcall_thread.data();
295298
_nt = nrn_threads;
296-
_r = get_a_42_test_func_proc(_ml, id, _ppvar, _thread, _nt, *getarg(1));
299+
_r = x_plus_a_test_func_proc(_ml, id, _ppvar, _thread, _nt, *getarg(1));
297300
return(_r);
298301
}
299302

@@ -323,11 +326,11 @@ namespace neuron {
323326
}
324327

325328

326-
inline double get_a_42_test_func_proc(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a) {
329+
inline double x_plus_a_test_func_proc(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a) {
327330
auto inst = make_instance_test_func_proc(*_ml);
328-
double ret_get_a_42 = 0.0;
329-
ret_get_a_42 = a + 42.0;
330-
return ret_get_a_42;
331+
double ret_x_plus_a = 0.0;
332+
ret_x_plus_a = inst.x[id] + a;
333+
return ret_x_plus_a;
331334
}
332335

333336

func_proc_pnt/coreneuron/func_proc_pnt.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ namespace coreneuron {
210210
}
211211

212212

213-
inline double get_a_42_test_func_proc_pnt(int id, int pnodecount, test_func_proc_pnt_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a);
213+
inline double x_plus_a_test_func_proc_pnt(int id, int pnodecount, test_func_proc_pnt_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a);
214214
inline int set_x_42_test_func_proc_pnt(int id, int pnodecount, test_func_proc_pnt_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v);
215215
inline int set_x_a_test_func_proc_pnt(int id, int pnodecount, test_func_proc_pnt_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a);
216216

@@ -229,10 +229,10 @@ namespace coreneuron {
229229
}
230230

231231

232-
inline double get_a_42_test_func_proc_pnt(int id, int pnodecount, test_func_proc_pnt_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a) {
233-
double ret_get_a_42 = 0.0;
234-
ret_get_a_42 = a + 42.0;
235-
return ret_get_a_42;
232+
inline double x_plus_a_test_func_proc_pnt(int id, int pnodecount, test_func_proc_pnt_Instance* inst, double* data, const Datum* indexes, ThreadDatum* thread, NrnThread* nt, double v, double a) {
233+
double ret_x_plus_a = 0.0;
234+
ret_x_plus_a = inst->x[id] + a;
235+
return ret_x_plus_a;
236236
}
237237

238238

func_proc_pnt/neuron/func_proc_pnt.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace neuron {
143143
_setdata(_prop);
144144
}
145145
/* Mechanism procedures and functions */
146-
inline double get_a_42_test_func_proc_pnt(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a);
146+
inline double x_plus_a_test_func_proc_pnt(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a);
147147
inline int set_x_42_test_func_proc_pnt(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt);
148148
inline int set_x_a_test_func_proc_pnt(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a);
149149

@@ -163,7 +163,7 @@ namespace neuron {
163163
/* declaration of user functions */
164164
static double _hoc_set_x_42(void*);
165165
static double _hoc_set_x_a(void*);
166-
static double _hoc_get_a_42(void*);
166+
static double _hoc_x_plus_a(void*);
167167

168168

169169
/* connect user functions to hoc names */
@@ -176,7 +176,7 @@ namespace neuron {
176176
{"get_loc", _hoc_get_loc_pnt},
177177
{"set_x_42", _hoc_set_x_42},
178178
{"set_x_a", _hoc_set_x_a},
179-
{"get_a_42", _hoc_get_a_42},
179+
{"x_plus_a", _hoc_x_plus_a},
180180
{0, 0}
181181
};
182182
static double _hoc_set_x_42(void* _vptr) {
@@ -219,7 +219,7 @@ namespace neuron {
219219
set_x_a_test_func_proc_pnt(_ml, id, _ppvar, _thread, _nt, *getarg(1));
220220
return(_r);
221221
}
222-
static double _hoc_get_a_42(void* _vptr) {
222+
static double _hoc_x_plus_a(void* _vptr) {
223223
double _r{};
224224
Datum* _ppvar;
225225
Datum* _thread;
@@ -235,7 +235,7 @@ namespace neuron {
235235
_ppvar = _nrn_mechanism_access_dparam(_p);
236236
_thread = _extcall_thread.data();
237237
_nt = static_cast<NrnThread*>(_pnt->_vnt);
238-
_r = get_a_42_test_func_proc_pnt(_ml, id, _ppvar, _thread, _nt, *getarg(1));
238+
_r = x_plus_a_test_func_proc_pnt(_ml, id, _ppvar, _thread, _nt, *getarg(1));
239239
return(_r);
240240
}
241241

@@ -256,11 +256,11 @@ namespace neuron {
256256
}
257257

258258

259-
inline double get_a_42_test_func_proc_pnt(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a) {
259+
inline double x_plus_a_test_func_proc_pnt(_nrn_mechanism_cache_range* _ml, size_t id, Datum* _ppvar, Datum* _thread, NrnThread* _nt, double a) {
260260
auto inst = make_instance_test_func_proc_pnt(*_ml);
261-
double ret_get_a_42 = 0.0;
262-
ret_get_a_42 = a + 42.0;
263-
return ret_get_a_42;
261+
double ret_x_plus_a = 0.0;
262+
ret_x_plus_a = inst.x[id] + a;
263+
return ret_x_plus_a;
264264
}
265265

266266

0 commit comments

Comments
 (0)