From 0aa1c09d738380720969c43ce9a37947efa8a78e Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 17 Jul 2010 15:14:45 +0000 Subject: [PATCH] consolidate enum cp_types and enum vt_types . use this enum for some function arguments and struct members . drop some include "variable.h" which are no longer needed , propably many more could be droped . drop #define VT_* which have been used as workaround for the type mess . --- ChangeLog | 34 ++++++++++++++++++++++++ src/frontend/plotting/agraf.c | 1 - src/frontend/plotting/gnuplot.c | 1 - src/frontend/plotting/graf.c | 1 - src/frontend/plotting/plotcurv.c | 1 - src/frontend/plotting/plotit.c | 1 - src/frontend/plotting/xgraph.c | 1 - src/frontend/variable.c | 4 +-- src/frontend/variable.h | 16 ++++------- src/frontend/wdisp/windisp.c | 4 --- src/include/cpextern.h | 19 ++++++------- src/maths/cmaths/cmath4.c | 1 - src/maths/misc/randnumb.c | 1 - src/spicelib/devices/bsim3/b3par.c | 2 +- src/spicelib/devices/bsim3/b3set.c | 4 +-- src/spicelib/devices/bsim3soi/b4soiset.c | 3 +-- src/spicelib/devices/bsim3v0/b3v0par.c | 2 +- src/spicelib/devices/bsim3v1/b3v1par.c | 2 +- src/spicelib/devices/bsim3v1a/b3v1apar.c | 2 +- src/spicelib/devices/bsim3v1s/b3v1spar.c | 2 +- src/spicelib/devices/bsim3v32/b3v32par.c | 2 +- src/spicelib/devices/bsim4/b4par.c | 2 +- src/spicelib/devices/bsim4/b4set.c | 3 +-- src/spicelib/devices/bsim4v2/b4v2par.c | 2 +- src/spicelib/devices/bsim4v3/b4v3par.c | 2 +- src/spicelib/devices/bsim4v4/b4v4par.c | 2 +- src/spicelib/devices/bsim4v5/b4v5par.c | 2 +- src/spicelib/parser/inpgmod.c | 2 +- 28 files changed, 67 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index f03bcfd7f..3992701a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2010-07-17 Robert Larice + * src/frontend/variable.c , + * src/frontend/variable.h , + * src/frontend/plotting/agraf.c , + * src/frontend/plotting/gnuplot.c , + * src/frontend/plotting/graf.c , + * src/frontend/plotting/plotcurv.c , + * src/frontend/plotting/plotit.c , + * src/frontend/plotting/xgraph.c , + * src/frontend/wdisp/windisp.c , + * src/include/cpextern.h , + * src/maths/cmaths/cmath4.c , + * src/maths/misc/randnumb.c , + * src/spicelib/devices/bsim3/b3par.c , + * src/spicelib/devices/bsim3/b3set.c , + * src/spicelib/devices/bsim3soi/b4soiset.c , + * src/spicelib/devices/bsim3v0/b3v0par.c , + * src/spicelib/devices/bsim3v1/b3v1par.c , + * src/spicelib/devices/bsim3v1a/b3v1apar.c , + * src/spicelib/devices/bsim3v1s/b3v1spar.c , + * src/spicelib/devices/bsim3v32/b3v32par.c , + * src/spicelib/devices/bsim4/b4par.c , + * src/spicelib/devices/bsim4/b4set.c , + * src/spicelib/devices/bsim4v2/b4v2par.c , + * src/spicelib/devices/bsim4v3/b4v3par.c , + * src/spicelib/devices/bsim4v4/b4v4par.c , + * src/spicelib/devices/bsim4v5/b4v5par.c , + * src/spicelib/parser/inpgmod.c : + consolidate enum cp_types and enum vt_types . + use this enum for some function arguments and struct members . + drop some include "variable.h" which are no longer needed , + propably many more could be droped . + drop #define VT_* which have been used as workaround for the type mess . + 2010-07-17 Holger Vogt * typesdef.c: correct the number of available types and plots diff --git a/src/frontend/plotting/agraf.c b/src/frontend/plotting/agraf.c index a3bd22668..d58790d4c 100644 --- a/src/frontend/plotting/agraf.c +++ b/src/frontend/plotting/agraf.c @@ -14,7 +14,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "fteparse.h" #include "agraf.h" -#include #define FUDGE 7 #define MARGIN_BASE 11 diff --git a/src/frontend/plotting/gnuplot.c b/src/frontend/plotting/gnuplot.c index 545f80c35..a07c0d98b 100644 --- a/src/frontend/plotting/gnuplot.c +++ b/src/frontend/plotting/gnuplot.c @@ -17,7 +17,6 @@ #include "fteparse.h" #include "gnuplot.h" -#include "variable.h" #define GP_MAXVECTORS 64 diff --git a/src/frontend/plotting/graf.c b/src/frontend/plotting/graf.c index fc8daa3a0..79fde6309 100644 --- a/src/frontend/plotting/graf.c +++ b/src/frontend/plotting/graf.c @@ -22,7 +22,6 @@ $Id$ #include "ftedbgra.h" #include "ftedev.h" #include -#include #include "graf.h" #include "graphdb.h" #include "grid.h" diff --git a/src/frontend/plotting/plotcurv.c b/src/frontend/plotting/plotcurv.c index be52eb54c..24ca4f98f 100644 --- a/src/frontend/plotting/plotcurv.c +++ b/src/frontend/plotting/plotcurv.c @@ -13,7 +13,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include #include #include -#include #include "plotcurv.h" diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index 63ca3b9b5..2ca0410f6 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -10,7 +10,6 @@ #include #include -#include #include "plotit.h" #include "agraf.h" diff --git a/src/frontend/plotting/xgraph.c b/src/frontend/plotting/xgraph.c index 761c0a165..c24076718 100644 --- a/src/frontend/plotting/xgraph.c +++ b/src/frontend/plotting/xgraph.c @@ -14,7 +14,6 @@ Author: 1992 David A. Gates, U. C. Berkeley CAD Group #include "fteparse.h" #include "xgraph.h" -#include #define XG_MAXVECTORS 64 diff --git a/src/frontend/variable.c b/src/frontend/variable.c index ace12bc5c..21d09d980 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -85,7 +85,7 @@ cp_varwl(struct variable *var) /* Set a variable. */ void -cp_vset(char *varname, char type, char *value) +cp_vset(char *varname, enum vt_types type, char *value) { struct variable *v, *u, *w; int i; @@ -540,7 +540,7 @@ cp_remvar(char *varname) /* Determine the value of a variable. Fail if the variable is unset, * and if the type doesn't match, try and make it work... */ bool -cp_getvar(char *name, int type, void *retval) +cp_getvar(char *name, enum vt_types type, void *retval) { struct variable *v; struct variable *uv1, *uv2; diff --git a/src/frontend/variable.h b/src/frontend/variable.h index 2063064a2..53e838bfc 100644 --- a/src/frontend/variable.h +++ b/src/frontend/variable.h @@ -6,11 +6,13 @@ #ifndef _VARIABLE_H #define _VARIABLE_H +#include "cpextern.h" + /* Variables that are accessible to the parser via $varname * expansions. If the type is VT_LIST the value is a pointer to a * list of the elements. */ struct variable { - char va_type; + enum vt_types va_type; char *va_name; union { bool vV_bool; @@ -28,14 +30,6 @@ struct variable { #define va_string va_V.vV_string #define va_vlist va_V.vV_list -enum vt_types { - VT_BOOL, - VT_NUM, - VT_REAL, - VT_STRING, - VT_LIST -}; - struct xxx { struct variable *x_v; char x_char; @@ -51,10 +45,10 @@ extern bool cp_echo; /* extern struct variable *variables; */ wordlist * cp_varwl(struct variable *var); -void cp_vset(char *varname, char type, char *value); +void cp_vset(char *varname, enum vt_types type, char *value); struct variable * cp_setparse(wordlist *wl); void cp_remvar(char *varname); -bool cp_getvar(char *name, int type, void *retval); +bool cp_getvar(char *name, enum vt_types type, void *retval); wordlist * cp_variablesubst(wordlist *wlist); wordlist * vareval(char *string); void cp_vprint(void); diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index 39e5805a6..379702a18 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -27,10 +27,6 @@ */ #undef BOOLEAN -/* local definition, because inclusion of variable.h does not work under Windows */ -#define VT_NUM 1 -#define VT_STRING 3 - #include #include #include "suffix.h" diff --git a/src/include/cpextern.h b/src/include/cpextern.h index b8b25a990..f7cf4ad1d 100644 --- a/src/include/cpextern.h +++ b/src/include/cpextern.h @@ -160,6 +160,13 @@ void cp_rehash(char *pathlist, bool docc); /* variable.c */ +enum vt_types { + VT_BOOL, + VT_NUM, + VT_REAL, + VT_STRING, + VT_LIST +}; extern bool cp_ignoreeof; extern bool cp_noclobber; @@ -167,24 +174,18 @@ extern bool cp_noglob; extern bool cp_nonomatch; extern char cp_dol; extern void cp_remvar(char *varname); -extern void cp_vset(char *varname, char type, char *value); +extern void cp_vset(char *varname, enum vt_types type, char *value); extern struct variable *cp_setparse(wordlist *wl); +extern wordlist *vareval(char *string); /* var2.c */ -enum cp_types { - CP_BOOL, - CP_NUM, - CP_REAL, - CP_STRING, - CP_LIST -}; extern void cp_vprint(void); extern void com_set(wordlist *wl); extern void com_option(wordlist *wl); extern void com_state(wordlist *wl); extern void com_unset(wordlist *wl); extern void com_shift(wordlist *wl); -extern bool cp_getvar(char *name, int type, void *retval); +extern bool cp_getvar(char *name, enum vt_types type, void *retval); /* cpinterface.c etc -- stuff CP needs from FTE */ diff --git a/src/maths/cmaths/cmath4.c b/src/maths/cmaths/cmath4.c index ac6cf2567..4cbe4b208 100644 --- a/src/maths/cmaths/cmath4.c +++ b/src/maths/cmaths/cmath4.c @@ -30,7 +30,6 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "sim.h" /* To get SV_TIME */ -#include "../../frontend/variable.h" /* for VT_NUM in cx_interpolate */ extern bool cx_degrees; void * diff --git a/src/maths/misc/randnumb.c b/src/maths/misc/randnumb.c index 058b105ea..cfe6c1f74 100644 --- a/src/maths/misc/randnumb.c +++ b/src/maths/misc/randnumb.c @@ -9,7 +9,6 @@ Copyright 2008 Holger Vogt #include "ngspice.h" #include "cpdefs.h" #include "ftedefs.h" -#include "../frontend/variable.h" /* MINGW: random, srandom in libiberty.a, but not in libiberty.h */ diff --git a/src/spicelib/devices/bsim3/b3par.c b/src/spicelib/devices/bsim3/b3par.c index dc170e7f4..96e79c30e 100644 --- a/src/spicelib/devices/bsim3/b3par.c +++ b/src/spicelib/devices/bsim3/b3par.c @@ -26,7 +26,7 @@ IFvalue *select) BSIM3instance *here = (BSIM3instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM3_W: diff --git a/src/spicelib/devices/bsim3/b3set.c b/src/spicelib/devices/bsim3/b3set.c index bc30d5fc8..314b8550d 100644 --- a/src/spicelib/devices/bsim3/b3set.c +++ b/src/spicelib/devices/bsim3/b3set.c @@ -16,10 +16,10 @@ #include "const.h" #include "sperror.h" #include "suffix.h" + #ifdef USE_OMP3 +#include "cpextern.h" int nthreads; -extern bool cp_getvar(char *name, int type, void *retval); -#define VT_NUM 1 #endif #define MAX_EXP 5.834617425e14 diff --git a/src/spicelib/devices/bsim3soi/b4soiset.c b/src/spicelib/devices/bsim3soi/b4soiset.c index 4831adab3..cdd274ea9 100644 --- a/src/spicelib/devices/bsim3soi/b4soiset.c +++ b/src/spicelib/devices/bsim3soi/b4soiset.c @@ -26,9 +26,8 @@ static char rcsid[] = "$Id$"; #include "suffix.h" #ifdef USE_OMP4SOI +#include "cpextern.h" int nthreads; -extern bool cp_getvar(char *name, int type, void *retval); -#define VT_NUM 1 #endif #define SMOOTHFACTOR 0.1 diff --git a/src/spicelib/devices/bsim3v0/b3v0par.c b/src/spicelib/devices/bsim3v0/b3v0par.c index 6ad2dc1c2..01679513e 100644 --- a/src/spicelib/devices/bsim3v0/b3v0par.c +++ b/src/spicelib/devices/bsim3v0/b3v0par.c @@ -18,7 +18,7 @@ BSIM3v0param(int param, IFvalue *value, GENinstance *inst, IFvalue *select) BSIM3v0instance *here = (BSIM3v0instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM3v0_W: diff --git a/src/spicelib/devices/bsim3v1/b3v1par.c b/src/spicelib/devices/bsim3v1/b3v1par.c index cac6f8df8..8b65cb4ef 100644 --- a/src/spicelib/devices/bsim3v1/b3v1par.c +++ b/src/spicelib/devices/bsim3v1/b3v1par.c @@ -24,7 +24,7 @@ BSIM3v1param(int param, IFvalue *value, GENinstance *inst, IFvalue *select) BSIM3v1instance *here = (BSIM3v1instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM3v1_W: diff --git a/src/spicelib/devices/bsim3v1a/b3v1apar.c b/src/spicelib/devices/bsim3v1a/b3v1apar.c index dbbd6e11b..5ebcdc9e2 100644 --- a/src/spicelib/devices/bsim3v1a/b3v1apar.c +++ b/src/spicelib/devices/bsim3v1a/b3v1apar.c @@ -19,7 +19,7 @@ BSIM3v1Aparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) BSIM3v1Ainstance *here = (BSIM3v1Ainstance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM3v1A_W: diff --git a/src/spicelib/devices/bsim3v1s/b3v1spar.c b/src/spicelib/devices/bsim3v1s/b3v1spar.c index 0fb4d04aa..f2defb1ee 100644 --- a/src/spicelib/devices/bsim3v1s/b3v1spar.c +++ b/src/spicelib/devices/bsim3v1s/b3v1spar.c @@ -19,7 +19,7 @@ BSIM3v1Sparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) BSIM3v1Sinstance *here = (BSIM3v1Sinstance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM3v1S_W: diff --git a/src/spicelib/devices/bsim3v32/b3v32par.c b/src/spicelib/devices/bsim3v32/b3v32par.c index 410291d68..1f8d70c17 100644 --- a/src/spicelib/devices/bsim3v32/b3v32par.c +++ b/src/spicelib/devices/bsim3v32/b3v32par.c @@ -23,7 +23,7 @@ BSIM3v32param (int param, IFvalue *value, GENinstance *inst, IFvalue *select) BSIM3v32instance *here = (BSIM3v32instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM3v32_W: diff --git a/src/spicelib/devices/bsim4/b4par.c b/src/spicelib/devices/bsim4/b4par.c index bb2569a4b..a333086d1 100644 --- a/src/spicelib/devices/bsim4/b4par.c +++ b/src/spicelib/devices/bsim4/b4par.c @@ -32,7 +32,7 @@ IFvalue *select) BSIM4instance *here = (BSIM4instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM4_W: diff --git a/src/spicelib/devices/bsim4/b4set.c b/src/spicelib/devices/bsim4/b4set.c index 8c77e5d40..80af93311 100644 --- a/src/spicelib/devices/bsim4/b4set.c +++ b/src/spicelib/devices/bsim4/b4set.c @@ -32,9 +32,8 @@ #include "suffix.h" #ifdef USE_OMP4 +#include "cpextern.h" int nthreads; -extern bool cp_getvar(char *name, int type, void *retval); -#define VT_NUM 1 #endif #define MAX_EXP 5.834617425e14 diff --git a/src/spicelib/devices/bsim4v2/b4v2par.c b/src/spicelib/devices/bsim4v2/b4v2par.c index 9fdb32163..e3552625a 100644 --- a/src/spicelib/devices/bsim4v2/b4v2par.c +++ b/src/spicelib/devices/bsim4v2/b4v2par.c @@ -25,7 +25,7 @@ IFvalue *select) BSIM4v2instance *here = (BSIM4v2instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM4v2_W: diff --git a/src/spicelib/devices/bsim4v3/b4v3par.c b/src/spicelib/devices/bsim4v3/b4v3par.c index ceb218927..af7b50c7e 100644 --- a/src/spicelib/devices/bsim4v3/b4v3par.c +++ b/src/spicelib/devices/bsim4v3/b4v3par.c @@ -28,7 +28,7 @@ IFvalue *select) BSIM4v3instance *here = (BSIM4v3instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM4v3_W: diff --git a/src/spicelib/devices/bsim4v4/b4v4par.c b/src/spicelib/devices/bsim4v4/b4v4par.c index 332b0140b..46c1fd77d 100644 --- a/src/spicelib/devices/bsim4v4/b4v4par.c +++ b/src/spicelib/devices/bsim4v4/b4v4par.c @@ -29,7 +29,7 @@ IFvalue *select) BSIM4v4instance *here = (BSIM4v4instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM4v4_W: diff --git a/src/spicelib/devices/bsim4v5/b4v5par.c b/src/spicelib/devices/bsim4v5/b4v5par.c index 92f202973..940e66a80 100644 --- a/src/spicelib/devices/bsim4v5/b4v5par.c +++ b/src/spicelib/devices/bsim4v5/b4v5par.c @@ -30,7 +30,7 @@ IFvalue *select) BSIM4v5instance *here = (BSIM4v5instance*)inst; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; switch(param) { case BSIM4v5_W: diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index b3a01e33f..c08f0123f 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -204,7 +204,7 @@ INPgetModBin( CKTcircuit* ckt, char* name, INPmodel** model, INPtables* tab, cha int error; double scale; - if ( !cp_getvar( "scale", CP_REAL, (double*) &scale ) ) scale = 1; + if ( !cp_getvar( "scale", VT_REAL, (double*) &scale ) ) scale = 1; *model = NULL;