Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlglue.xs

    r374089a r3b9ca71  
    402402           }
    403403
    404 void
    405 new_variable_string(name, ival, summ, desc)
    406         const char * name
    407         const char * ival
    408         const char * summ
    409         const char * desc
    410         CODE:
    411         owl_variable_dict_newvar_string(owl_global_get_vardict(&g),
    412                                         name,
    413                                         summ,
    414                                         desc,
    415                                         ival);
    416 
    417 void
    418 new_variable_int(name, ival, summ, desc)
    419         const char * name
    420         int ival
    421         const char * summ
    422         const char * desc
    423         CODE:
    424         owl_variable_dict_newvar_int(owl_global_get_vardict(&g),
    425                                      name,
    426                                      summ,
    427                                      desc,
    428                                      ival);
    429 
    430 void
    431 new_variable_bool(name, ival, summ, desc)
    432         const char * name
    433         int ival
    434         const char * summ
    435         const char * desc
    436         CODE:
    437         owl_variable_dict_newvar_bool(owl_global_get_vardict(&g),
    438                                       name,
    439                                       summ,
    440                                       desc,
    441                                       ival);
     404
     405MODULE = BarnOwl                PACKAGE = BarnOwl::Internal
     406
     407void
     408new_variable(name, summary, description, validsettings, takes_on_off, get_tostring_fn, set_fromstring_fn, data)
     409    const char *name
     410    const char *summary
     411    const char *description
     412    const char *validsettings
     413    int takes_on_off
     414    SV *get_tostring_fn
     415    SV *set_fromstring_fn
     416    SV *data
     417    CODE:
     418{
     419        /* data is somewhat redundant given we can create closures, but oh
     420         * well. Might be convenient sometimes. */
     421        if(!SV_IS_CODEREF(get_tostring_fn)) {
     422                croak("To-string function must be a coderef!");
     423        }
     424        if(!SV_IS_CODEREF(set_fromstring_fn)) {
     425                croak("From-string function must be a coderef!");
     426        }
     427
     428        owl_variable_dict_newvar_other(owl_global_get_vardict(&g),
     429                                       name, summary, description, validsettings, takes_on_off,
     430                                       perl_closure_new(get_tostring_fn, data, false),
     431                                       perl_closure_new(set_fromstring_fn, data, false));
     432}
    442433
    443434void
Note: See TracChangeset for help on using the changeset viewer.