Changeset c0e728a
- Timestamp:
- Sep 30, 2011, 8:12:25 AM (13 years ago)
- Children:
- b54b06a
- Parents:
- 5f784ec
- git-author:
- Jason Gross <jgross@mit.edu> (06/27/11 01:41:01)
- git-committer:
- Jason Gross <jgross@mit.edu> (09/30/11 08:12:25)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.h
rb9517cf rc0e728a 237 237 void *pval_default; /* for types other and string */ 238 238 int ival_default; /* for types int and bool */ 239 c onst char *validsettings;/* documentation of valid settings */239 char *validsettings; /* documentation of valid settings */ 240 240 char *summary; /* summary of usage */ 241 241 char *description; /* detailed description */ -
variable.c
r5f784ec rc0e728a 3 3 4 4 #define OWLVAR_BOOL(name,default,summary,description) \ 5 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \5 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, g_strdup("on,off"), g_strdup(summary), g_strdup(description), NULL, \ 6 6 NULL, NULL, NULL, NULL, NULL, NULL } 7 7 8 8 #define OWLVAR_BOOL_FULL(name,default,summary,description,validate,set,get) \ 9 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, "on,off", g_strdup(summary), g_strdup(description), NULL, \9 { g_strdup(name), OWL_VARIABLE_BOOL, NULL, default, g_strdup("on,off"), g_strdup(summary), g_strdup(description), NULL, \ 10 10 validate, set, NULL, get, NULL, NULL } 11 11 12 12 #define OWLVAR_INT(name,default,summary,description) \ 13 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, "<int>", g_strdup(summary), g_strdup(description), NULL, \13 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, g_strdup("<int>"), g_strdup(summary), g_strdup(description), NULL, \ 14 14 NULL, NULL, NULL, NULL, NULL, NULL } 15 15 16 16 #define OWLVAR_INT_FULL(name,default,summary,description,validset,validate,set,get) \ 17 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \17 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, g_strdup(validset), g_strdup(summary), g_strdup(description), NULL, \ 18 18 validate, set, NULL, get, NULL, NULL } 19 19 20 20 #define OWLVAR_PATH(name,default,summary,description) \ 21 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<path>", g_strdup(summary), g_strdup(description), NULL, \21 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, g_strdup("<path>"), g_strdup(summary), g_strdup(description), NULL, \ 22 22 NULL, NULL, NULL, NULL, NULL, NULL } 23 23 24 24 #define OWLVAR_STRING(name,default,summary,description) \ 25 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, "<string>", g_strdup(summary), g_strdup(description), NULL, \25 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, g_strdup("<string>"), g_strdup(summary), g_strdup(description), NULL, \ 26 26 NULL, NULL, NULL, NULL, NULL, NULL } 27 27 28 28 #define OWLVAR_STRING_FULL(name,default,validset,summary,description,validate,set,get) \ 29 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, validset, g_strdup(summary), g_strdup(description), NULL, \29 { g_strdup(name), OWL_VARIABLE_STRING, g_strdup(default), 0, g_strdup(validset), g_strdup(summary), g_strdup(description), NULL, \ 30 30 validate, set, NULL, get, NULL, NULL } 31 31 … … 34 34 * correspond to the values that may be specified. */ 35 35 #define OWLVAR_ENUM(name,default,summary,description,validset) \ 36 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \36 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, g_strdup(validset), g_strdup(summary), g_strdup(description), NULL, \ 37 37 owl_variable_enum_validate, \ 38 38 NULL, owl_variable_enum_set_fromstring, \ … … 41 41 42 42 #define OWLVAR_ENUM_FULL(name,default,summary,description,validset,validate, set, get) \ 43 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, validset, g_strdup(summary), g_strdup(description), NULL, \43 { g_strdup(name), OWL_VARIABLE_INT, NULL, default, g_strdup(validset), g_strdup(summary), g_strdup(description), NULL, \ 44 44 validate, \ 45 45 set, owl_variable_enum_set_fromstring, \ … … 577 577 cur->summary = g_strdup(var->summary); 578 578 cur->description = g_strdup(var->description); 579 cur->validsettings = g_strdup(var->validsettings); 579 580 if (cur->type == OWL_VARIABLE_STRING) 580 581 cur->pval_default = g_strdup(var->pval_default); … … 659 660 var->summary = g_strdup(summary); 660 661 var->description = g_strdup(description); 661 var->validsettings = validsettings;662 var->validsettings = g_strdup(validsettings); 662 663 var->type = type; 663 664 return var; … … 696 697 { 697 698 owl_variable *old = owl_variable_get_var(vd, name); 698 boololdval;699 int oldval; 699 700 if (old && owl_variable_get_type(old) == OWL_VARIABLE_BOOL) 700 701 oldval = owl_variable_get_bool(old); … … 707 708 } 708 709 710 void owl_variable_dict_newvar_enum(owl_vardict *vd, const char *name, const char *summ, const char *desc, int initval, const char *validsettings) 711 { 712 owl_variable *old = owl_variable_get_var(vd, name); 713 int oldval; 714 if (old && owl_variable_get_type(old) == OWL_VARIABLE_INT) 715 oldval = owl_variable_get_int(old); 716 owl_variable *var = owl_variable_newvar(name, summ, desc, validsettings, OWL_VARIABLE_INT); 717 var->ival_default = initval; 718 var->validate_fn = owl_variable_enum_validate; 719 var->set_fromstring_fn = owl_variable_enum_set_fromstring; 720 var->get_tostring_fn = owl_variable_enum_get_tostring; 721 owl_variable_init_defaults(var); 722 if (old && owl_variable_get_type(old) == OWL_VARIABLE_INT) 723 var->set_fn(var, &oldval); 724 owl_variable_dict_add_variable(vd, var); 725 } 726 709 727 void owl_variable_dict_cleanup(owl_vardict *d) 710 728 { … … 722 740 g_free(v->summary); 723 741 g_free(v->description); 742 g_free(v->validsettings); 724 743 if (v->type == OWL_VARIABLE_STRING) 725 744 g_free(v->pval_default);
Note: See TracChangeset
for help on using the changeset viewer.