| 
									
										
										
										
											2011-02-22 10:33:14 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): none yet. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-04-16 22:40:48 +00:00
										 |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2002-11-25 11:16:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-22 10:33:14 +00:00
										 |  |  | /** \file PyObjectPlus.h
 | 
					
						
							|  |  |  |  *  \ingroup expressions | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-23 10:41:31 +00:00
										 |  |  | #ifndef __PYOBJECTPLUS_H__
 | 
					
						
							|  |  |  | #define __PYOBJECTPLUS_H__
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-25 14:32:35 +00:00
										 |  |  | /* for now keep weakrefs optional */ | 
					
						
							|  |  |  | #define USE_WEAKREFS
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef __cplusplus				// c++ only
 | 
					
						
							|  |  |  | #error Must be compiled with C++
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "KX_Python.h"
 | 
					
						
							| 
									
										
										
										
											2004-05-16 13:05:15 +00:00
										 |  |  | #include "STR_String.h"
 | 
					
						
							| 
									
										
										
										
											2009-05-11 12:41:48 +00:00
										 |  |  | #include "MT_Vector3.h"
 | 
					
						
							| 
									
										
										
										
											2009-05-10 20:53:58 +00:00
										 |  |  | #include "SG_QList.h"
 | 
					
						
							| 
									
										
										
										
											2011-03-30 16:14:54 +00:00
										 |  |  | #include <stddef.h>
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-31 04:11:39 +00:00
										 |  |  | #ifdef WITH_PYTHON
 | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | #ifdef USE_MATHUTILS
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							| 
									
										
										
										
											2011-07-15 04:01:47 +00:00
										 |  |  | #include "../../blender/python/mathutils/mathutils.h" /* so we can have mathutils callbacks */
 | 
					
						
							| 
									
										
										
										
											2011-07-22 11:21:01 +00:00
										 |  |  | #include "../../blender/python/generic/py_capi_utils.h" /* for PyC_LineSpit only */
 | 
					
						
							| 
									
										
										
										
											2009-06-25 10:11:37 +00:00
										 |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-05-07 05:23:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-16 05:27:11 +00:00
										 |  |  | #define MAX_PROP_NAME 64
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 08:55:54 +00:00
										 |  |  | /* Use with ShowDeprecationWarning macro */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	bool warn_done; | 
					
						
							|  |  |  | 	void *link; | 
					
						
							|  |  |  | } WarnLink; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 05:44:52 +00:00
										 |  |  | #define ShowDeprecationWarning(old_way, new_way)                              \
 | 
					
						
							|  |  |  | {                                                                             \ | 
					
						
							|  |  |  | 	static WarnLink wlink = {false, NULL};                                    \ | 
					
						
							|  |  |  | 	if ((m_ignore_deprecation_warnings || wlink.warn_done)==0)                \ | 
					
						
							|  |  |  | 	{                                                                         \ | 
					
						
							|  |  |  | 		ShowDeprecationWarning_func(old_way, new_way);                        \ | 
					
						
							|  |  |  | 		                                                                      \ | 
					
						
							|  |  |  | 		WarnLink *wlink_last= GetDeprecationWarningLinkLast();                \ | 
					
						
							|  |  |  | 		wlink.warn_done = true;                                               \ | 
					
						
							|  |  |  | 		wlink.link = NULL;                                                    \ | 
					
						
							|  |  |  | 		                                                                      \ | 
					
						
							|  |  |  | 		if(wlink_last) {                                                      \ | 
					
						
							|  |  |  | 			wlink_last->link= (void *)&(wlink);                               \ | 
					
						
							|  |  |  | 			SetDeprecationWarningLinkLast(&(wlink));                          \ | 
					
						
							|  |  |  | 		}                                                                     \ | 
					
						
							|  |  |  | 		else {                                                                \ | 
					
						
							|  |  |  | 			SetDeprecationWarningFirst(&(wlink));                             \ | 
					
						
							|  |  |  | 			SetDeprecationWarningLinkLast(&(wlink));                          \ | 
					
						
							|  |  |  | 		}                                                                     \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							|  |  |  | }                                                                             \ | 
					
						
							| 
									
										
										
										
											2009-05-04 08:55:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-27 16:34:13 +00:00
										 |  |  | typedef struct PyObjectPlus_Proxy { | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | 	PyObject_HEAD		/* required python macro   */ | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	class PyObjectPlus *ref;	// pointer to GE object, it holds a reference to this proxy
 | 
					
						
							|  |  |  | 	void *ptr;					// optional pointer to generic structure, the structure holds no reference to this proxy
 | 
					
						
							|  |  |  | 	bool py_owns;		// true if the object pointed by ref should be deleted when the proxy is deleted
 | 
					
						
							|  |  |  | 	bool py_ref;		// true if proxy is connected to a GE object (ref is used)
 | 
					
						
							| 
									
										
										
										
											2011-02-25 14:32:35 +00:00
										 |  |  | #ifdef USE_WEAKREFS
 | 
					
						
							|  |  |  | 	PyObject *in_weakreflist; // weak reference enabler
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | } PyObjectPlus_Proxy; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define BGE_PROXY_ERROR_MSG "Blender Game Engine data has been freed, cannot use this python variable"
 | 
					
						
							|  |  |  | #define BGE_PROXY_REF(_self) (((PyObjectPlus_Proxy *)_self)->ref)
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | #define BGE_PROXY_PTR(_self) (((PyObjectPlus_Proxy *)_self)->ptr)
 | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | #define BGE_PROXY_PYOWNS(_self) (((PyObjectPlus_Proxy *)_self)->py_owns)
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | #define BGE_PROXY_PYREF(_self) (((PyObjectPlus_Proxy *)_self)->py_ref)
 | 
					
						
							| 
									
										
										
										
											2011-02-25 15:07:25 +00:00
										 |  |  | #ifdef USE_WEAKREFS
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #  define BGE_PROXY_WKREF(_self) (((PyObjectPlus_Proxy *)_self)->in_weakreflist)
 | 
					
						
							| 
									
										
										
										
											2011-02-25 15:07:25 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-18 07:38:51 +00:00
										 |  |  | /* Note, sometimes we don't care what BGE type this is as long as its a proxy */ | 
					
						
							| 
									
										
										
										
											2009-06-29 12:06:46 +00:00
										 |  |  | #define BGE_PROXY_CHECK_TYPE(_type) ((_type)->tp_dealloc == PyObjectPlus::py_base_dealloc)
 | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-27 16:34:13 +00:00
										 |  |  | /* Opposite of BGE_PROXY_REF */ | 
					
						
							|  |  |  | #define BGE_PROXY_FROM_REF(_self) (((PyObjectPlus *)_self)->GetProxy())
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | // This must be the first line of each 
 | 
					
						
							|  |  |  | // PyC++ class
 | 
					
						
							|  |  |  | // AttributesPtr correspond to attributes of proxy generic pointer 
 | 
					
						
							|  |  |  | // each PyC++ class must be registered in KX_PythonInitTypes.cpp
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #define __Py_Header                                                           \
 | 
					
						
							|  |  |  | public:                                                                       \ | 
					
						
							|  |  |  | 	static PyTypeObject   Type;                                               \ | 
					
						
							|  |  |  | 	static PyMethodDef    Methods[];                                          \ | 
					
						
							|  |  |  | 	static PyAttributeDef Attributes[];                                       \ | 
					
						
							|  |  |  | 	virtual PyTypeObject *GetType(void) {                                     \ | 
					
						
							|  |  |  | 		return &Type;                                                         \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							|  |  |  | 	virtual PyObject *GetProxy() {                                            \ | 
					
						
							|  |  |  | 		return GetProxyPlus_Ext(this, &Type, NULL);                           \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							|  |  |  | 	virtual PyObject *NewProxy(bool py_owns) {                                \ | 
					
						
							|  |  |  | 		return NewProxyPlus_Ext(this, &Type, NULL, py_owns);                  \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | // leave above line empty (macro)!
 | 
					
						
							|  |  |  | // use this macro for class that use generic pointer in proxy
 | 
					
						
							|  |  |  | // GetProxy() and NewProxy() must be defined to set the correct pointer in the proxy
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #define __Py_HeaderPtr                                                        \
 | 
					
						
							|  |  |  | public:                                                                       \ | 
					
						
							|  |  |  | 	static PyTypeObject   Type;                                               \ | 
					
						
							|  |  |  | 	static PyMethodDef    Methods[];                                          \ | 
					
						
							|  |  |  | 	static PyAttributeDef Attributes[];                                       \ | 
					
						
							|  |  |  | 	static PyAttributeDef AttributesPtr[];                                    \ | 
					
						
							|  |  |  | 	virtual PyTypeObject *GetType(void) {                                     \ | 
					
						
							|  |  |  | 		return &Type;                                                         \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							|  |  |  | 	virtual PyObject *GetProxy();                                             \ | 
					
						
							|  |  |  | 	virtual PyObject *NewProxy(bool py_owns);                                 \ | 
					
						
							| 
									
										
										
										
											2009-08-18 15:37:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | // leave above line empty (macro)!
 | 
					
						
							| 
									
										
										
										
											2009-08-18 15:37:31 +00:00
										 |  |  | #ifdef WITH_CXX_GUARDEDALLOC
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #define Py_Header __Py_Header                                                 \
 | 
					
						
							|  |  |  | 	void *operator new(size_t num_bytes) {                                    \ | 
					
						
							|  |  |  | 		return MEM_mallocN(num_bytes, Type.tp_name);                          \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							|  |  |  | 	void operator delete(void *mem) {                                         \ | 
					
						
							|  |  |  | 		MEM_freeN(mem);                                                       \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							| 
									
										
										
										
											2009-08-18 15:37:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #  define Py_Header __Py_Header
 | 
					
						
							| 
									
										
										
										
											2009-08-18 15:37:31 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | #ifdef WITH_CXX_GUARDEDALLOC
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #define Py_HeaderPtr __Py_HeaderPtr                                           \
 | 
					
						
							|  |  |  | 	void *operator new(size_t num_bytes) {                                    \ | 
					
						
							|  |  |  | 		return MEM_mallocN(num_bytes, Type.tp_name);                          \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							| 
									
										
										
										
											2012-06-25 10:35:24 +00:00
										 |  |  | 	void operator delete(void *mem) {                                         \ | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | 		MEM_freeN(mem);                                                       \ | 
					
						
							|  |  |  | 	}                                                                         \ | 
					
						
							| 
									
										
										
										
											2009-04-07 11:06:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #  define Py_HeaderPtr __Py_HeaderPtr
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2009-04-07 11:06:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 09:56:30 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * nonzero values are an error for setattr | 
					
						
							|  |  |  |  * however because of the nested lookups we need to know if the errors | 
					
						
							|  |  |  |  * was because the attribute didnt exits of if there was some problem setting the value | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-12 14:22:51 +00:00
										 |  |  | #define PY_SET_ATTR_COERCE_FAIL	 2
 | 
					
						
							| 
									
										
										
										
											2009-04-12 09:56:30 +00:00
										 |  |  | #define PY_SET_ATTR_FAIL		 1
 | 
					
						
							| 
									
										
										
										
											2009-04-12 14:22:51 +00:00
										 |  |  | #define PY_SET_ATTR_MISSING		-1
 | 
					
						
							|  |  |  | #define PY_SET_ATTR_SUCCESS		 0
 | 
					
						
							| 
									
										
										
										
											2009-04-12 09:56:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-07 11:03:12 +00:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2012-03-03 11:45:08 +00:00
										 |  |  |  * These macros are helpful when embedding Python routines. The second | 
					
						
							| 
									
										
										
										
											2004-06-07 11:03:12 +00:00
										 |  |  |  * macro is one that also requires a documentation string | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #define KX_PYMETHOD(class_name, method_name)                                   \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name(PyObject* args, PyObject* kwds);                 \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self, PyObject* args, PyObject* kwds) {         \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "() - "               \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG);                              \ | 
					
						
							|  |  |  | 			return NULL;                                                       \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHOD_VARARGS(class_name, method_name)                           \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name(PyObject* args);                                 \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self, PyObject* args) {                         \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "() - "               \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG); return NULL;                 \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args);       \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHOD_NOARGS(class_name, method_name)                            \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name();                                               \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self) {                                         \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "() - "               \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG); return NULL;                 \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return((class_name*)BGE_PROXY_REF(self))->Py##method_name();           \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHOD_O(class_name, method_name)                                 \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name(PyObject* value);                                \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self, PyObject* value) {                        \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "(value) - "          \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG); return NULL;                 \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return((class_name*)BGE_PROXY_REF(self))->Py##method_name(value);      \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHOD_DOC(class_name, method_name)                               \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name(PyObject* args, PyObject* kwds);                 \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self, PyObject* args, PyObject* kwds) {         \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "(...) - "            \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG); return NULL;                 \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds); \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 	static const char method_name##_doc[];                                     \ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHOD_DOC_VARARGS(class_name, method_name)                       \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name(PyObject* args);                                 \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self, PyObject* args) {                         \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "(...) - "            \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG);                              \ | 
					
						
							|  |  |  | 			return NULL;                                                       \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return((class_name*)BGE_PROXY_REF(self))->Py##method_name(args);       \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 	static const char method_name##_doc[];                                     \ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHOD_DOC_O(class_name, method_name)                             \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name(PyObject* value);                                \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self, PyObject* value) {                        \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "(value) - "          \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG);                              \ | 
					
						
							|  |  |  | 			return NULL;                                                       \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value);     \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 	static const char method_name##_doc[];                                     \ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHOD_DOC_NOARGS(class_name, method_name)                        \
 | 
					
						
							|  |  |  | 	PyObject* Py##method_name();                                               \ | 
					
						
							|  |  |  | 	static PyObject*                                                           \ | 
					
						
							|  |  |  | 	sPy##method_name(PyObject* self) {                                         \ | 
					
						
							|  |  |  | 		if(BGE_PROXY_REF(self)==NULL) {                                        \ | 
					
						
							|  |  |  | 			PyErr_SetString(PyExc_RuntimeError,                                \ | 
					
						
							|  |  |  | 			                #class_name "." #method_name "() - "               \
 | 
					
						
							|  |  |  | 			                BGE_PROXY_ERROR_MSG);                              \ | 
					
						
							|  |  |  | 			return NULL;                                                       \ | 
					
						
							|  |  |  | 		}                                                                      \ | 
					
						
							|  |  |  | 		return ((class_name*)BGE_PROXY_REF(self))->Py##method_name();          \ | 
					
						
							|  |  |  | 	}                                                                          \ | 
					
						
							|  |  |  | 	static const char method_name##_doc[];                                     \ | 
					
						
							| 
									
										
										
										
											2008-07-04 00:05:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-07 11:03:12 +00:00
										 |  |  | /* The line above should remain empty */ | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Method table macro (with doc) | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define KX_PYMETHODTABLE(class_name, method_name) \
 | 
					
						
							| 
									
										
										
										
											2009-08-10 00:07:34 +00:00
										 |  |  | 	{#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (const char *)class_name::method_name##_doc} | 
					
						
							| 
									
										
										
										
											2004-06-07 11:03:12 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-29 16:36:58 +00:00
										 |  |  | #define KX_PYMETHODTABLE_O(class_name, method_name) \
 | 
					
						
							| 
									
										
										
										
											2009-08-10 00:07:34 +00:00
										 |  |  | 	{#method_name , (PyCFunction) class_name::sPy##method_name, METH_O, (const char *)class_name::method_name##_doc} | 
					
						
							| 
									
										
										
										
											2008-12-29 16:36:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHODTABLE_NOARGS(class_name, method_name) \
 | 
					
						
							| 
									
										
										
										
											2009-08-10 00:07:34 +00:00
										 |  |  | 	{#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (const char *)class_name::method_name##_doc} | 
					
						
							| 
									
										
											  
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											
										 
											2008-08-27 19:34:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-24 07:52:29 +00:00
										 |  |  | #define KX_PYMETHODTABLE_KEYWORDS(class_name, method_name) \
 | 
					
						
							|  |  |  | 	{#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS|METH_KEYWORDS, (const char *)class_name::method_name##_doc} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-07 11:03:12 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Function implementation macro | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define KX_PYMETHODDEF_DOC(class_name, method_name, doc_string) \
 | 
					
						
							| 
									
										
										
										
											2008-09-20 11:08:35 +00:00
										 |  |  | const char class_name::method_name##_doc[] = doc_string; \ | 
					
						
							| 
									
										
										
										
											2011-05-24 07:52:29 +00:00
										 |  |  | PyObject* class_name::Py##method_name(PyObject* args, PyObject* kwds) | 
					
						
							| 
									
										
										
										
											2004-06-07 11:03:12 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-29 16:36:58 +00:00
										 |  |  | #define KX_PYMETHODDEF_DOC_VARARGS(class_name, method_name, doc_string) \
 | 
					
						
							|  |  |  | const char class_name::method_name##_doc[] = doc_string; \ | 
					
						
							| 
									
										
										
										
											2009-04-19 17:29:07 +00:00
										 |  |  | PyObject* class_name::Py##method_name(PyObject* args) | 
					
						
							| 
									
										
										
										
											2008-12-29 16:36:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHODDEF_DOC_O(class_name, method_name, doc_string) \
 | 
					
						
							|  |  |  | const char class_name::method_name##_doc[] = doc_string; \ | 
					
						
							| 
									
										
										
										
											2009-04-19 17:29:07 +00:00
										 |  |  | PyObject* class_name::Py##method_name(PyObject* value) | 
					
						
							| 
									
										
										
										
											2008-12-29 16:36:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYMETHODDEF_DOC_NOARGS(class_name, method_name, doc_string) \
 | 
					
						
							| 
									
										
										
										
											2008-09-20 11:08:35 +00:00
										 |  |  | const char class_name::method_name##_doc[] = doc_string; \ | 
					
						
							| 
									
										
										
										
											2009-04-19 17:29:07 +00:00
										 |  |  | PyObject* class_name::Py##method_name() | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Attribute management | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | enum KX_PYATTRIBUTE_TYPE { | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_TYPE_BOOL, | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | 	KX_PYATTRIBUTE_TYPE_ENUM, | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 	KX_PYATTRIBUTE_TYPE_SHORT, | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_TYPE_INT, | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_TYPE_FLOAT, | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_TYPE_STRING, | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_TYPE_DUMMY, | 
					
						
							| 
									
										
										
										
											2009-03-22 21:36:48 +00:00
										 |  |  | 	KX_PYATTRIBUTE_TYPE_FUNCTION, | 
					
						
							| 
									
										
										
										
											2009-05-11 12:41:48 +00:00
										 |  |  | 	KX_PYATTRIBUTE_TYPE_VECTOR, | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	KX_PYATTRIBUTE_TYPE_FLAG, | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | 	KX_PYATTRIBUTE_TYPE_CHAR | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum KX_PYATTRIBUTE_ACCESS { | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_RW, | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_RO | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | struct KX_PYATTRIBUTE_DEF; | 
					
						
							| 
									
										
										
										
											2009-03-22 21:36:48 +00:00
										 |  |  | typedef int (*KX_PYATTRIBUTE_CHECK_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); | 
					
						
							|  |  |  | typedef int (*KX_PYATTRIBUTE_SET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); | 
					
						
							|  |  |  | typedef PyObject* (*KX_PYATTRIBUTE_GET_FUNCTION)(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct KX_PYATTRIBUTE_DEF { | 
					
						
							|  |  |  | 	const char *m_name;				// name of the python attribute
 | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_TYPE m_type;		// type of value
 | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_ACCESS m_access;	// read/write access or read-only
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	int m_imin;						// minimum value in case of integer attributes 
 | 
					
						
							|  |  |  | 									// (for string: minimum string length, for flag: mask value, for float: matrix row size)
 | 
					
						
							|  |  |  | 	int m_imax;						// maximum value in case of integer attributes 
 | 
					
						
							|  |  |  | 									// (for string: maximum string length, for flag: 1 if flag is negative, float: vector/matrix col size)
 | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 	float m_fmin;					// minimum value in case of float attributes
 | 
					
						
							|  |  |  | 	float m_fmax;					// maximum value in case of float attributes
 | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | 	bool   m_clamp;					// enforce min/max value by clamping
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	bool   m_usePtr;				// the attribute uses the proxy generic pointer, set at runtime
 | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 	size_t m_offset;				// position of field in structure
 | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | 	size_t m_size;					// size of field for runtime verification (enum only)
 | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 	size_t m_length;				// length of array, 1=simple attribute
 | 
					
						
							| 
									
										
										
										
											2009-03-22 21:36:48 +00:00
										 |  |  | 	KX_PYATTRIBUTE_CHECK_FUNCTION m_checkFunction;	// static function to check the assignment, returns 0 if no error
 | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_SET_FUNCTION m_setFunction;	// static function to check the assignment, returns 0 if no error
 | 
					
						
							|  |  |  | 	KX_PYATTRIBUTE_GET_FUNCTION m_getFunction;	// static function to check the assignment, returns 0 if no error
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 	// The following pointers are just used to have compile time check for attribute type.
 | 
					
						
							|  |  |  | 	// It would have been good to use a union but that would require C99 compatibility
 | 
					
						
							|  |  |  | 	// to initialize specific union fields through designated initializers.
 | 
					
						
							|  |  |  | 	struct { | 
					
						
							|  |  |  | 		bool *m_boolPtr; | 
					
						
							|  |  |  | 		short int *m_shortPtr; | 
					
						
							|  |  |  | 		int *m_intPtr; | 
					
						
							|  |  |  | 		float *m_floatPtr; | 
					
						
							|  |  |  | 		STR_String *m_stringPtr; | 
					
						
							| 
									
										
										
										
											2009-05-11 12:41:48 +00:00
										 |  |  | 		MT_Vector3 *m_vectorPtr; | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 		char *m_charPtr; | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 	} m_typeCheck; | 
					
						
							|  |  |  | } PyAttributeDef; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_BOOL_RW(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_BOOL_RW_CHECK(name,object,field,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_BOOL_RO(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RO, 0, 1, 0.f, 0.f, false, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* attribute points to a single bit of an integer field, attribute=true if bit is set */ | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLAG_RW(name,object,field,bit) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 0, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLAG_RW_CHECK(name,object,field,bit,function) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 0, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLAG_RO(name,object,field,bit) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RO, bit, 0, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* attribute points to a single bit of an integer field, attribute=true if bit is set*/ | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLAG_NEGATIVE_RW(name,object,field,bit) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 1, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLAG_NEGATIVE_RW_CHECK(name,object,field,bit,function) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RW, bit, 1, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLAG_NEGATIVE_RO(name,object,field,bit) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLAG, KX_PYATTRIBUTE_RO, bit, 1, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // enum field cannot be mapped to pointer (because we would need a pointer for each enum)
 | 
					
						
							|  |  |  | // use field size to verify mapping at runtime only, assuming enum size is equal to int size.
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_ENUM_RW(name,min,max,clamp,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_ENUM_RW_CHECK(name,min,max,clamp,object,field,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_ENUM_RO(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_ENUM, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_SHORT_RW(name,min,max,clamp,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_SHORT_RW_CHECK(name,min,max,clamp,object,field,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_SHORT_RO(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_SHORT_ARRAY_RW(name,min,max,clamp,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_SHORT_ARRAY_RW_CHECK(name,min,max,clamp,object,field,length,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_SHORT_ARRAY_RO(name,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, ((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-02-19 23:13:41 +00:00
										 |  |  | // SHORT_LIST
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_SHORT_LIST_RW(name,min,max,clamp,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-02-19 23:13:41 +00:00
										 |  |  | #define KX_PYATTRIBUTE_SHORT_LIST_RW_CHECK(name,min,max,clamp,object,field,length,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-02-19 23:13:41 +00:00
										 |  |  | #define KX_PYATTRIBUTE_SHORT_LIST_RO(name,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_SHORT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, &((object *)0)->field, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_RW(name,min,max,clamp,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_RW_CHECK(name,min,max,clamp,object,field,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_RO(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_ARRAY_RW(name,min,max,clamp,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK(name,min,max,clamp,object,field,length,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_ARRAY_RO(name,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, ((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-02-19 23:13:41 +00:00
										 |  |  | // INT_LIST
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_INT_LIST_RW(name,min,max,clamp,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-02-19 23:13:41 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_LIST_RW_CHECK(name,min,max,clamp,object,field,length,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-02-19 23:13:41 +00:00
										 |  |  | #define KX_PYATTRIBUTE_INT_LIST_RO(name,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_INT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, &((object *)0)->field, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | // always clamp for float
 | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_FLOAT_RW(name,min,max,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_FLOAT_RW_CHECK(name,min,max,object,field,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_FLOAT_RO(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, &((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							|  |  |  | // field must be float[n], returns a sequence
 | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_FLOAT_ARRAY_RW(name,min,max,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_FLOAT_ARRAY_RW_CHECK(name,min,max,object,field,length,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object,field), 0, length, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_FLOAT_ARRAY_RO(name,object,field,length) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, length, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							|  |  |  | // field must be float[n], returns a vector
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLOAT_VECTOR_RW(name,min,max,object,field,length) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, length, min, max, true, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLOAT_VECTOR_RW_CHECK(name,min,max,object,field,length,function) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, 0, length, min, max, true, false, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLOAT_VECTOR_RO(name,object,field,length) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, 0, length, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field, NULL, NULL, NULL} } | 
					
						
							|  |  |  | // field must be float[n][n], returns a matrix
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLOAT_MATRIX_RW(name,min,max,object,field,length) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, length, length, min, max, true, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field[0], NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLOAT_MATRIX_RW_CHECK(name,min,max,object,field,length,function) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RW, length, length, min, max, true, false, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field[0], NULL, NULL, NULL} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_FLOAT_MATRIX_RO(name,object,field,length) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FLOAT, KX_PYATTRIBUTE_RO, length, length, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, ((object *)0)->field[0], NULL, NULL, NULL} } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // only for STR_String member
 | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_STRING_RW(name,min,max,clamp,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-01-02 17:43:56 +00:00
										 |  |  | #define KX_PYATTRIBUTE_STRING_RW_CHECK(name,min,max,clamp,object,field,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RW, min, max, 0.f, 0.f, clamp, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | #define KX_PYATTRIBUTE_STRING_RO(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_STRING, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, &((object *)0)->field, NULL, NULL} } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // only for char [] array 
 | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_CHAR_RW(name,object,field) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_CHAR, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, true, false, offsetof(object,field), sizeof(((object *)0)->field), 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, ((object *)0)->field} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_CHAR_RW_CHECK(name,object,field,function) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_CHAR, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, true, false, offsetof(object,field), sizeof(((object *)0)->field), 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, ((object *)0)->field} } | 
					
						
							|  |  |  | #define KX_PYATTRIBUTE_CHAR_RO(name,object,field) \
 | 
					
						
							|  |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_CHAR, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), sizeof(((object *)0)->field), 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, ((object *)0)->field} } | 
					
						
							| 
									
										
										
										
											2009-05-11 12:41:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | // for MT_Vector3 member
 | 
					
						
							| 
									
										
										
										
											2009-05-11 12:41:48 +00:00
										 |  |  | #define KX_PYATTRIBUTE_VECTOR_RW(name,min,max,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} } | 
					
						
							| 
									
										
										
										
											2009-05-11 12:41:48 +00:00
										 |  |  | #define KX_PYATTRIBUTE_VECTOR_RW_CHECK(name,min,max,clamp,object,field,function) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RW, 0, 0, min, max, true, false, offsetof(object,field), 0, 1, &object::function, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} } | 
					
						
							| 
									
										
										
										
											2009-05-11 12:41:48 +00:00
										 |  |  | #define KX_PYATTRIBUTE_VECTOR_RO(name,object,field) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_VECTOR, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, offsetof(object,field), 0, 1 , NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, &((object *)0)->field, NULL} } | 
					
						
							| 
									
										
										
										
											2009-03-22 21:36:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-24 19:37:17 +00:00
										 |  |  | #define KX_PYATTRIBUTE_RW_FUNCTION(name,object,getfunction,setfunction) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0.f, false, false, 0, 0, 1, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-03-22 21:36:48 +00:00
										 |  |  | #define KX_PYATTRIBUTE_RO_FUNCTION(name,object,getfunction) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, 0, 0, 1, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-03-24 19:37:17 +00:00
										 |  |  | #define KX_PYATTRIBUTE_ARRAY_RW_FUNCTION(name,object,length,getfunction,setfunction) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RW, 0, 0, 0.f, 0,f, false, false, 0, 0, length, NULL, &object::setfunction, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2009-03-22 21:36:48 +00:00
										 |  |  | #define KX_PYATTRIBUTE_ARRAY_RO_FUNCTION(name,object,length,getfunction) \
 | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	{ name, KX_PYATTRIBUTE_TYPE_FUNCTION, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0,f, false, false, 0, 0, length, NULL, NULL, &object::getfunction, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} } | 
					
						
							| 
									
										
										
										
											2008-12-31 20:35:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-19 23:13:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | /*------------------------------
 | 
					
						
							|  |  |  |  * PyObjectPlus | 
					
						
							|  |  |  | ------------------------------*/ | 
					
						
							| 
									
										
										
										
											2012-06-06 22:38:39 +00:00
										 |  |  | typedef PyTypeObject *PyParentObject;  /* Define the PyParent Object */ | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-31 04:11:39 +00:00
										 |  |  | #else // WITH_PYTHON
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-10 20:59:30 +00:00
										 |  |  | #ifdef WITH_CXX_GUARDEDALLOC
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #define Py_Header                                                             \
 | 
					
						
							|  |  |  | public:                                                                       \ | 
					
						
							| 
									
										
										
										
											2012-06-25 09:14:37 +00:00
										 |  |  | 	MEM_CXX_CLASS_ALLOC_FUNCS("GE:PyObjectPlus")                              \ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | #define Py_HeaderPtr                                                          \
 | 
					
						
							| 
									
										
										
										
											2012-06-25 09:14:37 +00:00
										 |  |  | 	MEM_CXX_CLASS_ALLOC_FUNCS("GE:PyObjectPlusPtr")                           \ | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-10 20:59:30 +00:00
										 |  |  | #else // WITH_CXX_GUARDEDALLOC
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define Py_Header \
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | public: \ | 
					
						
							| 
									
										
										
										
											2010-10-10 20:59:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define Py_HeaderPtr \
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | public: \ | 
					
						
							| 
									
										
										
										
											2010-10-10 20:59:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif // WITH_CXX_GUARDEDALLOC
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-10 20:53:58 +00:00
										 |  |  | // By making SG_QList the ultimate parent for PyObjectPlus objects, it
 | 
					
						
							|  |  |  | // allows to put them in 2 different dynamic lists at the same time
 | 
					
						
							|  |  |  | // The use of these links is interesting because they free of memory allocation
 | 
					
						
							|  |  |  | // but it's very important not to mess up with them. If you decide that 
 | 
					
						
							|  |  |  | // the SG_QList or SG_DList component is used for something for a certain class,
 | 
					
						
							|  |  |  | // they cannot can be used for anything else at a parent level!
 | 
					
						
							|  |  |  | // What these lists are and what they are used for must be carefully documented
 | 
					
						
							|  |  |  | // at the level where they are used.
 | 
					
						
							|  |  |  | // DON'T MAKE ANY USE OF THESE LIST AT THIS LEVEL, they are already used
 | 
					
						
							|  |  |  | // at SCA_IActuator, SCA_ISensor, SCA_IController level which rules out the
 | 
					
						
							|  |  |  | // possibility to use them at SCA_ILogicBrick, CValue and PyObjectPlus level.
 | 
					
						
							|  |  |  | class PyObjectPlus : public SG_QList | 
					
						
							| 
									
										
										
										
											2004-11-22 10:19:19 +00:00
										 |  |  | {				// The PyObjectPlus abstract class
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | 	Py_Header							// Always start with Py_Header
 | 
					
						
							| 
									
										
										
										
											2004-11-22 10:19:19 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2009-06-28 11:22:26 +00:00
										 |  |  | 	PyObjectPlus(); | 
					
						
							| 
									
										
										
										
											2004-11-22 10:19:19 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2005-12-20 09:13:06 +00:00
										 |  |  | 	virtual ~PyObjectPlus();					// destructor
 | 
					
						
							| 
									
										
										
										
											2004-11-22 10:19:19 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2010-10-31 04:11:39 +00:00
										 |  |  | #ifdef WITH_PYTHON
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 	PyObject *m_proxy; /* actually a PyObjectPlus_Proxy */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-19 14:57:52 +00:00
										 |  |  | 	/* These static functions are referenced by ALL PyObjectPlus_Proxy types
 | 
					
						
							|  |  |  | 	 * they take the C++ reference from the PyObjectPlus_Proxy and call | 
					
						
							| 
									
										
										
										
											2012-06-17 09:58:26 +00:00
										 |  |  | 	 * its own virtual py_repr, py_base_dealloc, etc. functions. | 
					
						
							| 
									
										
										
										
											2009-04-19 14:57:52 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2009-06-29 12:06:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static PyObject*		py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* allows subclassing */ | 
					
						
							| 
									
										
										
										
											2009-04-19 14:57:52 +00:00
										 |  |  | 	static void			py_base_dealloc(PyObject *self); | 
					
						
							|  |  |  | 	static PyObject*		py_base_repr(PyObject *self); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* These are all virtual python methods that are defined in each class
 | 
					
						
							|  |  |  | 	 * Our own fake subclassing calls these on each class, then calls the parent */ | 
					
						
							|  |  |  | 	virtual PyObject*		py_repr(void); | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	/* subclass may overwrite this function to implement more sophisticated method of validating a proxy */ | 
					
						
							|  |  |  | 	virtual bool			py_is_valid(void) { return true; } | 
					
						
							| 
									
										
										
										
											2009-04-19 14:57:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-28 11:22:26 +00:00
										 |  |  | 	static PyObject*		py_get_attrdef(PyObject *self_py, const PyAttributeDef *attrdef); | 
					
						
							|  |  |  | 	static int				py_set_attrdef(PyObject *self_py, PyObject *value, const PyAttributeDef *attrdef); | 
					
						
							| 
									
										
										
										
											2009-04-17 20:06:06 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-04-19 12:46:39 +00:00
										 |  |  | 	/* Kindof dumb, always returns True, the false case is checked for, before this function gets accessed */ | 
					
						
							| 
									
										
										
										
											2009-04-28 13:11:56 +00:00
										 |  |  | 	static PyObject*	pyattr_get_invalid(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static PyObject *GetProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr); | 
					
						
							|  |  |  | 	/* self=NULL => proxy to generic pointer detached from GE object
 | 
					
						
							| 
									
										
										
										
											2012-03-09 18:28:30 +00:00
										 |  |  | 	 *              if py_owns is true, the memory pointed by ptr will be deleted automatically with MEM_freeN | 
					
						
							|  |  |  | 	 * self!=NULL=> proxy attached to GE object, ptr is optional and point to a struct from which attributes can be defined | 
					
						
							|  |  |  | 	 *              if py_owns is true, the object will be deleted automatically, ptr will NOT be deleted | 
					
						
							|  |  |  | 	 *              (assume object destructor takes care of it) */ | 
					
						
							| 
									
										
										
										
											2009-09-24 21:22:24 +00:00
										 |  |  | 	static PyObject *NewProxyPlus_Ext(PyObjectPlus *self, PyTypeObject *tp, void *ptr, bool py_owns); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 08:55:54 +00:00
										 |  |  | 	static	WarnLink*		GetDeprecationWarningLinkFirst(void); | 
					
						
							|  |  |  | 	static	WarnLink*		GetDeprecationWarningLinkLast(void); | 
					
						
							|  |  |  | 	static	void			SetDeprecationWarningFirst(WarnLink* wlink); | 
					
						
							|  |  |  | 	static	void			SetDeprecationWarningLinkLast(WarnLink* wlink); | 
					
						
							|  |  |  | 	static void			NullDeprecationWarning(); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-04-28 13:11:56 +00:00
										 |  |  | 	/** enable/disable display of deprecation warnings */ | 
					
						
							|  |  |  | 	static void			SetDeprecationWarnings(bool ignoreDeprecationWarnings); | 
					
						
							| 
									
										
										
										
											2011-09-25 12:31:21 +00:00
										 |  |  | 	/** Shows a deprecation warning */ | 
					
						
							| 
									
										
										
										
											2009-05-04 08:55:54 +00:00
										 |  |  | 	static void			ShowDeprecationWarning_func(const char* method,const char* prop); | 
					
						
							|  |  |  | 	static void			ClearDeprecationWarning(); | 
					
						
							| 
									
										
										
										
											2009-04-28 13:11:56 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 	void	InvalidateProxy(); | 
					
						
							| 
									
										
										
										
											2009-05-04 08:55:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Makes sure any internal data owned by this class is deep copied. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	virtual void ProcessReplica(); | 
					
						
							| 
									
										
										
										
											2009-02-26 09:04:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | 	static bool			m_ignore_deprecation_warnings; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-31 04:11:39 +00:00
										 |  |  | #ifdef WITH_PYTHON
 | 
					
						
							| 
									
										
										
										
											2011-11-06 01:39:36 +00:00
										 |  |  | PyObject *PyUnicode_From_STR_String(const STR_String& str); | 
					
						
							| 
									
										
										
										
											2009-09-29 21:42:40 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2002-10-12 11:37:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-23 10:41:31 +00:00
										 |  |  | #endif //  __PYOBJECTPLUS_H__
 |