Browse Source

struct variable, #6/18, collect struct variable operations

pre-master-46
rlar 10 years ago
parent
commit
f4f0ae3f61
  1. 32
      src/frontend/spiceif.c

32
src/frontend/spiceif.c

@ -960,30 +960,43 @@ parmtovar(IFvalue *pv, IFparm *opt)
{ {
/* It is not clear whether we want to name the variable /* It is not clear whether we want to name the variable
* by `keyword' or by `description' */ * by `keyword' or by `description' */
struct variable *vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
struct variable *vv;
switch (opt->dataType & IF_VARTYPES) { switch (opt->dataType & IF_VARTYPES) {
case IF_INTEGER: case IF_INTEGER:
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
vv->va_type = CP_NUM; vv->va_type = CP_NUM;
vv->va_num = pv->iValue; vv->va_num = pv->iValue;
break;
return vv;
case IF_REAL: case IF_REAL:
case IF_COMPLEX: case IF_COMPLEX:
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
vv->va_type = CP_REAL; vv->va_type = CP_REAL;
vv->va_real = pv->rValue; vv->va_real = pv->rValue;
break;
return vv;
case IF_STRING: case IF_STRING:
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
vv->va_type = CP_STRING; vv->va_type = CP_STRING;
vv->va_string = pv->sValue; vv->va_string = pv->sValue;
break;
return vv;
case IF_FLAG: case IF_FLAG:
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
vv->va_type = CP_BOOL; vv->va_type = CP_BOOL;
vv->va_bool = pv->iValue ? TRUE : FALSE; vv->va_bool = pv->iValue ? TRUE : FALSE;
break;
return vv;
case IF_REALVEC: { case IF_REALVEC: {
int i; int i;
vv = TMALLOC(struct variable, 1);
vv->va_name = copy(opt->description);
vv->va_next = NULL;
vv->va_type = CP_LIST; vv->va_type = CP_LIST;
vv->va_vlist = NULL; vv->va_vlist = NULL;
for (i = pv->v.numValue; --i >= 0;) { for (i = pv->v.numValue; --i >= 0;) {
@ -995,6 +1008,7 @@ parmtovar(IFvalue *pv, IFparm *opt)
nv->va_real = pv->v.vec.rVec[i]; nv->va_real = pv->v.vec.rVec[i];
vv->va_vlist = nv; vv->va_vlist = nv;
} }
return vv;
/* It is a linked list where the first node is a variable /* It is a linked list where the first node is a variable
* pointing to the different values of the variables. * pointing to the different values of the variables.
* *
@ -1010,8 +1024,6 @@ parmtovar(IFvalue *pv, IFparm *opt)
* So the list is starting from behind, but no problem * So the list is starting from behind, but no problem
* This works fine * This works fine
*/ */
break;
} }
default: default:
fprintf(cp_err, fprintf(cp_err,
@ -1019,8 +1031,6 @@ parmtovar(IFvalue *pv, IFparm *opt)
opt->dataType); opt->dataType);
return (NULL); return (NULL);
} }
return (vv);
} }

Loading…
Cancel
Save