2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
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,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifndef NO_EXP_PYTHON_EMBEDDING
|
|
|
|
|
|
|
|
#ifndef _adr_py_lib_h_ // only process once,
|
|
|
|
#define _adr_py_lib_h_ // even if multiply included
|
|
|
|
|
|
|
|
#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"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/*------------------------------
|
|
|
|
* Python defines
|
|
|
|
------------------------------*/
|
|
|
|
|
2008-09-06 14:13:31 +00:00
|
|
|
/*
|
|
|
|
Py_RETURN_NONE
|
|
|
|
Python 2.4 macro.
|
|
|
|
defined here until we switch to 2.4
|
|
|
|
also in api2_2x/gen_utils.h
|
|
|
|
*/
|
|
|
|
#ifndef Py_RETURN_NONE
|
|
|
|
#define Py_RETURN_NONE return Py_BuildValue("O", Py_None)
|
|
|
|
#endif
|
|
|
|
#ifndef Py_RETURN_FALSE
|
|
|
|
#define Py_RETURN_FALSE return PyBool_FromLong(0)
|
|
|
|
#endif
|
|
|
|
#ifndef Py_RETURN_TRUE
|
|
|
|
#define Py_RETURN_TRUE return PyBool_FromLong(1)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* for pre Py 2.5 */
|
|
|
|
#if PY_VERSION_HEX < 0x02050000
|
|
|
|
typedef int Py_ssize_t;
|
|
|
|
#define PY_SSIZE_T_MAX INT_MAX
|
|
|
|
#define PY_SSIZE_T_MIN INT_MIN
|
2008-10-02 00:22:28 +00:00
|
|
|
#define PY_METHODCHAR char *
|
2008-09-06 14:13:31 +00:00
|
|
|
#else
|
|
|
|
/* Py 2.5 and later */
|
|
|
|
#define intargfunc ssizeargfunc
|
|
|
|
#define intintargfunc ssizessizeargfunc
|
2008-10-02 00:22:28 +00:00
|
|
|
#define PY_METHODCHAR const char *
|
2008-09-06 14:13:31 +00:00
|
|
|
#endif
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// some basic python macros
|
2005-03-25 10:33:39 +00:00
|
|
|
#define Py_Return { Py_INCREF(Py_None); return Py_None;}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-09-20 11:08:35 +00:00
|
|
|
static inline void Py_Fatal(const char *M) {
|
2002-10-12 11:37:38 +00:00
|
|
|
//cout << M << endl;
|
|
|
|
exit(-1);
|
|
|
|
};
|
|
|
|
|
|
|
|
// This must be the first line of each
|
|
|
|
// PyC++ class
|
|
|
|
#define Py_Header \
|
|
|
|
public: \
|
|
|
|
static PyTypeObject Type; \
|
|
|
|
static PyMethodDef Methods[]; \
|
|
|
|
static PyParentObject Parents[]; \
|
|
|
|
virtual PyTypeObject *GetType(void) {return &Type;}; \
|
|
|
|
virtual PyParentObject *GetParents(void) {return Parents;}
|
|
|
|
|
2008-07-08 17:57:31 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
// This defines the _getattr_up macro
|
|
|
|
// which allows attribute and method calls
|
|
|
|
// to be properly passed up the hierarchy.
|
|
|
|
#define _getattr_up(Parent) \
|
2008-07-08 17:57:31 +00:00
|
|
|
PyObject *rvalue = NULL; \
|
|
|
|
if (attr=="__methods__") { \
|
|
|
|
PyObject *_attr_string = NULL; \
|
|
|
|
PyMethodDef *meth = Methods; \
|
|
|
|
rvalue = Parent::_getattr(attr); \
|
|
|
|
if (rvalue==NULL) { \
|
|
|
|
PyErr_Clear(); \
|
|
|
|
rvalue = PyList_New(0); \
|
|
|
|
} \
|
|
|
|
if (meth) { \
|
|
|
|
for (; meth->ml_name != NULL; meth++) { \
|
|
|
|
_attr_string = PyString_FromString(meth->ml_name); \
|
|
|
|
PyList_Append(rvalue, _attr_string); \
|
|
|
|
Py_DECREF(_attr_string); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
rvalue = Py_FindMethod(Methods, this, const_cast<char*>(attr.ReadPtr())); \
|
|
|
|
if (rvalue == NULL) { \
|
2002-10-12 11:37:38 +00:00
|
|
|
PyErr_Clear(); \
|
2008-07-08 17:57:31 +00:00
|
|
|
rvalue = Parent::_getattr(attr); \
|
2002-10-12 11:37:38 +00:00
|
|
|
} \
|
2008-07-08 17:57:31 +00:00
|
|
|
} \
|
|
|
|
return rvalue; \
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-06-07 11:03:12 +00:00
|
|
|
/**
|
|
|
|
* These macros are helpfull when embedding Python routines. The second
|
|
|
|
* macro is one that also requires a documentation string
|
|
|
|
*/
|
|
|
|
#define KX_PYMETHOD(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self, PyObject* args, PyObject* kwds); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self, args, kwds); \
|
|
|
|
}; \
|
|
|
|
|
2008-08-27 03:34:53 +00:00
|
|
|
#define KX_PYMETHOD_VARARGS(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self, PyObject* args); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self, args); \
|
|
|
|
}; \
|
|
|
|
|
2008-07-04 00:05:50 +00:00
|
|
|
#define KX_PYMETHOD_NOARGS(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self); \
|
|
|
|
}; \
|
|
|
|
|
|
|
|
#define KX_PYMETHOD_O(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self, PyObject* value); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self, value); \
|
|
|
|
}; \
|
|
|
|
|
2004-06-07 11:03:12 +00:00
|
|
|
#define KX_PYMETHOD_DOC(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self, PyObject* args, PyObject* kwds); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self, args, kwds); \
|
|
|
|
}; \
|
2008-09-20 11:08:35 +00:00
|
|
|
static const char method_name##_doc[]; \
|
2004-06-07 11:03:12 +00:00
|
|
|
|
2008-08-14 08:58:25 +00:00
|
|
|
#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self, PyObject* args); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self, args); \
|
|
|
|
}; \
|
2008-09-20 11:08:35 +00:00
|
|
|
static const char method_name##_doc[]; \
|
2008-08-14 08:58:25 +00:00
|
|
|
|
2008-07-04 00:05:50 +00:00
|
|
|
#define KX_PYMETHOD_DOC_O(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self, PyObject* value); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self, value); \
|
|
|
|
}; \
|
2008-09-20 11:08:35 +00:00
|
|
|
static const char method_name##_doc[]; \
|
2008-07-04 00:05:50 +00:00
|
|
|
|
|
|
|
#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \
|
|
|
|
PyObject* Py##method_name(PyObject* self); \
|
|
|
|
static PyObject* sPy##method_name( PyObject* self) { \
|
|
|
|
return ((class_name*) self)->Py##method_name(self); \
|
|
|
|
}; \
|
2008-09-20 11:08:35 +00:00
|
|
|
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) \
|
2008-10-02 00:22:28 +00:00
|
|
|
{#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (PY_METHODCHAR)class_name::method_name##_doc}
|
2004-06-07 11:03:12 +00:00
|
|
|
|
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
|
|
|
#define KX_PYMETHODTABLE_NOARG(class_name, method_name) \
|
2008-10-02 00:22:28 +00:00
|
|
|
{#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (PY_METHODCHAR)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
|
|
|
|
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; \
|
2004-07-17 05:28:23 +00:00
|
|
|
PyObject* class_name::Py##method_name(PyObject*, PyObject* args, PyObject*)
|
2004-06-07 11:03:12 +00:00
|
|
|
|
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
|
|
|
#define KX_PYMETHODDEF_DOC_NOARG(class_name, method_name, doc_string) \
|
2008-09-20 11:08:35 +00:00
|
|
|
const char class_name::method_name##_doc[] = doc_string; \
|
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
|
|
|
PyObject* class_name::Py##method_name(PyObject*)
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/*------------------------------
|
|
|
|
* PyObjectPlus
|
|
|
|
------------------------------*/
|
|
|
|
typedef PyTypeObject * PyParentObject; // Define the PyParent Object
|
|
|
|
|
2004-11-22 10:19:19 +00:00
|
|
|
class PyObjectPlus : public PyObject
|
|
|
|
{ // The PyObjectPlus abstract class
|
|
|
|
Py_Header; // Always start with Py_Header
|
|
|
|
|
|
|
|
public:
|
|
|
|
PyObjectPlus(PyTypeObject *T);
|
|
|
|
|
2005-12-20 09:13:06 +00:00
|
|
|
virtual ~PyObjectPlus(); // destructor
|
2004-11-22 10:19:19 +00:00
|
|
|
static void PyDestructor(PyObject *P) // python wrapper
|
|
|
|
{
|
|
|
|
delete ((PyObjectPlus *) P);
|
|
|
|
};
|
|
|
|
|
2005-12-20 09:13:06 +00:00
|
|
|
// void INCREF(void) {
|
|
|
|
// Py_INCREF(this);
|
|
|
|
// }; // incref method
|
|
|
|
// void DECREF(void) {
|
|
|
|
// Py_DECREF(this);
|
|
|
|
// }; // decref method
|
2004-11-22 10:19:19 +00:00
|
|
|
|
|
|
|
virtual PyObject *_getattr(const STR_String& attr); // _getattr method
|
|
|
|
static PyObject *__getattr(PyObject * PyObj, char *attr) // This should be the entry in Type.
|
|
|
|
{
|
|
|
|
return ((PyObjectPlus*) PyObj)->_getattr(STR_String(attr));
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int _delattr(const STR_String& attr);
|
|
|
|
virtual int _setattr(const STR_String& attr, PyObject *value); // _setattr method
|
|
|
|
static int __setattr(PyObject *PyObj, // This should be the entry in Type.
|
|
|
|
char *attr,
|
|
|
|
PyObject *value)
|
|
|
|
{
|
|
|
|
if (!value)
|
|
|
|
return ((PyObjectPlus*) PyObj)->_delattr(attr);
|
|
|
|
return ((PyObjectPlus*) PyObj)->_setattr(STR_String(attr), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual PyObject *_repr(void); // _repr method
|
|
|
|
static PyObject *__repr(PyObject *PyObj) // This should be the entry in Type.
|
|
|
|
{
|
|
|
|
return ((PyObjectPlus*) PyObj)->_repr();
|
|
|
|
}
|
|
|
|
|
|
|
|
// isA methods
|
|
|
|
bool isA(PyTypeObject *T);
|
|
|
|
bool isA(const char *mytypename);
|
|
|
|
PyObject *Py_isA(PyObject *args);
|
|
|
|
static PyObject *sPy_isA(PyObject *self, PyObject *args, PyObject *kwd)
|
|
|
|
{
|
|
|
|
return ((PyObjectPlus*)self)->Py_isA(args);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _adr_py_lib_h_
|
|
|
|
|
|
|
|
#endif //NO_EXP_PYTHON_EMBEDDING
|
|
|
|
|