NEURON
nrnjni.cpp
Go to the documentation of this file.
1 /** JNI code for Neuron.java
2 C implementations of Java native methods
3 */
4 
5 #include <../../nrnconf.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <OS/list.h>
10 
11 #include "ivoc.h"
12 #include "nrnoc2iv.h"
13 #include "parse.hpp"
14 #include "ivocvect.h"
15 
16 #include "neuron_Neuron.h" // generated JNI Header file
17 #include "njvm.h" // need nrnjava_env
18 #include "njreg.h" // generated registration structure
19  //via mk_njreg.sh from neuron_Neuron.h
20 #include "neuron_Redirect.h"
21 #include "njredirreg.h"
22 
23 char* nrn_dot2underbar(const char*);
24 jobject nj_encapsulate(Object*);
25 Object** nj_j2hObject(jobject, int);
26 
27 declarePtrList(NJSymList, Symbol)
28 // implemented in nrnjava.cpp
29 // list of cTemplate of java registered classes in id order.
30 // this parallels the classList in Neuron.Java
31 extern NJSymList* nrn_jclass_symlist;
32 extern Symbol* nrn_jobj_sym;
33 extern Symbol* nrn_vec_sym;
34 
35 //implemented in src/ivoc/pwman.cpp
36 void* nrnjava_pwm_listen(const char*, Object*);
37 void nrnjava_pwm_event(size_t, int, int, int, int, int);
38 
40 
41 extern "C" {
42 
43 /** Create a hoc class from a java one
44 @param classindex : +ve id for class (0,1, ...)
45 */
46 Symbol* java2nrn_class(const char* classname, int classindex,
47  const char* methods);
48 
49 extern double* hoc_varpointer;
50 
52 double hoc_integer(double);
53 Object* hoc_new_object(Symbol*, void*);
54 Object* hoc_newobj1(Symbol*, int);
55 #define call_ob_proc hoc_call_ob_proc
56 Object** hoc_objpop();
57 char** hoc_strpop();
58 void hoc_tobj_unref(Object**);
59 }
60 
61 /*** Explicit registration required ***/
62 // the class loader apparently doesn't fill in the slots except
63 // when you dynamically load the native methods.
64 
66  int cnt;
67  for (cnt=0; njreg_methods[cnt].name; ++cnt) {}
68  nrnjava_env->RegisterNatives(neuronCls, njreg_methods, cnt);
69 }
70 
71 void nrnjni_redirreg(jclass c) {
72  int cnt;
73  for (cnt=0; njredirreg_methods[cnt].name; ++cnt) {}
74  nrnjava_env->RegisterNatives(c, njredirreg_methods, cnt);
75 }
76 
77 static void illegalArg(JNIEnv* env, const char* s) {
78 // env->ThrowNew(env->FindClass("java.lang.IllegalArgumentException"), s);
79 }
80 
81 JNIEXPORT jstring JNICALL Java_neuron_Neuron_getHocStringArg(
82  JNIEnv *env, jclass cls, jint idx) {
83  char *str="";
84  if (!ifarg(idx)) {
85  printf("error - missing string as arg %d\n", idx);
86  illegalArg(env, "missing string");
87  return nil;
88  }
89  if (hoc_is_str_arg( idx )) {
90  str = gargstr( idx );
91  } else {
92  printf("error - expecting string as arg %d\n", idx);
93  illegalArg(env, "expecting string");
94  return nil;
95  }
96  jstring ret = env->NewStringUTF( str );
97  return ret;
98 }
99 
100 JNIEXPORT jdouble JNICALL Java_neuron_Neuron_getHocDoubleArg(
101  JNIEnv *env, jclass cls, jint idx, jint type) {
102  double ret;
103  if (!ifarg(idx)) {
104  printf("error - missing double as arg %d\n", idx);
105  illegalArg(env, "missing double");
106  return (jdouble)-1.0E98;
107  }
108  if (hoc_is_double_arg( idx )) {
109  ret = *(getarg( idx ));
110  } else {
111  printf("error - expecting double as arg %d\n", idx);
112  illegalArg(env, "expecting double");
113  return (jdouble)-1.0E98;
114  }
115  if (type == 1) {
116  ret = hoc_integer(ret);
117  }
118  return (jdouble)ret;
119 }
120 
121 static jobject h2jObject(Object* o) {
122  jobject jo;
123  if (o == 0) {
124  return 0;
125  }
126  hoc_obj_ref(o);
127  // one of several possibilities here
128  if (o->ctemplate->id < 0) { // a Java object
129  jo = (jobject)o->u.this_pointer;
130  }else if (o->ctemplate->sym == nrn_jobj_sym) {
131  // an unregistered java object
132  jo = (jobject)o->u.this_pointer;
133  }else{ //encapsulate in HocObject, HocVector, etc.
134  jo = nj_encapsulate(o);
135  }
136  return jo;
137 }
138 
139 JNIEXPORT jobject JNICALL Java_neuron_Neuron_getHocObjectArg
140  (JNIEnv *env, jclass cl, jint i, jthrowable e) {
141  jobject ret;
142 //printf("getHocObjArg %s %ld\n", hoc_object_name(o), (long)o);
143  if (!ifarg(i)) {
144  printf("error - missing Object as arg %d\n", i);
145  illegalArg(env, "missing Object");
146  return e;
147  }
148  if (hoc_is_object_arg(i)) {
149  Object* o = *hoc_objgetarg(i);
150  ret = h2jObject(o);
151  }else if (hoc_is_str_arg(i)) { //encapsulate in String
152  char* s = gargstr(i);
153  ret = Java_neuron_Neuron_getHocStringArg(env, cl, i);
154  }else{
155  printf("error - expecting Object or strdef as arg %d\n", i);
156  illegalArg(env, "expecting Object or strdef");
157  ret = e;
158  }
159  return ret;
160 }
161 
162 JNIEXPORT void JNICALL Java_neuron_Neuron_hocObjectUnref
163  (JNIEnv *, jclass, jlong i) {
164  Object* o = (Object*)i;
165 //printf("hocObjectUnref %d %s\n", (long)i, hoc_object_name(o));
166  hoc_obj_unref(o);
167 }
168 
169 JNIEXPORT jlong JNICALL Java_neuron_Neuron_getVarPointer
170  (JNIEnv *, jclass) {
171  // there must have been a prior call to hoc_pointer_(&varname)
172 //printf("getVarPointer %ld\n", (long)hoc_varpointer);
173  return (jlong)hoc_varpointer;
174 }
175 
176 JNIEXPORT jdouble JNICALL Java_neuron_Neuron_getVal
177  (JNIEnv *, jclass, jlong p){
178  double* pd = (double*)p;
179  return (jdouble)(*pd);
180 }
181 
182 JNIEXPORT void JNICALL Java_neuron_Neuron_setVal
183  (JNIEnv *, jclass, jlong p, jdouble d) {
184  double* pd = (double*)p;
185  *pd = d;
186 }
187 
188 JNIEXPORT void JNICALL Java_neuron_Neuron_java2nrnClass(
189  JNIEnv *env, jclass cls,
190  jstring classname, jint classindex,
191  jstring methods ) {
192 
193  const char *cn = env->GetStringUTFChars( classname,0 );
194  const char *m = env->GetStringUTFChars( methods,0 );
195  char* mangled = nrn_dot2underbar(cn);
196  env->ReleaseStringUTFChars(classname, cn);
197 
198 // printf("class %s methods\n%s\n", mangled, m);
199  Symbol* s = java2nrn_class(mangled, (int) classindex, m);
200  nrn_jclass_symlist->append(s);
201  delete [] mangled;
202  env->ReleaseStringUTFChars(methods, m);
203 }
204 
205 // Call a hoc method
206 JNIEXPORT jboolean JNICALL Java_neuron_Neuron_execute (
207  JNIEnv *env, jclass, jstring statement) {
208 // assert(env == nrnjava_env);
209  jnisave
210  const char* s = env->GetStringUTFChars(statement,0);
211  jboolean r = Oc::valid_stmt(s, 0);
212  env->ReleaseStringUTFChars(statement, s);
213  jnirestore
214  return r;
215 }
216 
217 
218 JNIEXPORT jint JNICALL Java_neuron_Neuron_getHocArgType
219  (JNIEnv *env, jclass, jint i) {
220  int type = hoc_argtype(i+1);
221  switch (type) {
222  case NUMBER:
223  return 1;
224  case STRING:
225  return 2;
226  case OBJECTVAR:
227  case OBJECTTMP:
228  return 3;
229  }
230  return 0;
231 }
232 
233 JNIEXPORT jstring JNICALL Java_neuron_Neuron_getHocArgSig
234  (JNIEnv *env, jclass) {
235  char sig[100];
236  int i;
237  for (i = 0; ifarg(i+1); ++i) {
238  int type = hoc_argtype(i+1);
239  switch (type) {
240  case NUMBER:
241  sig[i] = 'd';
242  break;
243  case STRING:
244  sig[i] = 'S';
245  break;
246  case OBJECTVAR:
247  case OBJECTTMP:
248  sig[i] = 'o';
249  break;
250  }
251  }
252  sig[i] = '\0';
253 // printf("getHocArgSig |%s|\n", sig);
254  return env->NewStringUTF(sig);
255 }
256 
257 JNIEXPORT jlong JNICALL Java_neuron_Neuron_vectorNew
258  (JNIEnv *env, jclass, jint size){
259  jnisave
260  Vect* v = vector_new1(size);
261  Object* ho = hoc_new_object(nrn_vec_sym, v);
262  hoc_obj_ref(ho);
263  jlong jc = (jlong)ho;
264  jnirestore
265  return jc;
266 }
267 
268 JNIEXPORT jint JNICALL Java_neuron_Neuron_vectorSize
269  (JNIEnv *, jclass, jlong jc){
270  Object* ho = (Object*)jc;
271  Vect* vec = (Vect*)ho->u.this_pointer;
272  return vec->size();
273 }
274 
275 static void outOfBounds(JNIEnv* env) {
276  env->ThrowNew(env->FindClass("java.lang.IndexOutOfBoundsException"), "HocVector");
277 }
278 
279 JNIEXPORT void JNICALL Java_neuron_Neuron_vectorSet
280  (JNIEnv *env, jclass, jlong jc, jint i, jdouble x) {
281  Object* ho = (Object*)jc;
282  Vect* vec = (Vect*)ho->u.this_pointer;
283  if (i < 0 || i >= vec->size()) {
284  printf("Neuron.vectorSet i=%d size=%d\n", i, vec->size());
285  outOfBounds(env);
286  }
287  vec->elem(i) = x;
288 }
289 
290 JNIEXPORT jdouble JNICALL Java_neuron_Neuron_vectorGet
291  (JNIEnv *env, jclass, jlong jc, jint i){
292  Object* ho = (Object*)jc;
293  Vect* vec = (Vect*)ho->u.this_pointer;
294  if (i < 0 || i >= vec->size()) {
295  printf("Neuron.vectorGet i=%d size=%d\n", i, vec->size());
296  outOfBounds(env);
297  }
298  return vec->elem(i);
299 }
300 
301 JNIEXPORT void JNICALL Java_neuron_Neuron_vectorToHoc
302  (JNIEnv *env, jclass, jlong jc, jdoubleArray ja, jint size) {
303  Object* ho = (Object*)jc;
304  Vect* vec = (Vect*)ho->u.this_pointer;
305  vector_resize(vec, size);
306  env->GetDoubleArrayRegion(ja, 0, size, &vec->elem(0));
307 }
308 
309 JNIEXPORT jdoubleArray JNICALL Java_neuron_Neuron_vectorFromHoc
310  (JNIEnv *env, jclass, jlong jc) {
311  Object* ho = (Object*)jc;
312  Vect* vec = (Vect*)ho->u.this_pointer;
313  jint size = vec->size();
314  jdoubleArray ja = env->NewDoubleArray(size);
315  env->SetDoubleArrayRegion(ja, 0, size, &vec->elem(0));
316  return ja;
317 }
318 
319 JNIEXPORT jlong JNICALL Java_neuron_Neuron_cppPointer
320  (JNIEnv *, jclass, jlong jc) {
321  Object* ho = (Object*)jc;
322  if (ho->ctemplate->sym->subtype == CPLUSOBJECT) {
323  return (jlong)ho->u.this_pointer;
324  }else{
325  return 0;
326  }
327 }
328 
329 JNIEXPORT jstring JNICALL Java_neuron_Neuron_hocObjectName
330  (JNIEnv *env, jclass, jlong jc) {
331  Object* ho = (Object*)jc;
332  char* s = hoc_object_name(ho);
333  jstring js = env->NewStringUTF(s);
334  return js;
335 }
336 
337 JNIEXPORT jlong JNICALL Java_neuron_Neuron_getNewHObject
338  (JNIEnv *env, jclass, jstring name, jint narg){
339  jnisave
340  const char* cn = env->GetStringUTFChars(name, 0);
341 // Symbol* s = hoc_table_lookup(cn, hoc_top_level_symlist);
342  Symbol* s = hoc_lookup(cn);
343 if (!s || s->type != TEMPLATE) {
344  printf("getNewHObject could not lookup %s or it is not a template.\n", cn);
345  return 0;
346 }
347  env->ReleaseStringUTFChars(name, cn);
348  Object* o = hoc_newobj1(s, narg);
349  hoc_obj_ref(o);
350  jnirestore
351  return (jlong)o;
352 }
353 
355  (JNIEnv *env, jclass, jstring name, jint narg) {
356  jnisave
357  const char* cn = env->GetStringUTFChars(name, 0);
358  Symbol* sym = hoc_lookup(cn);
359  env->ReleaseStringUTFChars(name, cn);
360  jnirestore
361  return hoc_call_func(sym, narg);
362 }
363 
364 JNIEXPORT jdouble JNICALL Java_neuron_Neuron_hDoubleMethod__JJI
365  (JNIEnv *env, jclass, jlong jc, jlong mid, jint narg){
366  jnisave
367  Object* ho = (Object*)jc;
368  Symbol* s = (Symbol*)mid;
369 //printf("hDoubleMethod %s.%s with %d args\n", hoc_object_name(ho), s->name, narg);
370  call_ob_proc(ho, s, narg);
371  jnirestore
372  return hoc_xpop();
373 }
374 
375 JNIEXPORT jstring JNICALL Java_neuron_Neuron_hCharsMethod
376  (JNIEnv *env, jclass, jlong jc, jlong mid, jint narg){
377  jnisave
378  Object* ho = (Object*)jc;
379  Symbol* sym = (Symbol*)mid;
380  call_ob_proc(ho, sym, narg);
381  char* s = *hoc_strpop();
382  jstring js = env->NewStringUTF(s);
383  jnirestore
384  return js;
385 }
386 
387 JNIEXPORT jobject JNICALL Java_neuron_Neuron_hObjectMethod
388  (JNIEnv *env, jclass, jlong jc, jlong mid, jint narg){
389  jnisave
390  Object* ho = (Object*)jc;
391  Symbol* s = (Symbol*)mid;
392  call_ob_proc(ho, s, narg);
393  Object** po = hoc_objpop();
394  jobject jo = h2jObject(*po);
395  hoc_tobj_unref(po);
396  // o may need to get it's refcount decremented here.
397  jnirestore
398  return jo;
399 }
400 
401 JNIEXPORT void JNICALL Java_neuron_Neuron_pushArgD
402  (JNIEnv *, jclass, jdouble x){
403 //printf("pushArgD %g\n", x);
404  hoc_pushx(x);
405 }
406 
407 JNIEXPORT void JNICALL Java_neuron_Neuron_pushArgS
408  (JNIEnv *env, jclass, jstring js){
409  // see java2nrn_smeth for a similar implementation
410  // hopefully 20 is sufficient before a string is freed.
411  // perhaps a more general implementation is needed.
412  // It would be safe to free these when the corresponding
413  // hCharsMethod call returns.
414  static char** cs;
415  static int i;
416 #define ncs 20
417  const char* jc = env->GetStringUTFChars(js, 0);
418  if (!cs) {
419  cs = new char*[ncs];
420  for (i=0; i < ncs; ++i) {
421  cs[i] = nil;
422  }
423  i = 0;
424  }
425  if (cs[i]) {
426  delete [] cs[i];
427  }
428  i = (i+1)%ncs;
429  cs[i] = new char[strlen(jc + 1)];
430  strcpy(cs[i], jc);
431  hoc_pushstr(cs + i);
432 //printf("pushArgS |%s|\n", cs[i]);
433  env->ReleaseStringUTFChars(js, jc);
434 }
435 
436 JNIEXPORT void JNICALL Java_neuron_Neuron_pushArgO
437  (JNIEnv *env, jclass, jobject jo, jint type){
438  jnisave
439 //printf("pushArgO jo=%p type=%d\n", jo, type);
440  Object** po = nj_j2hObject(jo, type);
441  if (!po) {
442  printf("Do not recognize the object argument type %d\n", type);
443  }
444  hoc_pushobj(po);
445 //printf("pushArgO %s refcount=%d\n", hoc_object_name(*po), (*po)->refcount);
446  jnirestore
447 }
448 
449 JNIEXPORT jlong JNICALL Java_neuron_Neuron_methodID
450  (JNIEnv *env, jclass, jlong jc, jstring name){
451  const char* s = env->GetStringUTFChars(name, 0);
452  Object* ho = (Object*)jc;
453  Symbol* sym = hoc_table_lookup(s, ho->ctemplate->symtable);
454 //printf("methodID %s %s\n", s, sym->name);
455  env->ReleaseStringUTFChars(name, s);
456  return (jlong)sym;
457 }
458 
459 JNIEXPORT jlong JNICALL Java_neuron_Neuron_pwmListen
460  (JNIEnv *env, jclass, jstring title, jobject jo, jint type) {
461  Object** po = nj_j2hObject(jo, type);
462  Object* ho = po ? *po : nil;
463  jnisave
464  const char* s = env->GetStringUTFChars(title, 0);
465 // printf("pwmListen env=%ld %s\n", (long)env, s);
466  jlong ic = (jlong)nrnjava_pwm_listen(s, ho); // implementation in src/ivoc/pwman.cpp
467  env->ReleaseStringUTFChars(title, s);
468  jnirestore
469  return ic;
470 }
471 
472 JNIEXPORT void JNICALL Java_neuron_Neuron_pwmEvent
473  (JNIEnv *env, jclass, jlong jwc, jint type, jint l, jint t, jint w, jint h) {
474  jnisave
475 // printf("pwmEvent env=%d type=%d l=%d t=%d w=%d h=%d\n",
476 //(long)env, type, l, t, w, h);
477  nrnjava_pwm_event(jwc, type, l, t, w, h); // see src/ivoc/pwman.cpp
478  jnirestore
479 }
480 
481 JNIEXPORT jstring JNICALL Java_neuron_Neuron_sGet
482  (JNIEnv *env, jclass, jstring js){
483  const char* s = env->GetStringUTFChars(js, 0);
484  Symbol* sym = hoc_table_lookup(s, hoc_top_level_symlist);
485  assert(sym && sym->type == STRING);
486  char** sval = hoc_top_level_data[sym->u.oboff].ppstr;
487  env->ReleaseStringUTFChars(js, s);
488  return env->NewStringUTF(*sval);
489 }
490 
491 JNIEXPORT jobject JNICALL Java_neuron_Neuron_oGet
492  (JNIEnv *env, jclass, jstring js){
493  const char* s = env->GetStringUTFChars(js, 0);
494  Symbol* sym = hoc_table_lookup(s, hoc_top_level_symlist);
495  assert(sym && sym->type == OBJECTVAR);
496  Object** po = hoc_top_level_data[sym->u.oboff].pobj;
497  env->ReleaseStringUTFChars(js, s);
498  jobject jo = h2jObject(*po);
499  hoc_obj_unref(*po);
500  return jo;
501 }
502 
503 JNIEXPORT jstring JNICALL Java_neuron_Neuron_hGetStringField
504  (JNIEnv *env, jclass, jlong v, jstring js){
505  const char* s = env->GetStringUTFChars(js, 0);
506  Object* o = (Object*)v;
507  Symbol* sym = hoc_table_lookup(s, o->ctemplate->symtable);
508  assert(sym && sym->type == STRING);
509  char** sval = hoc_top_level_data[sym->u.oboff].ppstr;
510  env->ReleaseStringUTFChars(js, s);
511  return env->NewStringUTF(*sval);
512 }
513 
514 JNIEXPORT jobject JNICALL Java_neuron_Neuron_hGetObjectField
515  (JNIEnv *env, jclass, jlong v, jstring js){
516  const char* s = env->GetStringUTFChars(js, 0);
517  Object* o = (Object*)v;
518  Symbol* sym = hoc_table_lookup(s, o->ctemplate->symtable);
519  assert(sym && sym->type == OBJECTVAR);
520  Object** po = o->u.dataspace[sym->u.oboff].pobj;
521  env->ReleaseStringUTFChars(js, s);
522  jobject jo = h2jObject(*po);
523  hoc_obj_unref(*po);
524  return jo;
525 }
526 
528  (JNIEnv *env, jclass, jlong v, jstring js, jobject joval, jint type){
529  jnisave
530  const char* s = env->GetStringUTFChars(js, 0);
531  Object* o = (Object*)v;
532  Symbol* sym = hoc_table_lookup(s, o->ctemplate->symtable);
533  assert(sym && sym->type == OBJECTVAR);
534  Object** po = o->u.dataspace[sym->u.oboff].pobj;
535  Object** poval = nj_j2hObject(joval, type);
536  Object* old = *po;
537  *po = *poval;
538  (*po)->refcount++;
539  hoc_obj_unref(old);
540  env->ReleaseStringUTFChars(js, s);
541  jnirestore
542 }
543 
544 
546  (JNIEnv *env, jclass, jstring js, jobject joval, jint type){
547  jnisave
548  const char* s = env->GetStringUTFChars(js, 0);
549  Symbol* sym = hoc_table_lookup(s, hoc_top_level_symlist);
550  assert(sym && sym->type == OBJECTVAR);
551  Object** po = hoc_top_level_data[sym->u.oboff].pobj;
552  Object** poval = nj_j2hObject(joval, type);
553  Object* old = *po;
554  *po = *poval;
555  (*po)->refcount++;
556  hoc_obj_unref(old);
557  env->ReleaseStringUTFChars(js, s);
558  jnirestore
559 }
560 
561 
562 JNIEXPORT void JNICALL Java_neuron_Redirect_consoleWrite
563  (JNIEnv *env, jclass, jint fd, jint b) {
564  jnisave
565 #ifdef _MSWIN
566  if (b != '\r') {
567  printf("%c", b);
568  }
569 #else
570 #ifdef MAC
571  if (b == '\r') {
572  b = '\n';
573  }
574  printf("%c", b);
575 #else
576  printf("%c", b);
577 #endif
578 #endif
579 // if (fd == 1) {
580 // fputc(b, stdout);
581 // }else{
582 // fputc(b, stderr);
583 // }
584  jnirestore
585 }
586 
587 
588 
o
Definition: seclist.cpp:180
Definition: hocdec.h:84
static jclass neuronCls
Definition: nrnjava.cpp:62
JNIEXPORT void JNICALL Java_neuron_Neuron_vectorSet(JNIEnv *env, jclass, jlong jc, jint i, jdouble x)
Definition: nrnjni.cpp:280
#define call_ob_proc
Definition: nrnjni.cpp:55
#define jnisave
Definition: njvm.h:4
#define assert(ex)
Definition: hocassrt.h:26
JNIEXPORT void JNICALL Java_neuron_Neuron_pushArgO(JNIEnv *env, jclass, jobject jo, jint type)
Definition: nrnjni.cpp:437
short type
Definition: cabvars.h:10
int hoc_is_str_arg(int narg)
Definition: code.cpp:741
Vect * vector_new1(int n)
Definition: ivocvect.cpp:264
JNIEXPORT void JNICALL Java_neuron_Neuron_java2nrnClass(JNIEnv *env, jclass cls, jstring classname, jint classindex, jstring methods)
Definition: nrnjni.cpp:188
void hoc_pushobj(Object **d)
Definition: code.cpp:647
#define jnirestore
Definition: njvm.h:5
JNIEXPORT void JNICALL Java_neuron_Redirect_consoleWrite(JNIEnv *env, jclass, jint fd, jint b)
Definition: nrnjni.cpp:563
#define Vect
Definition: ivocvect.h:14
JNIEXPORT void JNICALL Java_neuron_Neuron_vectorToHoc(JNIEnv *env, jclass, jlong jc, jdoubleArray ja, jint size)
Definition: nrnjni.cpp:302
if(status)
short type
Definition: model.h:58
int hoc_argtype(int narg)
Definition: code.cpp:727
Symbol * nrn_vec_sym
Definition: nrnjava.cpp:89
JNIEXPORT jint JNICALL Java_neuron_Neuron_getHocArgType(JNIEnv *env, jclass, jint i)
Definition: nrnjni.cpp:219
static void outOfBounds(JNIEnv *env)
Definition: nrnjni.cpp:275
int hoc_is_double_arg(int narg)
Definition: code.cpp:733
JNIEXPORT jobject JNICALL Java_neuron_Neuron_hObjectMethod(JNIEnv *env, jclass, jlong jc, jlong mid, jint narg)
Definition: nrnjni.cpp:388
Symbol * hoc_lookup(const char *)
void nrnjni_redirreg(jclass c)
Definition: nrnjni.cpp:71
void * this_pointer
Definition: hocdec.h:231
char * hoc_object_name(Object *ob)
Definition: hoc_oop.cpp:84
size_t p
Objectdata * hoc_top_level_data
Definition: hoc_oop.cpp:134
JNIEXPORT void JNICALL Java_neuron_Neuron_setVal(JNIEnv *, jclass, jlong p, jdouble d)
Definition: nrnjni.cpp:183
Object ** nj_j2hObject(jobject, int)
Definition: nrnjava.cpp:408
JNIEXPORT jdouble JNICALL Java_neuron_Neuron_getVal(JNIEnv *, jclass, jlong p)
Definition: nrnjni.cpp:177
static int narg()
Definition: ivocvect.cpp:135
#define v
Definition: md1redef.h:4
JNIEnv * nrnjava_env
Definition: njvm.cpp:59
char * nrn_dot2underbar(const char *)
JNI code for Neuron.java C implementations of Java native methods.
Definition: nrnjava.cpp:240
static jobject h2jObject(Object *o)
Definition: nrnjni.cpp:121
JNIEXPORT jlong JNICALL Java_neuron_Neuron_methodID(JNIEnv *env, jclass, jlong jc, jstring name)
Definition: nrnjni.cpp:450
JNIEXPORT jobject JNICALL Java_neuron_Neuron_oGet(JNIEnv *env, jclass, jstring js)
Definition: nrnjni.cpp:492
JNIEXPORT void JNICALL Java_neuron_Neuron_hSetObjectField__Ljava_lang_String_2Ljava_lang_Object_2I(JNIEnv *env, jclass, jstring js, jobject joval, jint type)
Definition: nrnjni.cpp:546
#define e
Definition: passive0.cpp:24
#define gargstr
Definition: hocdec.h:14
JNIEXPORT jstring JNICALL Java_neuron_Neuron_sGet(JNIEnv *env, jclass, jstring js)
Definition: nrnjni.cpp:482
Object ** hoc_objpop()
Definition: code.cpp:849
double hoc_call_func(Symbol *s, int narg)
Definition: code.cpp:1445
JNIEXPORT jstring JNICALL Java_neuron_Neuron_hGetStringField(JNIEnv *env, jclass, jlong v, jstring js)
Definition: nrnjni.cpp:504
JNIEXPORT jlong JNICALL Java_neuron_Neuron_cppPointer(JNIEnv *, jclass, jlong jc)
Definition: nrnjni.cpp:320
int refcount
Definition: hocdec.h:227
void nrnjava_pwm_event(size_t, int, int, int, int, int)
void * nrnjava_pwm_listen(const char *, Object *)
#define ncs
JNIEXPORT jint JNICALL Java_neuron_Neuron_vectorSize(JNIEnv *, jclass, jlong jc)
Definition: nrnjni.cpp:269
JNIEXPORT jlong JNICALL Java_neuron_Neuron_getVarPointer(JNIEnv *, jclass)
Definition: nrnjni.cpp:170
double * hoc_varpointer
Definition: hoc_init.cpp:262
JNIEXPORT jdouble JNICALL Java_neuron_Neuron_getHocDoubleArg(JNIEnv *env, jclass cls, jint idx, jint type)
Definition: nrnjni.cpp:100
_CONST char * s
Definition: system.cpp:74
JNIEXPORT jobject JNICALL Java_neuron_Neuron_getHocObjectArg(JNIEnv *env, jclass cl, jint i, jthrowable e)
Definition: nrnjni.cpp:140
Objectdata * dataspace
Definition: hocdec.h:230
void hoc_obj_unref(Object *obj)
Definition: hoc_oop.cpp:1998
HocStruct Object ** pobj
Definition: hocdec.h:219
void nrnjni_registration(jclass neuronCls)
Definition: nrnjni.cpp:65
#define printf
Definition: mwprefix.h:26
JNIEXPORT jdoubleArray JNICALL Java_neuron_Neuron_vectorFromHoc(JNIEnv *env, jclass, jlong jc)
Definition: nrnjni.cpp:310
double hoc_integer(double)
#define ret
Definition: redef.h:123
JNIEXPORT jlong JNICALL Java_neuron_Neuron_vectorNew(JNIEnv *env, jclass, jint size)
Definition: nrnjni.cpp:258
JNIEXPORT jstring JNICALL Java_neuron_Neuron_getHocArgSig(JNIEnv *env, jclass)
Definition: nrnjni.cpp:234
#define STRING
Definition: bbslsrv.cpp:9
JNIEXPORT jdouble JNICALL Java_neuron_Neuron_hDoubleMethod__JJI(JNIEnv *env, jclass, jlong jc, jlong mid, jint narg)
Definition: nrnjni.cpp:365
double hoc_xpop(void)
#define cnt
Definition: spt2queue.cpp:19
JNIEXPORT void JNICALL Java_neuron_Neuron_pushArgD(JNIEnv *, jclass, jdouble x)
Definition: nrnjni.cpp:402
void hoc_tobj_unref(Object **)
Definition: code.cpp:219
char ** ppstr
Definition: hocdec.h:218
Definition: model.h:57
Symlist * hoc_top_level_symlist
Neuron/Java Interface code.
Definition: symbol.cpp:41
static char * env[]
Definition: inithoc.cpp:228
JNIEXPORT jstring JNICALL Java_neuron_Neuron_getHocStringArg(JNIEnv *env, jclass cls, jint idx)
Definition: nrnjni.cpp:81
char * name
Definition: init.cpp:16
JNIEXPORT jdouble JNICALL Java_neuron_Neuron_hDoubleMethod__Ljava_lang_String_2I(JNIEnv *env, jclass, jstring name, jint narg)
Definition: nrnjni.cpp:355
#define nil
Definition: enter-scope.h:36
JNIEXPORT void JNICALL Java_neuron_Neuron_pwmEvent(JNIEnv *env, jclass, jlong jwc, jint type, jint l, jint t, jint w, jint h)
Definition: nrnjni.cpp:473
void hoc_obj_ref(Object *obj)
Definition: hoc_oop.cpp:1980
int oboff
Definition: hocdec.h:131
declarePtrList(NJSymList, Symbol) extern NJSymList *nrn_jclass_symlist
JNIEXPORT void JNICALL Java_neuron_Neuron_hocObjectUnref(JNIEnv *, jclass, jlong i)
Definition: nrnjni.cpp:163
Object * hoc_new_object(Symbol *, void *)
Definition: hoc_oop.cpp:465
int ifarg(int)
Definition: code.cpp:1562
void vector_resize(Vect *v, int n)
Definition: ivocvect.cpp:269
Symbol NJSymList * nrn_jclass_symlist
Definition: nrnjava.cpp:81
Object * hoc_newobj1(Symbol *, int)
Definition: hoc_oop.cpp:576
JNIEXPORT jdouble JNICALL Java_neuron_Neuron_vectorGet(JNIEnv *env, jclass, jlong jc, jint i)
Definition: nrnjni.cpp:291
void hoc_pushx(double)
Symbol * java2nrn_class(const char *classname, int classindex, const char *methods)
Create a hoc class from a java one.
Definition: hoc_oop.cpp:1628
Symbol * nrn_jobj_sym
Definition: nrnjava.cpp:88
JNIEXPORT jlong JNICALL Java_neuron_Neuron_getNewHObject(JNIEnv *env, jclass, jstring name, jint narg)
Definition: nrnjni.cpp:338
#define CPLUSOBJECT
Definition: hocdec.h:104
static bool valid_stmt(const char *, Object *ob=NULL)
Definition: hocdec.h:226
JNIEXPORT jlong JNICALL Java_neuron_Neuron_pwmListen(JNIEnv *env, jclass, jstring title, jobject jo, jint type)
Definition: nrnjni.cpp:460
#define getarg
Definition: hocdec.h:15
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:60
JNIEXPORT jobject JNICALL Java_neuron_Neuron_hGetObjectField(JNIEnv *env, jclass, jlong v, jstring js)
Definition: nrnjni.cpp:515
#define i
Definition: md1redef.h:12
#define c
static void illegalArg(JNIEnv *env, const char *s)
Definition: nrnjni.cpp:77
char ** hoc_strpop()
Definition: code.cpp:868
Item * title
Definition: model.cpp:40
JNIEXPORT void JNICALL Java_neuron_Neuron_hSetObjectField__JLjava_lang_String_2Ljava_lang_Object_2I(JNIEnv *env, jclass, jlong v, jstring js, jobject joval, jint type)
Definition: nrnjni.cpp:528
JNIEXPORT jstring JNICALL Java_neuron_Neuron_hocObjectName(JNIEnv *env, jclass, jlong jc)
Definition: nrnjni.cpp:330
int hoc_is_object_arg(int narg)
Definition: code.cpp:745
void hoc_pushstr(char **d)
Definition: code.cpp:665
jobject nj_encapsulate(Object *)
a hoc object must be encapsulated in a java object for use in java.
Definition: nrnjava.cpp:486
union Symbol::@18 u
union Object::@54 u
double t
Definition: init.cpp:123
JNIEXPORT jboolean JNICALL Java_neuron_Neuron_execute(JNIEnv *env, jclass, jstring statement)
Definition: nrnjni.cpp:206
JNIEXPORT void JNICALL Java_neuron_Neuron_pushArgS(JNIEnv *env, jclass, jstring js)
Definition: nrnjni.cpp:408
Object ** hoc_objgetarg(int)
Definition: code.cpp:1568
static struct @17 methods[]
#define OBJECTTMP
Definition: hocdec.h:101
JNIEXPORT jstring JNICALL Java_neuron_Neuron_hCharsMethod(JNIEnv *env, jclass, jlong jc, jlong mid, jint narg)
Definition: nrnjni.cpp:376