Hey y'all,
Trying to get the hang of this xs stuff and at a hump I can't seem to get over ...
Modifying a passed parameter.
The goal is to return the Int value and modify the passed arg to true or false (pass or fail on the conversion)
MyLib is a stupid simple string class, strToInt() works correctly, both in the return value as well as modifying the passfail value.
However, It does not show the changes in Perl.
The xs code. (with some printf's)
int
MyLib::strToInt(passfail)
bool passfail;
CODE:
if(passfail) {
printf("It's true in xs. %i\n", passfail);
} else {
printf("It's false in xs. %i\n", passfail);
}
RETVAL = THIS->strToInt(&passfail);
if(passfail) {
printf("It's true out xs. %i\n", passfail);
} else {
printf("It's false out xs. %i\n", passfail);
}
OUTPUT:
RETVAL
passfail
The Perl calling code.
my $passfail = 0;
my $tmp = MyLib->new("12");
my $t = $tmp->strToInt(\$passfail);
print "It's $t\n" if $passfail eq 1;
The above code produces the following output:
It's false in xs. 0
It's true out xs. 1
So the xs and C code works
What the blazes am I doing wrong!
Perlxstut makes it look simple ...
Thanks
-Enjoy
fh : )_~
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.