Browse Source

struct variable, #9/18, introduce `var_set_xxx()'

pre-master-46
rlar 10 years ago
parent
commit
bbbd531d8d
  1. 35
      src/frontend/variable.c
  2. 6
      src/frontend/variable.h

35
src/frontend/variable.c

@ -984,3 +984,38 @@ cp_vprint(void)
tfree(vars); tfree(vars);
} }
void
var_set_bool(struct variable *v, bool value)
{
v->va_type = CP_BOOL;
v->va_bool = value;
}
void
var_set_num(struct variable *v, int value)
{
v->va_type = CP_NUM;
v->va_num = value;
}
void
var_set_real(struct variable *v, double value)
{
v->va_type = CP_REAL;
v->va_real = value;
}
void
var_set_string(struct variable *v, char *value)
{
v->va_type = CP_STRING;
v->va_string = value;
}
void
var_set_vlist(struct variable *v, struct variable *value)
{
v->va_type = CP_LIST;
v->va_vlist = value;
}

6
src/frontend/variable.h

@ -43,4 +43,10 @@ wordlist *cp_varwl(struct variable *var);
wordlist *cp_variablesubst(wordlist *wlist); wordlist *cp_variablesubst(wordlist *wlist);
void free_struct_variable(struct variable *v); void free_struct_variable(struct variable *v);
void var_set_bool(struct variable *, bool);
void var_set_num(struct variable *, int);
void var_set_real(struct variable *, double);
void var_set_string(struct variable *, char *);
void var_set_vlist(struct variable *, struct variable *);
#endif #endif
Loading…
Cancel
Save