David Goldsmith | 1 Nov 05:00 2008
Picon

Current state of C++ and numpy array <=> std::array "support"

Hi, folks.  I see in the SWIG News that the Summer of Code resulted in some increase in SWIG's "support" of C++;
have these additions been incorporated into 1.3.36?  Are there still "holes," or is it fair to say that SWIG
now fully supports C++?  Also, what's the status of conversion, via SWIG, back and forth between numpy
arrays and C++ STL std::arrays?  Thanks!

DG 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
William S Fulton | 1 Nov 10:21 2008
Picon

Re: Current approach with returning multi-dimensional arrays from C to Java via pointers

I don't think this is a common api and there are no standard typemaps to 
deal these types. You could adapt the StringBuffer typemaps in this 
patch: 
http://sourceforge.net/tracker/index.php?func=detail&aid=1123777&group_id=1645&atid=301645 
or adapt the char* typemap example from Examples/java/typemap. There are 
various 1D array solutions in the documentation. For pointer to pointer 
typemaps, I suggest you take one of the 1D array solutions and modify 
the typemaps for your desired 2D arrays. In summary I'm afraid you are 
going to have to learn how to write some typemaps for your needs.

William

Rob Ratcliff wrote:
> My question is an orphan of 3 weeks now. :-(
>
> Did anybody have any comments on how they're doing this kind of thing
> with Java?
>
> Rob Ratcliff wrote:
> > Hi,
> >
> > I've been reading through the mailing list, documentation and examples
> > to see how to best map functions like this:
> >
> > void get_stringArray (char ***rlist, long *imax);
> >
> > void get_doubleArray (double  **data, long *imax);
> >
> > void get_double2DArray (double  ***data, long *imax, long **jmax );
> >
(Continue reading)

William S Fulton | 1 Nov 10:26 2008
Picon

Re: When was the -MF flag added to swig

J. Davison de St. Germain wrote:
> Hi,
> 
>    Can someone tell me when (at which version) the -MF flag was added to 
> the swig executable?  I looked at the docs and as far as I can tell the 
> "-MF" flag is not a swig option, even though (some) "swig -help" says it 
> is.  Any help and/or pointers is most appreciated.
> 
It was added in swig-1.3.23 as recorded in the CHANGES file. The 
documentation does not contain the full list of options and you are best 
off running swig -help, as suggested in the documentation :).

William

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
William S Fulton | 1 Nov 10:30 2008
Picon

Re: using SWIG to generate JNI for netCDF-4, which depends on HDF5...

Ed Hartnett wrote:
> Howdy all!
> 
> I am a maintainer of a a free software package for storing scientific
> data called netCDF. It's a popular C-based library (and has been for
> almost 20 years.)
> 
> I am trying to create a JNI of netCDF-4, the latest major upgrade,
> which came out last June. It uses another library called HDF5.
> 
> In producing a JNI I am using a very simple .i file:
> 
>  %module netcdf
>  %{
>  /* Includes the header in the wrapper code */
>  #include "netcdf.h"
>  #include <hdf5.h>
>  %}
>  
>  /* Parse the header file to generate wrappers */
>  %include "netcdf.h"
>  %include <hdf5.h>
> 
> Swig produces the wrapper code:
> swig -I/shecky/local/include -java netcdf.i
> 
> I have a small program which loads the library:
> // main.java
> 
> public class main {
(Continue reading)

Rob Ratcliff | 1 Nov 21:15 2008

Re: Current approach with returning multi-dimensional arrays from C to Java via pointers

Thanks for the "pointers" William! I missed seeing the examples
directory. I'll send the solution out to the list if I get there soon.

William S Fulton wrote:
> I don't think this is a common api and there are no standard typemaps
> to deal these types. You could adapt the StringBuffer typemaps in this
> patch:
> http://sourceforge.net/tracker/index.php?func=detail&aid=1123777&group_id=1645&atid=301645
> or adapt the char* typemap example from Examples/java/typemap. There
> are various 1D array solutions in the documentation. For pointer to
> pointer typemaps, I suggest you take one of the 1D array solutions and
> modify the typemaps for your desired 2D arrays. In summary I'm afraid
> you are going to have to learn how to write some typemaps for your needs.
>
> William

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
William S Fulton | 1 Nov 22:11 2008
Picon

Re: Problem with template class

Mark Elston wrote:
> My setup:  SWIG 1.3.36; Windows.
> 
> I have a header file that has several template classes defined
> in it that I need to include in my processing.  Unfortunately,
> one of the first is causing a lot of trouble for me.  It looks
> like this:
> 
> template <class F, class B>
> class XXX {
> private:
>     //! actual body area which has enough area to store F and B
>     mutable char body[sizeof(F) > sizeof(B) ? sizeof(F) : sizeof(B)];
>   ...
> };
> 
> The body declaration is causing SWIG to barf on the file.
> 
> My first inclination was to try to %ignore the whole class with:
> 
>    %ignore template <class F, class B> class XXX;
> 
> but that didn't work.  It gives an error:
> 
>    MyMod.i(45): Error: Syntax error in input(1).
> 
> Oddly enough the line of the error is 2 lines *before* the
> %ignore directive.  If I comment out the directive then there
> is no error.  It is *always* 2 lines before the directive no
> matter where I place the directive, so SWIG is becoming confused
(Continue reading)

William S Fulton | 1 Nov 22:24 2008
Picon

Re: Namespaces and includes

Here is a fixed version:

%{
   // My C++ code
   namespace MyNS
   {
     template<class T>
       class MyTemplate
       {
         // ...
       };
     typedef MyTemplate<float> MyFloatTemplate;
   }

   // Another C++ code
   namespace MyNS
   {
     class MyClass
     {
       MyFloatTemplate var;

     };
   }
%}

// My SWIG interface
namespace MyNS
{
   template<class Real>
     class MyTemplate
(Continue reading)

William S Fulton | 1 Nov 22:43 2008
Picon

Re: Derived use of std::vector

Gerwin de Haan wrote:
> Dear list,
> 
> For a while I have been working on SWIG wrappings for the
> OpenSceneGraph graphics library. In a newer revision of this library,
> some functionality involving std::vector was changed (a MixinVector
> class was introduced which mimics the interface of std::vector).
> Question in short: Does anyone have experience in wrapping classes
> that "derive" from std::vector (or classes with similiar style)?  Can
> I apply "macros" that are used to wrap std_vector.i on other/derived
> classes directly?
> If this triggers anything, please read on for an extended description
> of my problem.
> 
> 
> 
> Before, I was happily using the std_vector.i constructions to allow
> direct access to std::vector types, e.g. I could use arrays of the
> Vec2 type:
> 
> --- osg C++ ---
> template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>
> class TemplateArray : public Array, public std::vector<T>
> {...}
> --- SWIG ---
> %template(vectorVec2)     std::vector<osg::Vec2>;
> %template(Vec2Array)
> osg::TemplateArray<osg::Vec2,osg::Array::Vec2ArrayType,2,GL_FLOAT>;
> --- Python ---
> v2a = osg.Vec2Array()
(Continue reading)

William S Fulton | 1 Nov 22:48 2008
Picon

Re: SWIG's first summer of code

Hendrik Maryns wrote:
> Hendrik Maryns schreef:
>> William S Fulton schreef:
>>> Cheryl Foil has added an interesting feature to improve code 
>>> documentation in the target language. This works when C/C++ code is 
>>> documented using the industry standard Doxygen tool for annotating 
>>> methods, classes, variables etc. The new feature extracts the Doxygen 
>>> comments from the code for use by one of the many target languages. 
>>> Cheryl has added initial support for Java so that the Doxygen comments 
>>> are turned into JavaDoc comments embedded into the generated Java 
>>> wrappers, see 
>>> http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-cherylfoil/Doc/Manual/Doxygen.html
>> Cool!
> 
> But see attached patch (I hope that works here).
> 

Thanks applied.

William

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
William S Fulton | 1 Nov 22:56 2008
Picon

Re: Python operators

  Geoffrey Philbrick wrote:
> When SWIG wraps the equality operator, it only allows objects of the 
> same type to compared; otherwise you get an error like this:
> 
>  
> 
>  >>> Color(1,2,3) == None
> 
> Traceback (most recent call last):
> 
>   File "<stdin>", line 1, in <module>
> 
>   File "/sw/coreex/008-geoffp-01/cppCircle.py", line 1488, in __eq__
> 
>     return _cppCircle.Color___eq__(*args)
> 
> ValueError: invalid null reference in method 'Color___eq__', argument 2 
> of type 'Color const &'
> 
>  
> 
> A fix posted on the Internet is to use this code in the interface file:
> 
>  
> 
> %feature("pythonprepend") operator== %{
>         if not isinstance(args[1], type(args[0])):
>             return False
> %}
> 
(Continue reading)


Gmane