Image.c
* moved to getseters (use new generic ID funcs) * added 'reflect' attribute Text.c * moved to getseters (new generic ID funcs too) NLA.c * moved to getseters (ditto) Ipo.c * bugfix, allow nested loops on an IPO's curves. Blender.c * removed undocumented function RemoveFakeuser, since actions now have the fakeUser attribute.
This commit is contained in:
@@ -94,11 +94,6 @@ struct ID; /*keep me up here */
|
||||
#include "Types.h"
|
||||
#include "Main.h"
|
||||
|
||||
/*for the removefakeuser hack*/
|
||||
#include "NLA.h" /*This must come first*/
|
||||
#include "BKE_action.h"
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* Python API function prototypes for the Blender module. */
|
||||
/**********************************************************/
|
||||
@@ -175,10 +170,6 @@ static char Blender_Run_doc[] =
|
||||
"(script) - Run the given Python script.\n\
|
||||
(script) - the path to a file or the name of an available Blender Text.";
|
||||
|
||||
static char Blender_RemoveFakeuser_doc[] =
|
||||
"(datablock) - remove the fake user from a datablock. useful for deleting actions.\n\
|
||||
(datablock) - the datablock that has a fakeuser. currently only action object accepted.";
|
||||
|
||||
static char Blender_ShowHelp_doc[] =
|
||||
"(script) - Show help for the given Python script.\n\
|
||||
This will try to open the 'Scripts Help Browser' script, so to have\n\
|
||||
@@ -214,7 +205,6 @@ static struct PyMethodDef Blender_methods[] = {
|
||||
{"Load", Blender_Load, METH_VARARGS, Blender_Load_doc},
|
||||
{"Save", Blender_Save, METH_VARARGS, Blender_Save_doc},
|
||||
{"Run", Blender_Run, METH_VARARGS, Blender_Run_doc},
|
||||
{"RemoveFakeuser", Blender_RemoveFakeuser, METH_VARARGS, Blender_RemoveFakeuser_doc},
|
||||
{"ShowHelp", Blender_ShowHelp, METH_VARARGS, Blender_ShowHelp_doc},
|
||||
{"CountPackedFiles", ( PyCFunction ) Blender_CountPackedFiles, METH_NOARGS, Blender_CountPackedFiles_doc},
|
||||
{"PackAll", ( PyCFunction ) Blender_PackAll, METH_NOARGS, Blender_PackAll_doc},
|
||||
@@ -847,32 +837,6 @@ static PyObject * Blender_UpdateMenus( PyObject * self )
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *Blender_RemoveFakeuser(PyObject *self, PyObject *args)
|
||||
{
|
||||
ID *id;
|
||||
BPy_Action *py_thing; /*lousy coder antont did not know how to accept any bpy thing with ID..*/
|
||||
|
||||
if( !PyArg_ParseTuple( args, "O!", &Action_Type, &py_thing ) )
|
||||
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
||||
"expected python action type" );
|
||||
|
||||
id= (ID *)py_thing->action;
|
||||
|
||||
if(id) {
|
||||
if( id->flag & LIB_FAKEUSER) {
|
||||
id->flag -= LIB_FAKEUSER;
|
||||
id->us--;
|
||||
}
|
||||
else
|
||||
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
||||
"given datablock has no fakeusers");
|
||||
} else
|
||||
return EXPP_ReturnPyObjError( PyExc_AttributeError,
|
||||
"given object does not have a Blender ID");
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Blender_PackAll */
|
||||
/* Python equivalent: Blender.PackAll */
|
||||
|
||||
@@ -62,6 +62,15 @@ current image frame, some images change frame if they are a sequence */
|
||||
#define EXPP_IMAGE_REP_MAX 16
|
||||
|
||||
|
||||
enum img_consts {
|
||||
EXPP_IMAGE_ATTR_XREP = 0,
|
||||
EXPP_IMAGE_ATTR_YREP,
|
||||
EXPP_IMAGE_ATTR_START,
|
||||
EXPP_IMAGE_ATTR_END,
|
||||
EXPP_IMAGE_ATTR_SPEED,
|
||||
EXPP_IMAGE_ATTR_BINDCODE,
|
||||
};
|
||||
|
||||
/************************/
|
||||
/*** The Image Module ***/
|
||||
/************************/
|
||||
@@ -87,7 +96,8 @@ static PyObject *Image_getBindCode( BPy_Image * self );
|
||||
static PyObject *Image_getStart( BPy_Image * self );
|
||||
static PyObject *Image_getEnd( BPy_Image * self );
|
||||
static PyObject *Image_getSpeed( BPy_Image * self );
|
||||
static PyObject *Image_setFilename( BPy_Image * self, PyObject * args );
|
||||
static int Image_setFilename( BPy_Image * self, PyObject * args );
|
||||
static PyObject *Image_oldsetFilename( BPy_Image * self, PyObject * args );
|
||||
static PyObject *Image_setXRep( BPy_Image * self, PyObject * args );
|
||||
static PyObject *Image_setYRep( BPy_Image * self, PyObject * args );
|
||||
static PyObject *Image_setStart( BPy_Image * self, PyObject * args );
|
||||
@@ -155,7 +165,7 @@ static PyMethodDef BPy_Image_methods[] = {
|
||||
see also image.glLoad()."},
|
||||
{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
|
||||
"(str) - Change Image object name"},
|
||||
{"setFilename", ( PyCFunction ) Image_setFilename, METH_VARARGS,
|
||||
{"setFilename", ( PyCFunction ) Image_oldsetFilename, METH_VARARGS,
|
||||
"(str) - Change Image file name"},
|
||||
{"setXRep", ( PyCFunction ) Image_setXRep, METH_VARARGS,
|
||||
"(int) - Change Image object x repetition value"},
|
||||
@@ -707,7 +717,8 @@ PyObject *Image_Init( void )
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
Image_Type.ob_type = &PyType_Type;
|
||||
if( PyType_Ready( &Image_Type ) < 0 )
|
||||
return NULL;
|
||||
|
||||
submodule =
|
||||
Py_InitModule3( "Blender.Image", M_Image_methods,
|
||||
@@ -720,39 +731,9 @@ PyObject *Image_Init( void )
|
||||
/* Python Image_Type callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Image_dealloc( BPy_Image * self );
|
||||
static int Image_setAttr( BPy_Image * self, char *name, PyObject * v );
|
||||
static int Image_compare( BPy_Image * a, BPy_Image * b );
|
||||
static PyObject *Image_getAttr( BPy_Image * self, char *name );
|
||||
static PyObject *Image_repr( BPy_Image * self );
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Image_Type structure definition: */
|
||||
/*****************************************************************************/
|
||||
PyTypeObject Image_Type = {
|
||||
PyObject_HEAD_INIT( NULL ) /* required macro. ( no comma needed ) */
|
||||
0, /* ob_size */
|
||||
"Blender Image", /* tp_name */
|
||||
sizeof( BPy_Image ), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
( destructor ) Image_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
( getattrfunc ) Image_getAttr, /* tp_getattr */
|
||||
( setattrfunc ) Image_setAttr, /* tp_setattr */
|
||||
( cmpfunc ) Image_compare, /* tp_compare */
|
||||
( reprfunc ) Image_repr, /* 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_Image_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* up to tp_del, to avoid a warning */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_dealloc */
|
||||
/* Description: This is a callback function for the BPy_Image type. It is */
|
||||
@@ -825,9 +806,7 @@ static PyObject *Image_getSize( BPy_Image * self )
|
||||
|
||||
PyList_SetItem( attr, 0, PyInt_FromLong(ibuf->x));
|
||||
PyList_SetItem( attr, 1, PyInt_FromLong(ibuf->y));
|
||||
return attr;
|
||||
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
static PyObject *Image_getDepth( BPy_Image * self )
|
||||
@@ -972,25 +951,28 @@ static PyObject *Image_glLoad( BPy_Image * self )
|
||||
return PyLong_FromUnsignedLong( image->bindcode );
|
||||
}
|
||||
|
||||
static PyObject *Image_setFilename( BPy_Image * self, PyObject * args )
|
||||
static int Image_setFilename( BPy_Image * self, PyObject * value )
|
||||
{
|
||||
char *name;
|
||||
int namelen = 0;
|
||||
|
||||
/* max len is FILE_MAXDIR == 160, FILE_MAXFILE == 80 chars like done in DNA_image_types.h */
|
||||
name = PyString_AsString(value);
|
||||
|
||||
if( !PyArg_ParseTuple( args, "s#", &name, &namelen ) )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
if( !name )
|
||||
return ( EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected a string argument" ) );
|
||||
|
||||
if( namelen >= FILE_MAXDIR + FILE_MAXFILE )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
/* max len is FILE_MAXDIR == 160, FILE_MAXFILE == 80 chars like done in DNA_image_types.h */
|
||||
if( strlen(name) >= FILE_MAXDIR + FILE_MAXFILE )
|
||||
return ( EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"string argument is limited to 240 chars at most" ) );
|
||||
|
||||
PyOS_snprintf( self->image->name, (FILE_MAXDIR + FILE_MAXFILE) * sizeof( char ), "%s",
|
||||
name );
|
||||
strcpy( self->image->name, name );
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
static PyObject *Image_oldsetFilename( BPy_Image * self, PyObject * args )
|
||||
{
|
||||
return EXPP_setterWrapper( (void *)self, args, (setter)Image_setFilename );
|
||||
}
|
||||
|
||||
static PyObject *Image_setXRep( BPy_Image * self, PyObject * args )
|
||||
@@ -1080,166 +1062,6 @@ static PyObject *Image_setSpeed( BPy_Image * self, PyObject * args )
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_getAttr */
|
||||
/* Description: This is a callback function for the BPy_Image type. It is */
|
||||
/* the function that accesses BPy_Image member variables and */
|
||||
/* methods. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Image_getAttr( BPy_Image * self, char *name )
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
attr = PyString_FromString( self->image->id.name + 2 );
|
||||
else if ( strcmp( name, "properties" ) == 0 )
|
||||
return BPy_Wrap_IDProperty( (ID*)self->image, IDP_GetProperties((ID*)self->image, 1), NULL );
|
||||
else if( strcmp( name, "filename" ) == 0 )
|
||||
attr = PyString_FromString( self->image->name );
|
||||
else if( strcmp( name, "size" ) == 0 )
|
||||
return Image_getSize( self );
|
||||
else if( strcmp( name, "depth" ) == 0 )
|
||||
return Image_getDepth( self );
|
||||
else if( strcmp( name, "xrep" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->xrep );
|
||||
else if( strcmp( name, "yrep" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->yrep );
|
||||
else if( strcmp( name, "start" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->twsta );
|
||||
else if( strcmp( name, "end" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->twend );
|
||||
else if( strcmp( name, "speed" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->animspeed );
|
||||
else if( strcmp( name, "packed" ) == 0 ) {
|
||||
if (self->image->packedfile) attr = Py_True;
|
||||
else attr = Py_False;
|
||||
Py_INCREF(attr);
|
||||
} else if( strcmp( name, "has_data" ) == 0 ) {
|
||||
if (self->image->ibufs.first) attr = Py_True;
|
||||
else attr = Py_False;
|
||||
Py_INCREF(attr);
|
||||
} else if( strcmp( name, "fields" ) == 0 ) {
|
||||
if (self->image->flag & IMA_FIELDS) attr = Py_True;
|
||||
else attr = Py_False;
|
||||
Py_INCREF(attr);
|
||||
} else if( strcmp( name, "fields_odd" ) == 0 ) {
|
||||
if (self->image->flag & IMA_STD_FIELD) attr = Py_True;
|
||||
else attr = Py_False;
|
||||
Py_INCREF(attr);
|
||||
} else if( strcmp( name, "antialias" ) == 0 ) {
|
||||
if (self->image->flag & IMA_ANTIALI) attr = Py_True;
|
||||
else attr = Py_False;
|
||||
Py_INCREF(attr);
|
||||
} else if ( strcmp( name, "lib" ) == 0 ) {
|
||||
/* WARNING - Not standard, until we move to get/setattrs
|
||||
at the moment we cant return None at the end because it raises an error */
|
||||
attr = EXPP_GetIdLib((ID *)self->image);
|
||||
if (attr) return attr;
|
||||
} else if( strcmp( name, "bindcode" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->bindcode );
|
||||
else if( strcmp( name, "users" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->id.us );
|
||||
else if( strcmp( name, "__members__" ) == 0 )
|
||||
attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
|
||||
"name", "filename", "size", "depth",
|
||||
"xrep", "yrep", "start", "end",
|
||||
"speed", "packed", "has_data"
|
||||
"fields", "odd", "antialias",
|
||||
"bindcode", "users", "lib" );
|
||||
|
||||
if( !attr )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
||||
"couldn't create PyObject" ) );
|
||||
|
||||
if( attr != Py_None )
|
||||
return attr; /* attribute found, return its value */
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod( BPy_Image_methods, ( PyObject * ) self, name );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_setAttr */
|
||||
/* Description: This is a callback function for the BPy_Image type. It is the*/
|
||||
/* function that changes Image object members values. If this */
|
||||
/* data is linked to a Blender Image, it also gets updated. */
|
||||
/*****************************************************************************/
|
||||
static int Image_setAttr( BPy_Image * self, char *name, PyObject * value )
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
|
||||
/* We're playing a trick on the Python API users here. Even if they use
|
||||
* Image.member = val instead of Image.setMember(value), we end up using the
|
||||
* function anyway, since it already has error checking, clamps to the right
|
||||
* interval and updates the Blender Image structure when necessary. */
|
||||
|
||||
valtuple = Py_BuildValue( "(O)", value ); /*the set* functions expect a tuple */
|
||||
|
||||
if( !valtuple )
|
||||
return EXPP_ReturnIntError( PyExc_MemoryError,
|
||||
"ImageSetAttr: couldn't create PyTuple" );
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
error = GenericLib_setName_with_method( self, valtuple );
|
||||
else if( strcmp( name, "filename" ) == 0 )
|
||||
error = Image_setFilename( self, valtuple );
|
||||
else if( strcmp( name, "xrep" ) == 0 )
|
||||
error = Image_setXRep( self, valtuple );
|
||||
else if( strcmp( name, "yrep" ) == 0 )
|
||||
error = Image_setYRep( self, valtuple );
|
||||
else if( strcmp( name, "start" ) == 0 )
|
||||
error = Image_setStart( self, valtuple );
|
||||
else if( strcmp( name, "end" ) == 0 )
|
||||
error = Image_setEnd( self, valtuple );
|
||||
else if( strcmp( name, "speed" ) == 0 )
|
||||
error = Image_setSpeed( self, valtuple );
|
||||
|
||||
else if( strcmp( name, "fields" ) == 0 ) {
|
||||
int param = PyObject_IsTrue( value );
|
||||
if( param == -1 )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected true/false argument" );
|
||||
|
||||
if (param) self->image->flag |= IMA_FIELDS;
|
||||
else self->image->flag &= ~IMA_FIELDS;
|
||||
Py_INCREF( Py_None );
|
||||
error = Py_None;
|
||||
} else if( strcmp( name, "fields_odd" ) == 0 ) {
|
||||
int param = PyObject_IsTrue( value );
|
||||
if( param == -1 )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected true/false argument" );
|
||||
|
||||
if (param) self->image->flag |= IMA_STD_FIELD;
|
||||
else self->image->flag &= ~IMA_STD_FIELD;
|
||||
Py_INCREF( Py_None );
|
||||
error = Py_None;
|
||||
} else if( strcmp( name, "antialias" ) == 0 ) {
|
||||
int param = PyObject_IsTrue( value );
|
||||
if( param == -1 )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected true/false argument" );
|
||||
|
||||
if (param) self->image->flag |= IMA_ANTIALI;
|
||||
else self->image->flag &= ~IMA_ANTIALI;
|
||||
Py_INCREF( Py_None );
|
||||
error = Py_None;
|
||||
} else { /* Error: no such member in the Image object structure */
|
||||
/*Py_DECREF( value ); borrowed ref, no need to decref */
|
||||
Py_DECREF( valtuple );
|
||||
return ( EXPP_ReturnIntError( PyExc_KeyError,
|
||||
"attribute not found or immutable" ) );
|
||||
}
|
||||
|
||||
Py_DECREF( valtuple );
|
||||
|
||||
if( error != Py_None )
|
||||
return -1;
|
||||
|
||||
Py_DECREF( Py_None ); /* incref'ed by the called set* function */
|
||||
return 0; /* normal exit */
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_compare */
|
||||
@@ -1264,3 +1086,255 @@ static PyObject *Image_repr( BPy_Image * self )
|
||||
return PyString_FromFormat( "[Image \"%s\"]",
|
||||
self->image->id.name + 2 );
|
||||
}
|
||||
|
||||
static PyObject *Image_getPacked(BPy_Image *self, void *closure)
|
||||
{
|
||||
if (self->image->packedfile)
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static PyObject *Image_hasData(BPy_Image *self, void *closure)
|
||||
{
|
||||
if (self->image->ibufs.first)
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static PyObject *Image_getFlag(BPy_Image *self, void *flag)
|
||||
{
|
||||
if (self->image->flag & (int)flag)
|
||||
Py_RETURN_TRUE;
|
||||
else
|
||||
Py_RETURN_FALSE;
|
||||
|
||||
}
|
||||
|
||||
static int Image_setFlag(BPy_Image *self, PyObject *value, void *flag)
|
||||
{
|
||||
if ( PyObject_IsTrue(value) )
|
||||
self->image->flag |= (int)flag;
|
||||
else
|
||||
self->image->flag &= ~(int)flag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get integer attributes
|
||||
*/
|
||||
static PyObject *getIntAttr( BPy_Image *self, void *type )
|
||||
{
|
||||
PyObject *attr = NULL;
|
||||
int param;
|
||||
struct Image *image = self->image;
|
||||
|
||||
switch( (int)type ) {
|
||||
case EXPP_IMAGE_ATTR_XREP:
|
||||
param = image->xrep;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_YREP:
|
||||
param = image->xrep;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_START:
|
||||
param = image->twsta;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_END:
|
||||
param = image->twend;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_SPEED:
|
||||
param = image->animspeed;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_BINDCODE:
|
||||
param = image->bindcode;
|
||||
break;
|
||||
default:
|
||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||
"undefined type in getIntAttr" );
|
||||
}
|
||||
|
||||
attr = PyInt_FromLong( param );
|
||||
|
||||
if( attr )
|
||||
return attr;
|
||||
|
||||
return EXPP_ReturnPyObjError( PyExc_MemoryError,
|
||||
"PyInt_FromLong() failed!" );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* set integer attributes which require clamping
|
||||
*/
|
||||
|
||||
static int setIntAttrClamp( BPy_Image *self, PyObject *value, void *type )
|
||||
{
|
||||
void *param;
|
||||
struct Image *image = self->image;
|
||||
int min, max, size;
|
||||
|
||||
switch( (int)type ) {
|
||||
case EXPP_IMAGE_ATTR_XREP:
|
||||
min = EXPP_IMAGE_REP_MIN;
|
||||
max = EXPP_IMAGE_REP_MAX;
|
||||
size = 'h';
|
||||
param = (void *)&image->xrep;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_YREP:
|
||||
min = EXPP_IMAGE_REP_MIN;
|
||||
max = EXPP_IMAGE_REP_MAX;
|
||||
size = 'h';
|
||||
param = (void *)&image->yrep;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_START:
|
||||
min = 0;
|
||||
max = 128;
|
||||
size = 'h';
|
||||
param = (void *)&image->twsta;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_END:
|
||||
min = 0;
|
||||
max = 128;
|
||||
size = 'h';
|
||||
param = (void *)&image->twend;
|
||||
break;
|
||||
case EXPP_IMAGE_ATTR_SPEED:
|
||||
min = 0;
|
||||
max = 100;
|
||||
size = 'h';
|
||||
param = (void *)&image->animspeed;
|
||||
break;
|
||||
|
||||
default:
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"undefined type in setIntAttrClamp");
|
||||
}
|
||||
return EXPP_setIValueClamped( value, param, min, max, size );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python attributes get/set structure: */
|
||||
/*****************************************************************************/
|
||||
static PyGetSetDef BPy_Image_getseters[] = {
|
||||
GENERIC_LIB_GETSETATTR,
|
||||
{"filename", (getter)Image_getFilename, (setter)Image_setFilename,
|
||||
"image path", NULL},
|
||||
/* readonly */
|
||||
{"depth", (getter)Image_getDepth, (setter)NULL,
|
||||
"image depth", NULL},
|
||||
{"size", (getter)Image_getSize, (setter)NULL,
|
||||
"image size", NULL},
|
||||
{"packed", (getter)Image_getPacked, (setter)NULL,
|
||||
"image packed state", NULL },
|
||||
{"has_data", (getter)Image_hasData, (setter)NULL,
|
||||
"is image data loaded", NULL },
|
||||
/* ints */
|
||||
{"xrep", (getter)getIntAttr, (setter)setIntAttrClamp,
|
||||
"image xrep", (void *)EXPP_IMAGE_ATTR_XREP },
|
||||
{"yrep", (getter)getIntAttr, (setter)setIntAttrClamp,
|
||||
"image yrep", (void *)EXPP_IMAGE_ATTR_YREP },
|
||||
{"start", (getter)getIntAttr, (setter)setIntAttrClamp,
|
||||
"image start frame", (void *)EXPP_IMAGE_ATTR_START },
|
||||
{"end", (getter)getIntAttr, (setter)setIntAttrClamp,
|
||||
"image end frame", (void *)EXPP_IMAGE_ATTR_END },
|
||||
{"speed", (getter)getIntAttr, (setter)setIntAttrClamp,
|
||||
"image end frame", (void *)EXPP_IMAGE_ATTR_SPEED },
|
||||
{"bindcode", (getter)getIntAttr, (setter)NULL,
|
||||
"openGL bindcode", (void *)EXPP_IMAGE_ATTR_BINDCODE },
|
||||
/* flags */
|
||||
{"fields", (getter)Image_getFlag, (setter)Image_setFlag,
|
||||
"image fields toggle", (void *)IMA_FIELDS },
|
||||
{"fields_odd", (getter)Image_getFlag, (setter)Image_setFlag,
|
||||
"image fields toggle", (void *)IMA_STD_FIELD },
|
||||
{"antialias", (getter)Image_getFlag, (setter)Image_setFlag,
|
||||
"image fields toggle", (void *)IMA_ANTIALI },
|
||||
{"reflect", (getter)Image_getFlag, (setter)Image_setFlag,
|
||||
"image fields toggle", (void *)IMA_REFLECT },
|
||||
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Image_Type structure definition: */
|
||||
/*****************************************************************************/
|
||||
PyTypeObject Image_Type = {
|
||||
PyObject_HEAD_INIT( NULL ) /* required macro. ( no comma needed ) */
|
||||
0, /* ob_size */
|
||||
"Blender Image", /* tp_name */
|
||||
sizeof( BPy_Image ), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
( destructor ) Image_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
NULL, /* tp_getattr */
|
||||
NULL, /* tp_setattr */
|
||||
( cmpfunc ) Image_compare, /* tp_compare */
|
||||
( reprfunc ) Image_repr, /* tp_repr */
|
||||
|
||||
/* Method suites for standard classes */
|
||||
|
||||
NULL, /* PyNumberMethods *tp_as_number; */
|
||||
NULL, /* PySequenceMethods *tp_as_sequence; */
|
||||
NULL, /* PyMappingMethods *tp_as_mapping; */
|
||||
|
||||
/* More standard operations (here for binary compatibility) */
|
||||
|
||||
NULL, /* hashfunc tp_hash; */
|
||||
NULL, /* ternaryfunc tp_call; */
|
||||
NULL, /* reprfunc tp_str; */
|
||||
NULL, /* getattrofunc tp_getattro; */
|
||||
NULL, /* setattrofunc tp_setattro; */
|
||||
|
||||
/* Functions to access object as input/output buffer */
|
||||
NULL, /* PyBufferProcs *tp_as_buffer; */
|
||||
|
||||
/*** Flags to define presence of optional/expanded features ***/
|
||||
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
|
||||
|
||||
NULL, /* char *tp_doc; Documentation string */
|
||||
/*** Assigned meaning in release 2.0 ***/
|
||||
/* call function for all accessible objects */
|
||||
NULL, /* traverseproc tp_traverse; */
|
||||
|
||||
/* delete references to contained objects */
|
||||
NULL, /* inquiry tp_clear; */
|
||||
|
||||
/*** Assigned meaning in release 2.1 ***/
|
||||
/*** rich comparisons ***/
|
||||
NULL, /* richcmpfunc tp_richcompare; */
|
||||
|
||||
/*** weak reference enabler ***/
|
||||
0, /* long tp_weaklistoffset; */
|
||||
|
||||
/*** Added in release 2.2 ***/
|
||||
/* Iterators */
|
||||
NULL, /* getiterfunc tp_iter; */
|
||||
NULL, /* iternextfunc tp_iternext; */
|
||||
|
||||
/*** Attribute descriptor and subclassing stuff ***/
|
||||
BPy_Image_methods, /* struct PyMethodDef *tp_methods; */
|
||||
NULL, /* struct PyMemberDef *tp_members; */
|
||||
BPy_Image_getseters, /* struct PyGetSetDef *tp_getset; */
|
||||
NULL, /* struct _typeobject *tp_base; */
|
||||
NULL, /* PyObject *tp_dict; */
|
||||
NULL, /* descrgetfunc tp_descr_get; */
|
||||
NULL, /* descrsetfunc tp_descr_set; */
|
||||
0, /* long tp_dictoffset; */
|
||||
NULL, /* initproc tp_init; */
|
||||
NULL, /* allocfunc tp_alloc; */
|
||||
NULL, /* newfunc tp_new; */
|
||||
/* Low-level free-memory routine */
|
||||
NULL, /* freefunc tp_free; */
|
||||
/* For PyObject_IS_GC */
|
||||
NULL, /* inquiry tp_is_gc; */
|
||||
NULL, /* PyObject *tp_bases; */
|
||||
/* method resolution order */
|
||||
NULL, /* PyObject *tp_mro; */
|
||||
NULL, /* PyObject *tp_cache; */
|
||||
NULL, /* PyObject *tp_subclasses; */
|
||||
NULL, /* PyObject *tp_weaklist; */
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -1556,8 +1556,13 @@ static int Ipo_contains( BPy_Ipo *self, PyObject *key )
|
||||
|
||||
static PyObject *Ipo_getIter( BPy_Ipo * self )
|
||||
{
|
||||
self->iter = 0;
|
||||
return EXPP_incr_ret ( (PyObject *) self );
|
||||
/* return a new IPO object if we are looping on the existing one
|
||||
This allows nested loops */
|
||||
if (self->iter==0) {
|
||||
return EXPP_incr_ret ( (PyObject *) self );
|
||||
} else {
|
||||
return Ipo_CreatePyObject(self->ipo);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1589,6 +1594,7 @@ static PyObject *Ipo_nextIter( BPy_Ipo * self )
|
||||
}
|
||||
}
|
||||
|
||||
self->iter = 0; /* allow iter use again */
|
||||
/* ran out of curves */
|
||||
return EXPP_ReturnPyObjError( PyExc_StopIteration,
|
||||
"iterator at end" );
|
||||
|
||||
@@ -120,39 +120,9 @@ static PyMethodDef BPy_Action_methods[] = {
|
||||
/* Python TypeAction callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Action_dealloc( BPy_Action * bone );
|
||||
static PyObject *Action_getAttr( BPy_Action * bone, char *name );
|
||||
static int Action_setAttr( BPy_Action * bone, char *name, PyObject * v );
|
||||
static int Action_compare( BPy_Action * a, BPy_Action * b );
|
||||
static PyObject *Action_repr( BPy_Action * bone );
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeAction structure definition: */
|
||||
/*****************************************************************************/
|
||||
PyTypeObject Action_Type = {
|
||||
PyObject_HEAD_INIT( NULL )
|
||||
0, /* ob_size */
|
||||
"Blender Action", /* tp_name */
|
||||
sizeof( BPy_Action ), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
( destructor ) Action_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
( getattrfunc ) Action_getAttr, /* tp_getattr */
|
||||
( setattrfunc ) Action_setAttr, /* tp_setattr */
|
||||
( cmpfunc ) Action_compare, /* tp_compare */
|
||||
( reprfunc ) Action_repr, /* 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_Action_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static PyObject *M_NLA_NewAction( PyObject * self_unused, PyObject * args )
|
||||
{
|
||||
@@ -400,66 +370,12 @@ static void Action_dealloc( BPy_Action * self )
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static PyObject *Action_getAttr( BPy_Action * self, char *name )
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
attr = GenericLib_getName( self );
|
||||
else if( strcmp( name, "__members__" ) == 0 ) {
|
||||
attr = Py_BuildValue( "[s]", "name" );
|
||||
}
|
||||
|
||||
if( !attr )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
||||
"couldn't create PyObject" ) );
|
||||
|
||||
if( attr != Py_None )
|
||||
return attr; /* member attribute found, return it */
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod( BPy_Action_methods, ( PyObject * ) self, name );
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int Action_setAttr( BPy_Action * self, char *name, PyObject * value )
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
|
||||
valtuple = Py_BuildValue( "(O)", value ); /* the set* functions expect a tuple */
|
||||
|
||||
if( !valtuple )
|
||||
return EXPP_ReturnIntError( PyExc_MemoryError,
|
||||
"ActionSetAttr: couldn't create tuple" );
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
error = GenericLib_setName_with_method( self, valtuple );
|
||||
else { /* Error */
|
||||
Py_DECREF( valtuple );
|
||||
|
||||
/* ... member with the given name was found */
|
||||
return ( EXPP_ReturnIntError
|
||||
( PyExc_KeyError, "attribute not found" ) );
|
||||
}
|
||||
|
||||
Py_DECREF( valtuple );
|
||||
|
||||
if( error != Py_None )
|
||||
return -1;
|
||||
|
||||
Py_DECREF( Py_None ); /* was incref'ed by the called Action_set* function */
|
||||
return 0; /* normal exit */
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int Action_compare( BPy_Action * a, BPy_Action * b )
|
||||
{
|
||||
return ( a->action == b->action ) ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static PyObject *Action_repr( BPy_Action * self )
|
||||
{
|
||||
@@ -503,6 +419,97 @@ struct bAction *Action_FromPyObject( PyObject * py_obj )
|
||||
return ( blen_obj->action );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python attributes get/set structure: */
|
||||
/*****************************************************************************/
|
||||
static PyGetSetDef BPy_Action_getseters[] = {
|
||||
GENERIC_LIB_GETSETATTR,
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeAction structure definition: */
|
||||
/*****************************************************************************/
|
||||
PyTypeObject Action_Type = {
|
||||
PyObject_HEAD_INIT( NULL )
|
||||
0, /* ob_size */
|
||||
"Blender Action", /* tp_name */
|
||||
sizeof( BPy_Action ), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
( destructor ) Action_dealloc, /* tp_dealloc */
|
||||
NULL, /* tp_print */
|
||||
NULL, /* tp_getattr */
|
||||
NULL, /* tp_setattr */
|
||||
( cmpfunc ) Action_compare, /* tp_compare */
|
||||
( reprfunc ) Action_repr, /* tp_repr */
|
||||
/* Method suites for standard classes */
|
||||
|
||||
NULL, /* PyNumberMethods *tp_as_number; */
|
||||
NULL, /* PySequenceMethods *tp_as_sequence; */
|
||||
NULL, /* PyMappingMethods *tp_as_mapping; */
|
||||
|
||||
/* More standard operations (here for binary compatibility) */
|
||||
|
||||
NULL, /* hashfunc tp_hash; */
|
||||
NULL, /* ternaryfunc tp_call; */
|
||||
NULL, /* reprfunc tp_str; */
|
||||
NULL, /* getattrofunc tp_getattro; */
|
||||
NULL, /* setattrofunc tp_setattro; */
|
||||
|
||||
/* Functions to access object as input/output buffer */
|
||||
NULL, /* PyBufferProcs *tp_as_buffer; */
|
||||
|
||||
/*** Flags to define presence of optional/expanded features ***/
|
||||
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
|
||||
|
||||
NULL, /* char *tp_doc; Documentation string */
|
||||
/*** Assigned meaning in release 2.0 ***/
|
||||
/* call function for all accessible objects */
|
||||
NULL, /* traverseproc tp_traverse; */
|
||||
|
||||
/* delete references to contained objects */
|
||||
NULL, /* inquiry tp_clear; */
|
||||
|
||||
/*** Assigned meaning in release 2.1 ***/
|
||||
/*** rich comparisons ***/
|
||||
NULL, /* richcmpfunc tp_richcompare; */
|
||||
|
||||
/*** weak reference enabler ***/
|
||||
0, /* long tp_weaklistoffset; */
|
||||
|
||||
/*** Added in release 2.2 ***/
|
||||
/* Iterators */
|
||||
NULL, /* getiterfunc tp_iter; */
|
||||
NULL, /* iternextfunc tp_iternext; */
|
||||
|
||||
/*** Attribute descriptor and subclassing stuff ***/
|
||||
BPy_Action_methods, /* struct PyMethodDef *tp_methods; */
|
||||
NULL, /* struct PyMemberDef *tp_members; */
|
||||
BPy_Action_getseters, /* struct PyGetSetDef *tp_getset; */
|
||||
NULL, /* struct _typeobject *tp_base; */
|
||||
NULL, /* PyObject *tp_dict; */
|
||||
NULL, /* descrgetfunc tp_descr_get; */
|
||||
NULL, /* descrsetfunc tp_descr_set; */
|
||||
0, /* long tp_dictoffset; */
|
||||
NULL, /* initproc tp_init; */
|
||||
NULL, /* allocfunc tp_alloc; */
|
||||
NULL, /* newfunc tp_new; */
|
||||
/* Low-level free-memory routine */
|
||||
NULL, /* freefunc tp_free; */
|
||||
/* For PyObject_IS_GC */
|
||||
NULL, /* inquiry tp_is_gc; */
|
||||
NULL, /* PyObject *tp_bases; */
|
||||
/* method resolution order */
|
||||
NULL, /* PyObject *tp_mro; */
|
||||
NULL, /* PyObject *tp_cache; */
|
||||
NULL, /* PyObject *tp_subclasses; */
|
||||
NULL, /* PyObject *tp_weaklist; */
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ActionStrip wrapper */
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -133,39 +133,9 @@ static PyMethodDef BPy_Text_methods[] = {
|
||||
/* Python Text_Type callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Text_dealloc( BPy_Text * self );
|
||||
static int Text_setAttr( BPy_Text * self, char *name, PyObject * v );
|
||||
static PyObject *Text_getAttr( BPy_Text * self, char *name );
|
||||
static int Text_compare( BPy_Text * a, BPy_Text * b );
|
||||
static PyObject *Text_repr( BPy_Text * self );
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Text_Type structure definition: */
|
||||
/*****************************************************************************/
|
||||
PyTypeObject Text_Type = {
|
||||
PyObject_HEAD_INIT( NULL )
|
||||
0, /* ob_size */
|
||||
"Blender Text", /* tp_name */
|
||||
sizeof( BPy_Text ), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
( destructor ) Text_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
( getattrfunc ) Text_getAttr, /* tp_getattr */
|
||||
( setattrfunc ) Text_setAttr, /* tp_setattr */
|
||||
( cmpfunc ) Text_compare, /* tp_compare */
|
||||
( reprfunc ) Text_repr, /* 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_Text_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Text_New */
|
||||
/* Python equivalent: Blender.Text.New */
|
||||
@@ -350,7 +320,8 @@ PyObject *Text_Init( void )
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
Text_Type.ob_type = &PyType_Type;
|
||||
if( PyType_Ready( &Text_Type ) < 0 )
|
||||
return NULL;
|
||||
|
||||
submodule =
|
||||
Py_InitModule3( "Blender.Text", M_Text_methods, M_Text_doc );
|
||||
@@ -527,88 +498,6 @@ static void Text_dealloc( BPy_Text * self )
|
||||
PyObject_DEL( self );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Text_getAttr */
|
||||
/* Description: This is a callback function for the BPy_Text type. It is */
|
||||
/* the function that accesses BPy_Text member variables and */
|
||||
/* methods. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Text_getAttr( BPy_Text * self, char *name )
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
if( !self->text || !Text_IsLinked( self ) )
|
||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||
"Text was already deleted!" );
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
attr = PyString_FromString( self->text->id.name + 2 );
|
||||
else if( strcmp( name, "filename" ) == 0 )
|
||||
return Text_getFilename( self ); /* special: can be null */
|
||||
else if( strcmp( name, "mode" ) == 0 )
|
||||
attr = PyInt_FromLong( self->text->flags );
|
||||
else if( strcmp( name, "nlines" ) == 0 )
|
||||
attr = Text_getNLines( self );
|
||||
|
||||
else if( strcmp( name, "__members__" ) == 0 )
|
||||
attr = Py_BuildValue( "[s,s,s,s]",
|
||||
"name", "filename", "mode", "nlines" );
|
||||
|
||||
if( !attr )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
|
||||
"couldn't create PyObject" ) );
|
||||
|
||||
if( attr != Py_None )
|
||||
return attr; /* attribute found, return its value */
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod( BPy_Text_methods, ( PyObject * ) self, name );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Text_setAttr */
|
||||
/* Description: This is a callback function for the BPy_Text type. It is the */
|
||||
/* function that changes Text Data members values. If this */
|
||||
/* data is linked to a Blender Text, it also gets updated. */
|
||||
/*****************************************************************************/
|
||||
static int Text_setAttr( BPy_Text * self, char *name, PyObject * value )
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
|
||||
if( !self->text || !Text_IsLinked( self ) )
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"Text was already deleted!" );
|
||||
|
||||
/* We're playing a trick on the Python API users here. Even if they use
|
||||
* Text.member = val instead of Text.setMember(value), we end up using the
|
||||
* function anyway, since it already has error checking, clamps to the right
|
||||
* interval and updates the Blender Text structure when necessary. */
|
||||
|
||||
valtuple = Py_BuildValue( "(O)", value ); /* the set* functions expect a tuple */
|
||||
|
||||
if( !valtuple )
|
||||
return EXPP_ReturnIntError( PyExc_MemoryError,
|
||||
"TextSetAttr: couldn't create PyTuple" );
|
||||
|
||||
if( strcmp( name, "name" ) == 0 )
|
||||
error = GenericLib_setName_with_method( self, valtuple );
|
||||
else { /* Error: no such member in the Text Data structure */
|
||||
Py_DECREF( value );
|
||||
Py_DECREF( valtuple );
|
||||
return ( EXPP_ReturnIntError( PyExc_KeyError,
|
||||
"attribute not found or immutable" ) );
|
||||
}
|
||||
|
||||
Py_DECREF( valtuple );
|
||||
|
||||
if( error != Py_None )
|
||||
return -1;
|
||||
|
||||
Py_DECREF( Py_None ); /* incref'ed by the called set* function */
|
||||
return 0; /* normal exit */
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Text_compare */
|
||||
/* Description: This is a callback function for the BPy_Text type. It */
|
||||
@@ -653,3 +542,108 @@ static int Text_IsLinked( BPy_Text * self )
|
||||
self->text = NULL; /* so we invalidate the pointer */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python attributes get/set functions: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Text_getMode(BPy_Text * self)
|
||||
{
|
||||
return PyInt_FromLong( self->text->flags );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python attributes get/set structure: */
|
||||
/*****************************************************************************/
|
||||
static PyGetSetDef BPy_Text_getseters[] = {
|
||||
GENERIC_LIB_GETSETATTR,
|
||||
{"filename", (getter)Text_getFilename, (setter)NULL,
|
||||
"text filename", NULL},
|
||||
{"mode", (getter)Text_getMode, (setter)NULL,
|
||||
"text mode flag", NULL},
|
||||
{"nlines", (getter)Text_getNLines, (setter)NULL,
|
||||
"number of lines", NULL},
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Text_Type structure definition: */
|
||||
/*****************************************************************************/
|
||||
PyTypeObject Text_Type = {
|
||||
PyObject_HEAD_INIT( NULL )
|
||||
NULL, /* ob_size */
|
||||
"Blender Text", /* tp_name */
|
||||
sizeof( BPy_Text ), /* tp_basicsize */
|
||||
NULL, /* tp_itemsize */
|
||||
/* methods */
|
||||
( destructor ) Text_dealloc, /* tp_dealloc */
|
||||
NULL, /* tp_print */
|
||||
NULL, /* tp_getattr */
|
||||
NULL, /* tp_setattr */
|
||||
( cmpfunc ) Text_compare, /* tp_compare */
|
||||
( reprfunc ) Text_repr, /* tp_repr */
|
||||
|
||||
/* Method suites for standard classes */
|
||||
|
||||
NULL, /* PyNumberMethods *tp_as_number; */
|
||||
NULL, /* PySequenceMethods *tp_as_sequence; */
|
||||
NULL, /* PyMappingMethods *tp_as_mapping; */
|
||||
|
||||
/* More standard operations (here for binary compatibility) */
|
||||
|
||||
NULL, /* hashfunc tp_hash; */
|
||||
NULL, /* ternaryfunc tp_call; */
|
||||
NULL, /* reprfunc tp_str; */
|
||||
NULL, /* getattrofunc tp_getattro; */
|
||||
NULL, /* setattrofunc tp_setattro; */
|
||||
|
||||
/* Functions to access object as input/output buffer */
|
||||
NULL, /* PyBufferProcs *tp_as_buffer; */
|
||||
|
||||
/*** Flags to define presence of optional/expanded features ***/
|
||||
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
|
||||
|
||||
NULL, /* char *tp_doc; Documentation string */
|
||||
/*** Assigned meaning in release 2.0 ***/
|
||||
/* call function for all accessible objects */
|
||||
NULL, /* traverseproc tp_traverse; */
|
||||
|
||||
/* delete references to contained objects */
|
||||
NULL, /* inquiry tp_clear; */
|
||||
|
||||
/*** Assigned meaning in release 2.1 ***/
|
||||
/*** rich comparisons ***/
|
||||
NULL, /* richcmpfunc tp_richcompare; */
|
||||
|
||||
/*** weak reference enabler ***/
|
||||
0, /* long tp_weaklistoffset; */
|
||||
|
||||
/*** Added in release 2.2 ***/
|
||||
/* Iterators */
|
||||
NULL, /* getiterfunc tp_iter; */
|
||||
NULL, /* iternextfunc tp_iternext; */
|
||||
|
||||
/*** Attribute descriptor and subclassing stuff ***/
|
||||
BPy_Text_methods, /* struct PyMethodDef *tp_methods; */
|
||||
NULL, /* struct PyMemberDef *tp_members; */
|
||||
BPy_Text_getseters, /* struct PyGetSetDef *tp_getset; */
|
||||
NULL, /* struct _typeobject *tp_base; */
|
||||
NULL, /* PyObject *tp_dict; */
|
||||
NULL, /* descrgetfunc tp_descr_get; */
|
||||
NULL, /* descrsetfunc tp_descr_set; */
|
||||
0, /* long tp_dictoffset; */
|
||||
NULL, /* initproc tp_init; */
|
||||
NULL, /* allocfunc tp_alloc; */
|
||||
NULL, /* newfunc tp_new; */
|
||||
/* Low-level free-memory routine */
|
||||
NULL, /* freefunc tp_free; */
|
||||
/* For PyObject_IS_GC */
|
||||
NULL, /* inquiry tp_is_gc; */
|
||||
NULL, /* PyObject *tp_bases; */
|
||||
/* method resolution order */
|
||||
NULL, /* PyObject *tp_mro; */
|
||||
NULL, /* PyObject *tp_cache; */
|
||||
NULL, /* PyObject *tp_subclasses; */
|
||||
NULL, /* PyObject *tp_weaklist; */
|
||||
NULL
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user