Exppython:
- Continued getting rid of print methods and updating repr ones: Needed to fix crashes on Windows >= 98 systems. - Found and fixed a few small memory leaks in EXPP_interface, related to execution of script links.
This commit is contained in:
@@ -572,36 +572,6 @@ PyObject * RunPython(Text *text, PyObject *globaldict)
|
|||||||
* to speed-up execution if the user executes the script multiple times */
|
* to speed-up execution if the user executes the script multiple times */
|
||||||
|
|
||||||
if (!text->compiled) { /* if it wasn't already compiled, do it now */
|
if (!text->compiled) { /* if it wasn't already compiled, do it now */
|
||||||
|
|
||||||
/*#ifdef BLENDER_SANDBOX_MODE
|
|
||||||
|
|
||||||
// IGNORE THIS ALL FOR A WHILE, IT'S VERY INCOMPLETE AND WILL CHANGE
|
|
||||||
// CONSIDERABLY, SOON. The #ifdef won't stay, either.
|
|
||||||
|
|
||||||
// The import statement is a security risk, so we don't allow it in
|
|
||||||
// SANDBOX MODE. Instead, we import all needed modules ourselves and
|
|
||||||
// substitute all 'import' and '__import__' statements in the code by
|
|
||||||
// '#mport' and '#_import__', resp., making their lines become comments
|
|
||||||
// in Python (to let scripts run without import errors).
|
|
||||||
|
|
||||||
// Disable importing only for the safest sandbox mode
|
|
||||||
|
|
||||||
txt_move_bof(text, 0); // move to the beginning of the script
|
|
||||||
|
|
||||||
// Search all occurrences of 'import' in the script
|
|
||||||
// XXX Also check for from ... import ...
|
|
||||||
while (txt_find_string (text, "import")) {
|
|
||||||
char *line = text->sell->line;
|
|
||||||
|
|
||||||
if (text->curc > 1) // is it '__import__' ?
|
|
||||||
if (strncmp (&line[text->curc - 2],
|
|
||||||
"__import__", 10) == 0) text->curc -= 2;
|
|
||||||
|
|
||||||
line[text->curc] = '#'; // change them to '#mport' or '#_import__'
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif */
|
|
||||||
|
|
||||||
buf = txt_to_buf(text);
|
buf = txt_to_buf(text);
|
||||||
|
|
||||||
text->compiled = Py_CompileString(buf, GetName(text), Py_file_input);
|
text->compiled = Py_CompileString(buf, GetName(text), Py_file_input);
|
||||||
@@ -615,12 +585,6 @@ PyObject * RunPython(Text *text, PyObject *globaldict)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#ifdef BLENDER_SANDBOX_MODE
|
|
||||||
//save the script as a dict entry and call the eval code for it
|
|
||||||
//then return
|
|
||||||
PyDict_SetItemString(globaldict, "_SB_code", text->compiled);
|
|
||||||
#endif */
|
|
||||||
|
|
||||||
return PyEval_EvalCode(text->compiled, globaldict, globaldict);
|
return PyEval_EvalCode(text->compiled, globaldict, globaldict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -311,17 +311,6 @@ static int Armature_setAttr (BPy_Armature *self, char *name, PyObject *value)
|
|||||||
return 0; /* normal exit */
|
return 0; /* normal exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: Armature_print */
|
|
||||||
/* Description: This is a callback function for the BPy_Armature type. It */
|
|
||||||
/* builds a meaninful string to 'print' armature objects. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static int Armature_print(BPy_Armature *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
fprintf(fp, "[Armature \"%s\"]", self->armature->id.name+2);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Armature_repr */
|
/* Function: Armature_repr */
|
||||||
/* Description: This is a callback function for the BPy_Armature type. It */
|
/* Description: This is a callback function for the BPy_Armature type. It */
|
||||||
@@ -329,7 +318,7 @@ static int Armature_print(BPy_Armature *self, FILE *fp, int flags)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Armature_repr (BPy_Armature *self)
|
static PyObject *Armature_repr (BPy_Armature *self)
|
||||||
{
|
{
|
||||||
return PyString_FromString(self->armature->id.name+2);
|
return PyString_FromFormat("[Armature \"%s\"]", self->armature->id.name+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@@ -132,7 +132,6 @@ static PyObject *Armature_getAttr (BPy_Armature *armature, char *name);
|
|||||||
static int Armature_setAttr (BPy_Armature *armature, char *name, PyObject *v);
|
static int Armature_setAttr (BPy_Armature *armature, char *name, PyObject *v);
|
||||||
static int Armature_compare (BPy_Armature *a1, BPy_Armature *a2);
|
static int Armature_compare (BPy_Armature *a1, BPy_Armature *a2);
|
||||||
static PyObject *Armature_repr (BPy_Armature *armature);
|
static PyObject *Armature_repr (BPy_Armature *armature);
|
||||||
static int Armature_print (BPy_Armature *armature, FILE *fp, int flags);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python TypeArmature structure definition: */
|
/* Python TypeArmature structure definition: */
|
||||||
@@ -146,7 +145,7 @@ PyTypeObject Armature_Type =
|
|||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Armature_dealloc, /* tp_dealloc */
|
(destructor)Armature_dealloc, /* tp_dealloc */
|
||||||
(printfunc)Armature_print, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Armature_getAttr, /* tp_getattr */
|
(getattrfunc)Armature_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Armature_setAttr, /* tp_setattr */
|
(setattrfunc)Armature_setAttr, /* tp_setattr */
|
||||||
(cmpfunc)Armature_compare, /* tp_compare */
|
(cmpfunc)Armature_compare, /* tp_compare */
|
||||||
|
@@ -141,7 +141,6 @@ static PyObject *Bone_getAttr (BPy_Bone *bone, char *name);
|
|||||||
static int Bone_setAttr (BPy_Bone *bone, char *name, PyObject *v);
|
static int Bone_setAttr (BPy_Bone *bone, char *name, PyObject *v);
|
||||||
static int Bone_compare (BPy_Bone *a1, BPy_Bone *a2);
|
static int Bone_compare (BPy_Bone *a1, BPy_Bone *a2);
|
||||||
static PyObject *Bone_repr (BPy_Bone *bone);
|
static PyObject *Bone_repr (BPy_Bone *bone);
|
||||||
static int Bone_print (BPy_Bone *bone, FILE *fp, int flags);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python TypeBone structure definition: */
|
/* Python TypeBone structure definition: */
|
||||||
@@ -155,7 +154,7 @@ PyTypeObject Bone_Type =
|
|||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Bone_dealloc, /* tp_dealloc */
|
(destructor)Bone_dealloc, /* tp_dealloc */
|
||||||
(printfunc)Bone_print, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Bone_getAttr, /* tp_getattr */
|
(getattrfunc)Bone_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Bone_setAttr, /* tp_setattr */
|
(setattrfunc)Bone_setAttr, /* tp_setattr */
|
||||||
(cmpfunc)Bone_compare, /* tp_compare */
|
(cmpfunc)Bone_compare, /* tp_compare */
|
||||||
@@ -645,18 +644,6 @@ static int Bone_setAttr (BPy_Bone *self, char *name, PyObject *value)
|
|||||||
return 0; /* normal exit */
|
return 0; /* normal exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: Bone_print */
|
|
||||||
/* Description: This is a callback function for the BPy_Bone type. It */
|
|
||||||
/* builds a meaninful string to 'print' bone objects. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static int Bone_print(BPy_Bone *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
if (self->bone) fprintf(fp, "[Bone \"%s\"]", self->bone->name);
|
|
||||||
else fprintf(fp, "[Bone NULL]");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Bone_repr */
|
/* Function: Bone_repr */
|
||||||
/* Description: This is a callback function for the BPy_Bone type. It */
|
/* Description: This is a callback function for the BPy_Bone type. It */
|
||||||
@@ -664,7 +651,8 @@ static int Bone_print(BPy_Bone *self, FILE *fp, int flags)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Bone_repr (BPy_Bone *self)
|
static PyObject *Bone_repr (BPy_Bone *self)
|
||||||
{
|
{
|
||||||
if (self->bone) return PyString_FromString(self->bone->name);
|
if (self->bone)
|
||||||
|
return PyString_FromFormat("[Bone \"%s\"]", self->bone->name);
|
||||||
else return PyString_FromString("NULL");
|
else return PyString_FromString("NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,7 +50,6 @@ PyTypeObject Camera_Type =
|
|||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Camera_dealloc, /* tp_dealloc */
|
(destructor)Camera_dealloc, /* tp_dealloc */
|
||||||
// (printfunc)Camera_print, /* tp_print */
|
|
||||||
0, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Camera_getAttr, /* tp_getattr */
|
(getattrfunc)Camera_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Camera_setAttr, /* tp_setattr */
|
(setattrfunc)Camera_setAttr, /* tp_setattr */
|
||||||
@@ -76,7 +75,6 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
|
|||||||
Camera *blcam; /* for actual Camera Data we create in Blender */
|
Camera *blcam; /* for actual Camera Data we create in Blender */
|
||||||
char buf[21];
|
char buf[21];
|
||||||
|
|
||||||
printf ("In Camera_New()\n");
|
|
||||||
/* Parse the arguments passed in by the Python interpreter */
|
/* Parse the arguments passed in by the Python interpreter */
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
|
||||||
&type_str, &name_str))
|
&type_str, &name_str))
|
||||||
@@ -583,13 +581,7 @@ static int Camera_compare (BPy_Camera *a, BPy_Camera *b)
|
|||||||
Camera *pa = a->camera, *pb = b->camera;
|
Camera *pa = a->camera, *pb = b->camera;
|
||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
static int Camera_print(BPy_Camera *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
fprintf(fp, "[Camera \"%s\"]", self->camera->id.name+2);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
static PyObject *Camera_repr (BPy_Camera *self)
|
static PyObject *Camera_repr (BPy_Camera *self)
|
||||||
{
|
{
|
||||||
return PyString_FromFormat("[Camera \"%s\"]", self->camera->id.name+2);
|
return PyString_FromFormat("[Camera \"%s\"]", self->camera->id.name+2);
|
||||||
|
@@ -174,7 +174,6 @@ static PyMethodDef BPy_Camera_methods[] = {
|
|||||||
/* Python Camera_Type callback function prototypes: */
|
/* Python Camera_Type callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void Camera_dealloc (BPy_Camera *self);
|
static void Camera_dealloc (BPy_Camera *self);
|
||||||
//static int Camera_print (BPy_Camera *self, FILE *fp, int flags);
|
|
||||||
static int Camera_setAttr (BPy_Camera *self, char *name, PyObject *v);
|
static int Camera_setAttr (BPy_Camera *self, char *name, PyObject *v);
|
||||||
static int Camera_compare (BPy_Camera *a, BPy_Camera *b);
|
static int Camera_compare (BPy_Camera *a, BPy_Camera *b);
|
||||||
static PyObject *Camera_getAttr (BPy_Camera *self, char *name);
|
static PyObject *Camera_getAttr (BPy_Camera *self, char *name);
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
#include <DNA_scriptlink_types.h>
|
#include <DNA_scriptlink_types.h>
|
||||||
#include <DNA_world_types.h>
|
#include <DNA_world_types.h>
|
||||||
|
|
||||||
|
#include "EXPP_interface.h"
|
||||||
#include "gen_utils.h"
|
#include "gen_utils.h"
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
|
|
||||||
@@ -54,13 +55,21 @@ void initBlenderApi2_2x (void)
|
|||||||
M_Blender_Init ();
|
M_Blender_Init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void discardFromBDict (char *key)
|
||||||
|
{
|
||||||
|
PyObject *oldval = PyDict_GetItemString(g_blenderdict, key);
|
||||||
|
if (oldval) { Py_DECREF(oldval); }
|
||||||
|
}
|
||||||
|
|
||||||
void clearScriptLinks (void)
|
void clearScriptLinks (void)
|
||||||
{
|
{
|
||||||
|
discardFromBDict ("bylink");
|
||||||
Py_INCREF (Py_False);
|
Py_INCREF (Py_False);
|
||||||
PyDict_SetItemString (g_blenderdict, "bylink", Py_False);
|
PyDict_SetItemString (g_blenderdict, "bylink", Py_False);
|
||||||
/* Old API meant link could be unset. Or even valid when bylink is false.
|
/* Old API meant link could be unset. Or even valid when bylink is false.
|
||||||
* This way, you can import it and check its value afterwards, ignoring
|
* This way, you can import it and check its value afterwards, ignoring
|
||||||
* bylink. */
|
* bylink. */
|
||||||
|
discardFromBDict ("link");
|
||||||
Py_INCREF (Py_None);
|
Py_INCREF (Py_None);
|
||||||
PyDict_SetItemString (g_blenderdict, "link", Py_None);
|
PyDict_SetItemString (g_blenderdict, "link", Py_None);
|
||||||
}
|
}
|
||||||
@@ -112,11 +121,13 @@ ScriptLink * setScriptLinks(ID *id, short event)
|
|||||||
link = Py_None;
|
link = Py_None;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Py_INCREF(Py_None);
|
//Py_INCREF(Py_None);
|
||||||
link = Py_None;
|
//link = Py_None;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
discardFromBDict ("bylink");
|
||||||
|
|
||||||
if (scriptlink == NULL)
|
if (scriptlink == NULL)
|
||||||
{
|
{
|
||||||
/* This is probably not an internal error anymore :)
|
/* This is probably not an internal error anymore :)
|
||||||
@@ -133,7 +144,10 @@ TODO: Check this
|
|||||||
PyDict_SetItemString(g_blenderdict, "bylink", Py_True);
|
PyDict_SetItemString(g_blenderdict, "bylink", Py_True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
discardFromBDict ("link");
|
||||||
PyDict_SetItemString(g_blenderdict, "link", link);
|
PyDict_SetItemString(g_blenderdict, "link", link);
|
||||||
|
|
||||||
|
discardFromBDict ("event");
|
||||||
PyDict_SetItemString(g_blenderdict, "event",
|
PyDict_SetItemString(g_blenderdict, "event",
|
||||||
Py_BuildValue("s", event_to_name(event)));
|
Py_BuildValue("s", event_to_name(event)));
|
||||||
|
|
||||||
|
@@ -34,3 +34,4 @@
|
|||||||
void initBlenderApi2_2x (void);
|
void initBlenderApi2_2x (void);
|
||||||
void clearScriptLinks (void);
|
void clearScriptLinks (void);
|
||||||
ScriptLink * setScriptLinks(ID *id, short event);
|
ScriptLink * setScriptLinks(ID *id, short event);
|
||||||
|
void discardFromBDict (char *key);
|
||||||
|
@@ -146,7 +146,7 @@ static PyObject *M_Image_Get(PyObject *self, PyObject *args)
|
|||||||
|
|
||||||
else { /* () - return a list of all images in the scene */
|
else { /* () - return a list of all images in the scene */
|
||||||
int index = 0;
|
int index = 0;
|
||||||
PyObject *img_list, *pystr;
|
PyObject *img_list, *pyobj;
|
||||||
|
|
||||||
img_list = PyList_New (BLI_countlist (&(G.main->image)));
|
img_list = PyList_New (BLI_countlist (&(G.main->image)));
|
||||||
|
|
||||||
@@ -155,13 +155,13 @@ static PyObject *M_Image_Get(PyObject *self, PyObject *args)
|
|||||||
"couldn't create PyList"));
|
"couldn't create PyList"));
|
||||||
|
|
||||||
while (img_iter) {
|
while (img_iter) {
|
||||||
pystr = PyString_FromString (img_iter->id.name+2);
|
pyobj = Image_CreatePyObject (img_iter);
|
||||||
|
|
||||||
if (!pystr)
|
if (!pyobj)
|
||||||
return (PythonReturnErrorObject (PyExc_MemoryError,
|
return (PythonReturnErrorObject (PyExc_MemoryError,
|
||||||
"couldn't create PyString"));
|
"couldn't create PyObject"));
|
||||||
|
|
||||||
PyList_SET_ITEM (img_list, index, pystr);
|
PyList_SET_ITEM (img_list, index, pyobj);
|
||||||
|
|
||||||
img_iter = img_iter->id.next;
|
img_iter = img_iter->id.next;
|
||||||
index++;
|
index++;
|
||||||
@@ -251,12 +251,11 @@ static PyMethodDef BPy_Image_methods[] = {
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python Image_Type callback function prototypes: */
|
/* Python Image_Type callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void Image_Dealloc (BPy_Image *self);
|
static void Image_dealloc (BPy_Image *self);
|
||||||
static int Image_SetAttr (BPy_Image *self, char *name, PyObject *v);
|
static int Image_setAttr (BPy_Image *self, char *name, PyObject *v);
|
||||||
static int Image_Compare (BPy_Image *a, BPy_Image *b);
|
static int Image_compare (BPy_Image *a, BPy_Image *b);
|
||||||
static int Image_Print (BPy_Image *self, FILE *fp, int flags);
|
static PyObject *Image_getAttr (BPy_Image *self, char *name);
|
||||||
static PyObject *Image_GetAttr (BPy_Image *self, char *name);
|
static PyObject *Image_repr (BPy_Image *self);
|
||||||
static PyObject *Image_Repr (BPy_Image *self);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python Image_Type structure definition: */
|
/* Python Image_Type structure definition: */
|
||||||
@@ -269,12 +268,12 @@ PyTypeObject Image_Type =
|
|||||||
sizeof (BPy_Image), /* tp_basicsize */
|
sizeof (BPy_Image), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Image_Dealloc, /* tp_dealloc */
|
(destructor)Image_dealloc, /* tp_dealloc */
|
||||||
(printfunc)Image_Print, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Image_GetAttr, /* tp_getattr */
|
(getattrfunc)Image_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Image_SetAttr, /* tp_setattr */
|
(setattrfunc)Image_setAttr, /* tp_setattr */
|
||||||
(cmpfunc)Image_Compare, /* tp_compare */
|
(cmpfunc)Image_compare, /* tp_compare */
|
||||||
(reprfunc)Image_Repr, /* tp_repr */
|
(reprfunc)Image_repr, /* tp_repr */
|
||||||
0, /* tp_as_number */
|
0, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
0, /* tp_as_mapping */
|
0, /* tp_as_mapping */
|
||||||
@@ -287,11 +286,11 @@ PyTypeObject Image_Type =
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: ImageDealloc */
|
/* Function: Image_dealloc */
|
||||||
/* Description: This is a callback function for the BPy_Image type. It is */
|
/* Description: This is a callback function for the BPy_Image type. It is */
|
||||||
/* the destructor function. */
|
/* the destructor function. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void Image_Dealloc (BPy_Image *self)
|
static void Image_dealloc (BPy_Image *self)
|
||||||
{
|
{
|
||||||
PyObject_DEL (self);
|
PyObject_DEL (self);
|
||||||
}
|
}
|
||||||
@@ -403,12 +402,12 @@ static PyObject *Image_setYRep(BPy_Image *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Image_GetAttr */
|
/* Function: Image_getAttr */
|
||||||
/* Description: This is a callback function for the BPy_Image type. It is */
|
/* Description: This is a callback function for the BPy_Image type. It is */
|
||||||
/* the function that accesses BPy_Image member variables and */
|
/* the function that accesses BPy_Image member variables and */
|
||||||
/* methods. */
|
/* methods. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Image_GetAttr (BPy_Image *self, char *name)
|
static PyObject *Image_getAttr (BPy_Image *self, char *name)
|
||||||
{
|
{
|
||||||
PyObject *attr = Py_None;
|
PyObject *attr = Py_None;
|
||||||
|
|
||||||
@@ -436,12 +435,12 @@ static PyObject *Image_GetAttr (BPy_Image *self, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Image_SetAttr */
|
/* Function: Image_setAttr */
|
||||||
/* Description: This is a callback function for the BPy_Image type. It is the*/
|
/* Description: This is a callback function for the BPy_Image type. It is the*/
|
||||||
/* function that changes Image Data members values. If this */
|
/* function that changes Image Data members values. If this */
|
||||||
/* data is linked to a Blender Image, it also gets updated. */
|
/* data is linked to a Blender Image, it also gets updated. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int Image_SetAttr (BPy_Image *self, char *name, PyObject *value)
|
static int Image_setAttr (BPy_Image *self, char *name, PyObject *value)
|
||||||
{
|
{
|
||||||
PyObject *valtuple;
|
PyObject *valtuple;
|
||||||
PyObject *error = NULL;
|
PyObject *error = NULL;
|
||||||
@@ -479,36 +478,25 @@ static int Image_SetAttr (BPy_Image *self, char *name, PyObject *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Image_Compare */
|
/* Function: Image_compare */
|
||||||
/* Description: This is a callback function for the BPy_Image type. It */
|
/* Description: This is a callback function for the BPy_Image type. It */
|
||||||
/* compares two Image_Type objects. Only the "==" and "!=" */
|
/* compares two Image_Type objects. Only the "==" and "!=" */
|
||||||
/* comparisons are meaninful. Returns 0 for equality and -1 if */
|
/* comparisons are meaninful. Returns 0 for equality and -1 if */
|
||||||
/* they don't point to the same Blender Image struct. */
|
/* they don't point to the same Blender Image struct. */
|
||||||
/* In Python it becomes 1 if they are equal, 0 otherwise. */
|
/* In Python it becomes 1 if they are equal, 0 otherwise. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int Image_Compare (BPy_Image *a, BPy_Image *b)
|
static int Image_compare (BPy_Image *a, BPy_Image *b)
|
||||||
{
|
{
|
||||||
Image *pa = a->image, *pb = b->image;
|
Image *pa = a->image, *pb = b->image;
|
||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Image_Print */
|
/* Function: Image_repr */
|
||||||
/* Description: This is a callback function for the BPy_Image type. It */
|
|
||||||
/* builds a meaninful string to 'print' image objects. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static int Image_Print(BPy_Image *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
fprintf(fp, "[Image \"%s\"]", self->image->id.name+2);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: Image_Repr */
|
|
||||||
/* Description: This is a callback function for the BPy_Image type. It */
|
/* Description: This is a callback function for the BPy_Image type. It */
|
||||||
/* builds a meaninful string to represent image objects. */
|
/* builds a meaninful string to represent image objects. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Image_Repr (BPy_Image *self)
|
static PyObject *Image_repr (BPy_Image *self)
|
||||||
{
|
{
|
||||||
return PyString_FromString(self->image->id.name+2);
|
return PyString_FromFormat("[Image \"%s\"]", self->image->id.name+2);
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ extern PyTypeObject Image_Type; /* The Image PyType Object */
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Module Blender.Image - public functions */
|
/* Module Blender.Image - public functions */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *M_Image_Init (void);
|
PyObject *Image_Init (void);
|
||||||
PyObject *Image_CreatePyObject (Image *image);
|
PyObject *Image_CreatePyObject (Image *image);
|
||||||
int Image_CheckPyObject (PyObject *pyobj);
|
int Image_CheckPyObject (PyObject *pyobj);
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ PyTypeObject Lamp_Type =
|
|||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Lamp_dealloc, /* tp_dealloc */
|
(destructor)Lamp_dealloc, /* tp_dealloc */
|
||||||
(printfunc)Lamp_print, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Lamp_getAttr, /* tp_getattr */
|
(getattrfunc)Lamp_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Lamp_setAttr, /* tp_setattr */
|
(setattrfunc)Lamp_setAttr, /* tp_setattr */
|
||||||
(cmpfunc)Lamp_compare, /* tp_compare */
|
(cmpfunc)Lamp_compare, /* tp_compare */
|
||||||
@@ -1024,17 +1024,6 @@ static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b)
|
|||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: Lamp_print */
|
|
||||||
/* Description: This is a callback function for the BPy_Lamp type. It */
|
|
||||||
/* builds a meaninful string to 'print' lamp objects. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static int Lamp_print(BPy_Lamp *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
fprintf(fp, "[Lamp \"%s\"]", self->lamp->id.name+2);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Lamp_repr */
|
/* Function: Lamp_repr */
|
||||||
/* Description: This is a callback function for the BPy_Lamp type. It */
|
/* Description: This is a callback function for the BPy_Lamp type. It */
|
||||||
@@ -1042,5 +1031,5 @@ static int Lamp_print(BPy_Lamp *self, FILE *fp, int flags)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Lamp_repr (BPy_Lamp *self)
|
static PyObject *Lamp_repr (BPy_Lamp *self)
|
||||||
{
|
{
|
||||||
return PyString_FromString(self->lamp->id.name+2);
|
return PyString_FromFormat("[Lamp \"%s\"]", self->lamp->id.name+2);
|
||||||
}
|
}
|
||||||
|
@@ -279,7 +279,6 @@ static PyObject *Lamp_getAttr (BPy_Lamp *lamp, char *name);
|
|||||||
static int Lamp_setAttr (BPy_Lamp *lamp, char *name, PyObject *v);
|
static int Lamp_setAttr (BPy_Lamp *lamp, char *name, PyObject *v);
|
||||||
static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b);
|
static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b);
|
||||||
static PyObject *Lamp_repr (BPy_Lamp *lamp);
|
static PyObject *Lamp_repr (BPy_Lamp *lamp);
|
||||||
static int Lamp_print (BPy_Lamp *lamp, FILE *fp, int flags);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* EXPP_LAMP_H */
|
#endif /* EXPP_LAMP_H */
|
||||||
|
@@ -422,11 +422,10 @@ static PyMethodDef BPy_Material_methods[] = {
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python Material_Type callback function prototypes: */
|
/* Python Material_Type callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void Material_Dealloc (BPy_Material *self);
|
static void Material_dealloc (BPy_Material *self);
|
||||||
static int Material_Print (BPy_Material *self, FILE *fp, int flags);
|
static int Material_setAttr (BPy_Material *self, char *name, PyObject *v);
|
||||||
static int Material_SetAttr (BPy_Material *self, char *name, PyObject *v);
|
static PyObject *Material_getAttr (BPy_Material *self, char *name);
|
||||||
static PyObject *Material_GetAttr (BPy_Material *self, char *name);
|
static PyObject *Material_repr (BPy_Material *self);
|
||||||
static PyObject *Material_Repr (BPy_Material *self);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python Material_Type structure definition: */
|
/* Python Material_Type structure definition: */
|
||||||
@@ -439,12 +438,12 @@ PyTypeObject Material_Type =
|
|||||||
sizeof (BPy_Material), /* tp_basicsize */
|
sizeof (BPy_Material), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Material_Dealloc, /* tp_dealloc */
|
(destructor)Material_dealloc, /* tp_dealloc */
|
||||||
(printfunc)Material_Print, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Material_GetAttr, /* tp_getattr */
|
(getattrfunc)Material_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Material_SetAttr, /* tp_setattr */
|
(setattrfunc)Material_setAttr, /* tp_setattr */
|
||||||
0, /* tp_compare */
|
0, /* tp_compare */
|
||||||
(reprfunc)Material_Repr, /* tp_repr */
|
(reprfunc)Material_repr, /* tp_repr */
|
||||||
0, /* tp_as_number */
|
0, /* tp_as_number */
|
||||||
0, /* tp_as_sequence */
|
0, /* tp_as_sequence */
|
||||||
0, /* tp_as_mapping */
|
0, /* tp_as_mapping */
|
||||||
@@ -457,11 +456,11 @@ PyTypeObject Material_Type =
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Material_Dealloc */
|
/* Function: Material_dealloc */
|
||||||
/* Description: This is a callback function for the BPy_Material type. It is */
|
/* Description: This is a callback function for the BPy_Material type. It is */
|
||||||
/* the destructor function. */
|
/* the destructor function. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void Material_Dealloc (BPy_Material *self)
|
static void Material_dealloc (BPy_Material *self)
|
||||||
{
|
{
|
||||||
Py_DECREF (self->col);
|
Py_DECREF (self->col);
|
||||||
Py_DECREF (self->amb);
|
Py_DECREF (self->amb);
|
||||||
@@ -1124,12 +1123,12 @@ static PyObject *Material_setNRings(BPy_Material *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Material_GetAttr */
|
/* Function: Material_getAttr */
|
||||||
/* Description: This is a callback function for the BPy_Material type. It is */
|
/* Description: This is a callback function for the BPy_Material type. It is */
|
||||||
/* the function that accesses BPy_Material "member variables" */
|
/* the function that accesses BPy_Material "member variables" */
|
||||||
/* and methods. */
|
/* and methods. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Material_GetAttr (BPy_Material *self, char *name)
|
static PyObject *Material_getAttr (BPy_Material *self, char *name)
|
||||||
{
|
{
|
||||||
PyObject *attr = Py_None;
|
PyObject *attr = Py_None;
|
||||||
|
|
||||||
@@ -1207,12 +1206,12 @@ static PyObject *Material_GetAttr (BPy_Material *self, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Function: Material_SetAttr */
|
/* Function: Material_setAttr */
|
||||||
/* Description: This is a callback function for the BPy_Material type. */
|
/* Description: This is a callback function for the BPy_Material type. */
|
||||||
/* It is the function that sets Material attributes (member */
|
/* It is the function that sets Material attributes (member */
|
||||||
/* variables). */
|
/* variables). */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
static int Material_SetAttr (BPy_Material *self, char *name, PyObject *value)
|
static int Material_setAttr (BPy_Material *self, char *name, PyObject *value)
|
||||||
{
|
{
|
||||||
PyObject *valtuple;
|
PyObject *valtuple;
|
||||||
PyObject *error = NULL;
|
PyObject *error = NULL;
|
||||||
@@ -1302,34 +1301,18 @@ static int Material_SetAttr (BPy_Material *self, char *name, PyObject *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Material_Print */
|
/* Function: Material_repr */
|
||||||
/* Description: This is a callback function for the BPy_Material type. It */
|
|
||||||
/* builds a meaninful string to 'print' material objects. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static int Material_Print(BPy_Material *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
fprintf(fp, "[Material \"%s\"]", self->material->id.name+2);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: Material_Repr */
|
|
||||||
/* Description: This is a callback function for the BPy_Material type. It */
|
/* Description: This is a callback function for the BPy_Material type. It */
|
||||||
/* builds a meaninful string to represent material objects. */
|
/* builds a meaninful string to represent material objects. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *Material_Repr (BPy_Material *self)
|
static PyObject *Material_repr (BPy_Material *self)
|
||||||
{
|
{
|
||||||
char buf[40];
|
return PyString_FromFormat ("[Material \"%s\"]", self->material->id.name+2);
|
||||||
|
|
||||||
PyOS_snprintf(buf, sizeof(buf), "[Material \"%s\"]",
|
|
||||||
self->material->id.name+2);
|
|
||||||
|
|
||||||
return PyString_FromString(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* These three functions are used in NMesh.c */
|
/* These functions are used in NMesh.c and Object.c */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
PyObject *EXPP_PyList_fromMaterialList (Material **matlist, int len)
|
PyObject *EXPP_PyList_fromMaterialList (Material **matlist, int len)
|
||||||
{
|
{
|
||||||
|
@@ -670,9 +670,6 @@ static PyObject *NMesh_update(PyObject *self, PyObject *args)
|
|||||||
nmesh->mesh = Mesh_fromNMesh(nmesh);
|
nmesh->mesh = Mesh_fromNMesh(nmesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh->mat = EXPP_newMaterialList_fromPyList(nmesh->materials);
|
|
||||||
EXPP_incr_mats_us(mesh->mat, PyList_Size (nmesh->materials));
|
|
||||||
|
|
||||||
nmesh_updateMaterials(nmesh);
|
nmesh_updateMaterials(nmesh);
|
||||||
/**@ This is another ugly fix due to the weird material handling of blender.
|
/**@ This is another ugly fix due to the weird material handling of blender.
|
||||||
* it makes sure that object material lists get updated (by their length)
|
* it makes sure that object material lists get updated (by their length)
|
||||||
@@ -1336,7 +1333,7 @@ Material **nmesh_updateMaterials(BPy_NMesh *nmesh)
|
|||||||
{
|
{
|
||||||
Material **matlist;
|
Material **matlist;
|
||||||
Mesh *mesh = nmesh->mesh;
|
Mesh *mesh = nmesh->mesh;
|
||||||
int len = PySequence_Length(nmesh->materials);
|
int len = PyList_Size(nmesh->materials);
|
||||||
|
|
||||||
if (!mesh) {
|
if (!mesh) {
|
||||||
printf("FATAL INTERNAL ERROR: illegal call to updateMaterials()\n");
|
printf("FATAL INTERNAL ERROR: illegal call to updateMaterials()\n");
|
||||||
@@ -1345,9 +1342,12 @@ Material **nmesh_updateMaterials(BPy_NMesh *nmesh)
|
|||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
matlist = EXPP_newMaterialList_fromPyList(nmesh->materials);
|
matlist = EXPP_newMaterialList_fromPyList(nmesh->materials);
|
||||||
if (mesh->mat)
|
EXPP_incr_mats_us(matlist, len);
|
||||||
MEM_freeN(mesh->mat);
|
|
||||||
|
if (mesh->mat) MEM_freeN(mesh->mat);
|
||||||
|
|
||||||
mesh->mat = matlist;
|
mesh->mat = matlist;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
matlist = 0;
|
matlist = 0;
|
||||||
}
|
}
|
||||||
@@ -1369,10 +1369,12 @@ PyObject *NMesh_assignMaterials_toObject(BPy_NMesh *nmesh, Object *ob)
|
|||||||
|
|
||||||
nmats = PyList_Size(nmesh->materials);
|
nmats = PyList_Size(nmesh->materials);
|
||||||
|
|
||||||
if (nmats > 0 && !mesh->mat) { /* explain ... */
|
if (nmats > 0 && !mesh->mat) {
|
||||||
ob->totcol = nmats;
|
ob->totcol = nmats;
|
||||||
mesh->totcol = nmats;
|
mesh->totcol = nmats;
|
||||||
mesh->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_memats");
|
mesh->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_memats");
|
||||||
|
|
||||||
|
if (ob->mat) MEM_freeN(ob->mat);
|
||||||
ob->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_obmats");
|
ob->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_obmats");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -163,7 +163,6 @@ static PyMethodDef BPy_Scene_methods[] = {
|
|||||||
/* Python Scene_Type callback function prototypes: */
|
/* Python Scene_Type callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void Scene_dealloc (BPy_Scene *self);
|
static void Scene_dealloc (BPy_Scene *self);
|
||||||
static int Scene_print (BPy_Scene *self, FILE *fp, int flags);
|
|
||||||
static int Scene_setAttr (BPy_Scene *self, char *name, PyObject *v);
|
static int Scene_setAttr (BPy_Scene *self, char *name, PyObject *v);
|
||||||
static int Scene_compare (BPy_Scene *a, BPy_Scene *b);
|
static int Scene_compare (BPy_Scene *a, BPy_Scene *b);
|
||||||
static PyObject *Scene_getAttr (BPy_Scene *self, char *name);
|
static PyObject *Scene_getAttr (BPy_Scene *self, char *name);
|
||||||
@@ -181,7 +180,7 @@ PyTypeObject Scene_Type =
|
|||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Scene_dealloc, /* tp_dealloc */
|
(destructor)Scene_dealloc, /* tp_dealloc */
|
||||||
(printfunc)Scene_print, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Scene_getAttr, /* tp_getattr */
|
(getattrfunc)Scene_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Scene_setAttr, /* tp_setattr */
|
(setattrfunc)Scene_setAttr, /* tp_setattr */
|
||||||
(cmpfunc)Scene_compare, /* tp_compare */
|
(cmpfunc)Scene_compare, /* tp_compare */
|
||||||
@@ -730,15 +729,9 @@ static int Scene_compare (BPy_Scene *a, BPy_Scene *b)
|
|||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Scene_print(BPy_Scene *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
fprintf(fp, "[Scene \"%s\"]", self->scene->id.name+2);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *Scene_repr (BPy_Scene *self)
|
static PyObject *Scene_repr (BPy_Scene *self)
|
||||||
{
|
{
|
||||||
return PyString_FromString(self->scene->id.name+2);
|
return PyString_FromFormat("[Scene \"%s\"]", self->scene->id.name+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Base *EXPP_Scene_getObjectBase(Scene *scene, Object *object)
|
Base *EXPP_Scene_getObjectBase(Scene *scene, Object *object)
|
||||||
|
@@ -485,21 +485,6 @@ static int Text_compare (BPy_Text *a, BPy_Text *b)
|
|||||||
return (pa == pb) ? 0:-1;
|
return (pa == pb) ? 0:-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: Text_print */
|
|
||||||
/* Description: This is a callback function for the BPy_Text type. It */
|
|
||||||
/* builds a meaninful string to 'print' text objects. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static int Text_print(BPy_Text *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
if (self->text && Text_IsLinked(self))
|
|
||||||
fprintf(fp, "[Text \"%s\"]", self->text->id.name+2);
|
|
||||||
else
|
|
||||||
fprintf(fp, "[Text <deleted>]");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: Text_repr */
|
/* Function: Text_repr */
|
||||||
/* Description: This is a callback function for the BPy_Text type. It */
|
/* Description: This is a callback function for the BPy_Text type. It */
|
||||||
@@ -508,9 +493,9 @@ static int Text_print(BPy_Text *self, FILE *fp, int flags)
|
|||||||
static PyObject *Text_repr (BPy_Text *self)
|
static PyObject *Text_repr (BPy_Text *self)
|
||||||
{
|
{
|
||||||
if (self->text && Text_IsLinked(self))
|
if (self->text && Text_IsLinked(self))
|
||||||
return PyString_FromString(self->text->id.name+2);
|
return PyString_FromFormat("[Text \"%s\"]", self->text->id.name+2);
|
||||||
else
|
else
|
||||||
return PyString_FromString("<deleted>");
|
return PyString_FromString("[Text <deleted>]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Internal function to confirm if a Text wasn't unlinked.
|
/* Internal function to confirm if a Text wasn't unlinked.
|
||||||
|
@@ -144,7 +144,6 @@ static PyMethodDef BPy_Text_methods[] = {
|
|||||||
/* Python Text_Type callback function prototypes: */
|
/* Python Text_Type callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void Text_dealloc (BPy_Text *self);
|
static void Text_dealloc (BPy_Text *self);
|
||||||
static int Text_print (BPy_Text *self, FILE *fp, int flags);
|
|
||||||
static int Text_setAttr (BPy_Text *self, char *name, PyObject *v);
|
static int Text_setAttr (BPy_Text *self, char *name, PyObject *v);
|
||||||
static PyObject *Text_getAttr (BPy_Text *self, char *name);
|
static PyObject *Text_getAttr (BPy_Text *self, char *name);
|
||||||
static int Text_compare (BPy_Text *a, BPy_Text *b);
|
static int Text_compare (BPy_Text *a, BPy_Text *b);
|
||||||
@@ -162,7 +161,7 @@ PyTypeObject Text_Type =
|
|||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)Text_dealloc, /* tp_dealloc */
|
(destructor)Text_dealloc, /* tp_dealloc */
|
||||||
(printfunc)Text_print, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)Text_getAttr, /* tp_getattr */
|
(getattrfunc)Text_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)Text_setAttr, /* tp_setattr */
|
(setattrfunc)Text_setAttr, /* tp_setattr */
|
||||||
(cmpfunc)Text_compare, /* tp_compare */
|
(cmpfunc)Text_compare, /* tp_compare */
|
||||||
|
@@ -37,11 +37,10 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Python rgbTuple_Type callback function prototypes: */
|
/* Python rgbTuple_Type callback function prototypes: */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void rgbTupleDeAlloc (BPy_rgbTuple *self);
|
static void rgbTuple_dealloc (BPy_rgbTuple *self);
|
||||||
static PyObject *rgbTupleGetAttr (BPy_rgbTuple *self, char *name);
|
static PyObject *rgbTuple_getAttr (BPy_rgbTuple *self, char *name);
|
||||||
static int rgbTupleSetAttr (BPy_rgbTuple *self, char *name, PyObject *v);
|
static int rgbTuple_setAttr (BPy_rgbTuple *self, char *name, PyObject *v);
|
||||||
static int rgbTuplePrint(BPy_rgbTuple *self, FILE *fp, int flags);
|
static PyObject *rgbTuple_repr (BPy_rgbTuple *self);
|
||||||
static PyObject *rgbTupleRepr (BPy_rgbTuple *self);
|
|
||||||
|
|
||||||
static int rgbTupleLength(BPy_rgbTuple *self);
|
static int rgbTupleLength(BPy_rgbTuple *self);
|
||||||
|
|
||||||
@@ -89,12 +88,12 @@ PyTypeObject rgbTuple_Type =
|
|||||||
sizeof (BPy_rgbTuple), /* tp_basicsize */
|
sizeof (BPy_rgbTuple), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
/* methods */
|
/* methods */
|
||||||
(destructor)rgbTupleDeAlloc, /* tp_dealloc */
|
(destructor)rgbTuple_deAlloc, /* tp_dealloc */
|
||||||
(printfunc)rgbTuplePrint, /* tp_print */
|
0, /* tp_print */
|
||||||
(getattrfunc)rgbTupleGetAttr, /* tp_getattr */
|
(getattrfunc)rgbTuple_getAttr, /* tp_getattr */
|
||||||
(setattrfunc)rgbTupleSetAttr, /* tp_setattr */
|
(setattrfunc)rgbTuple_setAttr, /* tp_setattr */
|
||||||
0, /* tp_compare */
|
0, /* tp_compare */
|
||||||
(reprfunc)rgbTupleRepr, /* tp_repr */
|
(reprfunc)rgbTuple_repr, /* tp_repr */
|
||||||
0, /* tp_as_number */
|
0, /* tp_as_number */
|
||||||
&rgbTupleAsSequence, /* tp_as_sequence */
|
&rgbTupleAsSequence, /* tp_as_sequence */
|
||||||
&rgbTupleAsMapping, /* tp_as_mapping */
|
&rgbTupleAsMapping, /* tp_as_mapping */
|
||||||
@@ -170,22 +169,22 @@ PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTupleDeAlloc */
|
/* Function: rgbTuple_deAlloc */
|
||||||
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
||||||
/* the destructor function. */
|
/* the destructor function. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static void rgbTupleDeAlloc (BPy_rgbTuple *self)
|
static void rgbTuple_deAlloc (BPy_rgbTuple *self)
|
||||||
{
|
{
|
||||||
PyObject_DEL (self);
|
PyObject_DEL (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTupleGetAttr */
|
/* Function: rgbTuple_getAttr */
|
||||||
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
||||||
/* the function that accesses BPy_rgbTuple member variables and */
|
/* the function that accesses BPy_rgbTuple member variables and */
|
||||||
/* methods. */
|
/* methods. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject* rgbTupleGetAttr (BPy_rgbTuple *self, char *name)
|
static PyObject* rgbTuple_getAttr (BPy_rgbTuple *self, char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -203,11 +202,11 @@ static PyObject* rgbTupleGetAttr (BPy_rgbTuple *self, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTupleSetAttr */
|
/* Function: rgbTuple_setAttr */
|
||||||
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
|
||||||
/* the function that changes BPy_rgbTuple member variables. */
|
/* the function that changes BPy_rgbTuple member variables. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int rgbTupleSetAttr (BPy_rgbTuple *self, char *name, PyObject *v)
|
static int rgbTuple_setAttr (BPy_rgbTuple *self, char *name, PyObject *v)
|
||||||
{
|
{
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
@@ -370,32 +369,17 @@ static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Function: rgbTuplePrint */
|
/* Function: rgbTuple_repr */
|
||||||
/* Description: This is a callback function for the BPy_rgbTuple type. It */
|
|
||||||
/* builds a meaninful string to 'print' rgbTuple objects. */
|
|
||||||
/*****************************************************************************/
|
|
||||||
static int rgbTuplePrint(BPy_rgbTuple *self, FILE *fp, int flags)
|
|
||||||
{
|
|
||||||
fprintf(fp, "[%f, %f, %f]",
|
|
||||||
*(self->rgb[0]), *(self->rgb[1]), *(self->rgb[2]));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/* Function: rgbTupleRepr */
|
|
||||||
/* Description: This is a callback function for the BPy_rgbTuple type. It */
|
/* Description: This is a callback function for the BPy_rgbTuple type. It */
|
||||||
/* builds a meaninful string to represent rgbTuple objects. */
|
/* builds a meaninful string to represent rgbTuple objects. */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static PyObject *rgbTupleRepr (BPy_rgbTuple *self)
|
static PyObject *rgbTuple_repr (BPy_rgbTuple *self)
|
||||||
{
|
{
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
char buf[64];
|
|
||||||
|
|
||||||
r = *(self->rgb[0]);
|
r = *(self->rgb[0]);
|
||||||
g = *(self->rgb[1]);
|
g = *(self->rgb[1]);
|
||||||
b = *(self->rgb[2]);
|
b = *(self->rgb[2]);
|
||||||
|
|
||||||
PyOS_snprintf(buf, sizeof(buf), "[%f, %f, %f]", r, g, b);
|
return PyString_FromFormat("[%f, %f, %f]", r, g, b);
|
||||||
|
|
||||||
return PyString_FromString(buf);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user