Subject: | Bad callback example in Inline::C Cookbook |
The Cookbook contains the following example:
###########################
use Inline C;
c_func_1('This is the first line');
c_func_2('This is the second line');
sub perl_sub_1 {
print map "$_\n", @_;
}
__DATA__
__C__
void c_func_1(SV* text) {
c_func_2(text);
}
void c_func_2(SV* text) {
Inline_Stack_Vars;
Inline_Stack_Push(newSVpvf("Plus an extra line"));
Inline_Stack_Done;
perl_call_pv("main::perl_sub_1", 0);
Inline_Stack_Void;
}
###########################
For that to work, I have to repositon the c_func_1() XSub underneath
the c_func_2() XSub - but that's not the problem.
The script does then run as intended, but if we call c_func_1 and
c_func_2 repeatedly in a for loop, then it all goes screwy. In a
nutshell, the Inline Stack macros are not, by themselves, capable of
performing callbacks correctly, and we should replace that example with
an example based on the perlcall documentation.
This should be fixed by the time 0.46_02 is released.
Cheers,
Rob