Changeset eeba011


Ignore:
Timestamp:
Jun 27, 2011, 4:28:49 AM (13 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
f4e857f
Parents:
3dfc083
git-author:
Jason Gross <jgross@mit.edu> (06/27/11 01:53:42)
git-committer:
Jason Gross <jgross@mit.edu> (06/27/11 04:28:49)
Message:
Drop require_type

It's not doing much for us (and would do even less after the next
commit), and dropping it makes owl_variable_dict_newvar_* a bit more
robust.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    r25891a8 reeba011  
    316316
    317317  owl_variable_dict_newvar_string(&vd, "stringvar", "", "", "testval");
    318   FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar", OWL_VARIABLE_STRING)));
     318  FAIL_UNLESS("get new string var", NULL != (v = owl_variable_get(&vd, "stringvar")));
    319319  FAIL_UNLESS("get new string val", !strcmp("testval", owl_variable_get_string(&vd, "stringvar")));
    320320  owl_variable_set_string(&vd, "stringvar", "new val");
     
    322322
    323323  owl_variable_dict_newvar_int(&vd, "intvar", "", "", 47);
    324   FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(&vd, "intvar", OWL_VARIABLE_INT)));
     324  FAIL_UNLESS("get new int var", NULL != (v = owl_variable_get(&vd, "intvar")));
    325325  FAIL_UNLESS("get new int val", 47 == owl_variable_get_int(&vd, "intvar"));
    326326  owl_variable_set_int(&vd, "intvar", 17);
     
    328328
    329329  owl_variable_dict_newvar_bool(&vd, "boolvar", "", "", 1);
    330   FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(&vd, "boolvar", OWL_VARIABLE_BOOL)));
     330  FAIL_UNLESS("get new bool var", NULL != (v = owl_variable_get(&vd, "boolvar")));
    331331  FAIL_UNLESS("get new bool val", owl_variable_get_bool(&vd, "boolvar"));
    332332  owl_variable_set_bool_off(&vd, "boolvar");
  • variable.c

    r3dfc083 reeba011  
    814814}
    815815
    816 owl_variable *owl_variable_get_var(const owl_vardict *d, const char *name, int require_type) {
     816owl_variable *owl_variable_get_var(const owl_vardict *d, const char *name)
     817{
    817818  owl_variable *v;
    818819  if (!name) return(NULL);
    819820  v = owl_dict_find_element(d, name);
    820   if (v == NULL || !v->get_fn || v->type != require_type) return(NULL);
     821  if (v == NULL || !v->get_fn) return NULL;
    821822  return v;
    822823}
    823824
    824825/* returns a reference */
    825 const void *owl_variable_get(const owl_vardict *d, const char *name, int require_type) {
    826   owl_variable *v = owl_variable_get_var(d, name, require_type);
     826const void *owl_variable_get(const owl_vardict *d, const char *name)
     827{
     828  const owl_variable *v = owl_variable_get_var(d, name);
    827829  if(v == NULL) return NULL;
    828830  return v->get_fn(v);
     
    831833/* returns a reference */
    832834const char *owl_variable_get_string(const owl_vardict *d, const char *name) {
    833   return owl_variable_get(d,name, OWL_VARIABLE_STRING);
     835  /* XXX TODO: Put type checking back in */
     836  return owl_variable_get(d, name);
    834837}
    835838
    836839/* returns a reference */
    837840const void *owl_variable_get_other(const owl_vardict *d, const char *name) {
    838   return owl_variable_get(d,name, OWL_VARIABLE_OTHER);
     841  /* XXX TODO: Put type checking back in */
     842  return owl_variable_get(d, name);
    839843}
    840844
    841845int owl_variable_get_int(const owl_vardict *d, const char *name) {
    842   const int *pi;
    843   pi = owl_variable_get(d,name,OWL_VARIABLE_INT);
     846  /* XXX TODO: Put type checking back in */
     847  const int *pi = owl_variable_get(d, name);
    844848  if (!pi) return(-1);
    845849  return(*pi);
     
    847851
    848852int owl_variable_get_bool(const owl_vardict *d, const char *name) {
    849   const int *pi;
    850   pi = owl_variable_get(d,name,OWL_VARIABLE_BOOL);
     853  /* XXX TODO: Put type checking back in */
     854  const int *pi = owl_variable_get(d, name);
    851855  if (!pi) return(-1);
    852856  return(*pi);
Note: See TracChangeset for help on using the changeset viewer.