Changeset ca54fd6 for functions.c


Ignore:
Timestamp:
Jul 3, 2011, 8:42:55 PM (11 years ago)
Author:
Jason Gross <jgross@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
ca749a9
Parents:
bc1d648
git-author:
Jason Gross <jgross@mit.edu> (06/27/11 01:14:13)
git-committer:
Jason Gross <jgross@mit.edu> (07/03/11 20:42:55)
Message:
Pass owl_variable * around instead of owl_vardict *.

This allows (forces) functions to do their own NULL- and type- checking
on variables.  The functions in varsubs.c get less checking, but if
these auto-generated functions are failing, something more serious is
probably wrong.

The owl_variable_get_* functions type-check their arguments, and
owl_function_error if the argument is the wrong type (it's a programmer
error and we should make some noise).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    rb8a3e00 rca54fd6  
    15721572void owl_function_printallvars(void)
    15731573{
     1574  const owl_variable *v;
    15741575  const char *name;
    15751576  char *var;
     
    15851586    if (name && name[0]!='_') {
    15861587      g_string_append_printf(str, "\n%-20s = ", name);
    1587       var = owl_variable_get_tostring(owl_global_get_vardict(&g), name);
     1588      v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1589      var = owl_variable_get_tostring(v);
    15881590      if (var) {
    15891591        g_string_append(str, var);
     
    16011603void owl_function_show_variables(void)
    16021604{
     1605  const owl_variable *v;
    16031606  GPtrArray *varnames;
    16041607  owl_fmtext fm; 
     
    16131616    varname = varnames->pdata[i];
    16141617    if (varname && varname[0]!='_') {
    1615       owl_variable_describe(owl_global_get_vardict(&g), varname, &fm);
     1618      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
     1619      owl_variable_describe(v, &fm);
    16161620    }
    16171621  }
     
    16231627void owl_function_show_variable(const char *name)
    16241628{
     1629  const owl_variable *v;
    16251630  owl_fmtext fm; 
    16261631
    16271632  owl_fmtext_init_null(&fm);
    1628   owl_variable_get_help(owl_global_get_vardict(&g), name, &fm);
     1633  v = owl_variable_get_var(owl_global_get_vardict(&g), name);
     1634  if (v)
     1635    owl_variable_get_help(v, &fm);
     1636  else
     1637    owl_fmtext_append_normal(&fm, "No such variable...\n");
    16291638  owl_function_popless_fmtext(&fm);
    16301639  owl_fmtext_cleanup(&fm);
Note: See TracChangeset for help on using the changeset viewer.