Changeset 06e04a9 for perlglue.xs
- Timestamp:
- Feb 19, 2013, 8:28:55 PM (12 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perlglue.xs
r374089a r06e04a9 402 402 } 403 403 404 405 MODULE = BarnOwl PACKAGE = BarnOwl::Internal 406 407 void 408 new_variable_full(name, summary, desc, type, data, default_val, get_fn, get_default_fn, tostring_fn, validate_fn, set_fn, fromstring_fn) 409 const char *name 410 const char *summary 411 const char *desc 412 int type 413 SV *data 414 SV *default_val 415 SV *get_fn 416 SV *get_default_fn 417 SV *tostring_fn 418 SV *validate_fn 419 SV *set_fn 420 SV *fromstring_fn 421 CODE: 422 { 423 owl_variable *variable = NULL; 424 int count = 0; 425 int res = -1; 426 GClosure *delete_fn = NULL; 427 if(!SV_IS_CODEREF(get_fn)) { 428 croak("Get function must be a coderef!"); 429 } 430 if(!SV_IS_CODEREF(tostring_fn)) { 431 croak("To-string function must be a coderef!"); 432 } 433 if(!SV_IS_CODEREF(validate_fn)) { 434 croak("Validation function must be a coderef!"); 435 } 436 if(!SV_IS_CODEREF(set_fn)) { 437 croak("Set function must be a coderef!"); 438 } 439 if(!SV_IS_CODEREF(fromstring_fn)) { 440 croak("From-string function must be a coderef!"); 441 } 442 if(!SV_IS_CODEREF(get_default_fn)) { 443 croak("Get-default function must be a coderef!"); 444 } 445 variable = owl_variable_newvar(name, summary, desc); 446 variable->type = type; 447 variable->get_fn = perl_closure_new(get_fn, data, false); 448 variable->get_tostring_fn = perl_closure_new(tostring_fn, data, false); 449 variable->validate_fn = perl_closure_new(validate_fn, data, false); 450 variable->set_fn = perl_closure_new(set_fn, data, false); 451 variable->set_fromstring_fn = perl_closure_new(set_fn, data, false); 452 variable->get_default_fn = perl_closure_new(get_default_fn, 453 data, false); 454 delete_fn = g_cclosure_new(G_CALLBACK(owl_perl_delete_perl_variable), 455 data, NULL); 456 g_closure_set_marshal(delete_fn,g_cclosure_marshal_VOID__VOID); 457 g_closure_ref(delete_fn); 458 g_closure_sink(delete_fn); 459 variable->delete_fn = delete_fn; 460 461 SvREFCNT_inc(data); 462 463 PUSHMARK(SP); 464 XPUSHs(sv_2mortal(newSViv(PTR2IV(variable)))); 465 XPUSHs(default_val); 466 XPUSHs(data); 467 PUTBACK; 468 count = call_sv(set_fn, G_SCALAR | G_EVAL); 469 SPAGAIN; 470 471 res = POPi; 472 owl_dict_insert_element(owl_global_get_vardict(&g), 473 variable->name, variable, NULL); 474 PUTBACK; 475 } 476 404 477 void 405 478 new_variable_string(name, ival, summ, desc)
Note: See TracChangeset
for help on using the changeset viewer.