Changeset 353719a for owl.h


Ignore:
Timestamp:
Feb 19, 2013, 8:29:04 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10
Children:
5001a3d
Parents:
06e04a9
git-author:
David Benjamin <davidben@mit.edu> (06/09/12 16:07:20)
git-committer:
David Benjamin <davidben@mit.edu> (02/19/13 20:29:04)
Message:
Start of perlvariables iteration N+1

New plan: the C <-> perl interface deals entirely with strings. Storage
is entirely perl-side. C does not know and doesn't care about the
underlying perl-side types. Note that this means an "int" variable in C
land and an "int" variable in perl land have no relation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    r06e04a9 r353719a  
    235235  char *name;
    236236  int   type;  /* OWL_VARIABLE_* */
    237   GValue gval_default;
     237  char *default_str;            /* the default value as a string */
    238238  const char *validsettings;    /* documentation of valid settings */
    239239  char *summary;                /* summary of usage */
    240240  char *description;            /* detailed description */
    241241  GValue val;                    /* current value */
    242   GClosure *validate_fn;
    243                                 /* returns 1 if newval is valid */
    244   GClosure *set_fn;
    245                                 /* sets the variable to a value
    246                                  * of the appropriate type.
    247                                  * unless documented, this
    248                                  * should make a copy.
    249                                  * returns 0 on success. */
    250242  GClosure *set_fromstring_fn;
    251243                                /* sets the variable to a value
     
    254246                                 * should make a copy.
    255247                                 * returns 0 on success. */
    256   GClosure *get_fn;
     248  GClosure *get_tostring_fn;
     249                                /* converts val to a string;
     250                                 * caller must free the result */
     251
     252  /* These are only valid for OWL_VARIABLE_{INT,BOOL,STRING} */
     253  GCallback get_fn;
    257254                                /* returns a reference to the current value.
    258255                                 * WARNING:  this approach is hard to make
    259256                                 * thread-safe... */
    260   GClosure *get_tostring_fn;
    261                                 /* converts val to a string;
    262                                  * caller must free the result */
    263   GClosure *delete_fn;
    264                                 /* frees val as needed */
    265   GClosure *get_default_fn;
    266                                /* return the default value, as set at creation time */
    267  
     257  GCallback validate_fn;
     258                                /* returns 1 if newval is valid */
     259  GCallback set_fn;
     260                                /* sets the variable to a value
     261                                 * of the appropriate type.
     262                                 * unless documented, this
     263                                 * should make a copy.
     264                                 * returns 0 on success. */
    268265} owl_variable;
    269266
    270267typedef struct _owl_variable_init_params {
    271   char *name;
     268  const char *name;
    272269  int   type;  /* OWL_VARIABLE_* */
    273   void *pval_default;  /* for types other and string */
    274   int   ival_default;  /* for types int and bool     */
     270  const char *pval_default;     /* for string */
     271  int   ival_default;           /* for types int and bool     */
    275272  const char *validsettings;    /* documentation of valid settings */
    276   char *summary;                /* summary of usage */
    277   char *description;            /* detailed description */
     273  const char *summary;          /* summary of usage */
     274  const char *description;      /* detailed description */
    278275  void *val;                    /* current value */
    279276  GCallback validate_fn;
     
    298295                                /* converts val to a string;
    299296                                 * caller must free the result */
    300   GCallback delete_fn;
    301                                 /* frees val as needed */
    302   GCallback get_default_fn;
    303                                 /* return the default value as set at creation time */
    304297} owl_variable_init_params;
    305298
Note: See TracChangeset for help on using the changeset viewer.