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

This commit is contained in:
rlar 2016-03-25 15:42:15 +01:00
parent cc3a124120
commit bbbd531d8d
2 changed files with 41 additions and 0 deletions

View File

@ -984,3 +984,38 @@ cp_vprint(void)
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;
}

View File

@ -43,4 +43,10 @@ wordlist *cp_varwl(struct variable *var);
wordlist *cp_variablesubst(wordlist *wlist);
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