Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2003-07-05 05:18:41 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2003-07-05 05:18:41 +0400
commitaa820ec42094c2799ca618d3ee174993358c9573 (patch)
tree41a122e1c1abf87dbe0911548568c1301a277cf2 /source
parent20df091c042be721fae0cac911844d603f1dd140 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/BPY_interface.c36
-rw-r--r--source/blender/python/api2_2x/Armature.c13
-rw-r--r--source/blender/python/api2_2x/Armature.h3
-rw-r--r--source/blender/python/api2_2x/Bone.c18
-rw-r--r--source/blender/python/api2_2x/Camera.c10
-rw-r--r--source/blender/python/api2_2x/Camera.h1
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.c18
-rw-r--r--source/blender/python/api2_2x/EXPP_interface.h1
-rw-r--r--source/blender/python/api2_2x/Image.c66
-rw-r--r--source/blender/python/api2_2x/Image.h2
-rw-r--r--source/blender/python/api2_2x/Lamp.c25
-rw-r--r--source/blender/python/api2_2x/Lamp.h1
-rw-r--r--source/blender/python/api2_2x/Material.c55
-rw-r--r--source/blender/python/api2_2x/NMesh.c20
-rw-r--r--source/blender/python/api2_2x/Scene.c11
-rw-r--r--source/blender/python/api2_2x/Text.c19
-rw-r--r--source/blender/python/api2_2x/Text.h3
-rw-r--r--source/blender/python/api2_2x/rgbTuple.c54
-rw-r--r--source/blender/python/api2_2x/vector.c190
19 files changed, 207 insertions, 339 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 510dc52085e..43b9e0a910f 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -572,36 +572,6 @@ PyObject * RunPython(Text *text, PyObject *globaldict)
* to speed-up execution if the user executes the script multiple times */
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);
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);
}
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index 998a36bb11e..03322d678db 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -312,24 +312,13 @@ static int Armature_setAttr (BPy_Armature *self, char *name, PyObject *value)
}
/*****************************************************************************/
-/* 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 */
/* Description: This is a callback function for the BPy_Armature type. It */
/* builds a meaninful string to represent armature objects. */
/*****************************************************************************/
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);
}
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Armature.h b/source/blender/python/api2_2x/Armature.h
index b2fa9611daf..32c4f3648ac 100644
--- a/source/blender/python/api2_2x/Armature.h
+++ b/source/blender/python/api2_2x/Armature.h
@@ -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_compare (BPy_Armature *a1, BPy_Armature *a2);
static PyObject *Armature_repr (BPy_Armature *armature);
-static int Armature_print (BPy_Armature *armature, FILE *fp, int flags);
/*****************************************************************************/
/* Python TypeArmature structure definition: */
@@ -146,7 +145,7 @@ PyTypeObject Armature_Type =
0, /* tp_itemsize */
/* methods */
(destructor)Armature_dealloc, /* tp_dealloc */
- (printfunc)Armature_print, /* tp_print */
+ 0, /* tp_print */
(getattrfunc)Armature_getAttr, /* tp_getattr */
(setattrfunc)Armature_setAttr, /* tp_setattr */
(cmpfunc)Armature_compare, /* tp_compare */
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c
index 56390b99386..c088662b750 100644
--- a/source/blender/python/api2_2x/Bone.c
+++ b/source/blender/python/api2_2x/Bone.c
@@ -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_compare (BPy_Bone *a1, BPy_Bone *a2);
static PyObject *Bone_repr (BPy_Bone *bone);
-static int Bone_print (BPy_Bone *bone, FILE *fp, int flags);
/*****************************************************************************/
/* Python TypeBone structure definition: */
@@ -155,7 +154,7 @@ PyTypeObject Bone_Type =
0, /* tp_itemsize */
/* methods */
(destructor)Bone_dealloc, /* tp_dealloc */
- (printfunc)Bone_print, /* tp_print */
+ 0, /* tp_print */
(getattrfunc)Bone_getAttr, /* tp_getattr */
(setattrfunc)Bone_setAttr, /* tp_setattr */
(cmpfunc)Bone_compare, /* tp_compare */
@@ -646,25 +645,14 @@ static int Bone_setAttr (BPy_Bone *self, char *name, PyObject *value)
}
/*****************************************************************************/
-/* 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 */
/* Description: This is a callback function for the BPy_Bone type. It */
/* builds a meaninful string to represent bone objects. */
/*****************************************************************************/
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");
}
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index 913949789d4..f1317c876e5 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -50,7 +50,6 @@ PyTypeObject Camera_Type =
0, /* tp_itemsize */
/* methods */
(destructor)Camera_dealloc, /* tp_dealloc */
-// (printfunc)Camera_print, /* tp_print */
0, /* tp_print */
(getattrfunc)Camera_getAttr, /* tp_getattr */
(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 */
char buf[21];
- printf ("In Camera_New()\n");
/* Parse the arguments passed in by the Python interpreter */
if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
&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;
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)
{
return PyString_FromFormat("[Camera \"%s\"]", self->camera->id.name+2);
diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h
index b0a2a643c43..da9f6d9fd14 100644
--- a/source/blender/python/api2_2x/Camera.h
+++ b/source/blender/python/api2_2x/Camera.h
@@ -174,7 +174,6 @@ static PyMethodDef BPy_Camera_methods[] = {
/* Python Camera_Type callback function prototypes: */
/*****************************************************************************/
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_compare (BPy_Camera *a, BPy_Camera *b);
static PyObject *Camera_getAttr (BPy_Camera *self, char *name);
diff --git a/source/blender/python/api2_2x/EXPP_interface.c b/source/blender/python/api2_2x/EXPP_interface.c
index d386bffcd48..56a71112c62 100644
--- a/source/blender/python/api2_2x/EXPP_interface.c
+++ b/source/blender/python/api2_2x/EXPP_interface.c
@@ -44,6 +44,7 @@
#include <DNA_scriptlink_types.h>
#include <DNA_world_types.h>
+#include "EXPP_interface.h"
#include "gen_utils.h"
#include "modules.h"
@@ -54,13 +55,21 @@ void initBlenderApi2_2x (void)
M_Blender_Init ();
}
+void discardFromBDict (char *key)
+{
+ PyObject *oldval = PyDict_GetItemString(g_blenderdict, key);
+ if (oldval) { Py_DECREF(oldval); }
+}
+
void clearScriptLinks (void)
{
+ discardFromBDict ("bylink");
Py_INCREF (Py_False);
PyDict_SetItemString (g_blenderdict, "bylink", Py_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
* bylink. */
+ discardFromBDict ("link");
Py_INCREF (Py_None);
PyDict_SetItemString (g_blenderdict, "link", Py_None);
}
@@ -112,11 +121,13 @@ ScriptLink * setScriptLinks(ID *id, short event)
link = Py_None;
break;
default:
- Py_INCREF(Py_None);
- link = Py_None;
+ //Py_INCREF(Py_None);
+ //link = Py_None;
return NULL;
}
+ discardFromBDict ("bylink");
+
if (scriptlink == NULL)
{
/* This is probably not an internal error anymore :)
@@ -133,7 +144,10 @@ TODO: Check this
PyDict_SetItemString(g_blenderdict, "bylink", Py_True);
}
+ discardFromBDict ("link");
PyDict_SetItemString(g_blenderdict, "link", link);
+
+ discardFromBDict ("event");
PyDict_SetItemString(g_blenderdict, "event",
Py_BuildValue("s", event_to_name(event)));
diff --git a/source/blender/python/api2_2x/EXPP_interface.h b/source/blender/python/api2_2x/EXPP_interface.h
index 6e4ef1f2687..c9e77b96704 100644
--- a/source/blender/python/api2_2x/EXPP_interface.h
+++ b/source/blender/python/api2_2x/EXPP_interface.h
@@ -34,3 +34,4 @@
void initBlenderApi2_2x (void);
void clearScriptLinks (void);
ScriptLink * setScriptLinks(ID *id, short event);
+void discardFromBDict (char *key);
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index 6a73e655624..72c6df7cf15 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -146,7 +146,7 @@ static PyObject *M_Image_Get(PyObject *self, PyObject *args)
else { /* () - return a list of all images in the scene */
int index = 0;
- PyObject *img_list, *pystr;
+ PyObject *img_list, *pyobj;
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"));
while (img_iter) {
- pystr = PyString_FromString (img_iter->id.name+2);
+ pyobj = Image_CreatePyObject (img_iter);
- if (!pystr)
+ if (!pyobj)
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;
index++;
@@ -251,12 +251,11 @@ static PyMethodDef BPy_Image_methods[] = {
/*****************************************************************************/
/* 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 int Image_Print (BPy_Image *self, FILE *fp, int flags);
-static PyObject *Image_GetAttr (BPy_Image *self, char *name);
-static PyObject *Image_Repr (BPy_Image *self);
+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: */
@@ -269,12 +268,12 @@ PyTypeObject Image_Type =
sizeof (BPy_Image), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)Image_Dealloc, /* tp_dealloc */
- (printfunc)Image_Print, /* tp_print */
- (getattrfunc)Image_GetAttr, /* tp_getattr */
- (setattrfunc)Image_SetAttr, /* tp_setattr */
- (cmpfunc)Image_Compare, /* tp_compare */
- (reprfunc)Image_Repr, /* tp_repr */
+ (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 */
@@ -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 */
/* the destructor function. */
/*****************************************************************************/
-static void Image_Dealloc (BPy_Image *self)
+static void Image_dealloc (BPy_Image *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 */
/* the function that accesses BPy_Image member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject *Image_GetAttr (BPy_Image *self, char *name)
+static PyObject *Image_getAttr (BPy_Image *self, char *name)
{
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*/
/* function that changes Image Data 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)
+static int Image_setAttr (BPy_Image *self, char *name, PyObject *value)
{
PyObject *valtuple;
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 */
/* compares two Image_Type objects. Only the "==" and "!=" */
/* comparisons are meaninful. Returns 0 for equality and -1 if */
/* they don't point to the same Blender Image struct. */
/* 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;
return (pa == pb) ? 0:-1;
}
/*****************************************************************************/
-/* Function: Image_Print */
-/* 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 */
+/* Function: Image_repr */
/* Description: This is a callback function for the BPy_Image type. It */
/* 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);
}
diff --git a/source/blender/python/api2_2x/Image.h b/source/blender/python/api2_2x/Image.h
index 163eba90eb1..4a62d22bf34 100644
--- a/source/blender/python/api2_2x/Image.h
+++ b/source/blender/python/api2_2x/Image.h
@@ -52,7 +52,7 @@ extern PyTypeObject Image_Type; /* The Image PyType Object */
/*****************************************************************************/
/* Module Blender.Image - public functions */
/*****************************************************************************/
-PyObject *M_Image_Init (void);
+PyObject *Image_Init (void);
PyObject *Image_CreatePyObject (Image *image);
int Image_CheckPyObject (PyObject *pyobj);
diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c
index a5abfb5ebd3..5b9086fd680 100644
--- a/source/blender/python/api2_2x/Lamp.c
+++ b/source/blender/python/api2_2x/Lamp.c
@@ -42,12 +42,12 @@ PyTypeObject Lamp_Type =
sizeof (BPy_Lamp), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)Lamp_dealloc, /* tp_dealloc */
- (printfunc)Lamp_print, /* tp_print */
- (getattrfunc)Lamp_getAttr, /* tp_getattr */
- (setattrfunc)Lamp_setAttr, /* tp_setattr */
- (cmpfunc)Lamp_compare, /* tp_compare */
- (reprfunc)Lamp_repr, /* tp_repr */
+ (destructor)Lamp_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc)Lamp_getAttr, /* tp_getattr */
+ (setattrfunc)Lamp_setAttr, /* tp_setattr */
+ (cmpfunc)Lamp_compare, /* tp_compare */
+ (reprfunc)Lamp_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
@@ -1025,22 +1025,11 @@ static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b)
}
/*****************************************************************************/
-/* 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 */
/* Description: This is a callback function for the BPy_Lamp type. It */
/* builds a meaninful string to represent lamp objects. */
/*****************************************************************************/
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);
}
diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h
index 50451ed7bb7..c584d5b7ca0 100644
--- a/source/blender/python/api2_2x/Lamp.h
+++ b/source/blender/python/api2_2x/Lamp.h
@@ -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_compare (BPy_Lamp *a, BPy_Lamp *b);
static PyObject *Lamp_repr (BPy_Lamp *lamp);
-static int Lamp_print (BPy_Lamp *lamp, FILE *fp, int flags);
#endif /* EXPP_LAMP_H */
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index c4cd3e19091..30b3d61ea81 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -422,11 +422,10 @@ static PyMethodDef BPy_Material_methods[] = {
/*****************************************************************************/
/* Python Material_Type callback function prototypes: */
/*****************************************************************************/
-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 PyObject *Material_GetAttr (BPy_Material *self, char *name);
-static PyObject *Material_Repr (BPy_Material *self);
+static void Material_dealloc (BPy_Material *self);
+static int Material_setAttr (BPy_Material *self, char *name, PyObject *v);
+static PyObject *Material_getAttr (BPy_Material *self, char *name);
+static PyObject *Material_repr (BPy_Material *self);
/*****************************************************************************/
/* Python Material_Type structure definition: */
@@ -439,12 +438,12 @@ PyTypeObject Material_Type =
sizeof (BPy_Material), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)Material_Dealloc, /* tp_dealloc */
- (printfunc)Material_Print, /* tp_print */
- (getattrfunc)Material_GetAttr, /* tp_getattr */
- (setattrfunc)Material_SetAttr, /* tp_setattr */
+ (destructor)Material_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc)Material_getAttr, /* tp_getattr */
+ (setattrfunc)Material_setAttr, /* tp_setattr */
0, /* tp_compare */
- (reprfunc)Material_Repr, /* tp_repr */
+ (reprfunc)Material_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
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 */
/* the destructor function. */
/*****************************************************************************/
-static void Material_Dealloc (BPy_Material *self)
+static void Material_dealloc (BPy_Material *self)
{
Py_DECREF (self->col);
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 */
/* the function that accesses BPy_Material "member variables" */
/* and methods. */
/*****************************************************************************/
-static PyObject *Material_GetAttr (BPy_Material *self, char *name)
+static PyObject *Material_getAttr (BPy_Material *self, char *name)
{
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. */
/* It is the function that sets Material attributes (member */
/* 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 *error = NULL;
@@ -1302,34 +1301,18 @@ static int Material_SetAttr (BPy_Material *self, char *name, PyObject *value)
}
/*****************************************************************************/
-/* Function: Material_Print */
-/* 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 */
+/* Function: Material_repr */
/* Description: This is a callback function for the BPy_Material type. It */
/* 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];
-
- PyOS_snprintf(buf, sizeof(buf), "[Material \"%s\"]",
- self->material->id.name+2);
-
- return PyString_FromString(buf);
+ return PyString_FromFormat ("[Material \"%s\"]", self->material->id.name+2);
}
/*****************************************************************************/
-/* 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)
{
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index b61be7d8b91..fdfd6d6714f 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -670,9 +670,6 @@ static PyObject *NMesh_update(PyObject *self, PyObject *args)
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);
/**@ 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)
@@ -1336,7 +1333,7 @@ Material **nmesh_updateMaterials(BPy_NMesh *nmesh)
{
Material **matlist;
Mesh *mesh = nmesh->mesh;
- int len = PySequence_Length(nmesh->materials);
+ int len = PyList_Size(nmesh->materials);
if (!mesh) {
printf("FATAL INTERNAL ERROR: illegal call to updateMaterials()\n");
@@ -1345,9 +1342,12 @@ Material **nmesh_updateMaterials(BPy_NMesh *nmesh)
if (len > 0) {
matlist = EXPP_newMaterialList_fromPyList(nmesh->materials);
- if (mesh->mat)
- MEM_freeN(mesh->mat);
- mesh->mat = matlist;
+ EXPP_incr_mats_us(matlist, len);
+
+ if (mesh->mat) MEM_freeN(mesh->mat);
+
+ mesh->mat = matlist;
+
} else {
matlist = 0;
}
@@ -1369,11 +1369,13 @@ PyObject *NMesh_assignMaterials_toObject(BPy_NMesh *nmesh, Object *ob)
nmats = PyList_Size(nmesh->materials);
- if (nmats > 0 && !mesh->mat) { /* explain ... */
+ if (nmats > 0 && !mesh->mat) {
ob->totcol = nmats;
mesh->totcol = nmats;
mesh->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_memats");
- ob->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_obmats");
+
+ if (ob->mat) MEM_freeN(ob->mat);
+ ob->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_obmats");
}
for (i = 0; i < nmats; i++) {
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index 72516fc02a3..11b2db24c75 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -163,7 +163,6 @@ static PyMethodDef BPy_Scene_methods[] = {
/* Python Scene_Type callback function prototypes: */
/*****************************************************************************/
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_compare (BPy_Scene *a, BPy_Scene *b);
static PyObject *Scene_getAttr (BPy_Scene *self, char *name);
@@ -181,7 +180,7 @@ PyTypeObject Scene_Type =
0, /* tp_itemsize */
/* methods */
(destructor)Scene_dealloc, /* tp_dealloc */
- (printfunc)Scene_print, /* tp_print */
+ 0, /* tp_print */
(getattrfunc)Scene_getAttr, /* tp_getattr */
(setattrfunc)Scene_setAttr, /* tp_setattr */
(cmpfunc)Scene_compare, /* tp_compare */
@@ -730,15 +729,9 @@ static int Scene_compare (BPy_Scene *a, BPy_Scene *b)
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)
{
- 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)
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
index b08da585c2e..e9343cb2a7b 100644
--- a/source/blender/python/api2_2x/Text.c
+++ b/source/blender/python/api2_2x/Text.c
@@ -486,21 +486,6 @@ static int Text_compare (BPy_Text *a, BPy_Text *b)
}
/*****************************************************************************/
-/* 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 */
/* Description: This is a callback function for the BPy_Text type. It */
/* builds a meaninful string to represent text objects. */
@@ -508,9 +493,9 @@ static int Text_print(BPy_Text *self, FILE *fp, int flags)
static PyObject *Text_repr (BPy_Text *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
- return PyString_FromString("<deleted>");
+ return PyString_FromString("[Text <deleted>]");
}
/* Internal function to confirm if a Text wasn't unlinked.
diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h
index b2ce00c1253..68819c641dd 100644
--- a/source/blender/python/api2_2x/Text.h
+++ b/source/blender/python/api2_2x/Text.h
@@ -144,7 +144,6 @@ static PyMethodDef BPy_Text_methods[] = {
/* Python Text_Type callback function prototypes: */
/*****************************************************************************/
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 PyObject *Text_getAttr (BPy_Text *self, char *name);
static int Text_compare (BPy_Text *a, BPy_Text *b);
@@ -162,7 +161,7 @@ PyTypeObject Text_Type =
0, /* tp_itemsize */
/* methods */
(destructor)Text_dealloc, /* tp_dealloc */
- (printfunc)Text_print, /* tp_print */
+ 0, /* tp_print */
(getattrfunc)Text_getAttr, /* tp_getattr */
(setattrfunc)Text_setAttr, /* tp_setattr */
(cmpfunc)Text_compare, /* tp_compare */
diff --git a/source/blender/python/api2_2x/rgbTuple.c b/source/blender/python/api2_2x/rgbTuple.c
index 356ca4145ed..2e33525fa9e 100644
--- a/source/blender/python/api2_2x/rgbTuple.c
+++ b/source/blender/python/api2_2x/rgbTuple.c
@@ -37,11 +37,10 @@
/*****************************************************************************/
/* Python rgbTuple_Type callback function prototypes: */
/*****************************************************************************/
-static void rgbTupleDeAlloc (BPy_rgbTuple *self);
-static PyObject *rgbTupleGetAttr (BPy_rgbTuple *self, char *name);
-static int rgbTupleSetAttr (BPy_rgbTuple *self, char *name, PyObject *v);
-static int rgbTuplePrint(BPy_rgbTuple *self, FILE *fp, int flags);
-static PyObject *rgbTupleRepr (BPy_rgbTuple *self);
+static void rgbTuple_dealloc (BPy_rgbTuple *self);
+static PyObject *rgbTuple_getAttr (BPy_rgbTuple *self, char *name);
+static int rgbTuple_setAttr (BPy_rgbTuple *self, char *name, PyObject *v);
+static PyObject *rgbTuple_repr (BPy_rgbTuple *self);
static int rgbTupleLength(BPy_rgbTuple *self);
@@ -86,15 +85,15 @@ PyTypeObject rgbTuple_Type =
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"rgbTuple", /* tp_name */
- sizeof (BPy_rgbTuple), /* tp_basicsize */
+ sizeof (BPy_rgbTuple), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
- (destructor)rgbTupleDeAlloc, /* tp_dealloc */
- (printfunc)rgbTuplePrint, /* tp_print */
- (getattrfunc)rgbTupleGetAttr, /* tp_getattr */
- (setattrfunc)rgbTupleSetAttr, /* tp_setattr */
+ (destructor)rgbTuple_deAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc)rgbTuple_getAttr, /* tp_getattr */
+ (setattrfunc)rgbTuple_setAttr, /* tp_setattr */
0, /* tp_compare */
- (reprfunc)rgbTupleRepr, /* tp_repr */
+ (reprfunc)rgbTuple_repr, /* tp_repr */
0, /* tp_as_number */
&rgbTupleAsSequence, /* tp_as_sequence */
&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 */
/* the destructor function. */
/*****************************************************************************/
-static void rgbTupleDeAlloc (BPy_rgbTuple *self)
+static void rgbTuple_deAlloc (BPy_rgbTuple *self)
{
PyObject_DEL (self);
}
/*****************************************************************************/
-/* Function: rgbTupleGetAttr */
+/* Function: rgbTuple_getAttr */
/* Description: This is a callback function for the BPy_rgbTuple type. It is */
/* the function that accesses BPy_rgbTuple member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject* rgbTupleGetAttr (BPy_rgbTuple *self, char *name)
+static PyObject* rgbTuple_getAttr (BPy_rgbTuple *self, char *name)
{
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 */
/* 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;
@@ -370,32 +369,17 @@ static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end,
}
/*****************************************************************************/
-/* Function: rgbTuplePrint */
-/* 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 */
+/* Function: rgbTuple_repr */
/* Description: This is a callback function for the BPy_rgbTuple type. It */
/* 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;
- char buf[64];
r = *(self->rgb[0]);
g = *(self->rgb[1]);
b = *(self->rgb[2]);
- PyOS_snprintf(buf, sizeof(buf), "[%f, %f, %f]", r, g, b);
-
- return PyString_FromString(buf);
+ return PyString_FromFormat("[%f, %f, %f]", r, g, b);
}
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c
index fac409ab92f..69b32716a2c 100644
--- a/source/blender/python/api2_2x/vector.c
+++ b/source/blender/python/api2_2x/vector.c
@@ -35,159 +35,159 @@
/*****************************/
/* Vector Python Object */
/*****************************/
-#define VectorObject_Check(v) ((v)->ob_type == &vector_Type)
+#define VectorObject_Check(v) ((v)->ob_type == &vector_Type)
static void Vector_dealloc(VectorObject *self)
{
- PyObject_DEL (self);
+ PyObject_DEL (self);
}
static PyObject *Vector_getattr(VectorObject *self, char *name)
{
- if (self->size==3 && ELEM3(name[0], 'x', 'y', 'z') && name[1]==0)
- return PyFloat_FromDouble(self->vec[ name[0]-'x' ]);
+ if (self->size==3 && ELEM3(name[0], 'x', 'y', 'z') && name[1]==0)
+ return PyFloat_FromDouble(self->vec[ name[0]-'x' ]);
- return EXPP_ReturnPyObjError(PyExc_AttributeError, "attribute not found");
+ return EXPP_ReturnPyObjError(PyExc_AttributeError, "attribute not found");
}
static int Vector_setattr(VectorObject *self, char *name, PyObject *v)
{
- float val;
-
- if (!PyArg_Parse(v, "f", &val))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "expected float argument");
-
- if (self->size==3 && ELEM3(name[0], 'x', 'y', 'z') && name[1]==0)
- self->vec[ name[0]-'x' ]= val;
- else
- return -1;
-
- return 0;
+ float val;
+
+ if (!PyArg_Parse(v, "f", &val))
+ return EXPP_ReturnIntError(PyExc_TypeError,
+ "expected float argument");
+
+ if (self->size==3 && ELEM3(name[0], 'x', 'y', 'z') && name[1]==0)
+ self->vec[ name[0]-'x' ]= val;
+ else
+ return -1;
+
+ return 0;
}
/* Vectors Sequence methods */
static int Vector_len(VectorObject *self)
{
- return self->size;
+ return self->size;
}
static PyObject *Vector_item(VectorObject *self, int i)
{
- if (i < 0 || i >= self->size)
- return EXPP_ReturnPyObjError (PyExc_IndexError,
- "array index out of range");
+ if (i < 0 || i >= self->size)
+ return EXPP_ReturnPyObjError (PyExc_IndexError,
+ "array index out of range");
- return Py_BuildValue("f", self->vec[i]);
+ return Py_BuildValue("f", self->vec[i]);
}
static PyObject *Vector_slice(VectorObject *self, int begin, int end)
{
- PyObject *list;
- int count;
-
- if (begin < 0) begin= 0;
- if (end > self->size) end= self->size;
- if (begin > end) begin= end;
+ PyObject *list;
+ int count;
+
+ if (begin < 0) begin= 0;
+ if (end > self->size) end= self->size;
+ if (begin > end) begin= end;
- list= PyList_New(end-begin);
+ list= PyList_New(end-begin);
- for (count = begin; count < end; count++)
- PyList_SetItem(list, count-begin, PyFloat_FromDouble(self->vec[count]));
+ for (count = begin; count < end; count++)
+ PyList_SetItem(list, count-begin, PyFloat_FromDouble(self->vec[count]));
- return list;
+ return list;
}
static int Vector_ass_item(VectorObject *self, int i, PyObject *ob)
{
- if (i < 0 || i >= self->size)
- return EXPP_ReturnIntError(PyExc_IndexError,
- "array assignment index out of range");
+ if (i < 0 || i >= self->size)
+ return EXPP_ReturnIntError(PyExc_IndexError,
+ "array assignment index out of range");
- if (!PyNumber_Check(ob))
- return EXPP_ReturnIntError(PyExc_IndexError,
- "vector member must be a number");
+ if (!PyNumber_Check(ob))
+ return EXPP_ReturnIntError(PyExc_IndexError,
+ "vector member must be a number");
- self->vec[i]= PyFloat_AsDouble(ob);
+ self->vec[i]= PyFloat_AsDouble(ob);
- return 0;
+ return 0;
}
static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *seq)
{
- int count;
-
- if (begin < 0) begin= 0;
- if (end > self->size) end= self->size;
- if (begin > end) begin= end;
-
- if (!PySequence_Check(seq))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "illegal argument type for built-in operation");
-
- if (PySequence_Length(seq) != (end - begin))
- return EXPP_ReturnIntError(PyExc_TypeError,
- "size mismatch in slice assignment");
-
- for (count = begin; count < end; count++) {
- PyObject *ob = PySequence_GetItem(seq, count);
-
- if (!PyArg_Parse(ob, "f", &self->vec[count])) {
- Py_DECREF(ob);
- return -1;
- }
-
- Py_DECREF(ob);
- }
-
- return 0;
+ int count;
+
+ if (begin < 0) begin= 0;
+ if (end > self->size) end= self->size;
+ if (begin > end) begin= end;
+
+ if (!PySequence_Check(seq))
+ return EXPP_ReturnIntError(PyExc_TypeError,
+ "illegal argument type for built-in operation");
+
+ if (PySequence_Length(seq) != (end - begin))
+ return EXPP_ReturnIntError(PyExc_TypeError,
+ "size mismatch in slice assignment");
+
+ for (count = begin; count < end; count++) {
+ PyObject *ob = PySequence_GetItem(seq, count);
+
+ if (!PyArg_Parse(ob, "f", &self->vec[count])) {
+ Py_DECREF(ob);
+ return -1;
+ }
+
+ Py_DECREF(ob);
+ }
+
+ return 0;
}
static PyObject *Vector_repr (VectorObject *self)
{
- return EXPP_tuple_repr((PyObject *) self, self->size);
+ return EXPP_tuple_repr((PyObject *) self, self->size);
}
static PySequenceMethods Vector_SeqMethods =
{
- (inquiry) Vector_len, /* sq_length */
- (binaryfunc) 0, /* sq_concat */
- (intargfunc) 0, /* sq_repeat */
- (intargfunc) Vector_item, /* sq_item */
- (intintargfunc) Vector_slice, /* sq_slice */
- (intobjargproc) Vector_ass_item, /* sq_ass_item */
- (intintobjargproc) Vector_ass_slice, /* sq_ass_slice */
+ (inquiry) Vector_len, /* sq_length */
+ (binaryfunc) 0, /* sq_concat */
+ (intargfunc) 0, /* sq_repeat */
+ (intargfunc) Vector_item, /* sq_item */
+ (intintargfunc) Vector_slice, /* sq_slice */
+ (intobjargproc) Vector_ass_item, /* sq_ass_item */
+ (intintobjargproc) Vector_ass_slice, /* sq_ass_slice */
};
PyTypeObject vector_Type =
{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "vector", /*tp_name*/
- sizeof(VectorObject), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor) Vector_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) Vector_getattr, /*tp_getattr*/
- (setattrfunc) Vector_setattr, /*tp_setattr*/
- 0, /*tp_compare*/
- (reprfunc) Vector_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- &Vector_SeqMethods, /*tp_as_sequence*/
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "vector", /*tp_name*/
+ sizeof(VectorObject), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor) Vector_dealloc, /*tp_dealloc*/
+ (printfunc) 0, /*tp_print*/
+ (getattrfunc) Vector_getattr, /*tp_getattr*/
+ (setattrfunc) Vector_setattr, /*tp_setattr*/
+ 0, /*tp_compare*/
+ (reprfunc) Vector_repr, /*tp_repr*/
+ 0, /*tp_as_number*/
+ &Vector_SeqMethods, /*tp_as_sequence*/
};
PyObject *newVectorObject(float *vec, int size)
{
- VectorObject *self;
+ VectorObject *self;
vector_Type.ob_type = &PyType_Type;
- self= PyObject_NEW(VectorObject, &vector_Type);
-
- self->vec= vec;
- self->size= size;
-
- return (PyObject*) self;
+ self= PyObject_NEW(VectorObject, &vector_Type);
+
+ self->vec= vec;
+ self->size= size;
+
+ return (PyObject*) self;
}