Changeset 06e04a9 for owl.h


Ignore:
Timestamp:
Feb 19, 2013, 8:28:55 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10
Children:
353719a
Parents:
6a20996
git-author:
Adam Glasgall <adam@crossproduct.net> (07/20/11 00:04:42)
git-committer:
David Benjamin <davidben@mit.edu> (02/19/13 20:28:55)
Message:
perlvariables - iteration N

Later commits reworked a lot of this, but the use of GValue over void*
was kept.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    rc42a8d1 r06e04a9  
    235235  char *name;
    236236  int   type;  /* OWL_VARIABLE_* */
     237  GValue gval_default;
     238  const char *validsettings;    /* documentation of valid settings */
     239  char *summary;                /* summary of usage */
     240  char *description;            /* detailed description */
     241  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. */
     250  GClosure *set_fromstring_fn;
     251                                /* sets the variable to a value
     252                                 * of the appropriate type.
     253                                 * unless documented, this
     254                                 * should make a copy.
     255                                 * returns 0 on success. */
     256  GClosure *get_fn;
     257                                /* returns a reference to the current value.
     258                                 * WARNING:  this approach is hard to make
     259                                 * 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 
     268} owl_variable;
     269
     270typedef struct _owl_variable_init_params {
     271  char *name;
     272  int   type;  /* OWL_VARIABLE_* */
    237273  void *pval_default;  /* for types other and string */
    238274  int   ival_default;  /* for types int and bool     */
     
    241277  char *description;            /* detailed description */
    242278  void *val;                    /* current value */
    243   int  (*validate_fn)(const struct _owl_variable *v, const void *newval);
     279  GCallback validate_fn;
    244280                                /* returns 1 if newval is valid */
    245   int  (*set_fn)(struct _owl_variable *v, const void *newval);
     281  GCallback set_fn;
    246282                                /* sets the variable to a value
    247283                                 * of the appropriate type.
     
    249285                                 * should make a copy.
    250286                                 * returns 0 on success. */
    251   int  (*set_fromstring_fn)(struct _owl_variable *v, const char *newval);
     287  GCallback set_fromstring_fn;
    252288                                /* sets the variable to a value
    253289                                 * of the appropriate type.
     
    255291                                 * should make a copy.
    256292                                 * returns 0 on success. */
    257   const void *(*get_fn)(const struct _owl_variable *v);
     293  GCallback get_fn;
    258294                                /* returns a reference to the current value.
    259295                                 * WARNING:  this approach is hard to make
    260296                                 * thread-safe... */
    261   CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
     297  GCallback get_tostring_fn;
    262298                                /* converts val to a string;
    263299                                 * caller must free the result */
    264   void (*delete_fn)(struct _owl_variable *v);
     300  GCallback delete_fn;
    265301                                /* frees val as needed */
    266 } owl_variable;
     302  GCallback get_default_fn;
     303                                /* return the default value as set at creation time */
     304} owl_variable_init_params;
     305
    267306
    268307typedef struct _owl_input {
     
    614653#endif
    615654
     655/* We have to dynamically bind these ourselves */
     656extern gboolean (*gvalue_from_sv) (GValue * value, SV * sv);
     657extern SV * (*sv_from_gvalue) (const GValue * value);
     658extern GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap);
     659
     660
    616661#endif /* INC_BARNOWL_OWL_H */
Note: See TracChangeset for help on using the changeset viewer.