|
Re: typemap for overloaded contructor: msg#00121programming.swig
> > Sebastian Haase writes: > > > Hi, > > > I get > > > TypeError: No matching function for overloaded 'new_PriismFile' > > > > > > I have these constructors: > > > PriismFile(float *img3DStack, int nx, int ny, int nz); > > > PriismFile(unsigned short *img3DStack, int nx, int ny, int nz); > > > > > > and these typemaps > > > %typemap(python,in) (unsigned short *img3DStack, int nx, int ny, int > nz) > > > <...> > > > %typemap(python,in) (float *img3DStack, int nx, int ny, int nz) > <...> > > > > > > If I comment out any one of the two contructors it recognizes it > fine, > > > but as soon as I have more than one contructor I get the error. > > > > > > > I'm not sure why you are defining typemaps like that. You do realize > > that by defining a typemap in the way shown, you are collapsing all of > > those arguments down so a single scripting language object. Yes? > > In any event, the only way to make overloaded methods work with > > typemaps is to write a bunch of typecheck rules that disambiguate > > arguments. To see how to do that, look at the perl5.swg file in the > > SWIG library. > > I convert (float *img3DStack, int nx, int ny, int nz) into one 3D-numarray > (Numerical Python!) > object representing the whole data stack of size nx x ny x nz. > I am looking at python.swg right now, and I found the "Typechecking rules" > section. > But what is the actual syntax of "%typecheck" ? Is it documented anywhere ? > I was trying : > %typecheck(SWIG_TYPECHECK_SEB_PYARRAY) float * { > $1 = PyArray_Check( $input ) ? 1 : 0; > } > But no success yet. ( SWIG actually complains about a syntax error) > Can I put "(float *img3DStack, int nx, int ny, int nz)" instead of just > "float *" ? sorry for the confusion - this works now: %typecheck(SWIG_TYPECHECK_FLOAT) (float *img3DStack, int nx, int ny, int nz) { $1 = PyArray_Check($input) ? ((PyArrayObject*)$input)->descr->type_num == tFloat32 : 0; } %typecheck(SWIG_TYPECHECK_FLOAT) (unsigned short *img3DStack, int nx, int ny, int nz) { $1 = PyArray_Check($input) ? ((PyArrayObject*)$input)->descr->type_num == tUInt16 : 0; } But still: where can we find some "text" about typecheck ? Thanks so much for your answer - have a great day, Sebastian _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: typemap for overloaded contructor: 00121, Sebastian Haase |
|---|---|
| Next by Date: | Autoconf support suggestion: 00121, Sebastian Huber |
| Previous by Thread: | Re: typemap for overloaded contructori: 00121, Sebastian Haase |
| Next by Thread: | Core dump in SWIG 1.3.17 - (newbie): 00121, Sharma K M |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |