From 6cc45538efefe1062aa0bc0909903af3db5d338d Mon Sep 17 00:00:00 2001 From: Willian Padovani Germano Date: Thu, 12 Jun 2003 04:51:50 +0000 Subject: * Small changes in many files: - Trying to fix linking problems in OSX; - Making module .Get functions behave like the ones in Blender 2.25 - 2.27 (Guignot pointed the incompatibility); - Included more types to Blender.Types; - Found by luck and corrected two bugs that were making Blender crash; - Added/updated some simple functions. --- source/blender/python/BPY_interface.c | 2 +- source/blender/python/api2_2x/Armature.c | 18 +- source/blender/python/api2_2x/Armature.h | 2 +- source/blender/python/api2_2x/BGL.c | 10 +- source/blender/python/api2_2x/BGL.h | 2 +- source/blender/python/api2_2x/Bone.c | 7 +- source/blender/python/api2_2x/Camera.c | 263 +++++++++++++------------- source/blender/python/api2_2x/Camera.h | 2 - source/blender/python/api2_2x/Curve.c | 130 ++++++------- source/blender/python/api2_2x/Curve.h | 2 +- source/blender/python/api2_2x/Draw.c | 8 +- source/blender/python/api2_2x/Ipo.c | 308 ++++++++++++++++++------------- source/blender/python/api2_2x/Ipo.h | 4 +- source/blender/python/api2_2x/Lamp.c | 140 +++++++------- source/blender/python/api2_2x/Metaball.c | 49 ++++- source/blender/python/api2_2x/Metaball.h | 2 +- source/blender/python/api2_2x/NMesh.c | 8 +- source/blender/python/api2_2x/NMesh.h | 2 +- source/blender/python/api2_2x/Object.c | 13 +- source/blender/python/api2_2x/Scene.c | 16 +- source/blender/python/api2_2x/Text.h | 17 +- source/blender/python/api2_2x/Types.c | 51 +++-- source/blender/python/api2_2x/Types.h | 2 + source/blender/python/api2_2x/vector.c | 6 +- 24 files changed, 582 insertions(+), 482 deletions(-) diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 6fa69c0e795..85162182e31 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -451,7 +451,7 @@ PyObject * RunPython(Text *text, PyObject *globaldict) /*#ifdef BLENDER_SANDBOX_MODE // IGNORE THIS ALL FOR A WHILE, IT'S VERY INCOMPLETE AND WILL CHANGE -// CONSIDERABLY IN THE NEXT COMMIT. THE ifdef won't stay, either. +// 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 diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c index 997dc4135c1..0abd4e8d777 100644 --- a/source/blender/python/api2_2x/Armature.c +++ b/source/blender/python/api2_2x/Armature.c @@ -94,7 +94,7 @@ static PyObject *M_Armature_Get(PyObject *self, PyObject *args) armature_iter = G.main->armature.first; - /* Use the name to search for the armature requested. */ + /* Use the name to search for the armature requested. */ if (name) { /* (name) - Search armature by name */ wanted_armature = NULL; @@ -121,9 +121,9 @@ static PyObject *M_Armature_Get(PyObject *self, PyObject *args) else { - /* Return a list of all armatures in the scene */ + /* Return a list of with armatures in the scene */ int index = 0; - PyObject *armlist, *pystr; + PyObject *armlist, *pyobj; armlist = PyList_New (BLI_countlist (&(G.main->armature))); @@ -132,13 +132,13 @@ static PyObject *M_Armature_Get(PyObject *self, PyObject *args) "couldn't create PyList")); while (armature_iter) { - pystr = PyString_FromString (armature_iter->id.name+2); + pyobj = M_ArmatureCreatePyObject (armature_iter); - if (!pystr) + if (!pyobj) return (PythonReturnErrorObject (PyExc_MemoryError, "couldn't create PyString")); - PyList_SET_ITEM (armlist, index, pystr); + PyList_SET_ITEM (armlist, index, pyobj); armature_iter = armature_iter->id.next; index++; @@ -345,12 +345,10 @@ static PyObject *ArmatureRepr (C_Armature *self) /*****************************************************************************/ static int ArmatureCmp (C_Armature *a, C_Armature *b) { - if (aarmature, *pb = b->armature; + return (pa == pb) ? 0:-1; } - /*****************************************************************************/ /* Function: M_ArmatureCreatePyObject */ /* Description: This function will create a new BlenArmature from an */ diff --git a/source/blender/python/api2_2x/Armature.h b/source/blender/python/api2_2x/Armature.h index 60d9fd42cfb..a035796140d 100644 --- a/source/blender/python/api2_2x/Armature.h +++ b/source/blender/python/api2_2x/Armature.h @@ -137,7 +137,7 @@ static int ArmaturePrint (C_Armature *armature, FILE *fp, int flags); /*****************************************************************************/ /* Python TypeArmature structure definition: */ /*****************************************************************************/ -static PyTypeObject Armature_Type = +PyTypeObject Armature_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c index c8d73c37042..28adb0c9564 100644 --- a/source/blender/python/api2_2x/BGL.c +++ b/source/blender/python/api2_2x/BGL.c @@ -283,14 +283,14 @@ static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq) static void Buffer_dealloc(PyObject *self) { - Buffer *buf= (Buffer *) self; + Buffer *buf = (Buffer *)self; - if (buf->parent) Py_DECREF(buf->parent); - else MEM_freeN(buf->buf.asvoid); + if (buf->parent) Py_DECREF (buf->parent); + else MEM_freeN (buf->buf.asvoid); - MEM_freeN(buf->dimensions); + MEM_freeN (buf->dimensions); - PyMem_DEL(self); + PyObject_DEL (self); } static PyObject *Buffer_tolist(PyObject *self) diff --git a/source/blender/python/api2_2x/BGL.h b/source/blender/python/api2_2x/BGL.h index c81e8eba02e..11a312a153a 100644 --- a/source/blender/python/api2_2x/BGL.h +++ b/source/blender/python/api2_2x/BGL.h @@ -138,7 +138,7 @@ static PyObject *Buffer_repr(PyObject *self); PyTypeObject buffer_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "Buffer", /*tp_name*/ + "buffer", /*tp_name*/ sizeof(Buffer), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) Buffer_dealloc, /*tp_dealloc*/ diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index f618d4dbe74..80f29aaf1c0 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -146,7 +146,7 @@ static int BonePrint (C_Bone *bone, FILE *fp, int flags); /*****************************************************************************/ /* Python TypeBone structure definition: */ /*****************************************************************************/ -static PyTypeObject Bone_Type = +PyTypeObject Bone_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ @@ -680,9 +680,8 @@ static PyObject *BoneRepr (C_Bone *self) /**************************************************************************/ static int BoneCmp (C_Bone *a, C_Bone *b) { - if (abone, *pb = b->bone; + return (pa == pb) ? 0:-1; } diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index 11ffb48b390..c1c6e5011fc 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -34,12 +34,6 @@ * \ingroup scripts * \brief Blender.Camera Module and Camera Data PyObject implementation. * - * Note: Parameters between "<" and ">" are optional. But if one of them is - * given, all preceding ones must be given, too. Of course, this only relates - * to the Python functions and methods described here and only inside Python - * code. [ This will go to another file later, probably the main exppython - * doc file]. XXX Better: put optional args with their default value: - * (self, name = "MyName") */ #include @@ -88,9 +82,12 @@ static PyObject *M_Camera_Get (PyObject *self, PyObject *args); /* Blender.Camera.__doc__ */ /*****************************************************************************/ static char M_Camera_doc[] = -"The Blender Camera module\n\n\ -This module provides access to **Camera Data** objects in Blender\n\n\ -Example::\n\n\ +"The Blender Camera module\n\ +\n\ +This module provides access to **Camera Data** objects in Blender\n\ +\n\ +Example::\n\ +\n\ from Blender import Camera, Object, Scene\n\ c = Camera.New('ortho') # create new ortho camera data\n\ c.lens = 35.0 # set lens value\n\ @@ -101,14 +98,18 @@ Example::\n\n\ cur.setCurrentCamera(ob) # make this camera the active\n"; static char M_Camera_New_doc[] = -"(type) - return a new Camera object of type \"type\", \ -which can be 'persp' or 'ortho'.\n\ -() - return a new Camera object of type 'persp'."; +"Blender.Camera.New (type = 'persp', name = 'CamData'):\n\ +\n\ +(type) - Return a new Camera Data object of type \"type\",\n\ + which can be 'persp' or 'ortho';\n\ +() - Return a new Camera Data object of type 'persp'."; static char M_Camera_Get_doc[] = -"(name) - return the camera with the name 'name', \ -returns None if not found.\n If 'name' is not specified, \ -it returns a list of all cameras in the\ncurrent scene."; +"Blender.Camera.Get (name = None):\n\ +\n\ +(name) - Return the Camera Data object with the given 'name',\n\ + None if not found;\n\ +() - Return a list with all Camera Data objects in the current scene."; /*****************************************************************************/ /* Python method structure definition for Blender.Camera module: */ @@ -120,6 +121,7 @@ struct PyMethodDef M_Camera_methods[] = { {"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc}, {NULL, NULL, 0, NULL} }; + /*****************************************************************************/ /* Python BPy_Camera methods declarations: */ /*****************************************************************************/ @@ -150,8 +152,8 @@ static PyMethodDef BPy_Camera_methods[] = { {"getType", (PyCFunction)Camera_getType, METH_NOARGS, "() - Return Camera type - 'persp':0, 'ortho':1"}, {"getMode", (PyCFunction)Camera_getMode, METH_NOARGS, - "() - Return Camera mode flags (or'ed value) -\n\t" - "'showLimits':1, 'showMist':2"}, + "() - Return Camera mode flags (or'ed value) -\n" + " 'showLimits':1, 'showMist':2"}, {"getLens", (PyCFunction)Camera_getLens, METH_NOARGS, "() - Return Camera lens value"}, {"getClipStart", (PyCFunction)Camera_getClipStart, METH_NOARGS, @@ -161,19 +163,19 @@ static PyMethodDef BPy_Camera_methods[] = { {"getDrawSize", (PyCFunction)Camera_getDrawSize, METH_NOARGS, "() - Return Camera draw size value"}, {"setName", (PyCFunction)Camera_setName, METH_VARARGS, - "(str) - Change Camera Data name"}, + "(s) - Set Camera Data name"}, {"setType", (PyCFunction)Camera_setType, METH_VARARGS, - "(str) - Change Camera type, which can be 'persp' or 'ortho'"}, + "(s) - Set Camera type, which can be 'persp' or 'ortho'"}, {"setMode", (PyCFunction)Camera_setMode, METH_VARARGS, - "([str[,str]]) - Set Camera mode flag(s): 'showLimits' and 'showMist'"}, + "(>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"}, {"setLens", (PyCFunction)Camera_setLens, METH_VARARGS, - "(float) - Change Camera lens value"}, + "(f) - Set Camera lens value"}, {"setClipStart", (PyCFunction)Camera_setClipStart, METH_VARARGS, - "(float) - Change Camera clip start value"}, + "(f) - Set Camera clip start value"}, {"setClipEnd", (PyCFunction)Camera_setClipEnd, METH_VARARGS, - "(float) - Change Camera clip end value"}, + "(f) - Set Camera clip end value"}, {"setDrawSize", (PyCFunction)Camera_setDrawSize, METH_VARARGS, - "(float) - Change Camera draw size value"}, + "(f) - Set Camera draw size value"}, {0} }; @@ -238,52 +240,50 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords) char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */ char *name_str = "CamData"; static char *kwlist[] = {"type_str", "name_str", NULL}; - BPy_Camera *pycam; /* for Camera Data object wrapper in Python */ + PyObject *pycam; /* for Camera Data object wrapper in Python */ 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)) /* We expected string(s) (or nothing) as argument, but we didn't get that. */ - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected zero, one or two strings as arguments")); + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected zero, one or two strings as arguments"); blcam = add_camera(); /* first create the Camera Data in Blender */ if (blcam) /* now create the wrapper obj in Python */ - pycam = (BPy_Camera *)PyObject_NEW(BPy_Camera, &Camera_Type); + pycam = Camera_CreatePyObject (blcam); else - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't create Camera Data in Blender")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't create Camera Data in Blender"); /* let's return user count to zero, because ... */ - blcam->id.us = 0; /* ... add_camera() right above incref'ed it */ + blcam->id.us = 0; /* ... add_camera() incref'ed it */ /* XXX XXX Do this in other modules, too */ if (pycam == NULL) - return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create Camera Data object")); - - pycam->camera = blcam; /* link Python camera wrapper to Blender Camera */ + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create Camera PyObject"); if (strcmp (type_str, "persp") == 0) /* default, no need to set, so */ /*blcam->type = (short)EXPP_CAM_TYPE_PERSP*/; /* we comment this line */ else if (strcmp (type_str, "ortho") == 0) blcam->type = (short)EXPP_CAM_TYPE_ORTHO; else - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "unknown camera type")); + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "unknown camera type"); - if (strcmp(name_str, "CamData") == 0) - return (PyObject *)pycam; + if (strcmp (name_str, "CamData") == 0) + return pycam; else { /* user gave us a name for the camera, use it */ - PyOS_snprintf(buf, sizeof(buf), "%s", name_str); - rename_id(&blcam->id, buf); /* proper way in Blender */ + PyOS_snprintf (buf, sizeof(buf), "%s", name_str); + rename_id (&blcam->id, buf); /* proper way in Blender */ } - return (PyObject *)pycam; + return pycam; } /** @@ -292,11 +292,11 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords) * This is the .Get() function of the Blender.Camera submodule. It searches * the list of current Camera Data objects and returns a Python wrapper for * the one with the name provided by the user. If called with no arguments, - * it returns a list of all current Camera Data object names in Blender. - * \param - string: The name of an existing Blender Camera Data object. - * \return () - A list with the names of all current Camera Data objects;\n - * \return (name) - A Python wrapper for the Camera Data called 'name' + * it returns a list with Python wrappers for all current Camera Data objects * in Blender. + * \param - string: The name of an existing Blender Camera Data object. + * \return () - A list with wrappers for all current Camera Data objects;\n + * \return (name) - A wrapper for the Camera Data called 'name' in Blender. */ static PyObject *M_Camera_Get(PyObject *self, PyObject *args) @@ -305,59 +305,62 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args) Camera *cam_iter; if (!PyArg_ParseTuple(args, "|s", &name)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument (or nothing)")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected string argument (or nothing)"); cam_iter = G.main->camera.first; if (name) { /* (name) - Search camera by name */ - BPy_Camera *wanted_cam = NULL; + PyObject *wanted_cam = NULL; + + while (cam_iter && !wanted_cam) { + + if (strcmp (name, cam_iter->id.name+2) == 0) { + wanted_cam = Camera_CreatePyObject (cam_iter); + break; + } - while ((cam_iter) && (wanted_cam == NULL)) { - if (strcmp (name, cam_iter->id.name+2) == 0) { - wanted_cam = (BPy_Camera *)PyObject_NEW(BPy_Camera, &Camera_Type); - if (wanted_cam) wanted_cam->camera = cam_iter; - } cam_iter = cam_iter->id.next; } - if (wanted_cam == NULL) { /* Requested camera doesn't exist */ + if (!wanted_cam) { /* Requested camera doesn't exist */ char error_msg[64]; PyOS_snprintf(error_msg, sizeof(error_msg), "Camera \"%s\" not found", name); - return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); + return EXPP_ReturnPyObjError (PyExc_NameError, error_msg); } - return (PyObject *)wanted_cam; + return wanted_cam; } - else { /* () - return a list of all cameras in the scene */ + else { /* () - return a list of wrappers for all cameras in the scene */ int index = 0; - PyObject *camlist, *pystr; + PyObject *cam_pylist, *pyobj; - camlist = PyList_New (BLI_countlist (&(G.main->camera))); + cam_pylist = PyList_New (BLI_countlist (&(G.main->camera))); - if (camlist == NULL) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyList")); + if (!cam_pylist) + return PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create PyList"); while (cam_iter) { - pystr = PyString_FromString (cam_iter->id.name+2); + pyobj = Camera_CreatePyObject (cam_iter); - if (!pystr) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyString")); + if (!pyobj) + return PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create Camera PyObject"); - PyList_SET_ITEM (camlist, index, pystr); + PyList_SET_ITEM (cam_pylist, index, pyobj); cam_iter = cam_iter->id.next; index++; } - return (camlist); + return cam_pylist; } } + /*@}*/ /** @@ -365,7 +368,7 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args) * * This function is used by Blender_Init() in Blender.c to register the * Blender.Camera submodule in the main Blender module. - * \return PyObject*: The initialized submodule. + * \return The initialized submodule. */ PyObject *M_Camera_Init (void) @@ -379,7 +382,7 @@ PyObject *M_Camera_Init (void) submodule = Py_InitModule3("Blender.Camera", M_Camera_methods, M_Camera_doc); - return (submodule); + return submodule; } /* Three Python Camera_Type helper functions needed by the Object module: */ @@ -389,8 +392,8 @@ PyObject *M_Camera_Init (void) * * This is also used in Object.c when defining the object.data member variable * for an Object of type 'Camera'. - * \param cam - Camera*: A pointer to an existing Blender Camera Data object. - * \return PyObject*: The Camera Data wrapper created. + * \param cam - A pointer to an existing Blender Camera Data object. + * \return The Camera Data wrapper created. */ PyObject *Camera_CreatePyObject (Camera *cam) @@ -401,7 +404,7 @@ PyObject *Camera_CreatePyObject (Camera *cam) if (!pycam) return EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create BPy_Camera object"); + "couldn't create BPy_Camera PyObject"); pycam->camera = cam; @@ -413,8 +416,8 @@ PyObject *Camera_CreatePyObject (Camera *cam) * * This is also used in Object.c when handling the object.data member variable * for an object of type 'Camera'. - * \param pyobj - PyObject*: A pointer to a Camera PyObject. - * \return int: True or false. + * \param pyobj - A pointer to a Camera PyObject. + * \return True or false. */ int Camera_CheckPyObject (PyObject *pyobj) @@ -427,8 +430,8 @@ int Camera_CheckPyObject (PyObject *pyobj) * * This is also used in Object.c when handling the object.data member variable * for an object of type 'Camera'. - * \param pyobj - PyObject*: A pointer to a Camera PyObject. - * \return Camera*: A pointer to the wrapped Blender Camera Data object. + * \param pyobj - A pointer to a Camera PyObject. + * \return A pointer to the wrapped Blender Camera Data object. */ Camera *Camera_FromPyObject (PyObject *pyobj) @@ -461,8 +464,8 @@ static PyObject *Camera_getName(BPy_Camera *self) if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Camera.name attribute")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Camera.name attribute"); } /** @@ -477,8 +480,8 @@ static PyObject *Camera_getType(BPy_Camera *self) if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Camera.type attribute")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Camera.type attribute"); } /** @@ -493,8 +496,8 @@ static PyObject *Camera_getMode(BPy_Camera *self) if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Camera.Mode attribute")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Camera.Mode attribute"); } /** @@ -509,8 +512,8 @@ static PyObject *Camera_getLens(BPy_Camera *self) if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Camera.lens attribute")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Camera.lens attribute"); } /** @@ -525,8 +528,8 @@ static PyObject *Camera_getClipStart(BPy_Camera *self) if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Camera.clipStart attribute")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Camera.clipStart attribute"); } /** @@ -540,8 +543,8 @@ static PyObject *Camera_getClipEnd(BPy_Camera *self) if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Camera.clipEnd attribute")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Camera.clipEnd attribute"); } /** @@ -555,8 +558,8 @@ static PyObject *Camera_getDrawSize(BPy_Camera *self) if (attr) return attr; - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Camera.drawSize attribute")); + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Camera.drawSize attribute"); } /** @@ -570,8 +573,8 @@ static PyObject *Camera_setName(BPy_Camera *self, PyObject *args) char buf[21]; if (!PyArg_ParseTuple(args, "s", &name)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected string argument"); PyOS_snprintf(buf, sizeof(buf), "%s", name); @@ -591,16 +594,16 @@ static PyObject *Camera_setType(BPy_Camera *self, PyObject *args) char *type; if (!PyArg_ParseTuple(args, "s", &type)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected string argument"); if (strcmp (type, "persp") == 0) self->camera->type = (short)EXPP_CAM_TYPE_PERSP; else if (strcmp (type, "ortho") == 0) self->camera->type = (short)EXPP_CAM_TYPE_ORTHO; else - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "unknown camera type")); + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "unknown camera type"); Py_INCREF(Py_None); return Py_None; @@ -624,14 +627,14 @@ static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args) short value; if (!PyArg_ParseTuple(args, "h", &value)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument: 0 or 1")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected int argument: 0 or 1"); if (value == 0 || value == 1) self->camera->type = value; else - return (EXPP_ReturnPyObjError (PyExc_ValueError, - "expected int argument: 0 or 1")); + return EXPP_ReturnPyObjError (PyExc_ValueError, + "expected int argument: 0 or 1"); Py_INCREF(Py_None); return Py_None; @@ -654,8 +657,8 @@ static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args) short flag = 0; if (!PyArg_ParseTuple(args, "|ss", &mode_str1, &mode_str2)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected one or two strings as arguments")); + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected one or two strings as arguments"); if (mode_str1 != NULL) { if (strcmp(mode_str1, "showLimits") == 0) @@ -663,8 +666,8 @@ static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args) else if (strcmp(mode_str1, "showMist") == 0) flag |= (short)EXPP_CAM_MODE_SHOWMIST; else - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "first argument is an unknown camera flag")); + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "first argument is an unknown camera flag"); if (mode_str2 != NULL) { if (strcmp(mode_str2, "showLimits") == 0) @@ -672,8 +675,8 @@ static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args) else if (strcmp(mode_str2, "showMist") == 0) flag |= (short)EXPP_CAM_MODE_SHOWMIST; else - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "second argument is an unknown camera flag")); + return EXPP_ReturnPyObjError (PyExc_AttributeError, + "second argument is an unknown camera flag"); } } @@ -698,14 +701,14 @@ static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args) short value; if (!PyArg_ParseTuple(args, "h", &value)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument in [0,3]")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected int argument in [0,3]"); if (value >= 0 && value <= 3) self->camera->flag = value; else - return (EXPP_ReturnPyObjError (PyExc_ValueError, - "expected int argument in [0,3]")); + return EXPP_ReturnPyObjError (PyExc_ValueError, + "expected int argument in [0,3]"); Py_INCREF(Py_None); return Py_None; @@ -721,9 +724,9 @@ static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args) float value; if (!PyArg_ParseTuple(args, "f", &value)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected float argument")); - + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected float argument"); + self->camera->lens = EXPP_ClampFloat (value, EXPP_CAM_LENS_MIN, EXPP_CAM_LENS_MAX); @@ -741,8 +744,8 @@ static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args) float value; if (!PyArg_ParseTuple(args, "f", &value)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected float argument")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected float argument"); self->camera->clipsta = EXPP_ClampFloat (value, EXPP_CAM_CLIPSTART_MIN, EXPP_CAM_CLIPSTART_MAX); @@ -761,8 +764,8 @@ static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args) float value; if (!PyArg_ParseTuple(args, "f", &value)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected float argument")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected float argument"); self->camera->clipend = EXPP_ClampFloat (value, EXPP_CAM_CLIPEND_MIN, EXPP_CAM_CLIPEND_MAX); @@ -781,8 +784,8 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args) float value; if (!PyArg_ParseTuple(args, "f", &value)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected a float number as argument")); + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a float number as argument"); self->camera->drawsize = EXPP_ClampFloat (value, EXPP_CAM_DRAWSIZE_MIN, EXPP_CAM_DRAWSIZE_MAX); @@ -854,8 +857,8 @@ static PyObject *Camera_GetAttr (BPy_Camera *self, char *name) } if (!attr) - return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create PyObject")); + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create PyObject"); if (attr != Py_None) return attr; /* member attribute found, return it */ @@ -909,23 +912,23 @@ static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value) if ((strcmp (name, "Types") == 0) || /* user tried to change a */ (strcmp (name, "Modes") == 0)) /* constant dict type ... */ - return (EXPP_ReturnIntError (PyExc_AttributeError, - "constant dictionary -- cannot be changed")); + return EXPP_ReturnIntError (PyExc_AttributeError, + "constant dictionary -- cannot be changed"); else /* ... or no member with the given name was found */ - return (EXPP_ReturnIntError (PyExc_KeyError, - "attribute not found")); + return EXPP_ReturnIntError (PyExc_KeyError, + "attribute not found"); } /* valtuple won't be returned to the caller, so we need to DECREF it */ - Py_DECREF(valtuple); + Py_DECREF (valtuple); if (error != Py_None) return -1; /* Py_None was incref'ed by the called Camera_set* function. We probably * don't need to decref Py_None (!), but since Python/C API manual tells us * to treat it like any other PyObject regarding ref counting ... */ - Py_DECREF(Py_None); + Py_DECREF (Py_None); return 0; /* normal exit */ } diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h index 6f35d651e58..26e7fdfb889 100644 --- a/source/blender/python/api2_2x/Camera.h +++ b/source/blender/python/api2_2x/Camera.h @@ -33,9 +33,7 @@ #define EXPP_CAMERA_H #include - #include - #include "constant.h" #include "gen_utils.h" diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index 9e2c6169fc0..d28f95a9dc8 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -45,20 +45,20 @@ static PyObject *M_Curve_New(PyObject *self, PyObject *args) printf ("In Curve_New()\n"); if (!PyArg_ParseTuple(args, "|s", &name)) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument or no argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected string argument or no argument")); blcurve = add_curve(OB_CURVE); /* first create the Curve Data in Blender */ if (blcurve == NULL) - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't create Curve Data in Blender")); + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't create Curve Data in Blender")); pycurve = (C_Curve *)PyObject_NEW(C_Curve, &Curve_Type); if (pycurve == NULL) - return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create Curve Data object")); + return (EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create Curve Data object")); pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */ if (name) @@ -84,7 +84,7 @@ static PyObject *M_Curve_Get(PyObject *self, PyObject *args) printf ("In Curve_Get()\n"); if (!PyArg_ParseTuple(args, "|s", &name))//expects nothing or a string return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument")); + "expected string argument")); if(name){//a name has been given /* Use the name to search for the curve requested */ wanted_curv = NULL; @@ -93,8 +93,8 @@ static PyObject *M_Curve_Get(PyObject *self, PyObject *args) while ((curv_iter) && (wanted_curv == NULL)) { if (strcmp (name, curv_iter->id.name+2) == 0) { - wanted_curv = (C_Curve *)PyObject_NEW(C_Curve, &Curve_Type); - if (wanted_curv) wanted_curv->curve = curv_iter; + wanted_curv = (C_Curve *)PyObject_NEW(C_Curve, &Curve_Type); + if (wanted_curv) wanted_curv->curve = curv_iter; } curv_iter = curv_iter->id.next; @@ -109,33 +109,33 @@ static PyObject *M_Curve_Get(PyObject *self, PyObject *args) return (PyObject*)wanted_curv; - }//if(name) - else{//no name has been given; return a list of all curves by name. + }/*if(name)*/ + else{/*no name has been given; return a list with all curves in the scene */ int index = 0; - PyObject *curvlist, *pystr; + PyObject *curvlist, *pyobj; curv_iter = G.main->curve.first; curvlist = PyList_New (BLI_countlist (&(G.main->curve))); if (curvlist == NULL) return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyList")); + "couldn't create PyList")); while (curv_iter) { - pystr = PyString_FromString (curv_iter->id.name+2); + pyobj = CurveCreatePyObject (curv_iter); - if (!pystr) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyString")); + if (!pyobj) + return (PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create PyString")); - PyList_SET_ITEM (curvlist, index, pystr); + PyList_SET_ITEM (curvlist, index, pyobj); curv_iter = curv_iter->id.next; index++; } return (curvlist); - }//else + }/*else*/ } /*****************************************************************************/ @@ -168,7 +168,7 @@ static PyObject *Curve_getName(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.name attribute")); + "couldn't get Curve.name attribute")); } static PyObject *Curve_setName(C_Curve *self, PyObject *args) @@ -178,7 +178,7 @@ static PyObject *Curve_setName(C_Curve *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &(name))) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected string argument")); + "expected string argument")); PyOS_snprintf(buf, sizeof(buf), "%s", name); rename_id(&self->curve->id, buf); /* proper way in Blender */ @@ -193,7 +193,7 @@ static PyObject *Curve_getPathLen(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.pathlen attribute")); + "couldn't get Curve.pathlen attribute")); } @@ -201,8 +201,8 @@ static PyObject *Curve_setPathLen(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "i", &(self->curve->pathlen))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); Py_INCREF(Py_None); return Py_None; @@ -216,7 +216,7 @@ static PyObject *Curve_getTotcol(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.totcol attribute")); + "couldn't get Curve.totcol attribute")); } @@ -224,8 +224,8 @@ static PyObject *Curve_setTotcol(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "i", &(self->curve->totcol))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); Py_INCREF(Py_None); return Py_None; @@ -239,7 +239,7 @@ static PyObject *Curve_getMode(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.flag attribute")); + "couldn't get Curve.flag attribute")); } @@ -247,8 +247,8 @@ static PyObject *Curve_setMode(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "i", &(self->curve->flag))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); Py_INCREF(Py_None); return Py_None; @@ -262,7 +262,7 @@ static PyObject *Curve_getBevresol(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.bevresol attribute")); + "couldn't get Curve.bevresol attribute")); } @@ -270,8 +270,8 @@ static PyObject *Curve_setBevresol(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "i", &(self->curve->bevresol))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); Py_INCREF(Py_None); return Py_None; @@ -285,7 +285,7 @@ static PyObject *Curve_getResolu(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.resolu attribute")); + "couldn't get Curve.resolu attribute")); } @@ -293,8 +293,8 @@ static PyObject *Curve_setResolu(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "i", &(self->curve->resolu))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); Py_INCREF(Py_None); return Py_None; @@ -309,7 +309,7 @@ static PyObject *Curve_getResolv(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.resolv attribute")); + "couldn't get Curve.resolv attribute")); } @@ -317,8 +317,8 @@ static PyObject *Curve_setResolv(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "i", &(self->curve->resolv))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected int argument")); Py_INCREF(Py_None); return Py_None; @@ -333,7 +333,7 @@ static PyObject *Curve_getWidth(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.width attribute")); + "couldn't get Curve.width attribute")); } @@ -341,8 +341,8 @@ static PyObject *Curve_setWidth(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "f", &(self->curve->width))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); Py_INCREF(Py_None); return Py_None; @@ -356,7 +356,7 @@ static PyObject *Curve_getExt1(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.ext1 attribute")); + "couldn't get Curve.ext1 attribute")); } @@ -364,8 +364,8 @@ static PyObject *Curve_setExt1(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "f", &(self->curve->ext1))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); Py_INCREF(Py_None); return Py_None; @@ -380,7 +380,7 @@ static PyObject *Curve_getExt2(C_Curve *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Curve.ext2 attribute")); + "couldn't get Curve.ext2 attribute")); } @@ -388,8 +388,8 @@ static PyObject *Curve_setExt2(C_Curve *self, PyObject *args) { if (!PyArg_ParseTuple(args, "f", &(self->curve->ext2))) - return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float argument")); + return (EXPP_ReturnPyObjError (PyExc_AttributeError, + "expected float argument")); Py_INCREF(Py_None); return Py_None; @@ -408,13 +408,13 @@ static PyObject *Curve_setControlPoint(C_Curve *self, PyObject *args) if (ptrnurb->bp) if (!PyArg_ParseTuple(args, "iiffff", &numcourbe,&numpoint,&x,&y,&z,&w)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int float float float float arguments")); + "expected int int float float float float arguments")); if (ptrnurb->bezt) if (!PyArg_ParseTuple(args, "iifffffffff", &numcourbe,&numpoint, - bez,bez+1,bez+2,bez+3,bez+4,bez+5,bez+6,bez+7,bez+8)) + bez,bez+1,bez+2,bez+3,bez+4,bez+5,bez+6,bez+7,bez+8)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int float float float float float float " - "float float float arguments")); + "expected int int float float float float float float " + "float float float arguments")); for(i = 0;i< numcourbe;i++) ptrnurb=ptrnurb->next; @@ -428,10 +428,10 @@ static PyObject *Curve_setControlPoint(C_Curve *self, PyObject *args) if (ptrnurb->bezt) { for(i = 0;i<3;i++) - for(j = 0;j<3;j++) - ptrnurb->bezt[numpoint].vec[i][j] = bez[i*3+j]; + for(j = 0;j<3;j++) + ptrnurb->bezt[numpoint].vec[i][j] = bez[i*3+j]; } - + Py_INCREF(Py_None); return Py_None; } @@ -445,7 +445,7 @@ static PyObject *Curve_getControlPoint(C_Curve *self, PyObject *args) if (!PyArg_ParseTuple(args, "ii", &numcourbe,&numpoint)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected int int arguments")); + "expected int int arguments")); //check args ??? if (!self->curve->nurb.first)return liste; ptrnurb = self->curve->nurb.first; @@ -455,16 +455,16 @@ static PyObject *Curve_getControlPoint(C_Curve *self, PyObject *args) if (ptrnurb->bp) { for(i = 0;i< 4;i++) - PyList_Append(liste, PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i])); + PyList_Append(liste, PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i])); } if (ptrnurb->bezt) { liste = PyList_New(9); for(i = 0;i< 3;i++) - for(j = 0;j< 3;j++) - PyList_Append(liste, - PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j])); + for(j = 0;j< 3;j++) + PyList_Append(liste, + PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j])); } return liste; @@ -487,7 +487,7 @@ static PyObject *Curve_setLoc(C_Curve *self, PyObject *args) if (!PyArg_ParseTuple(args, "fff",&x,&y,&z)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float float float arguments")); + "expected float float float arguments")); self->curve->loc[0] = x; self->curve->loc[1] = y; @@ -513,7 +513,7 @@ static PyObject *Curve_setRot(C_Curve *self, PyObject *args) if (!PyArg_ParseTuple(args, "fff",&x,&y,&z)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float float float arguments")); + "expected float float float arguments")); self->curve->rot[0] = x; self->curve->rot[1] = y; @@ -538,7 +538,7 @@ static PyObject *Curve_setSize(C_Curve *self, PyObject *args) if (!PyArg_ParseTuple(args, "fff",&x,&y,&z)) return (EXPP_ReturnPyObjError (PyExc_AttributeError, - "expected float float float arguments")); + "expected float float float arguments")); self->curve->size[0] = x; self->curve->size[1] = y; @@ -598,7 +598,7 @@ static PyObject *CurveGetAttr (C_Curve *self, char *name)//getattr if (!attr) return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create PyObject")); + "couldn't create PyObject")); if (attr != Py_None) return attr; /* member attribute found, return it */ @@ -664,7 +664,7 @@ static int CurvePrint(C_Curve *self, FILE *fp, int flags) //print { fprintf(fp, "[Curve \"%s\"]\n", self->curve->id.name+2); - + return 0; } diff --git a/source/blender/python/api2_2x/Curve.h b/source/blender/python/api2_2x/Curve.h index c0921bead78..e739aae4582 100644 --- a/source/blender/python/api2_2x/Curve.h +++ b/source/blender/python/api2_2x/Curve.h @@ -198,7 +198,7 @@ struct Curve* CurveFromPyObject (PyObject *py_obj); /*****************************************************************************/ /* Python Curve_Type structure definition: */ /*****************************************************************************/ -static PyTypeObject Curve_Type = +PyTypeObject Curve_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index 7bbfa03d8a1..48b0c4c1abb 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -38,16 +38,16 @@ static void Button_dealloc(PyObject *self) { - Button *but= (Button*) self; + Button *but = (Button*)self; - if(but->type==3) MEM_freeN(but->val.asstr); + if(but->type == 3) MEM_freeN (but->val.asstr); - PyMem_DEL(self); + PyObject_DEL (self); } static PyObject *Button_getattr(PyObject *self, char *name) { - Button *but= (Button*) self; + Button *but = (Button*)self; if(strcmp(name, "val") == 0) { if (but->type==1) diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c index 796ca311c8b..40a673f88fc 100644 --- a/source/blender/python/api2_2x/Ipo.c +++ b/source/blender/python/api2_2x/Ipo.c @@ -37,28 +37,28 @@ /*****************************************************************************/ static PyObject *M_Ipo_New(PyObject *self, PyObject *args) { - Ipo *add_ipo(char *name, int idcode); - char*name = NULL; - int code = 0; + Ipo *add_ipo(char *name, int idcode); + char*name = NULL; + int code = 0; C_Ipo *pyipo; Ipo *blipo; - if (!PyArg_ParseTuple(args, "si", &name,&code)) + if (!PyArg_ParseTuple(args, "si", &name,&code)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string int arguments")); + "expected string int arguments")); blipo = add_ipo(name,code); if (blipo) - pyipo = (C_Ipo *)PyObject_NEW(C_Ipo, &Ipo_Type); + pyipo = (C_Ipo *)PyObject_NEW(C_Ipo, &Ipo_Type); else return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't create Ipo Data in Blender")); + "couldn't create Ipo Data in Blender")); if (pyipo == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create Ipo Data object")); + "couldn't create Ipo Data object")); pyipo->ipo = blipo; @@ -77,57 +77,57 @@ static PyObject *M_Ipo_Get(PyObject *self, PyObject *args) { char *name = NULL; Ipo *ipo_iter; - PyObject *ipolist, *pystr; + PyObject *ipolist, *pyobj; C_Ipo *wanted_ipo = NULL; char error_msg[64]; - if (!PyArg_ParseTuple(args, "|s", &name)) + if (!PyArg_ParseTuple(args, "|s", &name)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument (or nothing)")); + "expected string argument (or nothing)")); ipo_iter = G.main->ipo.first; - if (name) { /* (name) - Search ipo by name */ + if (name) { /* (name) - Search ipo by name */ while ((ipo_iter) && (wanted_ipo == NULL)) { if (strcmp (name, ipo_iter->id.name+2) == 0) { wanted_ipo = (C_Ipo *)PyObject_NEW(C_Ipo, &Ipo_Type); - if (wanted_ipo) wanted_ipo->ipo = ipo_iter; + if (wanted_ipo) wanted_ipo->ipo = ipo_iter; } ipo_iter = ipo_iter->id.next; } if (wanted_ipo == NULL) { /* Requested ipo doesn't exist */ PyOS_snprintf(error_msg, sizeof(error_msg), - "Ipo \"%s\" not found", name); + "Ipo \"%s\" not found", name); return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); } return (PyObject *)wanted_ipo; - } + } - else { /* () - return a list of all ipos in the scene */ + else { /* () - return a list with all ipos in the scene */ int index = 0; ipolist = PyList_New (BLI_countlist (&(G.main->ipo))); if (ipolist == NULL) return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyList")); - - while (ipo_iter) { - pystr = PyString_FromString (ipo_iter->id.name+2); + "couldn't create PyList")); - if (!pystr) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyString")); + while (ipo_iter) { + pyobj = Ipo_CreatePyObject (ipo_iter); + + if (!pyobj) + return (PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create PyString")); - PyList_SET_ITEM (ipolist, index, pystr); + PyList_SET_ITEM (ipolist, index, pyobj); ipo_iter = ipo_iter->id.next; index++; } - return (ipolist); + return (ipolist); } } @@ -138,9 +138,10 @@ PyObject *M_Ipo_Init (void) { PyObject *submodule; + Ipo_Type.ob_type = &PyType_Type; + printf ("In M_Ipo_Init()\n"); - submodule = Py_InitModule3("Blender.Ipo", - M_Ipo_methods, M_Ipo_doc); + submodule = Py_InitModule3("Blender.Ipo", M_Ipo_methods, M_Ipo_doc); return (submodule); } @@ -155,7 +156,7 @@ static PyObject *Ipo_getName(C_Ipo *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Ipo.name attribute")); + "couldn't get Ipo.name attribute")); } static PyObject *Ipo_setName(C_Ipo *self, PyObject *args) { @@ -164,7 +165,7 @@ static PyObject *Ipo_setName(C_Ipo *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &name)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); + "expected string argument")); PyOS_snprintf(buf, sizeof(buf), "%s", name); @@ -181,7 +182,7 @@ static PyObject *Ipo_getBlocktype(C_Ipo *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Ipo.blocktype attribute")); + "couldn't get Ipo.blocktype attribute")); } @@ -191,9 +192,9 @@ static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args) if (!PyArg_ParseTuple(args, "i", &blocktype)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); + "expected string argument")); - self->ipo->blocktype = (short)blocktype; + self->ipo->blocktype = (short)blocktype; Py_INCREF(Py_None); return Py_None; @@ -206,7 +207,7 @@ static PyObject *Ipo_getShowkey(C_Ipo *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Ipo.showkey attribute")); + "couldn't get Ipo.showkey attribute")); } @@ -216,9 +217,9 @@ static PyObject *Ipo_setShowkey(C_Ipo *self, PyObject *args) if (!PyArg_ParseTuple(args, "i", &showkey)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); + "expected string argument")); - self->ipo->showkey = (short)showkey; + self->ipo->showkey = (short)showkey; Py_INCREF(Py_None); return Py_None; @@ -231,7 +232,7 @@ static PyObject *Ipo_getPad(C_Ipo *self) if (attr) return attr; return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Ipo.pad attribute")); + "couldn't get Ipo.pad attribute")); } @@ -241,9 +242,9 @@ static PyObject *Ipo_setPad(C_Ipo *self, PyObject *args) if (!PyArg_ParseTuple(args, "i", &pad)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); + "expected string argument")); - self->ipo->pad = pad; + self->ipo->pad = pad; Py_INCREF(Py_None); return Py_None; @@ -251,7 +252,7 @@ static PyObject *Ipo_setPad(C_Ipo *self, PyObject *args) static PyObject *Ipo_getRctf(C_Ipo *self) { - PyObject* l = PyList_New(0); + PyObject* l = PyList_New(0); PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.xmin)); PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.xmax)); PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.ymin)); @@ -263,15 +264,15 @@ static PyObject *Ipo_getRctf(C_Ipo *self) static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args) { - float v[4]; + float v[4]; if (!PyArg_ParseTuple(args, "ffff",v,v+1,v+2,v+3)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected 4 float argument")); + "expected 4 float argument")); - self->ipo->cur.xmin = v[0]; - self->ipo->cur.xmax = v[1]; - self->ipo->cur.ymin = v[2]; - self->ipo->cur.ymax = v[3]; + self->ipo->cur.xmin = v[0]; + self->ipo->cur.xmax = v[1]; + self->ipo->cur.ymin = v[2]; + self->ipo->cur.ymax = v[3]; Py_INCREF(Py_None); return Py_None; @@ -279,104 +280,104 @@ static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args) static PyObject *Ipo_getNcurves(C_Ipo *self) { - int i = 0; + int i = 0; - IpoCurve *icu; - for (icu=self->ipo->curve.first; icu; icu=icu->next){ - i++; - } + IpoCurve *icu; + for (icu=self->ipo->curve.first; icu; icu=icu->next){ + i++; + } return (PyInt_FromLong(i) ); } static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args) -{ - struct BPoint *ptrbpoint; - int num = 0,i; - IpoCurve *icu; - PyObject* l; +{ + struct BPoint *ptrbpoint; + int num = 0,i; + IpoCurve *icu; + PyObject* l; if (!PyArg_ParseTuple(args, "i",&num)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - + "expected int argument")); + icu =self->ipo->curve.first; + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); + for(i = 0;inext; + } - ptrbpoint = icu->bp; - if(!ptrbpoint)return EXPP_ReturnPyObjError(PyExc_TypeError,"No base point"); + ptrbpoint = icu->bp; + if(!ptrbpoint)return EXPP_ReturnPyObjError(PyExc_TypeError,"No base point"); - l = PyList_New(0); - for(i=0;i<4;i++) - PyList_Append( l, PyFloat_FromDouble(ptrbpoint->vec[i])); - return l; + l = PyList_New(0); + for(i=0;i<4;i++) + PyList_Append( l, PyFloat_FromDouble(ptrbpoint->vec[i])); + return l; } static PyObject *Ipo_getCurveBeztriple(C_Ipo *self, PyObject *args) -{ - struct BezTriple *ptrbt; - int num = 0,pos,i,j; - IpoCurve *icu; - PyObject* l = PyList_New(0); +{ + struct BezTriple *ptrbt; + int num = 0,pos,i,j; + IpoCurve *icu; + PyObject* l = PyList_New(0); if (!PyArg_ParseTuple(args, "ii",&num,&pos)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - } - if (pos >= icu->totvert) - return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number"); - - ptrbt = icu->bezt + pos; - if(!ptrbt) - return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple"); - - for(i=0;i<3;i++) - for(j=0;j<3;j++) - PyList_Append( l, PyFloat_FromDouble(ptrbt->vec[i][j])); - return l; + "expected int argument")); + icu =self->ipo->curve.first; + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); + for(i = 0;inext; + } + if (pos >= icu->totvert) + return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number"); + + ptrbt = icu->bezt + pos; + if(!ptrbt) + return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple"); + + for(i=0;i<3;i++) + for(j=0;j<3;j++) + PyList_Append( l, PyFloat_FromDouble(ptrbt->vec[i][j])); + return l; } static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args) -{ - struct BezTriple *ptrbt; - int num = 0,pos,i; - IpoCurve *icu; - PyObject *listargs=0; +{ + struct BezTriple *ptrbt; + int num = 0,pos,i; + IpoCurve *icu; + PyObject *listargs=0; if (!PyArg_ParseTuple(args, "iiO",&num,&pos,&listargs)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - } - if (pos >= icu->totvert) - return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number"); - - ptrbt = icu->bezt + pos; - if(!ptrbt) - return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple"); - - for(i=0;i<9;i++) - { - PyObject * xx = PyList_GetItem(listargs,i); - ptrbt->vec[i/3][i%3] = PyFloat_AsDouble(xx); - } + "expected int argument")); + icu =self->ipo->curve.first; + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); + for(i = 0;inext; + } + if (pos >= icu->totvert) + return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number"); + + ptrbt = icu->bezt + pos; + if(!ptrbt) + return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple"); + + for(i=0;i<9;i++) + { + PyObject * xx = PyList_GetItem(listargs,i); + ptrbt->vec[i/3][i%3] = PyFloat_AsDouble(xx); + } Py_INCREF(Py_None); return Py_None; @@ -386,22 +387,22 @@ static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args) static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args) -{ - int num = 0,i; - IpoCurve *icu; +{ + int num = 0,i; + IpoCurve *icu; if (!PyArg_ParseTuple(args, "i",&num)) return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected int argument")); - icu =self->ipo->curve.first; - if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); - for(i = 0;inext; - + "expected int argument")); + icu =self->ipo->curve.first; + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); + for(i = 0;inext; + } - return PyFloat_FromDouble(icu->curval); + return PyFloat_FromDouble(icu->curval); } @@ -449,12 +450,53 @@ static int IpoPrint(C_Ipo *self, FILE *fp, int flags) } /*****************************************************************************/ -/* Function: IpoRepr */ -/* Description: This is a callback function for the C_Ipo type. It */ -/* builds a meaninful string to represent ipo objects. */ +/* Function: IpoRepr */ +/* Description: This is a callback function for the C_Ipo type. It */ +/* builds a meaninful string to represent ipo objects. */ /*****************************************************************************/ static PyObject *IpoRepr (C_Ipo *self) { return PyString_FromString(self->ipo->id.name+2); } +/* Three Python Ipo_Type helper functions needed by the Object module: */ + +/*****************************************************************************/ +/* Function: Ipo_CreatePyObject */ +/* Description: This function will create a new C_Ipo from an existing */ +/* Blender ipo structure. */ +/*****************************************************************************/ +PyObject *Ipo_CreatePyObject (Ipo *ipo) +{ + C_Ipo *pyipo; + + pyipo = (C_Ipo *)PyObject_NEW (C_Ipo, &Ipo_Type); + + if (!pyipo) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create C_Ipo object"); + + pyipo->ipo = ipo; + + return (PyObject *)pyipo; +} + +/*****************************************************************************/ +/* Function: Ipo_CheckPyObject */ +/* Description: This function returns true when the given PyObject is of the */ +/* type Ipo. Otherwise it will return false. */ +/*****************************************************************************/ +int Ipo_CheckPyObject (PyObject *pyobj) +{ + return (pyobj->ob_type == &Ipo_Type); +} + +/*****************************************************************************/ +/* Function: Ipo_FromPyObject */ +/* Description: This function returns the Blender ipo from the given */ +/* PyObject. */ +/*****************************************************************************/ +Ipo *Ipo_FromPyObject (PyObject *pyobj) +{ + return ((C_Ipo *)pyobj)->ipo; +} diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h index 441384e5534..602e8cc4b14 100644 --- a/source/blender/python/api2_2x/Ipo.h +++ b/source/blender/python/api2_2x/Ipo.h @@ -152,9 +152,9 @@ static PyObject *IpoRepr (C_Ipo *self); /*****************************************************************************/ /* Python Ipo_Type structure definition: */ /*****************************************************************************/ -static PyTypeObject Ipo_Type = +PyTypeObject Ipo_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Ipo", /* tp_name */ sizeof (C_Ipo), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 82cddc3fdd2..b267df09455 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -99,22 +99,22 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args) char *name = NULL; Lamp *lamp_iter; - if (!PyArg_ParseTuple(args, "|s", &name)) + if (!PyArg_ParseTuple(args, "|s", &name)) return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument (or nothing)")); lamp_iter = G.main->lamp.first; - if (name) { /* (name) - Search lamp by name */ + if (name) { /* (name) - Search lamp by name */ C_Lamp *wanted_lamp = NULL; while ((lamp_iter) && (wanted_lamp == NULL)) { - if (strcmp (name, lamp_iter->id.name+2) == 0) + if (strcmp (name, lamp_iter->id.name+2) == 0) wanted_lamp = (C_Lamp *)Lamp_CreatePyObject(lamp_iter); - lamp_iter = lamp_iter->id.next; + lamp_iter = lamp_iter->id.next; } if (wanted_lamp == NULL) { /* Requested lamp doesn't exist */ @@ -125,11 +125,11 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args) } return (PyObject *)wanted_lamp; - } + } - else { /* () - return a list of all lamps in the scene */ + else { /* () - return a list of all lamps in the scene */ int index = 0; - PyObject *lamplist, *pystr; + PyObject *lamplist, *pyobj; lamplist = PyList_New (BLI_countlist (&(G.main->lamp))); @@ -137,46 +137,46 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args) return (PythonReturnErrorObject (PyExc_MemoryError, "couldn't create PyList")); - while (lamp_iter) { - pystr = PyString_FromString (lamp_iter->id.name+2); + while (lamp_iter) { + pyobj = Lamp_CreatePyObject (lamp_iter); - if (!pystr) - return (PythonReturnErrorObject (PyExc_MemoryError, - "couldn't create PyString")); + if (!pyobj) + return (PythonReturnErrorObject (PyExc_MemoryError, + "couldn't create PyString")); - PyList_SET_ITEM (lamplist, index, pystr); + PyList_SET_ITEM (lamplist, index, pyobj); lamp_iter = lamp_iter->id.next; index++; - } + } - return (lamplist); - } + return lamplist; + } } static PyObject *M_Lamp_TypesDict (void) { /* create the Blender.Lamp.Types constant dict */ - PyObject *Types = M_constant_New(); + PyObject *Types = M_constant_New(); - if (Types) { - C_constant *c = (C_constant *)Types; + if (Types) { + C_constant *c = (C_constant *)Types; constant_insert (c, "Lamp", PyInt_FromLong (EXPP_LAMP_TYPE_LAMP)); constant_insert (c, "Sun", PyInt_FromLong (EXPP_LAMP_TYPE_SUN)); constant_insert (c, "Spot", PyInt_FromLong (EXPP_LAMP_TYPE_SPOT)); constant_insert (c, "Hemi", PyInt_FromLong (EXPP_LAMP_TYPE_HEMI)); - } + } - return Types; + return Types; } static PyObject *M_Lamp_ModesDict (void) { /* create the Blender.Lamp.Modes constant dict */ - PyObject *Modes = M_constant_New(); + PyObject *Modes = M_constant_New(); - if (Modes) { - C_constant *c = (C_constant *)Modes; + if (Modes) { + C_constant *c = (C_constant *)Modes; constant_insert (c, "Shadows", PyInt_FromLong (EXPP_LAMP_MODE_SHADOWS)); constant_insert (c, "Halo", PyInt_FromLong (EXPP_LAMP_MODE_HALO)); @@ -186,8 +186,8 @@ static PyObject *M_Lamp_ModesDict (void) constant_insert (c, "Sphere", PyInt_FromLong (EXPP_LAMP_MODE_SPHERE)); constant_insert (c, "Square", PyInt_FromLong (EXPP_LAMP_MODE_SQUARE)); constant_insert (c, "OnlyShadow", - PyInt_FromLong (EXPP_LAMP_MODE_ONLYSHADOW)); - } + PyInt_FromLong (EXPP_LAMP_MODE_ONLYSHADOW)); + } return Modes; } @@ -202,13 +202,13 @@ PyObject *M_Lamp_Init (void) Lamp_Type.ob_type = &PyType_Type; - Types = M_Lamp_TypesDict (); - Modes = M_Lamp_ModesDict (); + Types = M_Lamp_TypesDict (); + Modes = M_Lamp_ModesDict (); submodule = Py_InitModule3("Blender.Lamp", M_Lamp_methods, M_Lamp_doc); - if (Types) PyModule_AddObject(submodule, "Types", Types); - if (Modes) PyModule_AddObject(submodule, "Modes", Modes); + if (Types) PyModule_AddObject(submodule, "Types", Types); + if (Modes) PyModule_AddObject(submodule, "Modes", Modes); return (submodule); } @@ -222,24 +222,24 @@ PyObject *M_Lamp_Init (void) /*****************************************************************************/ PyObject *Lamp_CreatePyObject (Lamp *lamp) { - C_Lamp *pylamp; - float *rgb[3]; + C_Lamp *pylamp; + float *rgb[3]; - pylamp = (C_Lamp *)PyObject_NEW (C_Lamp, &Lamp_Type); + pylamp = (C_Lamp *)PyObject_NEW (C_Lamp, &Lamp_Type); - if (!pylamp) - return EXPP_ReturnPyObjError (PyExc_MemoryError, - "couldn't create C_Lamp object"); + if (!pylamp) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create C_Lamp object"); - pylamp->lamp = lamp; + pylamp->lamp = lamp; - rgb[0] = &lamp->r; - rgb[1] = &lamp->g; - rgb[2] = &lamp->b; + rgb[0] = &lamp->r; + rgb[1] = &lamp->g; + rgb[2] = &lamp->b; - pylamp->color = (C_rgbTuple *)rgbTuple_New(rgb); + pylamp->color = (C_rgbTuple *)rgbTuple_New(rgb); - return (PyObject *)pylamp; + return (PyObject *)pylamp; } /*****************************************************************************/ @@ -249,7 +249,7 @@ PyObject *Lamp_CreatePyObject (Lamp *lamp) /*****************************************************************************/ int Lamp_CheckPyObject (PyObject *pyobj) { - return (pyobj->ob_type == &Lamp_Type); + return (pyobj->ob_type == &Lamp_Type); } /*****************************************************************************/ @@ -259,7 +259,7 @@ int Lamp_CheckPyObject (PyObject *pyobj) /*****************************************************************************/ Lamp *Lamp_FromPyObject (PyObject *pyobj) { - return ((C_Lamp *)pyobj)->lamp; + return ((C_Lamp *)pyobj)->lamp; } /*****************************************************************************/ @@ -437,7 +437,7 @@ static PyObject *Lamp_getQuad2(C_Lamp *self) static PyObject *Lamp_getCol(C_Lamp *self) { - return rgbTuple_getCol(self->color); + return rgbTuple_getCol(self->color); } static PyObject *Lamp_setName(C_Lamp *self, PyObject *args) @@ -568,8 +568,8 @@ static PyObject *Lamp_setSamples(C_Lamp *self, PyObject *args) return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument in [1,16]")); - self->lamp->samp = EXPP_ClampInt (value, - EXPP_LAMP_SAMPLES_MIN, EXPP_LAMP_SAMPLES_MAX); + self->lamp->samp = EXPP_ClampInt (value, + EXPP_LAMP_SAMPLES_MIN, EXPP_LAMP_SAMPLES_MAX); Py_INCREF(Py_None); return Py_None; @@ -582,9 +582,9 @@ static PyObject *Lamp_setBufferSize(C_Lamp *self, PyObject *args) if (!PyArg_ParseTuple(args, "h", &value)) return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument in [512, 5120]")); - + self->lamp->bufsize = EXPP_ClampInt (value, - EXPP_LAMP_BUFFERSIZE_MIN, EXPP_LAMP_BUFFERSIZE_MAX); + EXPP_LAMP_BUFFERSIZE_MIN, EXPP_LAMP_BUFFERSIZE_MAX); Py_INCREF(Py_None); return Py_None; @@ -599,7 +599,7 @@ static PyObject *Lamp_setHaloStep(C_Lamp *self, PyObject *args) "expected int argument in [0,12]")); self->lamp->shadhalostep = EXPP_ClampInt (value, - EXPP_LAMP_HALOSTEP_MIN, EXPP_LAMP_HALOSTEP_MAX); + EXPP_LAMP_HALOSTEP_MIN, EXPP_LAMP_HALOSTEP_MAX); Py_INCREF(Py_None); return Py_None; @@ -614,7 +614,7 @@ static PyObject *Lamp_setEnergy(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->energy = EXPP_ClampFloat (value, - EXPP_LAMP_ENERGY_MIN, EXPP_LAMP_ENERGY_MAX); + EXPP_LAMP_ENERGY_MIN, EXPP_LAMP_ENERGY_MAX); Py_INCREF(Py_None); return Py_None; @@ -629,7 +629,7 @@ static PyObject *Lamp_setDist(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->dist = EXPP_ClampFloat (value, - EXPP_LAMP_DIST_MIN, EXPP_LAMP_DIST_MAX); + EXPP_LAMP_DIST_MIN, EXPP_LAMP_DIST_MAX); Py_INCREF(Py_None); return Py_None; @@ -644,7 +644,7 @@ static PyObject *Lamp_setSpotSize(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->spotsize = EXPP_ClampFloat (value, - EXPP_LAMP_SPOTSIZE_MIN, EXPP_LAMP_SPOTSIZE_MAX); + EXPP_LAMP_SPOTSIZE_MIN, EXPP_LAMP_SPOTSIZE_MAX); Py_INCREF(Py_None); return Py_None; @@ -659,7 +659,7 @@ static PyObject *Lamp_setSpotBlend(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->spotblend = EXPP_ClampFloat (value, - EXPP_LAMP_SPOTBLEND_MIN, EXPP_LAMP_SPOTBLEND_MAX); + EXPP_LAMP_SPOTBLEND_MIN, EXPP_LAMP_SPOTBLEND_MAX); Py_INCREF(Py_None); return Py_None; @@ -674,7 +674,7 @@ static PyObject *Lamp_setClipStart(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->clipsta = EXPP_ClampFloat (value, - EXPP_LAMP_CLIPSTART_MIN, EXPP_LAMP_CLIPSTART_MAX); + EXPP_LAMP_CLIPSTART_MIN, EXPP_LAMP_CLIPSTART_MAX); Py_INCREF(Py_None); return Py_None; @@ -689,7 +689,7 @@ static PyObject *Lamp_setClipEnd(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->clipend = EXPP_ClampFloat (value, - EXPP_LAMP_CLIPEND_MIN, EXPP_LAMP_CLIPEND_MAX); + EXPP_LAMP_CLIPEND_MIN, EXPP_LAMP_CLIPEND_MAX); Py_INCREF(Py_None); return Py_None; @@ -704,7 +704,7 @@ static PyObject *Lamp_setBias(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->bias = EXPP_ClampFloat (value, - EXPP_LAMP_BIAS_MIN, EXPP_LAMP_BIAS_MAX); + EXPP_LAMP_BIAS_MIN, EXPP_LAMP_BIAS_MAX); Py_INCREF(Py_None); return Py_None; @@ -719,7 +719,7 @@ static PyObject *Lamp_setSoftness(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->soft = EXPP_ClampFloat (value, - EXPP_LAMP_SOFTNESS_MIN, EXPP_LAMP_SOFTNESS_MAX); + EXPP_LAMP_SOFTNESS_MIN, EXPP_LAMP_SOFTNESS_MAX); Py_INCREF(Py_None); return Py_None; @@ -734,7 +734,7 @@ static PyObject *Lamp_setHaloInt(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->haint = EXPP_ClampFloat (value, - EXPP_LAMP_HALOINT_MIN, EXPP_LAMP_HALOINT_MAX); + EXPP_LAMP_HALOINT_MIN, EXPP_LAMP_HALOINT_MAX); Py_INCREF(Py_None); return Py_None; @@ -749,7 +749,7 @@ static PyObject *Lamp_setQuad1(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->att1 = EXPP_ClampFloat (value, - EXPP_LAMP_QUAD1_MIN, EXPP_LAMP_QUAD1_MAX); + EXPP_LAMP_QUAD1_MIN, EXPP_LAMP_QUAD1_MAX); Py_INCREF(Py_None); return Py_None; @@ -764,14 +764,14 @@ static PyObject *Lamp_setQuad2(C_Lamp *self, PyObject *args) "expected float argument")); self->lamp->att2 = EXPP_ClampFloat (value, - EXPP_LAMP_QUAD2_MIN, EXPP_LAMP_QUAD2_MAX); + EXPP_LAMP_QUAD2_MIN, EXPP_LAMP_QUAD2_MAX); Py_INCREF(Py_None); return Py_None; } static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key, - PyObject *args) + PyObject *args) { /* for compatibility with old bpython */ float value; @@ -780,7 +780,7 @@ static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key, "expected float argument in [0.0, 1.0]")); value = EXPP_ClampFloat (value, EXPP_LAMP_COL_MIN, - EXPP_LAMP_COL_MAX); + EXPP_LAMP_COL_MAX); if (!strcmp(key, "R")) self->lamp->r = value; @@ -789,13 +789,13 @@ static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key, else if (!strcmp(key, "B")) self->lamp->b = value; - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(Py_None); + return Py_None; } static PyObject *Lamp_setCol(C_Lamp *self, PyObject *args) { - return rgbTuple_setCol(self->color, args); + return rgbTuple_setCol(self->color, args); } /*****************************************************************************/ @@ -836,8 +836,8 @@ static PyObject *LampGetAttr (C_Lamp *self, char *name) attr = PyFloat_FromDouble(self->lamp->g); else if (strcmp(name, "B") == 0) attr = PyFloat_FromDouble(self->lamp->b); - else if (strcmp(name, "col") == 0) - attr = Lamp_getCol(self); + else if (strcmp(name, "col") == 0) + attr = Lamp_getCol(self); else if (strcmp(name, "energy") == 0) attr = PyFloat_FromDouble(self->lamp->energy); else if (strcmp(name, "dist") == 0) @@ -992,8 +992,8 @@ static int LampSetAttr (C_Lamp *self, char *name, PyObject *value) /*****************************************************************************/ static int LampCompare (C_Lamp *a, C_Lamp *b) { - Lamp *pa = a->lamp, *pb = b->lamp; - return (pa == pb) ? 0:-1; + Lamp *pa = a->lamp, *pb = b->lamp; + return (pa == pb) ? 0:-1; } /*****************************************************************************/ diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c index 0285d72e10f..629d1868425 100644 --- a/source/blender/python/api2_2x/Metaball.c +++ b/source/blender/python/api2_2x/Metaball.c @@ -111,7 +111,7 @@ static PyObject *M_Metaball_Get(PyObject *self, PyObject *args) else { /* () - return a list of all mballs in the scene */ int index = 0; - PyObject *mballlist, *pystr; + PyObject *mballlist, *pyobj; mballlist = PyList_New (BLI_countlist (&(G.main->mball))); @@ -120,13 +120,13 @@ static PyObject *M_Metaball_Get(PyObject *self, PyObject *args) "couldn't create PyList")); while (mball_iter) { - pystr = PyString_FromString (mball_iter->id.name+2); + pyobj = Metaball_CreatePyObject (mball_iter); - if (!pystr) + if (!pyobj) return (PythonReturnErrorObject (PyExc_MemoryError, "couldn't create PyString")); - PyList_SET_ITEM (mballlist, index, pystr); + PyList_SET_ITEM (mballlist, index, pyobj); mball_iter = mball_iter->id.next; index++; @@ -1039,3 +1039,44 @@ static PyObject *MetaballRepr (C_Metaball *self) return PyString_FromString(self->metaball->id.name+2); } +/* Three Python Metaball_Type helper functions needed by the Object module: */ + +/*****************************************************************************/ +/* Function: Metaball_CreatePyObject */ +/* Description: This function will create a new C_Metaball from an existing */ +/* Blender metaball structure. */ +/*****************************************************************************/ +PyObject *Metaball_CreatePyObject (MetaBall *metaball) +{ + C_Metaball *pymetaball; + + pymetaball = (C_Metaball *)PyObject_NEW (C_Metaball, &Metaball_Type); + + if (!pymetaball) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create C_Metaball object"); + + pymetaball->metaball = metaball; + + return (PyObject *)pymetaball; +} + +/*****************************************************************************/ +/* Function: Metaball_CheckPyObject */ +/* Description: This function returns true when the given PyObject is of the */ +/* type Metaball. Otherwise it will return false. */ +/*****************************************************************************/ +int Metaball_CheckPyObject (PyObject *pyobj) +{ + return (pyobj->ob_type == &Metaball_Type); +} + +/*****************************************************************************/ +/* Function: Metaball_FromPyObject */ +/* Description: This function returns the Blender metaball from the given */ +/* PyObject. */ +/*****************************************************************************/ +MetaBall *Metaball_FromPyObject (PyObject *pyobj) +{ + return ((C_Metaball *)pyobj)->metaball; +} diff --git a/source/blender/python/api2_2x/Metaball.h b/source/blender/python/api2_2x/Metaball.h index 02ffdd2d3f2..919cbe234b0 100644 --- a/source/blender/python/api2_2x/Metaball.h +++ b/source/blender/python/api2_2x/Metaball.h @@ -278,7 +278,7 @@ static PyObject *MetaballRepr (C_Metaball *self); /*****************************************************************************/ /* Python Metaball_Type structure definition: */ /*****************************************************************************/ -static PyTypeObject Metaball_Type = +PyTypeObject Metaball_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 28ef37ded1e..2bc2b009496 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -46,7 +46,7 @@ void mesh_update(Mesh *mesh) static void NMCol_dealloc(PyObject *self) { - PyMem_DEL(self); /* XXX PyObject_Del ?*/ + PyObject_DEL(self); /* XXX PyObject_Del ?*/ } static C_NMCol *newcol (char r, char g, char b, char a) @@ -144,7 +144,7 @@ static void NMFace_dealloc (PyObject *self) Py_DECREF(mf->col); Py_XDECREF(mf->image); - PyMem_DEL(self); + PyObject_DEL(self); } static C_NMFace *new_NMFace(PyObject *vertexlist) @@ -393,7 +393,7 @@ static PyObject *M_NMesh_Vert(PyObject *self, PyObject *args) static void NMVert_dealloc(PyObject *self) { - PyMem_DEL(self); + PyObject_DEL(self); } static PyObject *NMVert_getattr(PyObject *self, char *name) @@ -545,7 +545,7 @@ static void NMesh_dealloc(PyObject *self) Py_DECREF(me->verts); Py_DECREF(me->faces); - PyMem_DEL(self); + PyObject_DEL(self); } static PyObject *NMesh_getSelectedFaces(PyObject *self, PyObject *args) diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h index fa10beffb3a..860de6cfdac 100644 --- a/source/blender/python/api2_2x/NMesh.h +++ b/source/blender/python/api2_2x/NMesh.h @@ -73,7 +73,7 @@ PyTypeObject NMFace_Type; PyTypeObject NMVert_Type; PyTypeObject NMCol_Type; -PyTypeObject Image_Type; +extern PyTypeObject Image_Type; /* Globals */ diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 1c58227da14..ed5d536a1df 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -567,13 +567,13 @@ static PyObject *Object_getData (C_Object *self) //#obj_id = MAKE_ID2 (id->name[0], id->name[1]); switch (self->object->type)//#obj_id) { - case ID_AR: + case OB_ARMATURE://#ID_AR: data_object = M_ArmatureCreatePyObject (self->object->data); break; - case OB_CAMERA://#ID_CA: + case OB_CAMERA://#ID_CA: data_object = Camera_CreatePyObject (self->object->data); break; - case ID_CU: + case OB_CURVE://#ID_CU: data_object = CurveCreatePyObject (self->object->data); break; case ID_IM: @@ -581,12 +581,13 @@ static PyObject *Object_getData (C_Object *self) break; case ID_IP: break; - case ID_LA: + case OB_LAMP://#ID_LA: data_object = Lamp_CreatePyObject (self->object->data); break; case ID_MA: break; - case ID_ME: + case OB_MESH://#ID_ME: + data_object = NMesh_CreatePyObject (self->object->data); break; case ID_OB: data_object = M_ObjectCreatePyObject (self->object->data); @@ -1291,7 +1292,7 @@ static PyObject* ObjectGetAttr (C_Object *obj, char *name) if (StringEqual (name, "drawMode")) return (Py_BuildValue ("b", object->dtx)); - /* not an attribute, search the methods table */ + /* not an attribute, search the methods table */ return Py_FindMethod(C_Object_methods, (PyObject *)obj, name); } diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index 273a512c232..b1be2647874 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -295,30 +295,30 @@ static PyObject *M_Scene_Get(PyObject *self, PyObject *args) return wanted_scene; } - else { /* () - return a list of all scenes in Blender */ + else { /* () - return a list with wrappers for all scenes in Blender */ int index = 0; - PyObject *scenelist, *pystr; + PyObject *sce_pylist, *pyobj; - scenelist = PyList_New (BLI_countlist (&(G.main->scene))); + sce_pylist = PyList_New (BLI_countlist (&(G.main->scene))); - if (scenelist == NULL) + if (sce_pylist == NULL) return (PythonReturnErrorObject (PyExc_MemoryError, "couldn't create PyList")); while (scene_iter) { - pystr = PyString_FromString (scene_iter->id.name+2); + pyobj = Scene_CreatePyObject (scene_iter); - if (!pystr) + if (!pyobj) return (PythonReturnErrorObject (PyExc_MemoryError, "couldn't create PyString")); - PyList_SET_ITEM (scenelist, index, pystr); + PyList_SET_ITEM (sce_pylist, index, pyobj); scene_iter = scene_iter->id.next; index++; } - return scenelist; + return sce_pylist; } } diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h index 80311f06a15..be3df043f31 100644 --- a/source/blender/python/api2_2x/Text.h +++ b/source/blender/python/api2_2x/Text.h @@ -51,7 +51,7 @@ #define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW /*****************************************************************************/ -/* Python API function prototypes for the Text module. */ +/* Python API function prototypes for the Text module. */ /*****************************************************************************/ static PyObject *M_Text_New (PyObject *self, PyObject *args, PyObject *keywords); @@ -62,7 +62,7 @@ static PyObject *M_Text_unlink (PyObject *self, PyObject *args); /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ /* In Python these will be written to the console when doing a */ -/* Blender.Text.__doc__ */ +/* Blender.Text.__doc__ */ /*****************************************************************************/ static char M_Text_doc[] = "The Blender Text module\n\n"; @@ -83,7 +83,7 @@ static char M_Text_unlink_doc[] = "(text) - remove text object 'text' from the text window"; /*****************************************************************************/ -/* Python method structure definition for Blender.Text module: */ +/* Python method structure definition for Blender.Text module: */ /*****************************************************************************/ struct PyMethodDef M_Text_methods[] = { {"New",(PyCFunction)M_Text_New, METH_VARARGS|METH_KEYWORDS, @@ -96,15 +96,16 @@ struct PyMethodDef M_Text_methods[] = { }; /*****************************************************************************/ -/* Python C_Text structure definition: */ +/* Python C_Text structure definition: */ /*****************************************************************************/ typedef struct { PyObject_HEAD Text *text; + } C_Text; /*****************************************************************************/ -/* Python C_Text methods declarations: */ +/* Python C_Text methods declarations: */ /*****************************************************************************/ static PyObject *Text_getName(C_Text *self); static PyObject *Text_getFilename(C_Text *self); @@ -116,7 +117,7 @@ static PyObject *Text_set(C_Text *self, PyObject *args); static PyObject *Text_asLines(C_Text *self, PyObject *args); /*****************************************************************************/ -/* Python C_Text methods table: */ +/* Python C_Text methods table: */ /*****************************************************************************/ static PyMethodDef C_Text_methods[] = { /* name, method, flags, doc */ @@ -140,7 +141,7 @@ static PyMethodDef C_Text_methods[] = { }; /*****************************************************************************/ -/* Python Text_Type callback function prototypes: */ +/* Python Text_Type callback function prototypes: */ /*****************************************************************************/ static void TextDeAlloc (C_Text *self); static int TextPrint (C_Text *self, FILE *fp, int flags); @@ -150,7 +151,7 @@ static int TextCompare (C_Text *a, C_Text *b); static PyObject *TextRepr (C_Text *self); /*****************************************************************************/ -/* Python Text_Type structure definition: */ +/* Python Text_Type structure definition: */ /*****************************************************************************/ PyTypeObject Text_Type = { diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c index 7aa5c64ed14..2a22c59c014 100644 --- a/source/blender/python/api2_2x/Types.c +++ b/source/blender/python/api2_2x/Types.c @@ -40,35 +40,50 @@ PyObject *M_Types_Init (void) { PyObject *submodule, *dict; - submodule = Py_InitModule3("Blender.Types", Null_methods, M_Types_doc); + /* These are only set when some object initializes them. But unless we + * do it now, we get two easy ways to crash Blender. Maybe we'd better + * have an Init function for all these internal types that more than one + * module can use. We could call it after setting the Blender dictionary */ + vector_Type.ob_type = &PyType_Type; + rgbTuple_Type.ob_type = &PyType_Type; + constant_Type.ob_type = &PyType_Type; - dict = PyModule_GetDict(submodule); + submodule = Py_InitModule3 ("Blender.Types", Null_methods, M_Types_doc); + + dict = PyModule_GetDict(submodule); /* The Blender Object Type */ - PyDict_SetItemString(dict, "ObjectType", (PyObject *)&Object_Type); + PyDict_SetItemString(dict, "ObjectType", (PyObject *)&Object_Type); /* Blender Object Data Types */ - PyDict_SetItemString(dict, "NMeshType", (PyObject *)&NMesh_Type); - PyDict_SetItemString(dict, "NMFaceType", (PyObject *)&NMFace_Type); - PyDict_SetItemString(dict, "NMVertType", (PyObject *)&NMVert_Type); - PyDict_SetItemString(dict, "NMColType", (PyObject *)&NMCol_Type); + PyDict_SetItemString(dict, "NMeshType", (PyObject *)&NMesh_Type); + PyDict_SetItemString(dict, "NMFaceType", (PyObject *)&NMFace_Type); + PyDict_SetItemString(dict, "NMVertType", (PyObject *)&NMVert_Type); + PyDict_SetItemString(dict, "NMColType", (PyObject *)&NMCol_Type); + + PyDict_SetItemString(dict, "ArmatureType", (PyObject *)&Armature_Type); + PyDict_SetItemString(dict, "BoneType", (PyObject *)&Bone_Type); + + PyDict_SetItemString(dict, "CurveType", (PyObject *)&Curve_Type); + PyDict_SetItemString(dict, "IpoType", (PyObject *)&Ipo_Type); + PyDict_SetItemString(dict, "MetaballType", (PyObject *)&Metaball_Type); - PyDict_SetItemString(dict, "CameraType", (PyObject *)&Camera_Type); - PyDict_SetItemString(dict, "ImageType", (PyObject *)&Image_Type); - PyDict_SetItemString(dict, "LampType", (PyObject *)&Lamp_Type); - PyDict_SetItemString(dict, "TextType", (PyObject *)&Text_Type); + PyDict_SetItemString(dict, "CameraType", (PyObject *)&Camera_Type); + PyDict_SetItemString(dict, "ImageType", (PyObject *)&Image_Type); + PyDict_SetItemString(dict, "LampType", (PyObject *)&Lamp_Type); + PyDict_SetItemString(dict, "TextType", (PyObject *)&Text_Type); + PyDict_SetItemString(dict, "MaterialType", (PyObject *)&Material_Type); - PyDict_SetItemString(dict, "ButtonType", (PyObject *)&Button_Type); - PyDict_SetItemString(dict, "MaterialType",(PyObject *)&Material_Type); + PyDict_SetItemString(dict, "ButtonType", (PyObject *)&Button_Type); /* External helper Types available to the main ones above */ - PyDict_SetItemString(dict, "vectorType", (PyObject *)&vector_Type); - PyDict_SetItemString(dict, "bufferType", (PyObject *)&buffer_Type); - PyDict_SetItemString(dict, "constantType", (PyObject *)&constant_Type); - PyDict_SetItemString(dict, "rgbTupleType", (PyObject *)&rgbTuple_Type); + PyDict_SetItemString(dict, "vectorType", (PyObject *)&vector_Type); + PyDict_SetItemString(dict, "bufferType", (PyObject *)&buffer_Type); + PyDict_SetItemString(dict, "constantType", (PyObject *)&constant_Type); + PyDict_SetItemString(dict, "rgbTupleType", (PyObject *)&rgbTuple_Type); - return (submodule); + return submodule; } diff --git a/source/blender/python/api2_2x/Types.h b/source/blender/python/api2_2x/Types.h index fe8d256008f..7cc126dc4db 100644 --- a/source/blender/python/api2_2x/Types.h +++ b/source/blender/python/api2_2x/Types.h @@ -39,6 +39,8 @@ extern PyTypeObject Button_Type, Material_Type; extern PyTypeObject Object_Type; extern PyTypeObject NMesh_Type, NMFace_Type, NMVert_Type, NMCol_Type; extern PyTypeObject Camera_Type, Lamp_Type, Image_Type, Text_Type; +extern PyTypeObject Armature_Type, Bone_Type; +extern PyTypeObject Curve_Type, Ipo_Type, Metaball_Type; extern PyTypeObject vector_Type, buffer_Type, rgbTuple_Type, constant_Type; diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c index 765a3d6e24a..14c663434ba 100644 --- a/source/blender/python/api2_2x/vector.c +++ b/source/blender/python/api2_2x/vector.c @@ -39,7 +39,7 @@ static void Vector_dealloc(VectorObject *self) { - PyMem_DEL(self); + PyObject_DEL (self); } static PyObject *Vector_getattr(VectorObject *self, char *name) @@ -195,7 +195,7 @@ PyTypeObject vector_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "Vector", /*tp_name*/ + "vector", /*tp_name*/ sizeof(VectorObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ @@ -213,7 +213,7 @@ PyObject *newVectorObject(float *vec, int size) { VectorObject *self; - vector_Type.ob_type = &PyType_Type; + vector_Type.ob_type = &PyType_Type; self= PyObject_NEW(VectorObject, &vector_Type); -- cgit v1.2.3