Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    rbbc31e4 rc42a8d1  
    235235  char *name;
    236236  int   type;  /* OWL_VARIABLE_* */
    237   char *default_str;            /* the default value as a string */
    238   char *validsettings;          /* documentation of valid settings */
     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 */
    239240  char *summary;                /* summary of usage */
    240241  char *description;            /* detailed description */
    241   bool takes_on_off;            /* allow passing on/off in argument-less set/unset */
    242   GClosure *set_fromstring_fn;
     242  void *val;                    /* current value */
     243  int  (*validate_fn)(const struct _owl_variable *v, const void *newval);
     244                                /* returns 1 if newval is valid */
     245  int  (*set_fn)(struct _owl_variable *v, const void *newval);
    243246                                /* 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;
     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);
    249262                                /* 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;
    260                                 /* returns 1 if newval is valid */
    261   GCallback set_fn;
    262                                 /* sets the variable to a value
    263                                  * of the appropriate type.
    264                                  * unless documented, this
    265                                  * should make a copy.
    266                                  * returns 0 on success. */
     263                                 * caller must free the result */
     264  void (*delete_fn)(struct _owl_variable *v);
     265                                /* frees val as needed */
    267266} owl_variable;
    268 
    269267
    270268typedef struct _owl_input {
     
    616614#endif
    617615
    618 /* We have to dynamically bind these ourselves */
    619 extern gboolean (*gvalue_from_sv) (GValue * value, SV * sv);
    620 extern SV * (*sv_from_gvalue) (const GValue * value);
    621 extern GClosure * (*perl_closure_new) (SV * callback, SV * data, gboolean swap);
    622 
    623 
    624616#endif /* INC_BARNOWL_OWL_H */
Note: See TracChangeset for help on using the changeset viewer.