Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    rc42a8d1 rbbc31e4  
    235235  char *name;
    236236  int   type;  /* OWL_VARIABLE_* */
    237   void *pval_default;  /* for types other and string */
    238   int   ival_default;  /* for types int and bool     */
    239   const char *validsettings;    /* documentation of valid settings */
     237  char *default_str;            /* the default value as a string */
     238  char *validsettings;          /* documentation of valid settings */
    240239  char *summary;                /* summary of usage */
    241240  char *description;            /* detailed description */
    242   void *val;                    /* current value */
    243   int  (*validate_fn)(const struct _owl_variable *v, const void *newval);
     241  bool takes_on_off;            /* allow passing on/off in argument-less set/unset */
     242  GClosure *set_fromstring_fn;
     243                                /* sets the variable to a value
     244                                 * of the appropriate type.
     245                                 * unless documented, this
     246                                 * should make a copy.
     247                                 * returns 0 on success. */
     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  GValue val;                   /* current value, if default get_fn/set_fn */
     254
     255  GCallback get_fn;
     256                                /* returns a reference to the current value.
     257                                 * WARNING:  this approach is hard to make
     258                                 * thread-safe... */
     259  GCallback validate_fn;
    244260                                /* returns 1 if newval is valid */
    245   int  (*set_fn)(struct _owl_variable *v, const void *newval);
     261  GCallback set_fn;
    246262                                /* sets the variable to a value
    247                                  * of the appropriate type.
    248                                  * unless documented, this
    249                                  * should make a copy.
    250                                  * returns 0 on success. */
    251   int  (*set_fromstring_fn)(struct _owl_variable *v, const char *newval);
    252                                 /* sets the variable to a value
    253                                  * of the appropriate type.
    254                                  * unless documented, this
    255                                  * should make a copy.
    256                                  * returns 0 on success. */
    257   const void *(*get_fn)(const struct _owl_variable *v);
    258                                 /* returns a reference to the current value.
    259                                  * WARNING:  this approach is hard to make
    260                                  * thread-safe... */
    261   CALLER_OWN char *(*get_tostring_fn)(const struct _owl_variable *v, const void *val);
    262                                 /* converts val to a string;
    263                                  * caller must free the result */
    264   void (*delete_fn)(struct _owl_variable *v);
    265                                 /* frees val as needed */
     263                                 * of the appropriate type.
     264                                 * unless documented, this
     265                                 * should make a copy.
     266                                 * returns 0 on success. */
    266267} owl_variable;
     268
    267269
    268270typedef struct _owl_input {
     
    614616#endif
    615617
     618/* We have to dynamically bind these ourselves */
     619extern gboolean (*gvalue_from_sv) (GValue * value, SV * sv);
     620extern SV * (*sv_from_gvalue) (const GValue * value);
     621extern GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap);
     622
     623
    616624#endif /* INC_BARNOWL_OWL_H */
Note: See TracChangeset for help on using the changeset viewer.