diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-02-25 10:36:50 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-02-25 10:36:50 +0300 |
commit | 436e1697fdf07f5a17bcfbdde8b18e89e44e9cf1 (patch) | |
tree | 6e7695edfd05e95a01d4772f24afb84303a8ee0e /source/blender/python/api2_2x/Font.c | |
parent | e64b887fad611917916b2ce30bbcf2aa55593ea5 (diff) |
made attributes (name, property, users, fakeUser, lib) into functions all python types can use.
removed a lot of code duplication when moving to this.
Also removed unused functions GetMaterialByName(), same for Mesh, Object, World etc.
Diffstat (limited to 'source/blender/python/api2_2x/Font.c')
-rw-r--r-- | source/blender/python/api2_2x/Font.c | 61 |
1 files changed, 3 insertions, 58 deletions
diff --git a/source/blender/python/api2_2x/Font.c b/source/blender/python/api2_2x/Font.c index 660b1225eb7..44fa7ff0158 100644 --- a/source/blender/python/api2_2x/Font.c +++ b/source/blender/python/api2_2x/Font.c @@ -174,23 +174,10 @@ PyObject *M_Font_Load( PyObject * self, PyObject * args ) return ( PyObject * ) py_font; } -/*--------------- Python BPy_Font methods---------------------------*/ +/*--------------- Python BPy_Font getsetattr funcs ---------------------*/ -/*--------------- BPy_Font.getName()--------------------------------*/ -static PyObject *Font_getName( BPy_Font * self ) -{ - PyObject *attr = NULL; - - if( self->font ) - attr = PyString_FromString( self->font->id.name+2 ); - if( attr ) - return attr; - - return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, - "couldn't get Font.name attribute" ) ); -} -/*--------------- BPy_Font.getFilename()--------------------------------*/ +/*--------------- BPy_Font.filename-------------------------------------*/ static PyObject *Font_getFilename( BPy_Font * self ) { PyObject *attr = NULL; @@ -204,26 +191,6 @@ static PyObject *Font_getFilename( BPy_Font * self ) "couldn't get Font.filename attribute" ) ); } -static int Font_setName( BPy_Font * self, PyObject * value ) -{ - char *name = NULL; - - if( !(self->font) ) - return EXPP_ReturnIntError( PyExc_RuntimeError, - "Blender Font was deleted!" ); - - name = PyString_AsString ( value ); - if( !name ) - return EXPP_ReturnIntError( PyExc_TypeError, - "expected string argument" ); - - rename_id( &self->font->id, name ); - - return 0; -} - - - static int Font_setFilename( BPy_Font * self, PyObject * value ) { char *name = NULL; @@ -241,12 +208,6 @@ static int Font_setFilename( BPy_Font * self, PyObject * value ) return 0; } - -static PyObject *Font_getLib( BPy_Font * self ) -{ - return EXPP_GetIdLib((ID *)self->font); -} - /*--------------- BPy_Font.pack()---------------------------------*/ static PyObject *Font_pack( BPy_Font * self ) { @@ -283,27 +244,11 @@ static PyObject *Font_getPacked( BPy_Font * self ) return EXPP_incr_ret_False(); } -static PyObject *Font_getUsers( BPy_Font* self ) -{ - return PyInt_FromLong( self->font->id.us ); -} - /*****************************************************************************/ /* Python attributes get/set structure: */ /*****************************************************************************/ static PyGetSetDef BPy_Font_getseters[] = { - {"name", - (getter)Font_getName, (setter)Font_setName, - "Font name", - NULL}, - {"lib", - (getter)Font_getLib, (setter)NULL, - "Font linked library", - NULL}, - {"users", - (getter)Font_getUsers, (setter)NULL, - "Number of font users", - NULL}, + GENERIC_LIB_GETSETATTR, {"filename", (getter)Font_getFilename, (setter)Font_setFilename, "Font filepath", |