BGE Python API cleanup - no functionality changes
[blender.git] / source / gameengine / Ketsji / KX_ConstraintWrapper.cpp
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29 #include <Python.h>
30 #include "PyObjectPlus.h"
31 #include "KX_ConstraintWrapper.h"
32 #include "PHY_IPhysicsEnvironment.h"
33
34 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #endif
37
38 KX_ConstraintWrapper::KX_ConstraintWrapper(
39                                                 PHY_ConstraintType ctype,
40                                                 int constraintId,
41                                                 PHY_IPhysicsEnvironment* physenv,PyTypeObject *T) :
42                 PyObjectPlus(T),
43                 m_constraintId(constraintId),
44                 m_constraintType(ctype),
45                 m_physenv(physenv)
46 {
47 }
48 KX_ConstraintWrapper::~KX_ConstraintWrapper()
49 {
50 }
51 //python integration methods
52 PyObject* KX_ConstraintWrapper::PyTestMethod(PyObject* self, 
53                                                                                         PyObject* args, 
54                                                                                         PyObject* kwds)
55 {
56         
57         Py_RETURN_NONE;
58 }
59
60 PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self, 
61                                                                                         PyObject* args, 
62                                                                                         PyObject* kwds)
63 {
64         return PyInt_FromLong(m_constraintId);
65 }
66
67
68
69
70 //python specific stuff
71 PyTypeObject KX_ConstraintWrapper::Type = {
72         PyObject_HEAD_INIT(NULL)
73                 0,
74                 "KX_ConstraintWrapper",
75                 sizeof(PyObjectPlus_Proxy),
76                 0,
77                 py_base_dealloc,
78                 0,
79                 0,
80                 0,
81                 0,
82                 py_base_repr,
83                 0,0,0,0,0,0,
84                 py_base_getattro,
85                 py_base_setattro,
86                 0,0,0,0,0,0,0,0,0,
87                 Methods
88 };
89
90 PyParentObject KX_ConstraintWrapper::Parents[] = {
91         &KX_ConstraintWrapper::Type,
92         NULL
93 };
94
95 PyObject*       KX_ConstraintWrapper::py_getattro(PyObject *attr)
96 {
97         //here you can search for existing data members (like mass,friction etc.)
98         py_getattro_up(PyObjectPlus);
99 }
100
101 int     KX_ConstraintWrapper::py_setattro(PyObject *attr,PyObject* pyobj)
102 {
103         int result = 1;
104         /* what the heck is this supposed to do?, needs attention */
105         if (PyList_Check(pyobj))
106         {
107                 result = 0;
108         }
109         if (PyFloat_Check(pyobj))
110         {
111                 result = 0;
112
113         }
114         if (PyInt_Check(pyobj))
115         {
116                 result = 0;
117         }
118         if (PyString_Check(pyobj))
119         {
120                 result = 0;
121         }
122         if (result)
123                 result = PyObjectPlus::py_setattro(attr,pyobj);
124         return result;
125 };
126
127
128 PyMethodDef KX_ConstraintWrapper::Methods[] = {
129         {"testMethod",(PyCFunction) KX_ConstraintWrapper::sPyTestMethod, METH_VARARGS},
130         {"getConstraintId",(PyCFunction) KX_ConstraintWrapper::sPyGetConstraintId, METH_VARARGS},
131         {NULL,NULL} //Sentinel
132 };
133
134 PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
135         { NULL }        //Sentinel
136 };