BPython:
- fixed two warnings, unused var in Object.c and undeclared function in script.c - updated Blender.Draw doc, it was missing info about Button object - refactored pytype initialization to try to fix for once platform (and distro!) specific crashes on startup. This asked for tiny updates in Effect.[ch] (removed static from declaration, moved definitions to the .c file) and modules.h - fixed error I made trying to fix scripts w/ no [eol] char in menus. Thanks Michael Velikanje for reporting the problem!
This commit is contained in:
@@ -38,10 +38,10 @@
|
||||
#include "BPI_script.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "BKE_bad_level_calls.h" /* for BPY_clear_script */
|
||||
|
||||
/*
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BKE_bad_level_calls.h"
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_global.h"
|
||||
|
||||
@@ -611,8 +611,8 @@ int BPY_menu_do_python(short menutype, int event)
|
||||
buffer = MEM_mallocN(len+2, "pyfilebuf"); /* len+2 to add '\n\0' */
|
||||
len = fread(buffer, 1, len, fp);
|
||||
|
||||
buffer[len-1] = '\n'; /* to fix potential syntax error */
|
||||
buffer[len] = '\0';
|
||||
buffer[len] = '\n'; /* fix syntax error in files w/o eol*/
|
||||
buffer[len+1] = '\0';
|
||||
|
||||
/* fast clean-up of dos cr/lf line endings: change '\r' to space */
|
||||
|
||||
|
||||
@@ -207,14 +207,15 @@ void M_Blender_Init (void)
|
||||
/* TODO: create a docstring for the Blender module */
|
||||
module = Py_InitModule3("Blender", Blender_methods, NULL);
|
||||
|
||||
types_InitAll(); /* set all our pytypes to &PyType_Type*/
|
||||
|
||||
dict = PyModule_GetDict (module);
|
||||
g_blenderdict = dict;
|
||||
PyDict_SetItemString (dict, "Types", Types_Init());
|
||||
PyDict_SetItemString (dict, "sys", sys_Init());
|
||||
PyDict_SetItemString (dict, "Registry", Registry_Init());
|
||||
PyDict_SetItemString (dict, "Scene", Scene_Init());
|
||||
PyDict_SetItemString (dict, "Object", Object_Init());
|
||||
PyDict_SetItemString (dict, "Types", Types_Init());
|
||||
PyDict_SetItemString (dict, "NMesh", NMesh_Init());
|
||||
PyDict_SetItemString (dict, "Material", Material_Init());
|
||||
PyDict_SetItemString (dict, "Camera", Camera_Init());
|
||||
PyDict_SetItemString (dict, "Lamp", Lamp_Init());
|
||||
@@ -232,6 +233,7 @@ void M_Blender_Init (void)
|
||||
PyDict_SetItemString (dict, "Text", Text_Init());
|
||||
PyDict_SetItemString (dict, "World", World_Init());
|
||||
PyDict_SetItemString (dict, "Texture", Texture_Init());
|
||||
PyDict_SetItemString (dict, "NMesh", NMesh_Init());
|
||||
PyDict_SetItemString (dict, "Noise", Noise_Init());
|
||||
PyDict_SetItemString (dict, "Mathutils",Mathutils_Init());
|
||||
}
|
||||
|
||||
@@ -33,6 +33,40 @@
|
||||
#include "Particle.h"
|
||||
#include "Wave.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Effect methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef BPy_Effect_methods[] = {
|
||||
{0}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Effect_Type structure definition: */
|
||||
/*****************************************************************************/
|
||||
PyTypeObject Effect_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Effect", /* tp_name */
|
||||
sizeof (BPy_Effect), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)EffectDeAlloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
(getattrfunc)EffectGetAttr, /* tp_getattr */
|
||||
(setattrfunc)EffectSetAttr, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
(reprfunc)EffectRepr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_as_hash */
|
||||
0,0,0,0,0,0,
|
||||
0, /* tp_doc */
|
||||
0,0,0,0,0,0,
|
||||
BPy_Effect_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition for Blender.Effect module: */
|
||||
|
||||
@@ -46,14 +46,6 @@
|
||||
#include"gen_utils.h"
|
||||
#include "bpy_types.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python BPy_Effect methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef BPy_Effect_methods[] = {
|
||||
{0}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the Effect module. */
|
||||
/*****************************************************************************/
|
||||
@@ -79,32 +71,5 @@ PyObject *EffectRepr (BPy_Effect *msh);
|
||||
PyObject* EffectCreatePyObject (struct Effect *effect);
|
||||
int EffectCheckPyObject (PyObject *py_obj);
|
||||
struct Effect* EffectFromPyObject (PyObject *py_obj);
|
||||
/*****************************************************************************/
|
||||
/* Python Effect_Type structure definition: */
|
||||
/*****************************************************************************/
|
||||
static PyTypeObject Effect_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Effect", /* tp_name */
|
||||
sizeof (BPy_Effect), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)EffectDeAlloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
(getattrfunc)EffectGetAttr, /* tp_getattr */
|
||||
(setattrfunc)EffectSetAttr, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
(reprfunc)EffectRepr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_as_hash */
|
||||
0,0,0,0,0,0,
|
||||
0, /* tp_doc */
|
||||
0,0,0,0,0,0,
|
||||
BPy_Effect_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
#endif /* EXPP_EFFECT_H */
|
||||
|
||||
@@ -741,7 +741,7 @@ static PyObject *Object_getDrawMode (BPy_Object *self)
|
||||
|
||||
static PyObject *Object_getAction (BPy_Object *self)
|
||||
{
|
||||
BPy_Action *py_action = NULL;
|
||||
/*BPy_Action *py_action = NULL;*/
|
||||
|
||||
if(!self->object->action){
|
||||
Py_INCREF (Py_None);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
@@ -37,82 +37,106 @@ This module is a dictionary of all Blender Python types";
|
||||
|
||||
struct PyMethodDef Null_methods[] = {{NULL, NULL}};
|
||||
|
||||
void types_InitAll(void)
|
||||
{
|
||||
/* The internal types (lowercase first letter, like constant_Type) are only
|
||||
* set when some object initializes them. But unless we do it early, we get
|
||||
* some easy and unpredictable (varies with platform, even distro) ways to
|
||||
* crash Blender. Some modules also need this early up, so let's generalize
|
||||
* and init all our pytypes here. */
|
||||
|
||||
Action_Type.ob_type = &PyType_Type;
|
||||
Armature_Type.ob_type = &PyType_Type;
|
||||
BezTriple_Type.ob_type = &PyType_Type;
|
||||
Bone_Type.ob_type = &PyType_Type;
|
||||
Build_Type.ob_type = &PyType_Type;
|
||||
Button_Type.ob_type = &PyType_Type;
|
||||
Camera_Type.ob_type = &PyType_Type;
|
||||
Curve_Type.ob_type = &PyType_Type;
|
||||
Effect_Type.ob_type = &PyType_Type;
|
||||
Image_Type.ob_type = &PyType_Type;
|
||||
Ipo_Type.ob_type = &PyType_Type;
|
||||
IpoCurve_Type.ob_type = &PyType_Type;
|
||||
Lamp_Type.ob_type = &PyType_Type;
|
||||
Lattice_Type.ob_type = &PyType_Type;
|
||||
Material_Type.ob_type = &PyType_Type;
|
||||
Metaball_Type.ob_type = &PyType_Type;
|
||||
MTex_Type.ob_type = &PyType_Type;
|
||||
NMCol_Type.ob_type = &PyType_Type;
|
||||
NMFace_Type.ob_type = &PyType_Type;
|
||||
NMVert_Type.ob_type = &PyType_Type;
|
||||
NMesh_Type.ob_type = &PyType_Type;
|
||||
Object_Type.ob_type = &PyType_Type;
|
||||
Particle_Type.ob_type = &PyType_Type;
|
||||
Scene_Type.ob_type = &PyType_Type;
|
||||
Text_Type.ob_type = &PyType_Type;
|
||||
Texture_Type.ob_type = &PyType_Type;
|
||||
Wave_Type.ob_type = &PyType_Type;
|
||||
World_Type.ob_type = &PyType_Type;
|
||||
buffer_Type.ob_type = &PyType_Type;
|
||||
constant_Type.ob_type = &PyType_Type;
|
||||
euler_Type.ob_type = &PyType_Type;
|
||||
matrix_Type.ob_type = &PyType_Type;
|
||||
quaternion_Type.ob_type = &PyType_Type;
|
||||
rgbTuple_Type.ob_type = &PyType_Type;
|
||||
vector_Type.ob_type = &PyType_Type;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Types_Init */
|
||||
/* Function: Types_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *Types_Init (void)
|
||||
{
|
||||
PyObject *submodule, *dict;
|
||||
PyObject *submodule, *dict;
|
||||
|
||||
/* These are only set when some object initializes them. But unless we
|
||||
* do it now, we get an easy way to crash Blender. Maybe we'd better
|
||||
* have an Init function for all these internal types that more than one
|
||||
* module can use. We could call it after setting the Blender dictionary */
|
||||
Action_Type.ob_type = &PyType_Type;
|
||||
matrix_Type.ob_type = &PyType_Type;
|
||||
vector_Type.ob_type = &PyType_Type;
|
||||
euler_Type.ob_type = &PyType_Type;
|
||||
quaternion_Type.ob_type = &PyType_Type;
|
||||
rgbTuple_Type.ob_type = &PyType_Type;
|
||||
constant_Type.ob_type = &PyType_Type;
|
||||
buffer_Type.ob_type = &PyType_Type;
|
||||
Button_Type.ob_type = &PyType_Type;
|
||||
BezTriple_Type.ob_type = &PyType_Type;
|
||||
submodule = Py_InitModule3 ("Blender.Types", Null_methods, M_Types_doc);
|
||||
|
||||
/* Another one that needs to be here: */
|
||||
Text_Type.ob_type = &PyType_Type;
|
||||
dict = PyModule_GetDict(submodule);
|
||||
|
||||
Texture_Type.ob_type = &PyType_Type;
|
||||
MTex_Type.ob_type = &PyType_Type;
|
||||
/* The Blender Object Type */
|
||||
|
||||
submodule = Py_InitModule3 ("Blender.Types", Null_methods, M_Types_doc);
|
||||
PyDict_SetItemString(dict, "ObjectType", (PyObject *)&Object_Type);
|
||||
|
||||
dict = PyModule_GetDict(submodule);
|
||||
/* Blender Object Data Types */
|
||||
|
||||
/* The Blender Object Type */
|
||||
PyDict_SetItemString(dict, "SceneType", (PyObject *)&Scene_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "ObjectType", (PyObject *)&Object_Type);
|
||||
PyDict_SetItemString(dict, "NMeshType", (PyObject *)&NMesh_Type);
|
||||
PyDict_SetItemString(dict, "NMFaceType", (PyObject *)&NMFace_Type);
|
||||
PyDict_SetItemString(dict, "NMVertType", (PyObject *)&NMVert_Type);
|
||||
PyDict_SetItemString(dict, "NMColType", (PyObject *)&NMCol_Type);
|
||||
|
||||
/* Blender Object Data Types */
|
||||
PyDict_SetItemString(dict, "ArmatureType", (PyObject *)&Armature_Type);
|
||||
PyDict_SetItemString(dict, "BoneType", (PyObject *)&Bone_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "SceneType", (PyObject *)&Scene_Type);
|
||||
PyDict_SetItemString(dict, "CurveType", (PyObject *)&Curve_Type);
|
||||
PyDict_SetItemString(dict, "IpoType", (PyObject *)&Ipo_Type);
|
||||
PyDict_SetItemString(dict, "MetaballType", (PyObject *)&Metaball_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "NMeshType", (PyObject *)&NMesh_Type);
|
||||
PyDict_SetItemString(dict, "NMFaceType", (PyObject *)&NMFace_Type);
|
||||
PyDict_SetItemString(dict, "NMVertType", (PyObject *)&NMVert_Type);
|
||||
PyDict_SetItemString(dict, "NMColType", (PyObject *)&NMCol_Type);
|
||||
PyDict_SetItemString(dict, "CameraType", (PyObject *)&Camera_Type);
|
||||
PyDict_SetItemString(dict, "ImageType", (PyObject *)&Image_Type);
|
||||
PyDict_SetItemString(dict, "LampType", (PyObject *)&Lamp_Type);
|
||||
PyDict_SetItemString(dict, "TextType", (PyObject *)&Text_Type);
|
||||
PyDict_SetItemString(dict, "MaterialType", (PyObject *)&Material_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "ArmatureType", (PyObject *)&Armature_Type);
|
||||
PyDict_SetItemString(dict, "BoneType", (PyObject *)&Bone_Type);
|
||||
PyDict_SetItemString(dict, "ButtonType", (PyObject *)&Button_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "CurveType", (PyObject *)&Curve_Type);
|
||||
PyDict_SetItemString(dict, "IpoType", (PyObject *)&Ipo_Type);
|
||||
PyDict_SetItemString(dict, "MetaballType", (PyObject *)&Metaball_Type);
|
||||
PyDict_SetItemString(dict, "LatticeType", (PyObject *)&Lattice_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "CameraType", (PyObject *)&Camera_Type);
|
||||
PyDict_SetItemString(dict, "ImageType", (PyObject *)&Image_Type);
|
||||
PyDict_SetItemString(dict, "LampType", (PyObject *)&Lamp_Type);
|
||||
PyDict_SetItemString(dict, "TextType", (PyObject *)&Text_Type);
|
||||
PyDict_SetItemString(dict, "MaterialType", (PyObject *)&Material_Type);
|
||||
PyDict_SetItemString(dict, "TextureType", (PyObject *)&Texture_Type);
|
||||
PyDict_SetItemString(dict, "MTexType", (PyObject *)&MTex_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "ButtonType", (PyObject *)&Button_Type);
|
||||
/* External helper Types available to the main ones above */
|
||||
|
||||
PyDict_SetItemString(dict, "LatticeType", (PyObject *)&Lattice_Type);
|
||||
PyDict_SetItemString(dict, "vectorType", (PyObject *)&vector_Type);
|
||||
PyDict_SetItemString(dict, "bufferType", (PyObject *)&buffer_Type);
|
||||
PyDict_SetItemString(dict, "constantType", (PyObject *)&constant_Type);
|
||||
PyDict_SetItemString(dict, "rgbTupleType", (PyObject *)&rgbTuple_Type);
|
||||
PyDict_SetItemString(dict, "matrix_Type", (PyObject *)&matrix_Type);
|
||||
PyDict_SetItemString(dict, "eulerType", (PyObject *)&euler_Type);
|
||||
PyDict_SetItemString(dict, "quaternionType", (PyObject *)&quaternion_Type);
|
||||
PyDict_SetItemString(dict, "BezTripleType", (PyObject *)&BezTriple_Type);
|
||||
PyDict_SetItemString(dict, "ActionType", (PyObject *)&Action_Type);
|
||||
|
||||
PyDict_SetItemString(dict, "TextureType", (PyObject *)&Texture_Type);
|
||||
PyDict_SetItemString(dict, "MTexType", (PyObject *)&MTex_Type);
|
||||
|
||||
/* External helper Types available to the main ones above */
|
||||
|
||||
PyDict_SetItemString(dict, "vectorType", (PyObject *)&vector_Type);
|
||||
PyDict_SetItemString(dict, "bufferType", (PyObject *)&buffer_Type);
|
||||
PyDict_SetItemString(dict, "constantType", (PyObject *)&constant_Type);
|
||||
PyDict_SetItemString(dict, "rgbTupleType", (PyObject *)&rgbTuple_Type);
|
||||
PyDict_SetItemString(dict, "matrix_Type", (PyObject *)&matrix_Type);
|
||||
PyDict_SetItemString(dict, "eulerType", (PyObject *)&euler_Type);
|
||||
PyDict_SetItemString(dict, "quaternionType", (PyObject *)&quaternion_Type);
|
||||
PyDict_SetItemString(dict, "BezTripleType", (PyObject *)&BezTriple_Type);
|
||||
PyDict_SetItemString(dict, "ActionType", (PyObject *)&Action_Type);
|
||||
|
||||
return submodule;
|
||||
return submodule;
|
||||
}
|
||||
|
||||
@@ -34,22 +34,21 @@
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
extern PyTypeObject Button_Type, Material_Type;
|
||||
|
||||
extern PyTypeObject Texture_Type, MTex_Type;
|
||||
|
||||
extern PyTypeObject Action_Type, Armature_Type;
|
||||
extern PyTypeObject BezTriple_Type, Bone_Type, Build_Type, Button_Type;
|
||||
extern PyTypeObject Camera_Type, Curve_Type;
|
||||
extern PyTypeObject Effect_Type;
|
||||
extern PyTypeObject Image_Type, Ipo_Type, IpoCurve_Type;
|
||||
extern PyTypeObject Lamp_Type, Lattice_Type;
|
||||
extern PyTypeObject Material_Type, Metaball_Type, MTex_Type;
|
||||
extern PyTypeObject NMFace_Type, NMVert_Type, NMCol_Type, NMesh_Type;
|
||||
extern PyTypeObject Object_Type;
|
||||
extern PyTypeObject Particle_Type;
|
||||
extern PyTypeObject Scene_Type;
|
||||
extern PyTypeObject NMesh_Type, NMFace_Type, NMVert_Type, NMCol_Type;
|
||||
extern PyTypeObject Camera_Type, Lamp_Type, Image_Type, Text_Type;
|
||||
extern PyTypeObject Armature_Type, Bone_Type;
|
||||
extern PyTypeObject Curve_Type, Ipo_Type, Metaball_Type;
|
||||
extern PyTypeObject Lattice_Type;
|
||||
extern PyTypeObject Text_Type, Texture_Type;
|
||||
extern PyTypeObject Wave_Type, World_Type;
|
||||
|
||||
extern PyTypeObject buffer_Type, rgbTuple_Type,
|
||||
constant_Type, BezTriple_Type;
|
||||
|
||||
extern PyTypeObject vector_Type, matrix_Type, euler_Type, quaternion_Type;
|
||||
extern PyTypeObject Action_Type;
|
||||
extern PyTypeObject buffer_Type, constant_Type, euler_Type;
|
||||
extern PyTypeObject matrix_Type, quaternion_Type, rgbTuple_Type, vector_Type;
|
||||
|
||||
#endif /* EXPP_TYPES_H */
|
||||
|
||||
@@ -381,3 +381,12 @@ def Text(string, fontsize = 'normal'):
|
||||
@rtype: int
|
||||
@return: The width of I{string} drawn with the chosen I{fontsize}.
|
||||
"""
|
||||
|
||||
class Button:
|
||||
"""
|
||||
The Button object
|
||||
=================
|
||||
This object represents a button in Blender's GUI.
|
||||
@type val: int or float or string (depends on button type).
|
||||
@cvar val: The button's value.
|
||||
"""
|
||||
|
||||
@@ -264,7 +264,7 @@ PyObject *Matrix_Invert(MatrixObject *self)
|
||||
{
|
||||
float det;
|
||||
int x,y,z;
|
||||
float *mat;
|
||||
float *mat = NULL;
|
||||
float t;
|
||||
|
||||
if(self->rowSize != self->colSize)
|
||||
|
||||
@@ -62,6 +62,8 @@ extern PyObject *g_blenderdict;
|
||||
/*****************************************************************************/
|
||||
void M_Blender_Init (void);
|
||||
|
||||
void types_InitAll(void); /* in Types.c */
|
||||
|
||||
/* sys */
|
||||
PyObject * sys_Init (void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user