svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22875:22935
[blender.git] / source / gameengine / Ketsji / KX_PolyProxy.cpp
index 66457f46deb5e81fb2f23dcc0a0f6ad232dbd8fc..af8e0510a112f09cbbe0a918c7b1ad31ad8c1977 100644 (file)
 #include "KX_PyMath.h"
 
 PyTypeObject KX_PolyProxy::Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
        PyVarObject_HEAD_INIT(NULL, 0)
-#else
-       /* python 2.5 and below */
-       PyObject_HEAD_INIT( NULL )  /* required py macro */
-       0,                          /* ob_size */
-#endif
        "KX_PolyProxy",
        sizeof(PyObjectPlus_Proxy),
        0,
@@ -55,18 +49,15 @@ PyTypeObject KX_PolyProxy::Type = {
        0,
        0,
        py_base_repr,
-       0,0,0,0,0,0,
-       py_base_getattro,
-       py_base_setattro,
        0,0,0,0,0,0,0,0,0,
-       Methods
-};
-
-PyParentObject KX_PolyProxy::Parents[] = {
-       &KX_PolyProxy::Type,
+       Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+       0,0,0,0,0,0,0,
+       Methods,
+       0,
+       0,
        &CValue::Type,
-       &PyObjectPlus::Type,
-       NULL
+       0,0,0,0,0,0,
+       py_base_new
 };
 
 PyMethodDef KX_PolyProxy::Methods[] = {
@@ -98,16 +89,17 @@ PyAttributeDef KX_PolyProxy::Attributes[] = {
        { NULL }        //Sentinel
 };
 
+#if 0
 PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
 {
-       char *attr_str= PyString_AsString(attr);
+       char *attr_str= _PyUnicode_AsString(attr);
        if (!strcmp(attr_str, "matname"))
        {
-               return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
+               return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
        }
        if (!strcmp(attr_str, "texture"))
        {
-               return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
+               return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
        }
        if (!strcmp(attr_str, "material"))
        {
@@ -136,38 +128,35 @@ PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
                                // found it
                                break;
                }
-               return PyInt_FromLong(matid);
+               return PyLong_FromSsize_t(matid);
        }
        if (!strcmp(attr_str, "v1"))
        {
-               return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 0));
+               return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 0));
        }
        if (!strcmp(attr_str, "v2"))
        {
-               return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 1));
+               return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 1));
        }
        if (!strcmp(attr_str, "v3"))
        {
-               return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, 2));
+               return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 2));
        }
        if (!strcmp(attr_str, "v4"))
        {
-               return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffsetAbs(m_mesh, 3):0));
+               return PyLong_FromSsize_t(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffsetAbs(m_mesh, 3):0));
        }
        if (!strcmp(attr_str, "visible"))
        {
-               return PyInt_FromLong(m_polygon->IsVisible());
+               return PyLong_FromSsize_t(m_polygon->IsVisible());
        }
        if (!strcmp(attr_str, "collide"))
        {
-               return PyInt_FromLong(m_polygon->IsCollider());
+               return PyLong_FromSsize_t(m_polygon->IsCollider());
        }
-       py_getattro_up(CValue);
-}
-
-PyObject* KX_PolyProxy::py_getattro_dict() {
-       py_getattro_dict_up(CValue);
+       // py_getattro_up(CValue); // XXX -- todo, make all these attributes
 }
+#endif
 
 KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
 :      m_polygon(polygon),
@@ -204,37 +193,37 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
                        // found it
                        break;
        }
-       return PyInt_FromLong(matid);
+       return PyLong_FromSsize_t(matid);
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getNumVertex,
 "getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
 {
-       return PyInt_FromLong(m_polygon->VertexCount());
+       return PyLong_FromSsize_t(m_polygon->VertexCount());
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isVisible,
 "isVisible() : returns whether the polygon is visible or not\n")
 {
-       return PyInt_FromLong(m_polygon->IsVisible());
+       return PyLong_FromSsize_t(m_polygon->IsVisible());
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, isCollider,
 "isCollider() : returns whether the polygon is receives collision or not\n")
 {
-       return PyInt_FromLong(m_polygon->IsCollider());
+       return PyLong_FromSsize_t(m_polygon->IsCollider());
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialName,
 "getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n")
 {
-       return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
+       return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getTextureName,
 "getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n")
 {
-       return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
+       return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
 }
 
 KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
@@ -255,9 +244,9 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
        }
        if (index < m_polygon->VertexCount())
        {
-               return PyInt_FromLong(m_polygon->GetVertexOffsetAbs(m_mesh, index));
+               return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, index));
        }
-       return PyInt_FromLong(0);
+       return PyLong_FromSsize_t(0);
 }
 
 KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMesh,