use type void* to pass anonymous data to function if_option()

indicate its actual type with an enum cp_types argument
This commit is contained in:
rlar 2010-07-17 22:11:51 +00:00
parent 61bba96f42
commit 2990821053
7 changed files with 23 additions and 12 deletions

View File

@ -1,3 +1,13 @@
2010-07-17 Robert Larice
* src/main.c ,
* src/frontend/inp.c ,
* src/frontend/options.c ,
* src/frontend/spiceif.c ,
* src/frontend/spiceif.h ,
* src/include/fteext.h :
use type void* to pass anonymous data to function if_option()
indicate its actual type with an enum cp_types argument
2010-07-17 Robert Larice 2010-07-17 Robert Larice
* src/frontend/variable.c , * src/frontend/variable.c ,
* src/frontend/variable.h , * src/frontend/variable.h ,

View File

@ -894,11 +894,11 @@ inp_dodeck(
break; break;
case CP_NUM: case CP_NUM:
if_option(ct->ci_ckt, eev->va_name, if_option(ct->ci_ckt, eev->va_name,
eev->va_type, (char *) &eev->va_num); eev->va_type, &eev->va_num);
break; break;
case CP_REAL: case CP_REAL:
if_option(ct->ci_ckt, eev->va_name, if_option(ct->ci_ckt, eev->va_name,
eev->va_type, (char *) &eev->va_real); eev->va_type, &eev->va_real);
break; break;
case CP_STRING: case CP_STRING:
if_option(ct->ci_ckt, eev->va_name, if_option(ct->ci_ckt, eev->va_name,

View File

@ -243,7 +243,8 @@ int
cp_usrset(struct variable *var, bool isset) cp_usrset(struct variable *var, bool isset)
{ {
char val[BSIZE_SP]; char val[BSIZE_SP];
char *vv, *s; void *vv;
char *s;
struct variable *tv; struct variable *tv;
int iv; int iv;
double dv; double dv;
@ -375,11 +376,11 @@ cp_usrset(struct variable *var, bool isset)
if (var->va_bool) { if (var->va_bool) {
/*val[0] = '\0';*/ /*val[0] = '\0';*/
bv = TRUE; bv = TRUE;
vv = (char *) &bv; vv = &bv;
/*break;*/ /*break;*/
} else { } else {
bv = FALSE; bv = FALSE;
vv = (char *) &bv; vv = &bv;
} }
break; break;
case CP_STRING: case CP_STRING:
@ -389,12 +390,12 @@ cp_usrset(struct variable *var, bool isset)
case CP_NUM: case CP_NUM:
/*(void) sprintf(val, "%d", var->va_num);*/ /*(void) sprintf(val, "%d", var->va_num);*/
iv = var->va_num; iv = var->va_num;
vv = (char *) &iv; vv = &iv;
break; break;
case CP_REAL: case CP_REAL:
/*(void) strcpy(val, printnum(var->va_real));*/ /*(void) strcpy(val, printnum(var->va_real));*/
dv = var->va_real; dv = var->va_real;
vv = (char *) &dv; vv = &dv;
break; break;
case CP_LIST: case CP_LIST:
/* if_option can't handle lists anyway. */ /* if_option can't handle lists anyway. */

View File

@ -382,7 +382,7 @@ static char *obsolete[] = {
} ; } ;
int int
if_option(CKTcircuit *ckt, char *name, int type, char *value) if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
{ {
IFvalue pval; IFvalue pval;
int err, i; int err, i;
@ -467,7 +467,7 @@ if_option(CKTcircuit *ckt, char *name, int type, char *value)
break; break;
case IF_STRING: case IF_STRING:
if (type == CP_STRING) if (type == CP_STRING)
pval.sValue = copy(value); pval.sValue = copy((char*) value);
else else
goto badtype; goto badtype;
break; break;

View File

@ -9,7 +9,7 @@
CKTcircuit * if_inpdeck(struct line *deck, INPtables **tab); CKTcircuit * if_inpdeck(struct line *deck, INPtables **tab);
int if_run(CKTcircuit *t, char *what, wordlist *args, INPtables *tab); int if_run(CKTcircuit *t, char *what, wordlist *args, INPtables *tab);
int if_option(CKTcircuit *ckt, char *name, int type, char *value); int if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value);
void if_dump(CKTcircuit *ckt, FILE *file); void if_dump(CKTcircuit *ckt, FILE *file);
void if_cktfree(CKTcircuit *ckt, INPtables *tab); void if_cktfree(CKTcircuit *ckt, INPtables *tab);
char * if_errstring(int code); char * if_errstring(int code);

View File

@ -433,7 +433,7 @@ extern struct variable *spif_getparam(CKTcircuit *ckt, char **name, char *param,
extern struct variable *spif_getparam_special(CKTcircuit *ckt, char **name, char *param, int ind, int do_model); extern struct variable *spif_getparam_special(CKTcircuit *ckt, char **name, char *param, int ind, int do_model);
extern void if_cktfree(CKTcircuit *ckt, INPtables *tab); extern void if_cktfree(CKTcircuit *ckt, INPtables *tab);
extern void if_dump(CKTcircuit *ckt, FILE *file); extern void if_dump(CKTcircuit *ckt, FILE *file);
extern int if_option(CKTcircuit *ckt, char *name, int type, char *value); extern int if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value);
extern void if_setndnames(char *line); extern void if_setndnames(char *line);
extern void if_setparam_model(CKTcircuit *ckt, char **name, char *val ); extern void if_setparam_model(CKTcircuit *ckt, char **name, char *val );
extern void if_setparam(CKTcircuit *ckt, char **name, char *param, struct dvec *val, int do_model); extern void if_setparam(CKTcircuit *ckt, char **name, char *param, struct dvec *val, int do_model);

View File

@ -252,7 +252,7 @@ if_inpdeck(struct line *deck, INPtables **tab)
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
int int
if_option(CKTcircuit *ckt, char *name, int type, char *value) if_option(CKTcircuit *ckt, char *name, enum cp_types type, void *value)
{ {
return 0; return 0;
} }