- update to constant.c

- give it the key/items interface
  - creates some factory functions for const generation
- genutils methods
  - method for getting module constants
  - method for throwing errors with a print string
- updates to function names
- clean up interpreter launch a bit
This commit is contained in:
2005-08-17 14:26:00 +00:00
parent 2872263377
commit 8b060dd5ad
16 changed files with 435 additions and 361 deletions

View File

@@ -73,6 +73,14 @@
*/
//#include "api2_2x/Registry.h"
/*Declares the modules and their initialization functions
*These are TOP-LEVEL modules e.g. import `module` - there is no
*support for packages here e.g. import `package.module` */
static struct _inittab BPy_Inittab_Modules[] = {
{"Blender", M_Blender_Init},
{NULL}
};
/*************************************************************************
* Structure definitions
**************************************************************************/
@@ -105,11 +113,9 @@ PyObject *traceback_getFilename( PyObject * tb );
void BPY_free_screen_spacehandlers(struct bScreen *sc);
/****************************************************************************
* Description: This function will initialise Python and all the implemented
* api variations.
* Notes: Currently only the api for 2.2x will be initialised.
* Description: This function will start the interpreter and load all modules
* as well as search for a python installation.
****************************************************************************/
void BPY_start_python( int argc, char **argv )
{
@@ -120,35 +126,38 @@ void BPY_start_python( int argc, char **argv )
/* we keep a copy of the values of argc and argv so that the game engine
* can call BPY_start_python(0, NULL) whenever a game ends, without having
* to know argc and argv there (in source/blender/src/space.c) */
if( first_time ) {
argc_copy = argc;
argv_copy = argv;
}
//stuff for Registry module
bpy_registryDict = PyDict_New( );/* check comment at start of this file */
if( !bpy_registryDict )
printf( "Error: Couldn't create the Registry Python Dictionary!" );
Py_SetProgramName( "blender" );
/*
* Py_Initialize() will attempt to import the site module and
/* Py_Initialize() will attempt to import the site module and
* print an error if not found. See init_syspath() for the
* rest of our init msgs.
*/
/* Py_GetVersion() returns a ptr to astatic string */
// Py_GetVersion() returns a ptr to astatic string
printf( "Using Python version %.3s\n", Py_GetVersion() );
//Initialize the TOP-LEVEL modules
PyImport_ExtendInittab(BPy_Inittab_Modules);
//Start the interpreter
Py_Initialize( );
PySys_SetArgv( argc_copy, argv_copy );
//Overrides __import__
init_ourImport( );
initBlenderApi2_2x( );
//init a global dictionary
g_blenderdict = NULL;
//Look for a python installation
init_syspath( first_time ); /* not first_time: some msgs are suppressed */
return;
@@ -521,12 +530,12 @@ int BPY_txt_do_python_Text( struct Text *text )
script->py_globaldict = py_dict;
info = ( BPy_constant * ) M_constant_New( );
info = ( BPy_constant * ) PyConstant_New( );
if( info ) {
constant_insert( info, "name",
PyConstant_Insert( info, "name",
PyString_FromString( script->id.name + 2 ) );
Py_INCREF( Py_None );
constant_insert( info, "arg", Py_None );
PyConstant_Insert( info, "arg", Py_None );
PyDict_SetItemString( py_dict, "__script__",
( PyObject * ) info );
}
@@ -751,11 +760,11 @@ int BPY_menu_do_python( short menutype, int event )
script->py_globaldict = py_dict;
info = ( BPy_constant * ) M_constant_New( );
info = ( BPy_constant * ) PyConstant_New( );
if( info ) {
constant_insert( info, "name",
PyConstant_Insert( info, "name",
PyString_FromString( script->id.name + 2 ) );
constant_insert( info, "arg", pyarg );
PyConstant_Insert( info, "arg", pyarg );
PyDict_SetItemString( py_dict, "__script__",
( PyObject * ) info );
}

View File

@@ -752,24 +752,22 @@ static PyObject * Blender_UpdateMenus( PyObject * self )
/*****************************************************************************/
/* Function: initBlender */
/*****************************************************************************/
void M_Blender_Init( void )
void M_Blender_Init(void)
{
PyObject *module;
PyObject *dict, *smode, *SpaceHandlers;
g_blenderdict = NULL;
module = Py_InitModule3("Blender", Blender_methods,
"The main Blender module");
module = Py_InitModule3( "Blender", Blender_methods,
"The main Blender module" );
types_InitAll(); /* set all our pytypes to &PyType_Type */
types_InitAll( ); /* set all our pytypes to &PyType_Type */
SpaceHandlers = M_constant_New();
SpaceHandlers = PyConstant_New();
if (SpaceHandlers) {
BPy_constant *d = (BPy_constant *)SpaceHandlers;
constant_insert(d,"VIEW3D_EVENT",PyInt_FromLong(SPACEHANDLER_VIEW3D_EVENT));
constant_insert(d,"VIEW3D_DRAW", PyInt_FromLong(SPACEHANDLER_VIEW3D_DRAW));
PyConstant_Insert(d,"VIEW3D_EVENT",PyInt_FromLong(SPACEHANDLER_VIEW3D_EVENT));
PyConstant_Insert(d,"VIEW3D_DRAW", PyInt_FromLong(SPACEHANDLER_VIEW3D_DRAW));
PyModule_AddObject(module, "SpaceHandlers", SpaceHandlers);
}
@@ -779,45 +777,46 @@ void M_Blender_Init( void )
else
smode = PyString_FromString("interactive");
dict = PyModule_GetDict( module );
dict = PyModule_GetDict(module);
g_blenderdict = dict;
PyDict_SetItemString( dict, "bylink", EXPP_incr_ret_False() );
PyDict_SetItemString( dict, "link", EXPP_incr_ret ( Py_None ) );
PyDict_SetItemString( dict, "event", PyString_FromString( "" ) );
PyDict_SetItemString( dict, "mode", smode );
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, "Material", Material_Init( ) );
PyDict_SetItemString( dict, "Camera", Camera_Init( ) );
PyDict_SetItemString( dict, "Lamp", Lamp_Init( ) );
PyDict_SetItemString( dict, "Lattice", Lattice_Init( ) );
PyDict_SetItemString( dict, "Curve", Curve_Init( ) );
PyDict_SetItemString( dict, "Armature", Armature_Init( ) );
PyDict_SetItemString( dict, "Ipo", Ipo_Init( ) );
PyDict_SetItemString( dict, "IpoCurve", IpoCurve_Init( ) );
PyDict_SetItemString( dict, "Metaball", Metaball_Init( ) );
PyDict_SetItemString( dict, "Image", Image_Init( ) );
PyDict_SetItemString( dict, "Window", Window_Init( ) );
PyDict_SetItemString( dict, "Draw", Draw_Init( ) );
PyDict_SetItemString( dict, "BGL", BGL_Init( ) );
PyDict_SetItemString( dict, "Effect", Effect_Init( ) );
PyDict_SetItemString( dict, "Text", Text_Init( ) );
PyDict_SetItemString( dict, "Text3d", Text3d_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( ) );
PyDict_SetItemString( dict, "Library", Library_Init( ) );
PyDict_SetItemString( dict, "Sound", Sound_Init( ) );
PyDict_SetItemString( dict, "CurNurb", CurNurb_Init( ) );
PyDict_SetItemString( dict, "BezTriple", BezTriple_Init( ) );
PyModule_AddIntConstant( module, "TRUE", 1 );
PyModule_AddIntConstant(module, "TRUE", 1);
PyModule_AddIntConstant( module, "FALSE", 0 );
PyDict_SetItemString(dict, "bylink", EXPP_incr_ret_False());
PyDict_SetItemString(dict, "link", EXPP_incr_ret (Py_None));
PyDict_SetItemString(dict, "event", PyString_FromString(""));
PyDict_SetItemString(dict, "mode", smode);
PyDict_SetItemString(dict, "Armature", Armature_Init());
PyDict_SetItemString(dict, "BezTriple", BezTriple_Init());
PyDict_SetItemString(dict, "BGL", BGL_Init());
PyDict_SetItemString(dict, "CurNurb", CurNurb_Init());
PyDict_SetItemString(dict, "Curve", Curve_Init());
PyDict_SetItemString(dict, "Camera", Camera_Init());
PyDict_SetItemString(dict, "Draw", Draw_Init());
PyDict_SetItemString(dict, "Effect", Effect_Init());
PyDict_SetItemString(dict, "Ipo", Ipo_Init());
PyDict_SetItemString(dict, "IpoCurve", IpoCurve_Init());
PyDict_SetItemString(dict, "Image", Image_Init());
PyDict_SetItemString(dict, "Lamp", Lamp_Init());
PyDict_SetItemString(dict, "Lattice", Lattice_Init());
PyDict_SetItemString(dict, "Library", Library_Init());
PyDict_SetItemString(dict, "Material", Material_Init());
PyDict_SetItemString(dict, "Metaball", Metaball_Init());
PyDict_SetItemString(dict, "Mathutils", Mathutils_Init());
PyDict_SetItemString(dict, "NMesh", NMesh_Init());
PyDict_SetItemString(dict, "Noise", Noise_Init());
PyDict_SetItemString(dict, "Object", Object_Init());
PyDict_SetItemString(dict, "Registry", Registry_Init());
PyDict_SetItemString(dict, "sys", sys_Init());
PyDict_SetItemString(dict, "Scene", Scene_Init());
PyDict_SetItemString(dict, "Sound", Sound_Init());
PyDict_SetItemString(dict, "Types", Types_Init());
PyDict_SetItemString(dict, "Text", Text_Init());
PyDict_SetItemString(dict, "Text3d", Text3d_Init());
PyDict_SetItemString(dict, "Texture", Texture_Init());
PyDict_SetItemString(dict, "Window", Window_Init());
PyDict_SetItemString(dict, "World", World_Init());
}

View File

@@ -39,12 +39,6 @@
extern char bprogname[]; /* argv[0] from creator.c */
void initBlenderApi2_2x( void )
{
g_blenderdict = NULL;
M_Blender_Init( );
}
/* this makes sure BLI_gethome() returns a path with '.blender' appended
* Besides, this function now either returns userhome/.blender (if it exists)
* or blenderInstallDir/.blender/ otherwise (can also be cvs dir).

View File

@@ -389,10 +389,10 @@ static PyObject *Image_setPixelF( BPy_Image * self, PyObject * args )
pixel = ( char * ) image->ibuf->rect;
pixel[index] = ( int ) ( p[0] * 255.0 );
pixel[index + 1] = ( int ) ( p[1] * 255.0 );
pixel[index + 2] = ( int ) ( p[2] * 255.0 );
pixel[index + 3] = ( int ) ( p[3] * 255.0 );
pixel[index] = ( char ) ( p[0] * 255.0 );
pixel[index + 1] = ( char ) ( p[1] * 255.0 );
pixel[index + 2] = ( char ) ( p[2] * 255.0 );
pixel[index + 3] = ( char ) ( p[3] * 255.0 );
Py_RETURN_NONE;
}
@@ -448,10 +448,10 @@ static PyObject *Image_setPixelI( BPy_Image * self, PyObject * args )
pixel = ( char * ) image->ibuf->rect;
pixel[index] = p[0];
pixel[index + 1] = p[1];
pixel[index + 2] = p[2];
pixel[index + 3] = p[3];
pixel[index] = ( char ) p[0];
pixel[index + 1] = ( char ) p[1];
pixel[index + 2] = ( char ) p[2];
pixel[index + 3] = ( char ) p[3];
Py_RETURN_NONE;
}

View File

@@ -485,22 +485,22 @@ static PyObject *M_Lamp_Get( PyObject * self, PyObject * args )
static PyObject *Lamp_TypesDict( void )
{ /* create the Blender.Lamp.Types constant dict */
PyObject *Types = M_constant_New( );
PyObject *Types = PyConstant_New( );
if( Types ) {
BPy_constant *c = ( BPy_constant * ) Types;
constant_insert( c, "Lamp",
PyConstant_Insert( c, "Lamp",
PyInt_FromLong( EXPP_LAMP_TYPE_LAMP ) );
constant_insert( c, "Sun",
PyConstant_Insert( c, "Sun",
PyInt_FromLong( EXPP_LAMP_TYPE_SUN ) );
constant_insert( c, "Spot",
PyConstant_Insert( c, "Spot",
PyInt_FromLong( EXPP_LAMP_TYPE_SPOT ) );
constant_insert( c, "Hemi",
PyConstant_Insert( c, "Hemi",
PyInt_FromLong( EXPP_LAMP_TYPE_HEMI ) );
constant_insert( c, "Area",
PyConstant_Insert( c, "Area",
PyInt_FromLong( EXPP_LAMP_TYPE_AREA ) );
constant_insert( c, "Photon",
PyConstant_Insert( c, "Photon",
PyInt_FromLong( EXPP_LAMP_TYPE_YF_PHOTON ) );
}
@@ -509,30 +509,30 @@ static PyObject *Lamp_TypesDict( void )
static PyObject *Lamp_ModesDict( void )
{ /* create the Blender.Lamp.Modes constant dict */
PyObject *Modes = M_constant_New( );
PyObject *Modes = PyConstant_New( );
if( Modes ) {
BPy_constant *c = ( BPy_constant * ) Modes;
constant_insert( c, "Shadows",
PyConstant_Insert( c, "Shadows",
PyInt_FromLong( EXPP_LAMP_MODE_SHADOWS ) );
constant_insert( c, "Halo",
PyConstant_Insert( c, "Halo",
PyInt_FromLong( EXPP_LAMP_MODE_HALO ) );
constant_insert( c, "Layer",
PyConstant_Insert( c, "Layer",
PyInt_FromLong( EXPP_LAMP_MODE_LAYER ) );
constant_insert( c, "Quad",
PyConstant_Insert( c, "Quad",
PyInt_FromLong( EXPP_LAMP_MODE_QUAD ) );
constant_insert( c, "Negative",
PyConstant_Insert( c, "Negative",
PyInt_FromLong( EXPP_LAMP_MODE_NEGATIVE ) );
constant_insert( c, "Sphere",
PyConstant_Insert( c, "Sphere",
PyInt_FromLong( EXPP_LAMP_MODE_SPHERE ) );
constant_insert( c, "Square",
PyConstant_Insert( c, "Square",
PyInt_FromLong( EXPP_LAMP_MODE_SQUARE ) );
constant_insert( c, "OnlyShadow",
PyConstant_Insert( c, "OnlyShadow",
PyInt_FromLong( EXPP_LAMP_MODE_ONLYSHADOW ) );
constant_insert( c, "NoDiffuse",
PyConstant_Insert( c, "NoDiffuse",
PyInt_FromLong( EXPP_LAMP_MODE_NODIFFUSE ) );
constant_insert( c, "NoSpecular",
PyConstant_Insert( c, "NoSpecular",
PyInt_FromLong( EXPP_LAMP_MODE_NOSPECULAR ) );
}

View File

@@ -366,11 +366,11 @@ static PyObject *M_Material_Get( PyObject * self, PyObject * args )
static PyObject *Material_ModesDict( void )
{
PyObject *Modes = M_constant_New( );
PyObject *Modes = PyConstant_New( );
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(c, #name, PyInt_FromLong(EXPP_MAT_MODE_##name))
PyConstant_Insert(c, #name, PyInt_FromLong(EXPP_MAT_MODE_##name))
/* So that:
* EXPP_ADDCONST(TRACEABLE) becomes:
@@ -414,11 +414,11 @@ static PyObject *Material_ModesDict( void )
static PyObject *Material_ShadersDict( void )
{
PyObject *Shaders = M_constant_New( );
PyObject *Shaders = PyConstant_New( );
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(c, #name, PyInt_FromLong(EXPP_MAT_SHADER_##name))
PyConstant_Insert(c, #name, PyInt_FromLong(EXPP_MAT_SHADER_##name))
/* So that:
* EXPP_ADDCONST(DIFFUSE_LAMBERT) becomes:

View File

@@ -3223,17 +3223,17 @@ static struct PyMethodDef M_NMesh_methods[] = {
static PyObject *M_NMesh_Modes( void )
{
PyObject *Modes = M_constant_New( );
PyObject *Modes = PyConstant_New( );
if( Modes ) {
BPy_constant *d = ( BPy_constant * ) Modes;
constant_insert( d, "NOVNORMALSFLIP",
PyConstant_Insert( d, "NOVNORMALSFLIP",
PyInt_FromLong
( ME_NOPUNOFLIP ) );
constant_insert( d, "TWOSIDED",
PyConstant_Insert( d, "TWOSIDED",
PyInt_FromLong( ME_TWOSIDED ) );
constant_insert( d, "AUTOSMOOTH",
PyConstant_Insert( d, "AUTOSMOOTH",
PyInt_FromLong
( ME_AUTOSMOOTH ) );
}
@@ -3243,20 +3243,20 @@ static PyObject *M_NMesh_Modes( void )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(dict, name) \
constant_insert(dict, #name, PyInt_FromLong(TF_##name))
PyConstant_Insert(dict, #name, PyInt_FromLong(TF_##name))
/* Set constants for face drawing mode -- see drawmesh.c */
static PyObject *M_NMesh_FaceModesDict( void )
{
PyObject *FM = M_constant_New( );
PyObject *FM = PyConstant_New( );
if( FM ) {
BPy_constant *d = ( BPy_constant * ) FM;
constant_insert( d, "BILLBOARD",
PyConstant_Insert( d, "BILLBOARD",
PyInt_FromLong( TF_BILLBOARD2 ) );
constant_insert( d, "ALL", PyInt_FromLong( 0xffff ) );
constant_insert( d, "HALO", PyInt_FromLong( TF_BILLBOARD ) );
PyConstant_Insert( d, "ALL", PyInt_FromLong( 0xffff ) );
PyConstant_Insert( d, "HALO", PyInt_FromLong( TF_BILLBOARD ) );
EXPP_ADDCONST( d, DYNAMIC );
EXPP_ADDCONST( d, INVISIBLE );
EXPP_ADDCONST( d, LIGHT );
@@ -3274,7 +3274,7 @@ static PyObject *M_NMesh_FaceModesDict( void )
static PyObject *M_NMesh_FaceFlagsDict( void )
{
PyObject *FF = M_constant_New( );
PyObject *FF = PyConstant_New( );
if( FF ) {
BPy_constant *d = ( BPy_constant * ) FF;
@@ -3289,7 +3289,7 @@ static PyObject *M_NMesh_FaceFlagsDict( void )
static PyObject *M_NMesh_FaceTranspModesDict( void )
{
PyObject *FTM = M_constant_New( );
PyObject *FTM = PyConstant_New( );
if( FTM ) {
BPy_constant *d = ( BPy_constant * ) FTM;
@@ -3305,16 +3305,16 @@ static PyObject *M_NMesh_FaceTranspModesDict( void )
static PyObject *M_NMesh_EdgeFlagsDict( void )
{
PyObject *EF = M_constant_New( );
PyObject *EF = PyConstant_New( );
if( EF ) {
BPy_constant *d = ( BPy_constant * ) EF;
constant_insert(d, "SELECT", PyInt_FromLong(1));
constant_insert(d, "EDGEDRAW", PyInt_FromLong(ME_EDGEDRAW));
constant_insert(d, "EDGERENDER", PyInt_FromLong(ME_EDGERENDER));
constant_insert(d, "SEAM", PyInt_FromLong(ME_SEAM));
constant_insert(d, "FGON", PyInt_FromLong(ME_FGON));
PyConstant_Insert(d, "SELECT", PyInt_FromLong(1));
PyConstant_Insert(d, "EDGEDRAW", PyInt_FromLong(ME_EDGEDRAW));
PyConstant_Insert(d, "EDGERENDER", PyInt_FromLong(ME_EDGERENDER));
PyConstant_Insert(d, "SEAM", PyInt_FromLong(ME_SEAM));
PyConstant_Insert(d, "FGON", PyInt_FromLong(ME_FGON));
}
return EF;

View File

@@ -615,49 +615,49 @@ PyObject *Noise_Init(void)
setRndSeed( 0 );
/* Constant noisetype dictionary */
NoiseTypes = M_constant_New( );
NoiseTypes = PyConstant_New( );
if( NoiseTypes ) {
BPy_constant *nt = ( BPy_constant * ) NoiseTypes;
constant_insert( nt, "BLENDER",
PyConstant_Insert( nt, "BLENDER",
PyInt_FromLong( TEX_BLENDER ) );
constant_insert( nt, "STDPERLIN",
PyConstant_Insert( nt, "STDPERLIN",
PyInt_FromLong( TEX_STDPERLIN ) );
constant_insert( nt, "NEWPERLIN",
PyConstant_Insert( nt, "NEWPERLIN",
PyInt_FromLong( TEX_NEWPERLIN ) );
constant_insert( nt, "VORONOI_F1",
PyConstant_Insert( nt, "VORONOI_F1",
PyInt_FromLong( TEX_VORONOI_F1 ) );
constant_insert( nt, "VORONOI_F2",
PyConstant_Insert( nt, "VORONOI_F2",
PyInt_FromLong( TEX_VORONOI_F2 ) );
constant_insert( nt, "VORONOI_F3",
PyConstant_Insert( nt, "VORONOI_F3",
PyInt_FromLong( TEX_VORONOI_F3 ) );
constant_insert( nt, "VORONOI_F4",
PyConstant_Insert( nt, "VORONOI_F4",
PyInt_FromLong( TEX_VORONOI_F4 ) );
constant_insert( nt, "VORONOI_F2F1",
PyConstant_Insert( nt, "VORONOI_F2F1",
PyInt_FromLong( TEX_VORONOI_F2F1 ) );
constant_insert( nt, "VORONOI_CRACKLE",
PyConstant_Insert( nt, "VORONOI_CRACKLE",
PyInt_FromLong( TEX_VORONOI_CRACKLE ) );
constant_insert( nt, "CELLNOISE",
PyConstant_Insert( nt, "CELLNOISE",
PyInt_FromLong( TEX_CELLNOISE ) );
PyModule_AddObject( md, "NoiseTypes", NoiseTypes );
}
/* Constant distance metric dictionary for voronoi */
DistanceMetrics = M_constant_New( );
DistanceMetrics = PyConstant_New( );
if( DistanceMetrics ) {
BPy_constant *dm = ( BPy_constant * ) DistanceMetrics;
constant_insert( dm, "DISTANCE",
PyConstant_Insert( dm, "DISTANCE",
PyInt_FromLong( TEX_DISTANCE ) );
constant_insert( dm, "DISTANCE_SQUARED",
PyConstant_Insert( dm, "DISTANCE_SQUARED",
PyInt_FromLong( TEX_DISTANCE_SQUARED ) );
constant_insert( dm, "MANHATTAN",
PyConstant_Insert( dm, "MANHATTAN",
PyInt_FromLong( TEX_MANHATTAN ) );
constant_insert( dm, "CHEBYCHEV",
PyConstant_Insert( dm, "CHEBYCHEV",
PyInt_FromLong( TEX_CHEBYCHEV ) );
constant_insert( dm, "MINKOVSKY_HALF",
PyConstant_Insert( dm, "MINKOVSKY_HALF",
PyInt_FromLong( TEX_MINKOVSKY_HALF ) );
constant_insert( dm, "MINKOVSKY_FOUR",
PyConstant_Insert( dm, "MINKOVSKY_FOUR",
PyInt_FromLong( TEX_MINKOVSKY_FOUR ) );
constant_insert( dm, "MINKOVSKY",
PyConstant_Insert( dm, "MINKOVSKY",
PyInt_FromLong( TEX_MINKOVSKY ) );
PyModule_AddObject( md, "DistanceMetrics", DistanceMetrics );
}

View File

@@ -352,11 +352,11 @@ PyObject *M_Text3d_Get( PyObject * self, PyObject * args )
static PyObject *generate_ModuleIntConstant(char *name, int value)
{
PyObject *constant = M_constant_New();
PyObject *constant = PyConstant_New();
constant_insert((BPy_constant*)constant,
PyConstant_Insert((BPy_constant*)constant,
"value", PyInt_FromLong(value));
constant_insert((BPy_constant*)constant,
PyConstant_Insert((BPy_constant*)constant,
"name", PyString_FromString(name));
Py_INCREF(constant);

View File

@@ -600,11 +600,11 @@ static PyObject *M_Texture_Get( PyObject * self, PyObject * args )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_TYPE_##name))
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_TYPE_##name))
static PyObject *M_Texture_TypesDict( void )
{
PyObject *Types = M_constant_New( );
PyObject *Types = PyConstant_New( );
if( Types ) {
BPy_constant *d = ( BPy_constant * ) Types;
@@ -628,11 +628,11 @@ static PyObject *M_Texture_TypesDict( void )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_STYPE_##name))
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_STYPE_##name))
static PyObject *M_Texture_STypesDict( void )
{
PyObject *STypes = M_constant_New( );
PyObject *STypes = PyConstant_New( );
if( STypes ) {
BPy_constant *d = ( BPy_constant * ) STypes;
@@ -693,11 +693,11 @@ static PyObject *M_Texture_STypesDict( void )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_TEXCO_##name))
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_TEXCO_##name))
static PyObject *M_Texture_TexCoDict( void )
{
PyObject *TexCo = M_constant_New( );
PyObject *TexCo = PyConstant_New( );
if( TexCo ) {
BPy_constant *d = ( BPy_constant * ) TexCo;
@@ -717,11 +717,11 @@ static PyObject *M_Texture_TexCoDict( void )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_MAPTO_##name))
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_MAPTO_##name))
static PyObject *M_Texture_MapToDict( void )
{
PyObject *MapTo = M_constant_New( );
PyObject *MapTo = PyConstant_New( );
if( MapTo ) {
BPy_constant *d = ( BPy_constant * ) MapTo;
@@ -745,11 +745,11 @@ static PyObject *M_Texture_MapToDict( void )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_FLAG_##name))
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_FLAG_##name))
static PyObject *M_Texture_FlagsDict( void )
{
PyObject *Flags = M_constant_New( );
PyObject *Flags = PyConstant_New( );
if( Flags ) {
BPy_constant *d = ( BPy_constant * ) Flags;
@@ -763,11 +763,11 @@ static PyObject *M_Texture_FlagsDict( void )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_EXTEND_##name))
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_EXTEND_##name))
static PyObject *M_Texture_ExtendModesDict( void )
{
PyObject *ExtendModes = M_constant_New( );
PyObject *ExtendModes = PyConstant_New( );
if( ExtendModes ) {
BPy_constant *d = ( BPy_constant * ) ExtendModes;
@@ -782,11 +782,11 @@ static PyObject *M_Texture_ExtendModesDict( void )
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_IMAGEFLAG_##name))
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_IMAGEFLAG_##name))
static PyObject *M_Texture_ImageFlagsDict( void )
{
PyObject *ImageFlags = M_constant_New( );
PyObject *ImageFlags = PyConstant_New( );
if( ImageFlags ) {
BPy_constant *d = ( BPy_constant * ) ImageFlags;

View File

@@ -1350,28 +1350,28 @@ PyObject *Window_Init( void )
if( dict )
PyDict_SetItemString( dict, "Theme", Theme_Init( ) );
Types = M_constant_New( );
Qual = M_constant_New( );
MButs = M_constant_New( );
Types = PyConstant_New( );
Qual = PyConstant_New( );
MButs = PyConstant_New( );
if( Types ) {
BPy_constant *d = ( BPy_constant * ) Types;
constant_insert( d, "VIEW3D", PyInt_FromLong( SPACE_VIEW3D ) );
constant_insert( d, "IPO", PyInt_FromLong( SPACE_IPO ) );
constant_insert( d, "OOPS", PyInt_FromLong( SPACE_OOPS ) );
constant_insert( d, "BUTS", PyInt_FromLong( SPACE_BUTS ) );
constant_insert( d, "FILE", PyInt_FromLong( SPACE_FILE ) );
constant_insert( d, "IMAGE", PyInt_FromLong( SPACE_IMAGE ) );
constant_insert( d, "INFO", PyInt_FromLong( SPACE_INFO ) );
constant_insert( d, "SEQ", PyInt_FromLong( SPACE_SEQ ) );
constant_insert( d, "IMASEL", PyInt_FromLong( SPACE_IMASEL ) );
constant_insert( d, "SOUND", PyInt_FromLong( SPACE_SOUND ) );
constant_insert( d, "ACTION", PyInt_FromLong( SPACE_ACTION ) );
constant_insert( d, "TEXT", PyInt_FromLong( SPACE_TEXT ) );
constant_insert( d, "NLA", PyInt_FromLong( SPACE_NLA ) );
constant_insert( d, "SCRIPT", PyInt_FromLong( SPACE_SCRIPT ) );
constant_insert( d, "TIME", PyInt_FromLong( SPACE_TIME ) );
PyConstant_Insert( d, "VIEW3D", PyInt_FromLong( SPACE_VIEW3D ) );
PyConstant_Insert( d, "IPO", PyInt_FromLong( SPACE_IPO ) );
PyConstant_Insert( d, "OOPS", PyInt_FromLong( SPACE_OOPS ) );
PyConstant_Insert( d, "BUTS", PyInt_FromLong( SPACE_BUTS ) );
PyConstant_Insert( d, "FILE", PyInt_FromLong( SPACE_FILE ) );
PyConstant_Insert( d, "IMAGE", PyInt_FromLong( SPACE_IMAGE ) );
PyConstant_Insert( d, "INFO", PyInt_FromLong( SPACE_INFO ) );
PyConstant_Insert( d, "SEQ", PyInt_FromLong( SPACE_SEQ ) );
PyConstant_Insert( d, "IMASEL", PyInt_FromLong( SPACE_IMASEL ) );
PyConstant_Insert( d, "SOUND", PyInt_FromLong( SPACE_SOUND ) );
PyConstant_Insert( d, "ACTION", PyInt_FromLong( SPACE_ACTION ) );
PyConstant_Insert( d, "TEXT", PyInt_FromLong( SPACE_TEXT ) );
PyConstant_Insert( d, "NLA", PyInt_FromLong( SPACE_NLA ) );
PyConstant_Insert( d, "SCRIPT", PyInt_FromLong( SPACE_SCRIPT ) );
PyConstant_Insert( d, "TIME", PyInt_FromLong( SPACE_TIME ) );
PyModule_AddObject( submodule, "Types", Types );
}
@@ -1379,15 +1379,15 @@ PyObject *Window_Init( void )
if( Qual ) {
BPy_constant *d = ( BPy_constant * ) Qual;
constant_insert( d, "LALT", PyInt_FromLong( L_ALTKEY ) );
constant_insert( d, "RALT", PyInt_FromLong( R_ALTKEY ) );
constant_insert( d, "ALT", PyInt_FromLong( LR_ALTKEY ) );
constant_insert( d, "LCTRL", PyInt_FromLong( L_CTRLKEY ) );
constant_insert( d, "RCTRL", PyInt_FromLong( R_CTRLKEY ) );
constant_insert( d, "CTRL", PyInt_FromLong( LR_CTRLKEY ) );
constant_insert( d, "LSHIFT", PyInt_FromLong( L_SHIFTKEY ) );
constant_insert( d, "RSHIFT", PyInt_FromLong( R_SHIFTKEY ) );
constant_insert( d, "SHIFT", PyInt_FromLong( LR_SHIFTKEY ) );
PyConstant_Insert( d, "LALT", PyInt_FromLong( L_ALTKEY ) );
PyConstant_Insert( d, "RALT", PyInt_FromLong( R_ALTKEY ) );
PyConstant_Insert( d, "ALT", PyInt_FromLong( LR_ALTKEY ) );
PyConstant_Insert( d, "LCTRL", PyInt_FromLong( L_CTRLKEY ) );
PyConstant_Insert( d, "RCTRL", PyInt_FromLong( R_CTRLKEY ) );
PyConstant_Insert( d, "CTRL", PyInt_FromLong( LR_CTRLKEY ) );
PyConstant_Insert( d, "LSHIFT", PyInt_FromLong( L_SHIFTKEY ) );
PyConstant_Insert( d, "RSHIFT", PyInt_FromLong( R_SHIFTKEY ) );
PyConstant_Insert( d, "SHIFT", PyInt_FromLong( LR_SHIFTKEY ) );
PyModule_AddObject( submodule, "Qual", Qual );
}
@@ -1395,9 +1395,9 @@ PyObject *Window_Init( void )
if( MButs ) {
BPy_constant *d = ( BPy_constant * ) MButs;
constant_insert( d, "L", PyInt_FromLong( L_MOUSE ) );
constant_insert( d, "M", PyInt_FromLong( M_MOUSE ) );
constant_insert( d, "R", PyInt_FromLong( R_MOUSE ) );
PyConstant_Insert( d, "L", PyInt_FromLong( L_MOUSE ) );
PyConstant_Insert( d, "M", PyInt_FromLong( M_MOUSE ) );
PyConstant_Insert( d, "R", PyInt_FromLong( R_MOUSE ) );
PyModule_AddObject( submodule, "MButs", MButs );
}

View File

@@ -25,7 +25,7 @@
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
* Contributor(s): Willian P. Germano, Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -34,171 +34,196 @@
#include "gen_utils.h"
/* This file is heavily based on the old bpython Constant object code in
Blender */
/*****************************************************************************/
/* Python constant_Type callback function prototypes: */
/*****************************************************************************/
static void constant_dealloc( BPy_constant * cam );
static PyObject *constant_getAttr( BPy_constant * cam, char *name );
static PyObject *constant_repr( BPy_constant * cam );
static int constantLength( BPy_constant * self );
static PyObject *constantSubscript( BPy_constant * self, PyObject * key );
static int constantAssSubscript( BPy_constant * self, PyObject * who,
PyObject * cares );
/*****************************************************************************/
/* Python constant_Type Mapping Methods table: */
/*****************************************************************************/
static PyMappingMethods constantAsMapping = {
( inquiry ) constantLength, /* mp_length */
( binaryfunc ) constantSubscript, /* mp_subscript */
( objobjargproc ) constantAssSubscript, /* mp_ass_subscript */
};
/*****************************************************************************/
/* Python constant_Type structure definition: */
/*****************************************************************************/
PyTypeObject constant_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
"Blender constant", /* tp_name */
sizeof( BPy_constant ), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
( destructor ) constant_dealloc, /* tp_dealloc */
0, /* tp_print */
( getattrfunc ) constant_getAttr, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
( reprfunc ) constant_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
&constantAsMapping, /* tp_as_mapping */
0, /* tp_as_hash */
0, 0, 0, 0, 0, 0,
0, /* tp_doc */
0, 0, 0, 0, 0, 0,
0, /* tp_methods */
0, /* tp_members */
};
/*****************************************************************************/
/* Function: constant_New */
/*****************************************************************************/
static PyObject *new_const( void );
PyObject *M_constant_New( void )
{ /* can't be static, we call it in other files */
return new_const( );
//------------------METHOD IMPLEMENTATIONS-----------------------------
//------------------------constant.items()
//Returns a list of key:value pairs like dict.items()
PyObject* constant_items(BPy_constant *self)
{
return PyDict_Items(self->dict);
}
static PyObject *new_const( void )
{ /* this is the static one */
//------------------------constant.keys()
//Returns a list of keys like dict.keys()
PyObject* constant_keys(BPy_constant *self)
{
return PyDict_Keys(self->dict);
}
//------------------------constant.values()
//Returns a list of values like dict.values()
PyObject* constant_values(BPy_constant *self)
{
return PyDict_Values(self->dict);
}
//------------------ATTRIBUTE IMPLEMENTATION---------------------------
//------------------TYPE_OBECT IMPLEMENTATION--------------------------
//-----------------------(internal)
//Creates a new constant object
static PyObject *new_const(void)
{
BPy_constant *constant;
constant_Type.ob_type = &PyType_Type;
constant =
( BPy_constant * ) PyObject_NEW( BPy_constant,
&constant_Type );
if( constant == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create constant object" ) );
if( ( constant->dict = PyDict_New( ) ) == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create constant object's dictionary" ) );
return ( PyObject * ) constant;
}
/*****************************************************************************/
/* Python BPy_constant methods: */
/*****************************************************************************/
int constant_insert( BPy_constant * self, char *name, PyObject * value )
{
return PyDict_SetItemString( self->dict, name, value );
}
/*****************************************************************************/
/* Function: constant_dealloc */
/* Description: This is a callback function for the BPy_constant type. It is */
/* the destructor function. */
/*****************************************************************************/
static void constant_dealloc( BPy_constant * self )
{
Py_DECREF( self->dict );
PyObject_DEL( self );
}
/*****************************************************************************/
/* Function: constant_getAttr */
/* Description: This is a callback function for the BPy_constant type. It is */
/* the function that accesses BPy_constant member variables and */
/* methods. */
/*****************************************************************************/
static PyObject *constant_getAttr( BPy_constant * self, char *name )
{
if( self->dict ) {
PyObject *v;
if( !strcmp( name, "__members__" ) )
return PyDict_Keys( self->dict );
v = PyDict_GetItemString( self->dict, name );
if( v ) {
Py_INCREF( v ); /* was a borrowed ref */
return v;
}
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"attribute not found" ) );
constant = (BPy_constant *) PyObject_NEW(BPy_constant, &constant_Type);
if(constant == NULL){
return (EXPP_ReturnPyObjError(PyExc_MemoryError,
"couldn't create constant object"));
}
if((constant->dict = PyDict_New()) == NULL){
return (EXPP_ReturnPyObjError(PyExc_MemoryError,
"couldn't create constant object's dictionary"));
}
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"constant object lacks a dictionary" ) );
}
/*****************************************************************************/
/* Section: Sequence Mapping */
/* These functions provide code to access constant objects as */
/* mappings. */
/*****************************************************************************/
static int constantLength( BPy_constant * self )
return EXPP_incr_ret((PyObject *)constant);
}
//------------------------tp_doc
//The __doc__ string for this object
static char BPy_constant_doc[] = "This is an internal subobject of armature\
designed to act as a Py_Bone dictionary.";
//------------------------tp_methods
//This contains a list of all methods the object contains
static PyMethodDef BPy_constant_methods[] = {
{"items", (PyCFunction) constant_items, METH_NOARGS,
"() - Returns the key:value pairs from the dictionary"},
{"keys", (PyCFunction) constant_keys, METH_NOARGS,
"() - Returns the keys the dictionary"},
{"values", (PyCFunction) constant_values, METH_NOARGS,
"() - Returns the values from the dictionary"},
{NULL}
};
//------------------------mp_length
static int constantLength(BPy_constant *self)
{
return 0;
}
static PyObject *constantSubscript( BPy_constant * self, PyObject * key )
//------------------------mp_subscript
static PyObject *constantSubscript(BPy_constant *self, PyObject *key)
{
if( self->dict ) {
PyObject *v = PyDict_GetItem( self->dict, key );
if( v ) {
Py_INCREF( v );
return v;
if(self->dict) {
PyObject *v = PyDict_GetItem(self->dict, key);
if(v) {
return EXPP_incr_ret(v);
}
}
return NULL;
}
static int constantAssSubscript( BPy_constant * self, PyObject * who,
PyObject * cares )
//------------------------mp_ass_subscript
static int constantAssSubscript(BPy_constant *self, PyObject *who, PyObject *cares)
{
/* no user assignments allowed */
return 0;
return 0; /* no user assignments allowed */
}
/*****************************************************************************/
/* Function: constant_repr */
/* Description: This is a callback function for the BPy_constant type. It */
/* builds a meaninful string to represent constant objects. */
/*****************************************************************************/
static PyObject *constant_repr( BPy_constant * self )
//------------------------tp_getattr
static PyObject *constant_getAttr(BPy_constant * self, char *name)
{
PyObject *repr = PyObject_Repr( self->dict );
if(self->dict) {
PyObject *v;
if(!strcmp(name, "__members__"))
return PyDict_Keys(self->dict);
v = PyDict_GetItemString(self->dict, name);
if(v) {
return EXPP_incr_ret(v); /* was a borrowed ref */
}
return (EXPP_ReturnPyObjError(PyExc_AttributeError,
"attribute not found"));
}
return (EXPP_ReturnPyObjError(PyExc_RuntimeError,
"constant object lacks a dictionary"));
}
//------------------------tp_repr
static PyObject *constant_repr(BPy_constant * self)
{
PyObject *repr = PyObject_Repr(self->dict);
return repr;
}
//------------------------tp_dealloc
static void constant_dealloc(BPy_constant * self)
{
Py_DECREF(self->dict);
PyObject_DEL(self);
}
//------------------TYPE_OBECT DEFINITION------------------------------
static PyMappingMethods constantAsMapping = {
(inquiry) constantLength, // mp_length
(binaryfunc) constantSubscript, // mp_subscript
(objobjargproc) constantAssSubscript, // mp_ass_subscript
};
PyTypeObject constant_Type = {
PyObject_HEAD_INIT(NULL) //tp_head
0, //tp_internal
"Constant", //tp_name
sizeof(BPy_constant), //tp_basicsize
0, //tp_itemsize
(destructor)constant_dealloc, //tp_dealloc
0, //tp_print
(getattrfunc)constant_getAttr, //tp_getattr
0, //tp_setattr
0, //tp_compare
(reprfunc) constant_repr, //tp_repr
0, //tp_as_number
0, //tp_as_sequence
&constantAsMapping, //tp_as_mapping
0, //tp_hash
0, //tp_call
0, //tp_str
0, //tp_getattro
0, //tp_setattro
0, //tp_as_buffer
Py_TPFLAGS_DEFAULT, //tp_flags
BPy_constant_doc, //tp_doc
0, //tp_traverse
0, //tp_clear
0, //tp_richcompare
0, //tp_weaklistoffset
0, //tp_iter
0, //tp_iternext
BPy_constant_methods, //tp_methods
0, //tp_members
0, //tp_getset
0, //tp_base
0, //tp_dict
0, //tp_descr_get
0, //tp_descr_set
0, //tp_dictoffset
0, //tp_init
0, //tp_alloc
0, //tp_new
0, //tp_free
0, //tp_is_gc
0, //tp_bases
0, //tp_mro
0, //tp_cache
0, //tp_subclasses
0, //tp_weaklist
0 //tp_del
};
//------------------VISIBLE PROTOTYPE IMPLEMENTATION-------------------
//Creates a default empty constant
PyObject *PyConstant_New(void)
{
return new_const();
}
//Inserts a key:value pair into the constant and then returns 0/1
int PyConstant_Insert(BPy_constant *self, char *name, PyObject *value)
{
return PyDict_SetItemString(self->dict, name, value);
}
//This is a helper function for generating constants......
PyObject *PyConstant_NewInt(char *name, int value)
{
PyObject *constant = PyConstant_New();
PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
PyConstant_Insert((BPy_constant*)constant, "value", PyInt_FromLong(value));
return EXPP_incr_ret(constant);
}
//This is a helper function for generating constants......
PyObject *PyConstant_NewString(char *name, char *value)
{
PyObject *constant = PyConstant_New();
PyConstant_Insert((BPy_constant*)constant, "name", PyString_FromString(name));
PyConstant_Insert((BPy_constant*)constant, "value", PyString_FromString(value));
return EXPP_incr_ret(constant);
}

View File

@@ -25,7 +25,7 @@
*
* This is a new part of Blender.
*
* Contributor(s): Willian P. Germano
* Contributor(s): Willian P. Germano, Joseph Gilbert
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -35,28 +35,19 @@
#include <Python.h>
//-------------------TYPE CHECKS---------------------------------
#define BPy_Constant_Check(v) ((v)->ob_type==&constant_Type)
/* Objects of <type 'constant'> are used inside many other Blender Python
* objects, so this header file must contain only 'public' declarations */
/*****************************************************************************/
/* Python API function prototypes for the constant module. */
/*****************************************************************************/
PyObject *M_constant_New( void );
/*****************************************************************************/
/* Python BPy_constant structure definition: */
/*****************************************************************************/
//-------------------TYPEOBJECT----------------------------------
PyTypeObject constant_Type;
//-------------------STRUCT DEFINITION---------------------------
typedef struct {
PyObject_HEAD
PyObject * dict;
} BPy_constant;
/*****************************************************************************/
/* Python BPy_constant methods declarations: */
/*****************************************************************************/
int constant_insert( BPy_constant * self, char *name, PyObject * value );
//-------------------VISIBLE PROTOTYPES-------------------------
PyObject *PyConstant_New(void);
int PyConstant_Insert(BPy_constant *self, char *name, PyObject *value);
PyObject *PyConstant_NewInt(char *name, int value);
PyObject *PyConstant_NewString(char *name, char *value);
#endif /* EXPP_constant_H */

View File

@@ -39,6 +39,30 @@
#include "BKE_global.h"
#include "BKE_main.h"
//---------------------- EXPP_GetModuleConstant -------------------------
//Helper function for returning a module constant
PyObject *EXPP_GetModuleConstant(char *module, char *constant)
{
PyObject *py_module = NULL, *py_dict = NULL, *py_constant = NULL;
/*Careful to pass the correct Package.Module string here or
* else you add a empty module somewhere*/
py_module = PyImport_AddModule(module);
if(!py_module){ //null = error returning module
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"error encountered with returning module constant..." ) );
}
py_dict = PyModule_GetDict(py_module); //never fails
py_constant = PyDict_GetItemString(py_dict, constant);
if(!py_constant){ //null = key not found
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"error encountered with returning module constant..." ) );
}
return EXPP_incr_ret(py_constant);
}
/*****************************************************************************/
/* Description: This function clamps an int to the given interval */
/* [min, max]. */
@@ -117,6 +141,33 @@ int EXPP_ReturnIntError( PyObject * type, char *error_msg )
return -1;
}
int EXPP_intError(PyObject *type, const char *format, ...)
{
char *error = "";
va_list vlist;
va_start(vlist, format);
vsprintf(error, format, vlist);
va_end(vlist);
PyErr_SetString(type, error);
return -1;
}
//Like EXPP_ReturnPyObjError but takes a printf format string and multiple arguments
PyObject *EXPP_objError(PyObject *type, const char *format, ...)
{
char *error = "";
va_list vlist;
va_start(vlist, format);
vsprintf(error, format, vlist);
va_end(vlist);
PyErr_SetString(type, error);
return NULL;
}
/*****************************************************************************/
/* Description: This function increments the reference count of the given */
/* Python object (usually Py_None) and returns it. */

View File

@@ -51,6 +51,8 @@
#define Py_RETURN_NONE Py_INCREF( Py_None ); return Py_None
#endif
PyObject *EXPP_GetModuleConstant(char *module, char *constant);
int StringEqual( const char *string1, const char *string2 );
char *GetIdName( ID * id );
ID *GetIdFromList( ListBase * list, char *name );
@@ -73,6 +75,9 @@ PyObject *EXPP_incr_ret_False(void);
PyObject *EXPP_ReturnPyObjError( PyObject * type, char *error_msg );
int EXPP_ReturnIntError( PyObject * type, char *error_msg );
PyObject *EXPP_objError(PyObject *type, const char *format, ...);
int EXPP_intError(PyObject *type, const char *format, ...);
int EXPP_check_sequence_consistency( PyObject * seq, PyTypeObject * against );
PyObject *EXPP_tuple_repr( PyObject * self, int size );

View File

@@ -873,15 +873,15 @@ PyObject *Radio_Init( void )
submodule = Py_InitModule3( "Blender.Scene.Radio", M_Radio_methods,
"The Blender Radiosity submodule" );
Modes = M_constant_New( );
DrawTypes = M_constant_New( );
Modes = PyConstant_New( );
DrawTypes = PyConstant_New( );
if( Modes ) {
BPy_constant *d = ( BPy_constant * ) Modes;
constant_insert( d, "ShowLimits",
PyConstant_Insert( d, "ShowLimits",
PyInt_FromLong( EXPP_RADIO_flag_SHOWLIM ) );
constant_insert( d, "Z", PyInt_FromLong( EXPP_RADIO_flag_Z ) );
PyConstant_Insert( d, "Z", PyInt_FromLong( EXPP_RADIO_flag_Z ) );
PyModule_AddObject( submodule, "Modes", Modes );
}
@@ -889,11 +889,11 @@ PyObject *Radio_Init( void )
if( DrawTypes ) {
BPy_constant *d = ( BPy_constant * ) DrawTypes;
constant_insert( d, "Wire",
PyConstant_Insert( d, "Wire",
PyInt_FromLong( EXPP_RADIO_drawtype_WIRE ) );
constant_insert( d, "Solid",
PyConstant_Insert( d, "Solid",
PyInt_FromLong( EXPP_RADIO_drawtype_SOLID ) );
constant_insert( d, "Gouraud",
PyConstant_Insert( d, "Gouraud",
PyInt_FromLong
( EXPP_RADIO_drawtype_GOURAUD ) );