2013-05-05 1 views
2

bullet.pxd:Cython: Недействительные типы операндов для '+' (btVector3; btVector3)

cdef extern from "bullet/LinearMath/btVector3.h": 
    cdef cppclass btVector3: 
     btVector3(float, float, float) except + 
     btVector3 operator+(const btVector3&, const btVector3&) 

btmath.pyx:

cimport bullet as bt 

cdef class Vector: 

    cdef bt.btVector3* _this 

    def __cinit__(self, float x=0, float y=0, float z=0): 

     self._this = new bt.btVector3(x, y, z) 


    def __add__(Vector self, Vector other): 

     vec = Vector() 
     del vec._this 
     vec._this[0] = self._this[0] + other._this[0] 

     return vec 

Прототип оператора + в btVector3.h:

SIMD_FORCE_INLINE btVector3 
operator+(const btVector3& v1, const btVector3& v2); 

Как указано в названии, я получаю «Недопустимые типы операндов для« + »(btVector3; btVector3)». Я предполагаю, что это связано с тем, как Cython имеет дело с переходом по ссылке, может быть?

Любая помощь была бы принята с благодарностью.

ответ

2

Как выясняется, Cython рассматривает «этот» параметр как неявный в этом случае, так bullet.pxd должен выглядеть следующим образом:

cdef extern from "bullet/LinearMath/btVector3.h": 
    cdef cppclass btVector3: 
     btVector3(float, float, float) except + 
     btVector3 operator+(btVector3) 

Большого спасибо Роберт Брэдшоу, помогли мне понять это : https://groups.google.com/forum/#!topic/cython-users/8LtEE_Nvf0o

 Смежные вопросы

  • Нет связанных вопросов^_^