[PyQt] [SIP] sip and template

Kermit stef.kermit at gmail.com
Fri Feb 11 13:04:46 GMT 2011


hi,

since my last post, i've lot difficult to implement a "simple" binding with
sip

i try to bind the good ilmBase librairy.
i extract a exemple with error with sip

// ________________________C+++ File ________________________
#ifndef INCLUDED_IMATHVEC_H
#define INCLUDED_IMATHVEC_H

namespace Imath {
template <class T> class Vec2;

template <class T> class Vec2
{
  public:

    T x, y;

    T & operator [] (int i);
    const T & operator [] (int i) const;

    Vec2 ();                        // no initialization
    explicit Vec2 (T a);            // (a a)
    Vec2 (T a, T b);                // (a b)
// Base type -- in templates
typedef T BaseType;
};

// Typedefs for convenience
typedef Vec2 <int>    V2i;
typedef Vec2 <float>  V2f;
typedef Vec2 <double> V2d;

} // namespace Imath

#endif

// ________________________Sip  File ________________________
%Module KitCG 0

%UnitPostIncludeCode
namespace Imath {};
using namespace Imath;
%End

template<TYPE>
class Vec2
{
%TypeHeaderCode
#include "ImathVec.h"
%End
  public:
    TYPE x;
TYPE y;
// For info, TYPE x,y;  or mmore simple float x,y; generate a sip error

    TYPE & operator [] (int i);
    const TYPE & operator [] (int i) const;


    //-------------
    // Constructors
    //-------------

    Vec2 ();                        // no initialization
    explicit Vec2 (TYPE a);            // (a a)
    Vec2 (TYPE a, TYPE b);                // (a b)
 // Base type -- in templates
    typedef TYPE BaseType;
};


with this code, i've "sip: TYPE is undefined" error message

i read qlist.sip, but i understand is a converion between a QList in C++ and
python list

in my case, i want a v2f, v2d python object

thx for your help

Kermit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110211/df612b6b/attachment.html>


More information about the PyQt mailing list