Regarding that lengty thread about the list context version of the
APR::Table->get/FETCH,
here is what I found....
#!/usr/bin/perl
sub Foo::TIEHASH { return bless {}, 'Foo'; }
sub Foo::get { print ((wantarray()) ? "wantarray\n":"nope\n"); }
*Foo::FETCH = \&Foo::get;
my $foo = bless {}, 'Foo';
tie %foo, 'Foo';
print "TIE=";
@foo = $foo{'test'};
print "METHOD=";
@foo = $foo->get('test');
Gives:
TIE=nope
METHOD=wantarray
Wich doesn't seem right at all ;-(
And the second, more problematic thing is having an XSUB return a list...
Since all the XS wrapper code is automatically generated, using the
return type of the C-function (void or one element), you are always
stuck with a maximum of XSRETURN(1). I've looked around and couldn't
find a way to alter that.. Doug ?
An interesting solution would be to handle a certain function prototype, like
AV *mpxs_apr_table_get(...)
to be XS'ified something like that :
void
apr_table_get(...)
[...]
PREINIT:
AV *retval;
I32 i;
PPCODE:
retval = apr_table_get(...)
for(i=0; i < av_len(retval); i++) {
XPUSHs(av_fetch(retval,i,0));
}
Does this make any sense ? I thought about this mainly because I was searching
around existing code to find a place where a list is returned and couldn't find
one, as most of the apr_* ap_* stuff is C based, this isn't really designed to
return multiple values ;)
So, I figured that something like this would make it relatively simple to implement
any function that wants to return an array in perl context quite simple.
Feedback ?
--
Philippe M. Chiasson <[EMAIL PROTECTED]>
Extropia's Resident System Guru
http://www.eXtropia.com/
Usenet is essentially Letters to the Editor without the
editor. Editors don't appreciate this, for some reason.
-- Larry Wall
perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl
Hacker!\n$/&&print||$$++&&redo}'
PGP signature