Chapter 10
Next, the Inline_Stack_Vars macro is used to initialize temporaries for the
Inline::C stack macros:
Inline_Stack_Vars;
The next new macro usage is the pair Inline_Stack_Reset and Inline_Stack_Done.
These are required around any usage of Inline_Stack_Push. These macros push the list
of key/value pairs onto the return stack:
// get ready for Inline_Stack_Push
Inline_Stack_Reset;
// loop over key/value pairs
for (i = 1; i <= count; i++) {
value = hv_iternextsv(hv, &key, &len);
// push key and value
Inline_Stack_Push(sv_2mortal(newSVpvn(key, len)));
Inline_Stack_Push(sv_mortalcopy(value));
}
// done pushing on the stack
Inline_Stack_Done;
Then Inline::C's version of XSRETURN, Inline_Stack_Return, is used to return from the
function:
// return two SVs for each key in the hash
Inline_Stack_Return(count * 2);
A similar sequence is used in scalar context to return a single value:
// G_SCALAR or G_VOID context return a reference to the new hash
Inline_Stack_Reset;
Inline_Stack_Push(sv_2mortal(newRV_noinc((SV *)hv)));
Inline_Stack_Done;
Inline_Stack_Return(1);
This marks a difference from the XS code where the final XSRETURN(1) wasn't
required; in Inline::C Inline_Stack_Return is a required call regardless of the
number of return values.
250
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved