1 #include <../../nrnconf.h> 22 extern double chkarg(
int,
double low,
double high);
30 if (sym && sym->
extra) {
49 buf =
static_cast<char*
>(
emalloc(strlen(name)+1));
51 for (cp = buf; *cp; ++cp) {
62 if (sym && *cp ==
'\0') {
65 }
else if (sym && sym->
type == TEMPLATE && *cp !=
'\0') {
90 hoc_execerror(
"Cannot find the symbol associated with the pointer when called from Python.",
"Use a string instead of pointer argument");
118 if (val < limits[0]) {
119 return (
double)limits[0];
120 }
else if (val > limits[1]) {
121 return (
double)limits[1];
129 if (!sym) {
return (
char*)0; }
170 hoc_execerror(
"Cannot find the symbol associated with the pointer when called from Python.",
"Use a string instead of pointer argument");
179 if (*units == (
char*)0) {
194 buf =
static_cast<char *
>(
emalloc(strlen(neuron_home)+1));
195 strcpy(buf, neuron_home);
208 #if defined(WIN32)||defined(CYGWIN) 235 pushx((
double)strcmp(s1 ,s2));
249 char *pf, *
format, errbuf[100];
251 int n=0, iarg,
i, islong, convert, sawnum;
264 for (i=0; i < 20; ++
i) {
265 arglist[
i] =
nullptr;
270 for (pf = format; *pf; ++pf) {
276 if (! *pf)
goto incomplete;
280 if (! *pf)
goto incomplete;
282 if (convert && iarg >= 19) {
285 while(isdigit(*pf)) {
288 if (! *pf)
goto incomplete;
293 if (! *pf)
goto incomplete;
295 if (convert)
switch(*pf) {
305 arg[iarg].type =
'l';
306 arglist[iarg] = (
void*)&
arg[iarg].u.l;
308 arg[iarg].type =
'i';
309 arglist[iarg] = (
void*)&
arg[iarg].u.i;
316 arg[iarg].type =
'd';
317 arglist[iarg] = (
void*)&
arg[iarg].u.d;
319 arg[iarg].type =
'f';
320 arglist[iarg] = (
void*)&
arg[iarg].u.f;
329 if (! *pf)
goto incomplete;
331 if (!( (i == 1) || ((i == 2) && (pf[-1] ==
'^')))) {
342 arg[iarg].type =
's';
343 arg[iarg].u.s =
static_cast<char *
>(
emalloc(strlen(buf) + 1));
344 arglist[iarg] = (
void*)
arg[iarg].u.s;
347 if (islong || sawnum) {
350 arg[iarg].type =
'c';
351 arglist[iarg] = (
void*)&
arg[iarg].u.c;
359 if (!
ifarg(iarg+2)) {
365 sprintf(errbuf,
"arg %d must be a string", iarg+2);
371 sprintf(errbuf,
"arg %d must be a pointer to a number", iarg+2);
381 n =
vsscanf(buf, format, arglist);
384 n = sscanf(buf, format, arglist[0], arglist[1], arglist[2]);
385 }
else if (iarg < 13) {
386 n = sscanf(buf, format, arglist[0], arglist[1], arglist[2],
387 arglist[3], arglist[4], arglist[5], arglist[6], arglist[7],
388 arglist[8], arglist[9], arglist[10], arglist[11]);
395 for (i = 0; i <
n; ++
i) {
404 *hoc_pgetarg(i+3) = (double)
arg[i].u.l;
407 *hoc_pgetarg(i+3) = (double)
arg[i].u.f;
419 sprintf(errbuf,
"incomplete format specifier for arg %d", iarg + 3);
422 sprintf(errbuf,
"unknown conversion specifier for arg %d", iarg + 3);
425 sprintf(errbuf,
"missing arg %d", iarg + 2);
430 sprintf(errbuf,
"too many ( > %d) args", iarg + 2);
433 for (i=0; i < iarg; ++
i) {
447 #if defined(WIN32) && !defined(CYGWIN) 448 static char stdoutfile[]=
"\\systmp.tmp";
450 static char stdoutfile[]=
"/systmp.tmp";
455 if (hoc_plttext && !strchr(
gargstr(1),
'>')) {
458 n = strlen(
gargstr(1)) + strlen(stdoutfile);
463 if ((fp =
fopen(stdoutfile,
"r")) == (FILE *)0) {
464 hoc_execerror(
"Internal error in System(): can't open", stdoutfile);
466 while (fgets(st->
buf, 255, fp) == st->
buf) {
471 IGNORE(unlink(stdoutfile));
472 }
else if (
ifarg(2)) {
483 hoc_tmpbuf->
buf[0] =
'\0';
486 i += strlen(line->
buf);
487 if (hoc_tmpbuf->
size <= i) {
490 strcat(hoc_tmpbuf->
buf, line->
buf);
518 "Other Builtins", FUN_BLTIN,
520 "Procedures", PROCEDURE,
530 Printf(
"\n\nSymbol list %s\n\n", s);
548 Printf(
"ARRAY USERDOUBLE");
552 case NUMBER:
Printf(
"NUMBER %.8g", *(
OPVAL(sp)));
break;
554 case UNDEF:
Printf(
"UNDEF");
break;
555 case BLTIN:
Printf(
"BLTIN");
break;
556 case AUTO:
Printf(
"AUTO");
break;
560 case PROCEDURE:
Printf(
"PROCEDURE");
563 case FUN_BLTIN:
Printf(
"FUN_BLTIN");
break;
576 for (i = 0;
type_sym[
i].t_type != 0; i++)
614 if (val > high || val < low) {
615 hoc_execerror(
"Arg out of range in user function", (
char *)0);
644 if (strlen(str) > BUFSIZ - 20) {
651 sprintf(s,
"hoc_ac_ = %s\n", str);
676 if (strlen(str) > BUFSIZ - 10) {
702 if (strlen(s) > BUFSIZ - 20) {
705 sprintf(buf->
buf,
"{hoc_pointer_(&%s)}\n", s);
709 sprintf(buf,
"{hoc_pointer_(&%s)}\n", s);
732 x = (s->
type == OBJECTVAR) ? 2 : x;
733 x = (s->
type == SECTION) ? 3 : x;
735 x = (s->
type == VAR) ? 5 : x;
736 if (x == 5 && arg2 == 2) {
void hoc_name_declared(void)
Symlist * hoc_built_in_symlist
char * hoc_back2forward(char *)
void hoc_Symbol_units(void)
char * neuronhome_forward(void)
static int hoc_vsscanf(const char *buf)
int hoc_is_str_arg(int narg)
void hoc_symbol_limits(Symbol *sym, float low, float high)
static HocParmLimits limits[]
Symbol * hoc_parse_stmt(const char *str, Symlist **psymlist)
void hocstr_delete(HocStr *hs)
int hoc_is_double_arg(int narg)
char * hoc_symbol_units(Symbol *sym, const char *units)
Symbol * hoc_lookup(const char *)
char * hoc_forward2back(char *s)
#define nrn_fw_delete(fw)
float * hoc_sym_domain(Symbol *sym)
Symlist * hoc_top_level_symlist
Neuron/Java Interface code.
char ** hoc_pgargstr(int)
void hoc_neuronhome(void)
void hoc_Symbol_limits(void)
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
int system(const char *s)
Symbol * hoc_install(const char *, int, double, Symlist **)
double * hoc_pgetarg(int narg)
Symbol * hoc_name2sym(const char *name)
int hoc_xopen_run(Symbol *sp, const char *str)
Symbol * hoc_parse_expr(const char *str, Symlist **psymlist)
void hoc_assign_str(char **cpp, const char *buf)
int hoc_is_pdouble_arg(int narg)
Symbol * hoc_get_last_pointer_symbol()
HocSymExtension * hoc_var_extra(const char *name)
int const size_t const size_t n
FILE * popen(char *s1, char *s2)
void hocstr_resize(HocStr *hs, size_t n)
HocStr * hocstr_create(size_t size)
int hoc_oc(const char *buf)
double hoc_run_expr(Symbol *sym)
void hoc_execerror(const char *, const char *)
static void symdebug(const char *s, Symlist *list)
char * fgets_unlimited(HocStr *s, NrnFILEWrap *f)
char * emalloc(unsigned n)
double xred(const char *prompt, double defalt, double min, double max)
double chkarg(int, double low, double high)
void hoc_run_stmt(Symbol *sym)
HocStruct cTemplate * ctemplate
void sym_extra_alloc(Symbol *)
Symbol * hoc_table_lookup(const char *, Symlist *)
double * hoc_val_pointer(const char *s)
double check_domain_limits(float *limits, double val)
static char line[MAXLINE]
void hoc_pushstr(char **d)
char ** hoc_temp_charptr(void)
void setneuronhome(const char *)
int vsscanf(const char *str, const char *format, va_list args)
void hoc_symbol_tolerance(Symbol *sym, double tol)
static struct @44 type_sym[]