diff options
24 files changed, 325 insertions, 95 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c index 800124ddc7e..5e98241626f 100644 --- a/source/blender/python/api2_2x/Armature.c +++ b/source/blender/python/api2_2x/Armature.c @@ -159,6 +159,8 @@ PyObject *M_Armature_Init (void) printf ("In M_Armature_Init()\n"); + Armature_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Armature", M_Armature_methods, M_Armature_doc); diff --git a/source/blender/python/api2_2x/Armature.h b/source/blender/python/api2_2x/Armature.h index 17a3a4d36b2..60d9fd42cfb 100644 --- a/source/blender/python/api2_2x/Armature.h +++ b/source/blender/python/api2_2x/Armature.h @@ -139,7 +139,7 @@ static int ArmaturePrint (C_Armature *armature, FILE *fp, int flags); /*****************************************************************************/ static PyTypeObject Armature_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Armature", /* tp_name */ sizeof (C_Armature), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c index 0f45770c4c8..21451f10272 100644 --- a/source/blender/python/api2_2x/BGL.c +++ b/source/blender/python/api2_2x/BGL.c @@ -1000,6 +1000,8 @@ static struct PyMethodDef BGL_methods[] = { PyObject *M_BGL_Init(void) { + buffer_Type.ob_type = &PyType_Type; + PyObject *mod= Py_InitModule("Blender.BGL", BGL_methods); PyObject *dict= PyModule_GetDict(mod); diff --git a/source/blender/python/api2_2x/BGL.h b/source/blender/python/api2_2x/BGL.h index 8def0e78f8e..c81e8eba02e 100644 --- a/source/blender/python/api2_2x/BGL.h +++ b/source/blender/python/api2_2x/BGL.h @@ -136,7 +136,7 @@ static PyObject *Buffer_getattr(PyObject *self, char *name); static PyObject *Buffer_repr(PyObject *self); PyTypeObject buffer_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "Buffer", /*tp_name*/ sizeof(Buffer), /*tp_basicsize*/ diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index ca9b6764220..c6161ee3206 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -148,7 +148,7 @@ static int BonePrint (C_Bone *bone, FILE *fp, int flags); /*****************************************************************************/ static PyTypeObject Bone_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Bone", /* tp_name */ sizeof (C_Bone), /* tp_basicsize */ @@ -224,6 +224,8 @@ PyObject *M_Bone_Init (void) { PyObject *submodule; + Bone_Type.ob_type = &PyType_Type; + printf ("In M_Bone_Init()\n"); submodule = Py_InitModule3("Blender.Armature.Bone", diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c index 836b5408d87..a629ed48c86 100644 --- a/source/blender/python/api2_2x/Camera.c +++ b/source/blender/python/api2_2x/Camera.c @@ -161,6 +161,9 @@ PyObject *M_Camera_Init (void) PyObject *submodule; printf ("In M_Camera_Init()\n"); + + Camera_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Camera", M_Camera_methods, M_Camera_doc); diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h index e297d485a92..282b20f3f01 100644 --- a/source/blender/python/api2_2x/Camera.h +++ b/source/blender/python/api2_2x/Camera.h @@ -203,7 +203,7 @@ int CameraCheckPyObject (PyObject *pyobj); /*****************************************************************************/ PyTypeObject Camera_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Camera", /* tp_name */ sizeof (C_Camera), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c index c1400bce146..bc9a9571f70 100644 --- a/source/blender/python/api2_2x/Curve.c +++ b/source/blender/python/api2_2x/Curve.c @@ -145,6 +145,9 @@ PyObject *M_Curve_Init (void) { PyObject *submodule; printf ("In M_Curve_Init()\n"); + + Curve_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Curve",M_Curve_methods, M_Curve_doc); return (submodule); } diff --git a/source/blender/python/api2_2x/Curve.h b/source/blender/python/api2_2x/Curve.h index 37d86e408e5..c0921bead78 100644 --- a/source/blender/python/api2_2x/Curve.h +++ b/source/blender/python/api2_2x/Curve.h @@ -200,7 +200,7 @@ struct Curve* CurveFromPyObject (PyObject *py_obj); /*****************************************************************************/ static PyTypeObject Curve_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Curve", /* tp_name */ sizeof (C_Curve), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index f9feaf398de..c82a00a664b 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -637,6 +637,8 @@ PyObject *M_Draw_Init (void) printf("In M_Draw_Init()\n"); + Button_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Draw", Draw_methods, Draw_doc); dict= PyModule_GetDict(submodule); diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h index 1d3cfe0c1cb..8a4cdfa3cbb 100644 --- a/source/blender/python/api2_2x/Draw.h +++ b/source/blender/python/api2_2x/Draw.h @@ -102,7 +102,7 @@ static PyObject *Button_repr(PyObject *self); PyTypeObject Button_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "Button", /*tp_name*/ sizeof(Button), /*tp_basicsize*/ diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 809ca3456b5..9da15c94e4e 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -210,6 +210,8 @@ PyObject *M_Image_Init (void) { PyObject *submodule; + Image_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Image", M_Image_methods, M_Image_doc); return (submodule); @@ -261,7 +263,7 @@ static PyObject *Image_Repr (C_Image *self); /*****************************************************************************/ PyTypeObject Image_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Image", /* tp_name */ sizeof (C_Image), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 15b41e3698b..dd61dbd6c96 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -200,6 +200,8 @@ PyObject *M_Lamp_Init (void) { PyObject *submodule, *Types, *Modes; + Lamp_Type.ob_type = &PyType_Type; + Types = M_Lamp_TypesDict (); Modes = M_Lamp_ModesDict (); diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h index 36b899c908c..ddb8f87b29e 100644 --- a/source/blender/python/api2_2x/Lamp.h +++ b/source/blender/python/api2_2x/Lamp.h @@ -303,7 +303,7 @@ int LampCheckPyObject (PyObject *pyobj); /*****************************************************************************/ PyTypeObject Lamp_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Lamp", /* tp_name */ sizeof (C_Lamp), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index cbfe6d7618c..2d909d69c4a 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -250,6 +250,8 @@ PyObject *M_Material_Init (void) { PyObject *submodule; + Material_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Material", M_Material_methods, M_Material_doc); @@ -436,7 +438,7 @@ static PyObject *Material_Repr (C_Material *self); /*****************************************************************************/ PyTypeObject Material_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Material", /* tp_name */ sizeof (C_Material), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index dfc3ffed3ad..6a86fba9812 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -110,7 +110,7 @@ PyObject *NMCol_repr(C_NMCol *self) PyTypeObject NMCol_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "NMCol", /* tp_name */ sizeof(C_NMCol), /* tp_basicsize */ @@ -350,7 +350,7 @@ static PySequenceMethods NMFace_SeqMethods = PyTypeObject NMFace_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "NMFace", /*tp_name*/ sizeof(C_NMFace), /*tp_basicsize*/ @@ -521,7 +521,7 @@ static PySequenceMethods NMVert_SeqMethods = PyTypeObject NMVert_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "NMVert", /*tp_name*/ sizeof(C_NMVert), /*tp_basicsize*/ @@ -851,7 +851,7 @@ static int NMesh_setattr(PyObject *self, char *name, PyObject *v) PyTypeObject NMesh_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "NMesh", /*tp_name*/ sizeof(C_NMesh), /*tp_basicsize*/ @@ -1667,6 +1667,11 @@ PyObject *M_NMesh_Init (void) PyObject *FaceModes = M_NMesh_FaceModesDict (); PyObject *FaceTranspModes = M_NMesh_FaceTranspModesDict (); + NMCol_Type.ob_type = &PyType_Type; + NMFace_Type.ob_type = &PyType_Type; + NMVert_Type.ob_type = &PyType_Type; + NMesh_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.NMesh", M_NMesh_methods, M_NMesh_doc); if (FaceFlags) PyModule_AddObject (submodule, "FaceFlags" , FaceFlags); diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 71d8823faea..fb9bf671126 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -40,34 +40,42 @@ PyObject *M_Object_New(PyObject *self, PyObject *args) struct Object * object; C_Object * blen_object; int type; - char name[32]; + char * str_type; + char * name = NULL; printf ("In Object_New()\n"); - if (!PyArg_ParseTuple(args, "i", &type)) + if (!PyArg_ParseTuple(args, "s|s", &str_type, &name)) { PythonReturnErrorObject (PyExc_TypeError, - "type expected"); + "string expected as argument"); return (NULL); } - /* Create a new object. */ - switch (type) + if (strcmp (str_type, "Armature") == 0) type = OB_ARMATURE; + else if (strcmp (str_type, "Camera") == 0) type = OB_CAMERA; + else if (strcmp (str_type, "Curve") == 0) type = OB_CURVE; +/* else if (strcmp (str_type, "Text") == 0) type = OB_FONT; */ +/* else if (strcmp (str_type, "Ika") == 0) type = OB_IKA; */ + else if (strcmp (str_type, "Lamp") == 0) type = OB_LAMP; +/* else if (strcmp (str_type, "Lattice") == 0) type = OB_LATTICE; */ +/* else if (strcmp (str_type, "Mball") == 0) type = OB_MBALL; */ + else if (strcmp (str_type, "Mesh") == 0) type = OB_MESH; +/* else if (strcmp (str_type, "Surf") == 0) type = OB_SURF; */ +/* else if (strcmp (str_type, "Wave") == 0) type = OB_WAVE; */ + else if (strcmp (str_type, "Empty") == 0) type = OB_EMPTY; + else { - case OB_MESH: strcpy (name, "Mesh"); break; - case OB_CURVE: strcpy (name, "Curve"); break; - case OB_SURF: strcpy (name, "Surf"); break; - case OB_FONT: strcpy (name, "Text"); break; - case OB_MBALL: strcpy (name, "Mball"); break; - case OB_CAMERA: strcpy (name, "Camera"); break; - case OB_LAMP: strcpy (name, "Lamp"); break; - case OB_IKA: strcpy (name, "Ika"); break; - case OB_LATTICE: strcpy (name, "Lattice"); break; - case OB_WAVE: strcpy (name, "Wave"); break; - case OB_ARMATURE: strcpy (name, "Armature"); break; - default: strcpy (name, "Empty"); + return (PythonReturnErrorObject (PyExc_AttributeError, + "Unknown type specified")); } + /* Create a new object. */ + if (name == NULL) + { + /* No name is specified, set the name to the type of the object. */ + name = str_type; + } object = alloc_libblock (&(G.main->object), ID_OB, name); object->flag = 0; @@ -123,23 +131,28 @@ PyObject *M_Object_New(PyObject *self, PyObject *args) switch(type) { - case OB_MESH: - object->data = add_mesh(); - G.totmesh++; + case OB_ARMATURE: + /* TODO: Do we need to add something to G? (see the OB_LAMP case) */ + object->data = add_armature(); break; case OB_CAMERA: + /* TODO: Do we need to add something to G? (see the OB_LAMP case) */ object->data = add_camera(); break; + case OB_CURVE: + object->data = add_curve(OB_CURVE); + G.totcurve++; + break; case OB_LAMP: object->data = add_lamp(); G.totlamp++; break; + case OB_MESH: + object->data = add_mesh(); + G.totmesh++; + break; /* TODO the following types will be supported later - case OB_CURVE: - object->data = add_curve(OB_CURVE); - G.totcurve++; - break; case OB_SURF: object->data = add_curve(OB_SURF); G.totcurve++; @@ -161,9 +174,6 @@ PyObject *M_Object_New(PyObject *self, PyObject *args) case OB_WAVE: object->data = add_wave(); break; - case OB_ARMATURE: - object->data = add_armature(); - break; */ } @@ -306,6 +316,8 @@ PyObject *M_Object_Init (void) printf ("In initObject()\n"); + Object_Type.ob_type = &PyType_Type; + module = Py_InitModule3("Object", M_Object_methods, M_Object_doc); return (module); @@ -370,6 +382,9 @@ static PyObject *Object_getData (C_Object *self) obj_id = MAKE_ID2 (id->name[0], id->name[1]); switch (obj_id) { + case ID_AR: + data_object = M_ArmatureCreatePyObject (self->object->data); + break; case ID_CA: data_object = Camera_createPyObject (self->object->data); break; @@ -377,6 +392,7 @@ static PyObject *Object_getData (C_Object *self) data_object = CurveCreatePyObject (self->object->data); break; case ID_IM: + data_object = Image_CreatePyObject (self->object->data); break; case ID_IP: break; @@ -432,21 +448,22 @@ static PyObject *Object_getDeltaLocation (C_Object *self) static PyObject *Object_getDrawMode (C_Object *self) { - return (Py_None); + PyObject *attr = Py_BuildValue ("b", self->object->dtx); + + if (attr) return (attr); + + return (PythonReturnErrorObject (PyExc_RuntimeError, + "couldn't get Object.drawMode attribute")); } static PyObject *Object_getDrawType (C_Object *self) { - /* TODO: this needs to be verified, if the api is correct! */ -/* PyObject *attr = Py_BuildValue ("b", self->object->dt); if (attr) return (attr); return (PythonReturnErrorObject (PyExc_RuntimeError, "couldn't get Object.drawType attribute")); -*/ - return (Py_None); } static PyObject *Object_getEuler (C_Object *self) @@ -539,7 +556,22 @@ static PyObject *Object_getTracked (C_Object *self) static PyObject *Object_getType (C_Object *self) { - return (Py_None); + switch (self->object->type) + { + case OB_ARMATURE: return (Py_BuildValue ("s", "Armature")); + case OB_CAMERA: return (Py_BuildValue ("s", "Camera")); + case OB_CURVE: return (Py_BuildValue ("s", "Curve")); + case OB_EMPTY: return (Py_BuildValue ("s", "Empty")); + case OB_FONT: return (Py_BuildValue ("s", "Text")); + case OB_IKA: return (Py_BuildValue ("s", "Ika")); + case OB_LAMP: return (Py_BuildValue ("s", "Lamp")); + case OB_LATTICE: return (Py_BuildValue ("s", "Lattice")); + case OB_MBALL: return (Py_BuildValue ("s", "MBall")); + case OB_MESH: return (Py_BuildValue ("s", "Mesh")); + case OB_SURF: return (Py_BuildValue ("s", "Surf")); + case OB_WAVE: return (Py_BuildValue ("s", "Wave")); + default: return (Py_BuildValue ("s", "unknown")); + } } static PyObject *Object_link (C_Object *self, PyObject *args) @@ -567,22 +599,22 @@ static PyObject *Object_link (C_Object *self, PyObject *args) switch (obj_id) { - case ID_ME: - if (self->object->type != OB_MESH) + case ID_CA: + if (self->object->type != OB_CAMERA) { return (PythonReturnErrorObject (PyExc_AttributeError, "The 'link' object is incompatible with the base object")); } break; - case ID_CA: - if (self->object->type != OB_CAMERA) + case ID_LA: + if (self->object->type != OB_LAMP) { return (PythonReturnErrorObject (PyExc_AttributeError, "The 'link' object is incompatible with the base object")); } break; - case ID_LA: - if (self->object->type != OB_LAMP) + case ID_ME: + if (self->object->type != OB_MESH) { return (PythonReturnErrorObject (PyExc_AttributeError, "The 'link' object is incompatible with the base object")); @@ -597,9 +629,9 @@ static PyObject *Object_link (C_Object *self, PyObject *args) id_us_plus (id); if (oldid) { - if (id->us > 0) + if (oldid->us > 0) { - id->us--; + oldid->us--; } else { @@ -694,7 +726,7 @@ static PyObject *Object_setDeltaLocation (C_Object *self, PyObject *args) if (!PyArg_Parse (args, "fff", &dloc1, &dloc2, &dloc3)) { - return (PythonReturnErrorObject (PyExc_TypeError, + return (PythonReturnErrorObject (PyExc_AttributeError, "expected three float arguments")); } @@ -708,11 +740,31 @@ static PyObject *Object_setDeltaLocation (C_Object *self, PyObject *args) static PyObject *Object_setDrawMode (C_Object *self, PyObject *args) { + char dt; + + if (!PyArg_Parse (args, "b", &dt)) + { + return (PythonReturnErrorObject (PyExc_AttributeError, + "expected an integer as argument")); + } + self->object->dt = dt; + + Py_INCREF (Py_None); return (Py_None); } static PyObject *Object_setDrawType (C_Object *self, PyObject *args) -{ +{ + char dtx; + + if (!PyArg_Parse (args, "b", &dtx)) + { + return (PythonReturnErrorObject (PyExc_AttributeError, + "expected an integer as argument")); + } + self->object->dtx = dtx; + + Py_INCREF (Py_None); return (Py_None); } @@ -724,7 +776,7 @@ static PyObject *Object_setEuler (C_Object *self, PyObject *args) if (!PyArg_Parse (args, "fff", &drot1, &drot2, &drot3)) { - return (PythonReturnErrorObject (PyExc_TypeError, + return (PythonReturnErrorObject (PyExc_AttributeError, "expected three float arguments")); } @@ -744,7 +796,7 @@ static PyObject *Object_setLocation (C_Object *self, PyObject *args) if (!PyArg_Parse (args, "fff", &loc1, &loc2, &loc3)) { - return (PythonReturnErrorObject (PyExc_TypeError, + return (PythonReturnErrorObject (PyExc_AttributeError, "expected three float arguments")); } @@ -758,11 +810,123 @@ static PyObject *Object_setLocation (C_Object *self, PyObject *args) static PyObject *Object_setMaterials (C_Object *self, PyObject *args) { +#if 0 + PyObject * list; + int len; + int i; + Material ** matlist; + + if (!PyArg_Parse (args, "O", &list)) + { + return (PythonReturnErrorObject (PyExc_AttributeError, + "expected a list of materials as argument")); + } + + len = PySequence_Length (list); + if (len > 0) + { + matlist = EXPP_newMaterialList_fromPyList (list); + if (!matlist) + { + return (PythonReturnErrorObject (PyExc_AttributeError, + "material list must be a list of valid materials!")); + } + if ((len < 0) || (len > MAXMAT)) + { + return (PythonReturnErrorObject (PyExc_RuntimeError, + "illegal material index!")); + } + + if (self->object->mat) + { + /* TODO: create replacement function */ + releaseMaterialList (self->object->mat, len); + } + /* Increase the user count on all materials */ + for (i=0 ; i<len ; i++) + { + id_us_plus ((ID *) matlist[i]); + } + self->object->mat = matlist; + self->object->totcol = len; + self->object->actcol = -1; + + switch (self->object->type) + { + case OB_CURVE: /* fall through */ + case OB_FONT: /* fall through */ + case OB_MESH: /* fall through */ + case OB_MBALL: /* fall through */ + case OB_SURF + /* TODO: create replacement function */: + synchronizeMaterialLists (self->object, self->object->data); + break; + default: + break; + } + } +#endif + + Py_INCREF (Py_None); return (Py_None); } static PyObject *Object_shareFrom (C_Object *self, PyObject *args) { + C_Object * object; + ID * id; + ID * oldid; + + if (!PyArg_Parse (args, "O", &object)) + { + PythonReturnErrorObject (PyExc_AttributeError, + "expected an object argument"); + return (NULL); + } + if (!M_ObjectCheckPyObject ((PyObject*)object)) + { + PythonReturnErrorObject (PyExc_TypeError, + "argument 1 is not of type 'Object'"); + return (NULL); + } + + if (self->object->type != object->object->type) + { + PythonReturnErrorObject (PyExc_TypeError, + "objects are not of same data type"); + return (NULL); + } + switch (self->object->type) + { + case OB_MESH: + oldid = (ID*) self->object->data; + id = (ID*) object->data; + self->object->data = object->data; + if (self->data != NULL) + { + Py_DECREF (self->data); + self->data = NULL; + } + id_us_plus (id); + if (oldid) + { + if (oldid->us > 0) + { + oldid->us--; + } + else + { + return (PythonReturnErrorObject (PyExc_RuntimeError, + "old object reference count below 0")); + } + } + Py_INCREF (Py_None); + return (Py_None); + default: + PythonReturnErrorObject (PyExc_TypeError, + "type not supported"); + return (NULL); + } return (Py_None); } @@ -1081,9 +1245,19 @@ static int ObjectSetAttr (C_Object *obj, char *name, PyObject *value) if (StringEqual (name, "colbits")) return (!PyArg_Parse (value, "h", &(object->colbits))); if (StringEqual (name, "drawType")) - return (!PyArg_Parse (value, "b", &(object->dt))); + { + if (Object_setDrawType (obj, value) != Py_None) + return (-1); + else + return (0); + } if (StringEqual (name, "drawMode")) - return (!PyArg_Parse (value, "b", &(object->dtx))); + { + if (Object_setDrawMode (obj, value) != Py_None) + return (-1); + else + return (0); + } printf ("Unknown variable.\n"); return (0); diff --git a/source/blender/python/api2_2x/Object.h b/source/blender/python/api2_2x/Object.h index 08316739b10..65fbcc33ac2 100644 --- a/source/blender/python/api2_2x/Object.h +++ b/source/blender/python/api2_2x/Object.h @@ -36,6 +36,8 @@ #include <stdio.h> #include <BDR_editobject.h> +#include <BKE_armature.h> +#include <BKE_curve.h> #include <BKE_global.h> #include <BKE_library.h> #include <BKE_main.h> @@ -44,6 +46,7 @@ #include <BKE_scene.h> #include <BLI_arithb.h> #include <BLI_blenlib.h> +#include <DNA_armature_types.h> #include <DNA_ID.h> #include <DNA_ika_types.h> #include <DNA_listBase.h> @@ -155,53 +158,73 @@ static PyObject *Object_shareFrom (C_Object *self, PyObject *args); static PyMethodDef C_Object_methods[] = { /* name, method, flags, doc */ {"clrParent", (PyCFunction)Object_clrParent, METH_VARARGS, - "(x) - "}, + "Clears parent object. Optionally specify:\n\ +mode\n\t2: Keep object transform\nfast\n\t>0: Don't update scene \ +hierarchy (faster)"}, {"getData", (PyCFunction)Object_getData, METH_NOARGS, - "(x) - "}, + "Returns the datablock object containing the object's data, \ +e.g. Mesh"}, {"getDeformData", (PyCFunction)Object_getDeformData, METH_NOARGS, - "(x) - "}, + "Returns the datablock object containing the object's deformed \ +data.\nCurrently, this is only supported for a Mesh"}, {"getDeltaLocation", (PyCFunction)Object_getDeltaLocation, METH_NOARGS, - "(x) - "}, + "Returns the object's delta location (x, y, z)"}, {"getDrawMode", (PyCFunction)Object_getDrawMode, METH_NOARGS, - "(x) - "}, + "Returns the object draw modes"}, {"getDrawType", (PyCFunction)Object_getDrawType, METH_NOARGS, - "(x) - "}, + "Returns the object draw type"}, {"getEuler", (PyCFunction)Object_getEuler, METH_NOARGS, - "(x) - "}, + "Returns the object's rotation as Euler rotation vector\n\ +(rotX, rotY, rotZ)"}, {"getInverseMatrix", (PyCFunction)Object_getInverseMatrix, METH_NOARGS, - "(x) - "}, + "Returns the object's inverse matrix"}, {"getLocation", (PyCFunction)Object_getLocation, METH_VARARGS, - "(x) - "}, + "Returns the object's location (x, y, z)"}, {"getMaterials", (PyCFunction)Object_getMaterials, METH_NOARGS, - "(x) - "}, + "Returns list of materials assigned to the object"}, {"getMatrix", (PyCFunction)Object_getMatrix, METH_NOARGS, - "(x) - "}, + "Returns the object matrix"}, {"getParent", (PyCFunction)Object_getParent, METH_NOARGS, - "(x) - "}, + "Returns the object's parent object"}, {"getTracked", (PyCFunction)Object_getTracked, METH_NOARGS, - "(x) - "}, + "Returns the object's tracked object"}, {"getType", (PyCFunction)Object_getType, METH_NOARGS, - "(x) - "}, + "Returns type of string of Object"}, {"link", (PyCFunction)Object_link, METH_VARARGS, - "(x) - "}, + "Links Object with data provided in the argument. The data must \n\ +match the Object's type, so you cannot link a Lamp to a Mesh type object."}, {"makeParent", (PyCFunction)Object_makeParent, METH_VARARGS, - "(x) - "}, + "Makes the object the parent of the objects provided in the \n\ +argument which must be a list of valid Objects. Optional extra arguments:\n\ +mode:\n\t0: make parent with inverse\n\t1: without inverse\n\ +fase:\n\t0: update scene hierarchy automatically\n\t\ +don't update scene hierarchy (faster). In this case, you must\n\t\ +explicitely update the Scene hierarchy."}, {"materialUsage", (PyCFunction)Object_materialUsage, METH_VARARGS, - "(x) - "}, + "Determines the way the material is used and returs status.\n\ +Possible arguments (provide as strings):\n\ +\tData: Materials assigned to the object's data are shown. (default)\n\ +\tObject: Materials assigned to the object are shown."}, {"setDeltaLocation", (PyCFunction)Object_setDeltaLocation, METH_VARARGS, - "(x) - "}, + "Sets the object's delta location which must be a vector triple."}, {"setDrawMode", (PyCFunction)Object_setDrawMode, METH_VARARGS, - "(x) - "}, + "Sets the object's drawing mode. The argument can be a sum of:\n\ +2: axis\n4: texspace\n8: drawname\n16: drawimage\n32: drawwire"}, {"setDrawType", (PyCFunction)Object_setDrawType, METH_VARARGS, - "(x) - "}, + "Sets the object's drawing type. The argument must be one of:\n\ +1: Bounding box\n2: Wire\n3: Solid\n4: Shaded\n5: Textured"}, {"setEuler", (PyCFunction)Object_setEuler, METH_VARARGS, - "(x) - "}, + "Set the object's rotation according to the specified Euler\n\ +angles. The argument must be a vector triple"}, {"setLocation", (PyCFunction)Object_setLocation, METH_VARARGS, - "(x) - "}, + "Set the object's location. The first argument must be a vector\n\ +triple."}, {"setMaterials", (PyCFunction)Object_setMaterials, METH_VARARGS, - "(x) - "}, + "Sets materials. The argument must be a list of valid material\n\ +objects."}, {"shareFrom", (PyCFunction)Object_shareFrom, METH_VARARGS, - "(x) - "}, + "Link data of self with object specified in the argument. This\n\ +works only if self and the object specified are of the same type."}, }; /*****************************************************************************/ @@ -218,7 +241,7 @@ static PyObject* ObjectRepr (C_Object *obj); /*****************************************************************************/ PyTypeObject Object_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Object", /* tp_name */ sizeof (C_Object), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c index 49f871cdef0..d1f67bfd881 100644 --- a/source/blender/python/api2_2x/Text.c +++ b/source/blender/python/api2_2x/Text.c @@ -207,6 +207,8 @@ PyObject *M_Text_Init (void) { PyObject *submodule; + Text_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Text", M_Text_methods, M_Text_doc); return (submodule); diff --git a/source/blender/python/api2_2x/Text.h b/source/blender/python/api2_2x/Text.h index efac169cfcf..80311f06a15 100644 --- a/source/blender/python/api2_2x/Text.h +++ b/source/blender/python/api2_2x/Text.h @@ -154,7 +154,7 @@ static PyObject *TextRepr (C_Text *self); /*****************************************************************************/ PyTypeObject Text_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "Text", /* tp_name */ sizeof (C_Text), /* tp_basicsize */ diff --git a/source/blender/python/api2_2x/constant.c b/source/blender/python/api2_2x/constant.c index d116589b93b..16dad732a48 100644 --- a/source/blender/python/api2_2x/constant.c +++ b/source/blender/python/api2_2x/constant.c @@ -60,7 +60,7 @@ static PyMappingMethods constantAsMapping = /*****************************************************************************/ PyTypeObject constant_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "constant", /* tp_name */ sizeof (C_constant), /* tp_basicsize */ @@ -97,6 +97,8 @@ static PyObject *new_const(void) { /* this is the static one */ C_constant *constant; + constant_Type.ob_type = &PyType_Type; + printf ("In constant_New()\n"); constant = (C_constant *)PyObject_NEW(C_constant, &constant_Type); diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h index a9d4f39121e..bb6a82c0f53 100644 --- a/source/blender/python/api2_2x/modules.h +++ b/source/blender/python/api2_2x/modules.h @@ -89,9 +89,9 @@ int CurveCheckPyObject (PyObject *py_obj); /* Armature Data */ PyObject * M_Armature_Init (void); -PyObject * ArtmatureCreatePyObject (bArmature *armature); -bArmature* ArmatureFromPyObject (PyObject *py_obj); -int ArmatureCheckPyObject (PyObject *py_obj); +PyObject * M_ArmatureCreatePyObject (bArmature *armature); +bArmature* M_ArmatureFromPyObject (PyObject *py_obj); +int M_ArmatureCheckPyObject (PyObject *py_obj); /* Particle Effects Data */ /*PyObject * M_Effect_Init (void); @@ -102,8 +102,8 @@ int EffectCheckPyObject (PyObject *py_obj); /* Image */ PyObject * M_Image_Init (void); -PyObject * ImageCreatePyObject (Image *image); -int Image_checkPyObject (PyObject *pyobj); +PyObject * Image_CreatePyObject (Image *image); +int Image_CheckPyObject (PyObject *pyobj); /* Init functions for other modules */ PyObject * M_Window_Init (void); diff --git a/source/blender/python/api2_2x/rgbTuple.c b/source/blender/python/api2_2x/rgbTuple.c index 8ee0665f440..7638b89eeed 100644 --- a/source/blender/python/api2_2x/rgbTuple.c +++ b/source/blender/python/api2_2x/rgbTuple.c @@ -83,7 +83,7 @@ static PySequenceMethods rgbTupleAsSequence = /*****************************************************************************/ PyTypeObject rgbTuple_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "rgbTuple", /* tp_name */ sizeof (C_rgbTuple), /* tp_basicsize */ @@ -115,6 +115,8 @@ PyObject *rgbTuple_New(float *rgb[3]) printf ("In rgbTuple_New()\n"); + rgbTuple_Type.ob_type = &PyType_Type; + rgbTuple = (C_rgbTuple *)PyObject_NEW(C_rgbTuple, &rgbTuple_Type); if (rgbTuple == NULL) diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c index a29fdbc9d13..765a3d6e24a 100644 --- a/source/blender/python/api2_2x/vector.c +++ b/source/blender/python/api2_2x/vector.c @@ -193,7 +193,7 @@ static PySequenceMethods Vector_SeqMethods = PyTypeObject vector_Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "Vector", /*tp_name*/ sizeof(VectorObject), /*tp_basicsize*/ @@ -212,7 +212,9 @@ PyTypeObject vector_Type = PyObject *newVectorObject(float *vec, int size) { VectorObject *self; - + + vector_Type.ob_type = &PyType_Type; + self= PyObject_NEW(VectorObject, &vector_Type); self->vec= vec; |