Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Dealing with lists with SWIG.

Reply
Thread Tools

Dealing with lists with SWIG.

 
 
Motti Lanzkron
Guest
Posts: n/a
 
      06-23-2004
I'm trying to write a Perl module in C++ and I've downloaded SWIG.
But I'm having trouble finding how to deal with lists. The examples I
see only deal with scalars.

Perl: C++:
------------------------------------
sub foo { 1 } => int foo() { return 1; }
sub bar { (1..10) } => ????

What code do I in C++ write if I want to return a list of integers?
 
Reply With Quote
 
 
 
 
Tassilo v. Parseval
Guest
Posts: n/a
 
      06-23-2004
Also sprach Motti Lanzkron:

> I'm trying to write a Perl module in C++ and I've downloaded SWIG.
> But I'm having trouble finding how to deal with lists. The examples I
> see only deal with scalars.
>
> Perl: C++:
> ------------------------------------
> sub foo { 1 } => int foo() { return 1; }
> sub bar { (1..10) } => ????
>
> What code do I in C++ write if I want to return a list of integers?


I don't know much about SWIG other than that I dropped it after a few
minutes of disgust when I had a look at it a couple of years ago. Does
it help if you know how you'd do it in XS? It would look like:

void
bar ()
CODE:
{
register int i;
EXTEND(SP, 10); /* make room for ten values */

for (i = 0; i < 10; i++) {
ST(i) = sv_newmortal();
sv_setiv(ST(i), i);
}

XSRETURN(10);
}

Maybe you have the time and patience to make yourself acquainted with XS
or Inline::C. It is probably more difficult at the beginning, but it has
advantages on the long run. One advantage is that you can get help much
more easily.

Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus}) !JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexi ixesixeseg;y~\n~~dddd;eval
 
Reply With Quote
 
 
 
 
Motti Lanzkron
Guest
Posts: n/a
 
      06-24-2004
Tassilo v. Parseval wrote:
>Also sprach Motti Lanzkron:
>
>> I'm trying to write a Perl module in C++ and I've downloaded SWIG.
>> But I'm having trouble finding how to deal with lists. The examples I
>> see only deal with scalars.
>>
>> Perl: C++:
>> ------------------------------------
>> sub foo { 1 } => int foo() { return 1; }
>> sub bar { (1..10) } => ????
>>
>> What code do I in C++ write if I want to return a list of integers?

....
>Maybe you have the time and patience to make yourself acquainted with XS
>or Inline::C. It is probably more difficult at the beginning, but it has
>advantages on the long run. One advantage is that you can get help much
>more easily.


Unfortunately I lack the time and patience, I'll just write the whole
thing in C++ (which will probably end up taking more time ;o).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of lists of lists of lists... =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==?= Python 5 05-15-2006 11:47 AM
lists of lists Jon Slaughter C++ 4 12-13-2004 06:28 PM
Lists of Lists VWWall Computer Information 2 10-21-2004 01:15 AM
Counter for items in lists in lists? Charlotte Henkle Python 8 09-26-2004 04:22 AM
Sorting lists of lists... JustSomeGuy C++ 0 06-17-2004 05:44 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57