logo       

Teaching swig about arrays of structs within a struct?: msg#00076

programming.swig

Subject: Teaching swig about arrays of structs within a struct?

I have a swigged struct looking like:

typedef struct { int i; } A;
typedef struct { A *a; } B; // actually an array of (say) size 5

A *A_alloc();
B *B_alloc();

I can %extend the type B as

%extend B {
A *get_a(int i) { return self->a[i]; }
}

and (in python) talk about
b = B_alloc()
a = b.get_a(2)
to get (in C-speak) b->a[2].

What I haven't figured out how to do is to be able to say
a = b.a[2]
as this merely subscripts b.a, which it thinks is a string. Ideas?

This is using swig 1.3.22. While I'm writing, thanks for the updated
documentation.

R

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise