I just found out that I was unable to access elements from a std::list in Perl. After some mails in the users mailing list I figured out that other languages, like Python and Ruby, have accessors and setters for std::list.
My time, and my understanding on the std_list.i file for Perl is not complete, and therefore I just hacked it a little to implement a get method. Together with the size method (already available) it makes it possible to fetch elements from the list.
In the future I might try to implement a method to return the full list as a standard Perl list (not sure how hard that would be). But that or an iterator would be the preferred solutions (I know).
So, for now I would thank if you could accept this patch for the next release (although incomplete).
Thanks
Alberto
patch against r12897
Note that I did not test for built-in types. Sorry.
Meanwhile, added an elements method, that returns a list of elements. It seems to be working, but again, I didn't check the specializations for built-ins.
New patche, with elements method.
Patch fixed. It was a stupid bug.
If you like the idea, I can try to help adding more accessors, but for that I would need some feedback.
Cheers
Fixed patch.
The std_list_i_perl5.patch patch does not apply ... it is nothing like what is in Lib/perl5/std_list.i. Please submit a fixed patch. Also I don't think we'll apply any hacks... any improvements should provide the equivalent to what is in a normal perl like container. You'll have to explain that when you provide the fixed patch.
Well, after one year it would be magic if the patch still apply. :-)
If there are such big differences probably what I need already exists in swig (I do not look into it since February, when I submitted the patch)
Anyway, access on lists by index is an usual Perl idiom.
Will give feedback shortly, I hope (well, less than one year :-))
Cheers
ambs
9 years later, the only patches here don't apply and are a "hack" so I'm going to close this as out-of-date.
Aquick look at
Lib/perl5/std_list.i
suggests this hasn't been addressed since, so a patch would be useful - if anyone cares to come up with one, please open a PR at https://github.com/swig/swig