logo       

Typedefs of template instantiations not recognized properly?: msg#00119

programming.swig

Subject: Typedefs of template instantiations not recognized properly?

The typedef resolution mechanism seems (in my hands) to play poorly with namespaces and/or the template mechanism.

I've got a SWIG interface similar to:
----------------

namespace A {
struct OpaqueStruct;
typedef struct OpaqueStruct OpaqueType;
typedef std::vector<OpaqueType> OpaqueVectorType;

void FillVector(OpaqueVectorType);
}

%template(OpaqueVectorType) std::vector<A::OpaqueType>;

----------------

Now, when I use the wrapper as follows:
>>> vec = SwigModule.OpaqueVectorType()
>>> SwigModule.FillVector(vec)

I get the following error:
Type error. Got _p_std__vectorTA__OpaqueType_t, expected _p_A__OpaqueVectorType

That is, the wrapper code doesn't realize that std::vector<OpaqueType> and A::OpaqueVectorType are the same thing!

I can't really figure out if the problem is due to the template mechanism, the typedef mechanism, or throwing namespaces into the mix. (It doesn't matter whether the %template line is above or below the namespace definition.)

Any thoughts? Is this a known issue? Am I just doing something wrong?
Basically, is there anything I can do, short or find/replace on the interface files to get rid of the need for the typedefs?

Thanks,

Zach Pincus

Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine

_______________________________________________
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