/me just answers the prototype question ...
XS essentially boils down to two parts. The real C code that is littered with macros, which you are now writing, and a part that is preprocessed when converting XS files to C. The latter part might look like this:
MODULE = TEST PACKAGE = main long mktime (sec, min, hr, day, mon, yr) int sec int min int hr int day int mon int yr PROTOTYPE: $$$$$$ CODE: struct tm ltm; ltm.tm_sec = sec; ltm.tm_min = min; ltm.tm_hour = hr; ltm.tm_mday = day; ltm.tm_mon = mon; ltm.tm_year = yr; ltm.tm_wday = 0; ltm.tm_yday = 0; ltm.tm_isdst = 0; RETVAL = mktime (<m); OUTPUT: RETVAL
Which will be translated to something like
XS(XS_main_mktime); /* prototype to pass -Wmissing-prototypes */ XS(XS_main_mktime) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items != 6) croak_xs_usage(cv, "sec, min, hr, day, mon, yr"); { int sec = (int)SvIV(ST(0)); int min = (int)SvIV(ST(1)); int hr = (int)SvIV(ST(2)); int day = (int)SvIV(ST(3)); int mon = (int)SvIV(ST(4)); int yr = (int)SvIV(ST(5)); long RETVAL; dXSTARG; #line 122 "TEST.xs" struct tm ltm; ltm.tm_sec = sec; ltm.tm_min = min; ltm.tm_hour = hr; ltm.tm_mday = day; ltm.tm_mon = mon; ltm.tm_year = yr; ltm.tm_wday = 0; ltm.tm_yday = 0; ltm.tm_isdst = 0; RETVAL = mktime (<m); #line 239 "TEST.c" XSprePUSH; PUSHi((IV)RETVAL); } XSRETURN(1); } : : #ifdef __cplusplus extern "C" #endif XS(boot_TEST); /* prototype to pass -Wmissing-prototypes */ XS(boot_TEST) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif #if (PERL_REVISION == 5 && PERL_VERSION < 9) char* file = __FILE__; #else const char* file = __FILE__; #endif PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ XS_VERSION_BOOTCHECK ; (void)newXSproto_portable("main::mktime", XS_main_mktime, file +, "$$$$$$"); #if (PERL_REVISION == 5 && PERL_VERSION >= 9) if (PL_unitcheckav) call_list(PL_scopestack_ix, PL_unitcheckav); #endif XSRETURN_YES; }
The code to call to set the prototype is newXSproto_portable (), but I don't know if you can be in time to do so in Inline::C.
In reply to Re: Help me improve my XS.
by Tux
in thread Help me improve my XS.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |