Changeset 69f74c2 for perlglue.xs
- Timestamp:
- Feb 19, 2013, 8:29:34 PM (12 years ago)
- Branches:
- master, release-1.10
- Children:
- 3b9ca71
- Parents:
- e5210c9
- git-author:
- David Benjamin <davidben@mit.edu> (06/09/12 23:05:48)
- git-committer:
- David Benjamin <davidben@mit.edu> (02/19/13 20:29:34)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perlglue.xs
r353719a r69f74c2 405 405 MODULE = BarnOwl PACKAGE = BarnOwl::Internal 406 406 407 /* TODO: Revise this after churn is done. 408 void 409 new_variable_full(name, summary, desc, type, data, default_val, get_fn, get_default_fn, tostring_fn, validate_fn, set_fn, fromstring_fn) 407 void 408 new_variable(name, summary, description, validsettings, get_tostring_fn, set_fromstring_fn, data) 410 409 const char *name 411 410 const char *summary 412 const char *desc 413 int type 411 const char *description 412 const char *validsettings 413 SV *get_tostring_fn 414 SV *set_fromstring_fn 414 415 SV *data 415 SV *default_val416 SV *get_fn417 SV *get_default_fn418 SV *tostring_fn419 SV *validate_fn420 SV *set_fn421 SV *fromstring_fn422 416 CODE: 423 417 { 424 owl_variable *variable = NULL; 425 int count = 0; 426 int res = -1; 427 GClosure *delete_fn = NULL; 428 if(!SV_IS_CODEREF(get_fn)) { 429 croak("Get function must be a coderef!"); 430 } 431 if(!SV_IS_CODEREF(tostring_fn)) { 418 /* data is somewhat redundant given we can create closures, but oh 419 * well. Might be convenient sometimes. */ 420 if(!SV_IS_CODEREF(get_tostring_fn)) { 432 421 croak("To-string function must be a coderef!"); 433 422 } 434 if(!SV_IS_CODEREF(validate_fn)) { 435 croak("Validation function must be a coderef!"); 436 } 437 if(!SV_IS_CODEREF(set_fn)) { 438 croak("Set function must be a coderef!"); 439 } 440 if(!SV_IS_CODEREF(fromstring_fn)) { 423 if(!SV_IS_CODEREF(set_fromstring_fn)) { 441 424 croak("From-string function must be a coderef!"); 442 425 } 443 if(!SV_IS_CODEREF(get_default_fn)) { 444 croak("Get-default function must be a coderef!"); 445 } 446 variable = owl_variable_newvar(name, summary, desc); 447 variable->type = type; 448 variable->get_fn = perl_closure_new(get_fn, data, false); 449 variable->get_tostring_fn = perl_closure_new(tostring_fn, data, false); 450 variable->validate_fn = perl_closure_new(validate_fn, data, false); 451 variable->set_fn = perl_closure_new(set_fn, data, false); 452 variable->set_fromstring_fn = perl_closure_new(set_fn, data, false); 453 variable->get_default_fn = perl_closure_new(get_default_fn, 454 data, false); 455 delete_fn = g_cclosure_new(G_CALLBACK(owl_perl_delete_perl_variable), 456 data, NULL); 457 g_closure_set_marshal(delete_fn,g_cclosure_marshal_VOID__VOID); 458 g_closure_ref(delete_fn); 459 g_closure_sink(delete_fn); 460 variable->delete_fn = delete_fn; 461 462 SvREFCNT_inc(data); 463 464 PUSHMARK(SP); 465 XPUSHs(sv_2mortal(newSViv(PTR2IV(variable)))); 466 XPUSHs(default_val); 467 XPUSHs(data); 468 PUTBACK; 469 count = call_sv(set_fn, G_SCALAR | G_EVAL); 470 SPAGAIN; 471 472 res = POPi; 473 owl_dict_insert_element(owl_global_get_vardict(&g), 474 variable->name, variable, NULL); 475 PUTBACK; 426 427 owl_variable_dict_newvar_other(owl_global_get_vardict(&g), 428 name, summary, description, validsettings, 429 perl_closure_new(get_tostring_fn, data, false), 430 perl_closure_new(set_fromstring_fn, data, false)); 476 431 } 477 */478 479 void480 new_variable_string(name, ival, summ, desc)481 const char * name482 const char * ival483 const char * summ484 const char * desc485 CODE:486 owl_variable_dict_newvar_string(owl_global_get_vardict(&g),487 name,488 summ,489 desc,490 ival);491 492 void493 new_variable_int(name, ival, summ, desc)494 const char * name495 int ival496 const char * summ497 const char * desc498 CODE:499 owl_variable_dict_newvar_int(owl_global_get_vardict(&g),500 name,501 summ,502 desc,503 ival);504 505 void506 new_variable_bool(name, ival, summ, desc)507 const char * name508 int ival509 const char * summ510 const char * desc511 CODE:512 owl_variable_dict_newvar_bool(owl_global_get_vardict(&g),513 name,514 summ,515 desc,516 ival);517 432 518 433 void
Note: See TracChangeset
for help on using the changeset viewer.