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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2003-06-24 11:21:17 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2003-06-24 11:21:17 +0400
commit06ee04fb05ff58e6e0a781b64100825ba7358f19 (patch)
treec90b1415ebb106090c6f94b4ee782146245bc67d /source/blender/python/api2_2x
parenta0ea4df1ba0367657ba4e093ca0d1288d6258ba4 (diff)
* Added more doc files for epydoc and a test for the camera module.
* Moved public declarations in camera and lamp to a new file: bpy_types.h. * Fixed minor bugs in material, rgbTuple and Lamp + other minor changes. * Made part of the changes to conform to decided naming conventions.
Diffstat (limited to 'source/blender/python/api2_2x')
-rw-r--r--source/blender/python/api2_2x/BGL.c2
-rw-r--r--source/blender/python/api2_2x/Blender.c22
-rw-r--r--source/blender/python/api2_2x/Blender.h2
-rw-r--r--source/blender/python/api2_2x/Camera.c432
-rw-r--r--source/blender/python/api2_2x/Camera.h149
-rw-r--r--source/blender/python/api2_2x/Draw.c2
-rw-r--r--source/blender/python/api2_2x/Image.c4
-rw-r--r--source/blender/python/api2_2x/Lamp.c180
-rw-r--r--source/blender/python/api2_2x/Lamp.h166
-rw-r--r--source/blender/python/api2_2x/Material.c642
-rw-r--r--source/blender/python/api2_2x/Material.h8
-rw-r--r--source/blender/python/api2_2x/NMesh.c6
-rw-r--r--source/blender/python/api2_2x/Scene.c281
-rw-r--r--source/blender/python/api2_2x/Text.c4
-rw-r--r--source/blender/python/api2_2x/Types.c4
-rw-r--r--source/blender/python/api2_2x/Window.c10
-rw-r--r--source/blender/python/api2_2x/Window.h10
-rw-r--r--source/blender/python/api2_2x/bpy_types.h76
-rw-r--r--source/blender/python/api2_2x/doc/Blender.py58
-rw-r--r--source/blender/python/api2_2x/doc/Camera.py65
-rw-r--r--source/blender/python/api2_2x/doc/Lamp.py319
-rw-r--r--source/blender/python/api2_2x/doc/testcamera.py137
-rw-r--r--source/blender/python/api2_2x/modules.h24
-rw-r--r--source/blender/python/api2_2x/rgbTuple.c79
-rw-r--r--source/blender/python/api2_2x/rgbTuple.h8
25 files changed, 1329 insertions, 1361 deletions
diff --git a/source/blender/python/api2_2x/BGL.c b/source/blender/python/api2_2x/BGL.c
index 28adb0c9564..493d658ff4e 100644
--- a/source/blender/python/api2_2x/BGL.c
+++ b/source/blender/python/api2_2x/BGL.c
@@ -998,7 +998,7 @@ static struct PyMethodDef BGL_methods[] = {
{NULL, NULL}
};
-PyObject *M_BGL_Init(void)
+PyObject *BGL_Init(void)
{
PyObject *mod= Py_InitModule("Blender.BGL", BGL_methods);
PyObject *dict= PyModule_GetDict(mod);
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index f7059bf0b6a..c9ee4d62d7e 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -214,22 +214,22 @@ void M_Blender_Init (void)
dict = PyModule_GetDict (module);
g_blenderdict = dict;
- PyDict_SetItemString (dict, "Scene", M_Scene_Init());
+ PyDict_SetItemString (dict, "Scene", Scene_Init());
PyDict_SetItemString (dict, "Object", M_Object_Init());
- PyDict_SetItemString (dict, "Types", M_Types_Init());
- PyDict_SetItemString (dict, "NMesh", M_NMesh_Init());
- PyDict_SetItemString (dict, "Material", M_Material_Init());
- PyDict_SetItemString (dict, "Camera", M_Camera_Init());
- PyDict_SetItemString (dict, "Lamp", M_Lamp_Init());
+ PyDict_SetItemString (dict, "Types", Types_Init());
+ PyDict_SetItemString (dict, "NMesh", NMesh_Init());
+ PyDict_SetItemString (dict, "Material", Material_Init());
+ PyDict_SetItemString (dict, "Camera", Camera_Init());
+ PyDict_SetItemString (dict, "Lamp", Lamp_Init());
PyDict_SetItemString (dict, "Curve", M_Curve_Init());
PyDict_SetItemString (dict, "Armature", M_Armature_Init());
PyDict_SetItemString (dict, "Ipo", M_Ipo_Init());
PyDict_SetItemString (dict, "Metaball", M_Metaball_Init());
- PyDict_SetItemString (dict, "Image", M_Image_Init());
- PyDict_SetItemString (dict, "Window", M_Window_Init());
- PyDict_SetItemString (dict, "Draw", M_Draw_Init());
- PyDict_SetItemString (dict, "BGL", M_BGL_Init());
+ PyDict_SetItemString (dict, "Image", Image_Init());
+ PyDict_SetItemString (dict, "Window", Window_Init());
+ PyDict_SetItemString (dict, "Draw", Draw_Init());
+ PyDict_SetItemString (dict, "BGL", BGL_Init());
PyDict_SetItemString (dict, "Effect", M_Effect_Init());
- PyDict_SetItemString (dict, "Text", M_Text_Init());
+ PyDict_SetItemString (dict, "Text", Text_Init());
PyDict_SetItemString (dict, "World", M_World_Init());
}
diff --git a/source/blender/python/api2_2x/Blender.h b/source/blender/python/api2_2x/Blender.h
index 19e3d686630..ff72d3bbd36 100644
--- a/source/blender/python/api2_2x/Blender.h
+++ b/source/blender/python/api2_2x/Blender.h
@@ -71,7 +71,7 @@ PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args);
char Blender_Set_doc[] =
"(request, data) - Update settings in Blender\n\
\n\
-(request) A string indentifying the setting to change\n\
+(request) A string identifying the setting to change\n\
'curframe' - Sets the current frame using the number in data";
char Blender_Get_doc[] =
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index fc14f78532f..c1b3fc05c66 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -29,15 +29,6 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-/*!
- * \file Camera.c
- * \ingroup scripts
- * \brief Blender.Camera Module and Camera Data PyObject implementation.
- *
- * This file is kept as a reference for new developers. If you want to
- * create a new Python Module for Blender, Camera.c is a good starting point.
- */
-
#include <BKE_main.h>
#include <BKE_global.h>
#include <BKE_object.h>
@@ -48,203 +39,13 @@
/*****************************************************************************/
-/* Python BPy_Camera defaults: */
-/*****************************************************************************/
-
-/* Camera types */
-
-#define EXPP_CAM_TYPE_PERSP 0
-#define EXPP_CAM_TYPE_ORTHO 1
-
-/* Camera mode flags */
-
-#define EXPP_CAM_MODE_SHOWLIMITS 1
-#define EXPP_CAM_MODE_SHOWMIST 2
-
-/* Camera MIN, MAX values */
-
-#define EXPP_CAM_LENS_MIN 1.0
-#define EXPP_CAM_LENS_MAX 250.0
-#define EXPP_CAM_CLIPSTART_MIN 0.0
-#define EXPP_CAM_CLIPSTART_MAX 100.0
-#define EXPP_CAM_CLIPEND_MIN 1.0
-#define EXPP_CAM_CLIPEND_MAX 5000.0
-#define EXPP_CAM_DRAWSIZE_MIN 0.1
-#define EXPP_CAM_DRAWSIZE_MAX 10.0
-
-/*****************************************************************************/
-/* Python API function prototypes for the Camera module. */
-/*****************************************************************************/
-static PyObject *M_Camera_New (PyObject *self, PyObject *args,
- PyObject *keywords);
-static PyObject *M_Camera_Get (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.Camera.__doc__ */
-/*****************************************************************************/
-
-/*!
- * \var M_Camera_doc
- * \brief Doc string for the Blender.Camera module
- */
-
-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\
- 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\
- cur = Scene.getCurrent() # get current Scene\n\
- ob = Object.New('Camera') # make camera object\n\
- ob.link(c) # link camera data with this object\n\
- cur.link(ob) # link object into scene\n\
- cur.setCurrentCamera(ob) # make this camera the active";
-
-/*!
- * \var M_Camera_New_doc
- * \brief Doc string for the Blender.Camera.New() module function
- */
-
-static char M_Camera_New_doc[] =
-"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'.";
-
-/*!
- * \var M_Camera_Get_doc
- * \brief Doc string for the Blender.Camera.Get() module function
- */
-
-static char M_Camera_Get_doc[] =
-"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: */
-/*****************************************************************************/
-
-/*!
- * \var M_Camera_methods
- * \brief Table of module functions.
- *
- * The Blender.Camera functions are registered with this table.
- * Each entry defines: the method name in Python, the pointer to its C
- * function, the argument list expected and a doc string.
- */
-
-struct PyMethodDef M_Camera_methods[] = {
- {"New",(PyCFunction)M_Camera_New, METH_VARARGS|METH_KEYWORDS,
- M_Camera_New_doc},
- {"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
- {"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
- {NULL, NULL, 0, NULL}
-};
-
-/*****************************************************************************/
-/* Python BPy_Camera methods declarations: */
-/*****************************************************************************/
-static PyObject *Camera_getName(BPy_Camera *self);
-static PyObject *Camera_getType(BPy_Camera *self);
-static PyObject *Camera_getMode(BPy_Camera *self);
-static PyObject *Camera_getLens(BPy_Camera *self);
-static PyObject *Camera_getClipStart(BPy_Camera *self);
-static PyObject *Camera_getClipEnd(BPy_Camera *self);
-static PyObject *Camera_getDrawSize(BPy_Camera *self);
-static PyObject *Camera_setName(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setType(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args);
-static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args);
-
-/*****************************************************************************/
-/* Python BPy_Camera methods table: */
-/*****************************************************************************/
-
-/*!
- * \var BPy_Camera_methods
- * \showinitializer
- * \brief Table of Camera member functions
- *
- * This table registers the Camera PyObject methods.
- * Each entry defines: the method name in Python, the pointer to its C
- * function, the argument list expected and a doc string.
- */
-
-static PyMethodDef BPy_Camera_methods[] = {
- /* name, method, flags, doc */
- {"getName", (PyCFunction)Camera_getName, METH_NOARGS,
- "() - Return Camera Data name"},
- {"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"
- " 'showLimits':1, 'showMist':2"},
- {"getLens", (PyCFunction)Camera_getLens, METH_NOARGS,
- "() - Return Camera lens value"},
- {"getClipStart", (PyCFunction)Camera_getClipStart, METH_NOARGS,
- "() - Return Camera clip start value"},
- {"getClipEnd", (PyCFunction)Camera_getClipEnd, METH_NOARGS,
- "() - Return Camera clip end value"},
- {"getDrawSize", (PyCFunction)Camera_getDrawSize, METH_NOARGS,
- "() - Return Camera draw size value"},
- {"setName", (PyCFunction)Camera_setName, METH_VARARGS,
- "(s) - Set Camera Data name"},
- {"setType", (PyCFunction)Camera_setType, METH_VARARGS,
- "(s) - Set Camera type, which can be 'persp' or 'ortho'"},
- {"setMode", (PyCFunction)Camera_setMode, METH_VARARGS,
- "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
- {"setLens", (PyCFunction)Camera_setLens, METH_VARARGS,
- "(f) - Set Camera lens value"},
- {"setClipStart", (PyCFunction)Camera_setClipStart, METH_VARARGS,
- "(f) - Set Camera clip start value"},
- {"setClipEnd", (PyCFunction)Camera_setClipEnd, METH_VARARGS,
- "(f) - Set Camera clip end value"},
- {"setDrawSize", (PyCFunction)Camera_setDrawSize, METH_VARARGS,
- "(f) - Set Camera draw size value"},
- {0}
-};
-
-/*****************************************************************************/
-/* Python Camera_Type callback function prototypes: */
-/*****************************************************************************/
-static void Camera_DeAlloc (BPy_Camera *self);
-static int Camera_Print (BPy_Camera *self, FILE *fp, int flags);
-static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *v);
-static int Camera_Compare (BPy_Camera *a, BPy_Camera *b);
-static PyObject *Camera_GetAttr (BPy_Camera *self, char *name);
-static PyObject *Camera_Repr (BPy_Camera *self);
-
-/*!
- * \var Camera_Type
- * \brief Definition for the Camera PyObject struct
- *
- * Here we define the Camera PyType: its name, size, available function
- * pointers and table of bound methods.
- */
-
-/*****************************************************************************/
/* Python Camera_Type structure definition: */
/*****************************************************************************/
PyTypeObject Camera_Type =
{
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
- "Camera", /* tp_name */
+ "Blender Camera", /* tp_name */
sizeof (BPy_Camera), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
@@ -265,23 +66,6 @@ PyTypeObject Camera_Type =
0, /* tp_members */
};
-/*!
- * \defgroup M_Functions Blender.Camera functions
- */
-
-/*! @{ */
-
-/*!
- * \brief Python module function: Blender.Camera.New()
- *
- * This is the .New() function of the Blender.Camera submodule. It creates
- * new Camera Data in Blender and returns its wrapper PyObject. The
- * parameters are optional and default to type = 'persp' and name = 'CamData'.
- * \param <type> - string: The Camera type: 'persp' or 'ortho';
- * \param <name> - string: The Camera Data name.
- * \return A new Camera PyObject.
- */
-
static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
{
char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
@@ -292,7 +76,7 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
char buf[21];
printf ("In Camera_New()\n");
- /* Parse the arguments passed in by the Python interpreter */
+ /* Parse the arguments passed in by the Python interpreter */
if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
&type_str, &name_str))
/* We expected string(s) (or nothing) as argument, but we didn't get that. */
@@ -307,9 +91,9 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
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() incref'ed it */
- /* XXX XXX Do this in other modules, too */
+ /* let's return user count to zero, because ... */
+ 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,
@@ -333,19 +117,6 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
return pycam;
}
-/*!
- * \brief Python module function: Blender.Camera.Get()
- *
- * 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 with Python wrappers for all current Camera Data objects
- * in Blender.
- * \param <name> - 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)
{
char *name = NULL;
@@ -363,10 +134,10 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
while (cam_iter && !wanted_cam) {
- if (strcmp (name, cam_iter->id.name+2) == 0) {
+ if (strcmp (name, cam_iter->id.name+2) == 0) {
wanted_cam = Camera_CreatePyObject (cam_iter);
- break;
- }
+ break;
+ }
cam_iter = cam_iter->id.next;
}
@@ -408,17 +179,7 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
}
}
-/*@} Cam_M_Functions */
-
-/*!
- * \brief Initializes the Blender.Camera submodule
- *
- * This function is used by Blender_Init() in Blender.c to register the
- * Blender.Camera submodule in the main Blender module.
- * \return The initialized submodule.
- */
-
-PyObject *M_Camera_Init (void)
+PyObject *Camera_Init (void)
{
PyObject *submodule;
@@ -434,15 +195,6 @@ PyObject *M_Camera_Init (void)
/* Three Python Camera_Type helper functions needed by the Object module: */
-/*!
- * \brief Creates a new Python wrapper from an existing Blender Camera Data obj
- *
- * This is also used in Object.c when defining the object.data member variable
- * for an Object of type 'Camera'.
- * \param cam - A pointer to an existing Blender Camera Data object.
- * \return The Camera Data wrapper created.
- */
-
PyObject *Camera_CreatePyObject (Camera *cam)
{
BPy_Camera *pycam;
@@ -458,29 +210,11 @@ PyObject *Camera_CreatePyObject (Camera *cam)
return (PyObject *)pycam;
}
-/*!
- * \brief Checks if the given object is of type BPy_Camera
- *
- * This is also used in Object.c when handling the object.data member variable
- * for an object of type 'Camera'.
- * \param pyobj - A pointer to a Camera PyObject.
- * \return True or false.
- */
-
int Camera_CheckPyObject (PyObject *pyobj)
{
return (pyobj->ob_type == &Camera_Type);
}
-/*!
- * \brief Returns the Blender Camera object from the given PyObject
- *
- * This is also used in Object.c when handling the object.data member variable
- * for an object of type 'Camera'.
- * \param pyobj - A pointer to a Camera PyObject.
- * \return A pointer to the wrapped Blender Camera Data object.
- */
-
Camera *Camera_FromPyObject (PyObject *pyobj)
{
return ((BPy_Camera *)pyobj)->camera;
@@ -489,20 +223,6 @@ Camera *Camera_FromPyObject (PyObject *pyobj)
/*****************************************************************************/
/* Python BPy_Camera methods: */
/*****************************************************************************/
-
-/*!
- * \defgroup CamMethods Camera Method Functions
- *
- * These are the Camera PyObject methods.
- * @{
- */
-
-/*!
- * \brief Camera PyMethod getName
- *
- * \return string: The Camera Data name.
- */
-
static PyObject *Camera_getName(BPy_Camera *self)
{
PyObject *attr = PyString_FromString(self->camera->id.name+2);
@@ -513,12 +233,6 @@ static PyObject *Camera_getName(BPy_Camera *self)
"couldn't get Camera.name attribute");
}
-/*!
- * \brief Camera PyMethod getType
- *
- * \return int: The Camera Data type.
- */
-
static PyObject *Camera_getType(BPy_Camera *self)
{
PyObject *attr = PyInt_FromLong(self->camera->type);
@@ -529,12 +243,6 @@ static PyObject *Camera_getType(BPy_Camera *self)
"couldn't get Camera.type attribute");
}
-/*!
- * \brief Camera PyMethod getMode
- *
- * \return int: The Camera Data mode flags.
- */
-
static PyObject *Camera_getMode(BPy_Camera *self)
{
PyObject *attr = PyInt_FromLong(self->camera->flag);
@@ -545,12 +253,6 @@ static PyObject *Camera_getMode(BPy_Camera *self)
"couldn't get Camera.Mode attribute");
}
-/*!
- * \brief Camera PyMethod getLens
- *
- * \return float: The Camera Data lens value
- */
-
static PyObject *Camera_getLens(BPy_Camera *self)
{
PyObject *attr = PyFloat_FromDouble(self->camera->lens);
@@ -561,12 +263,6 @@ static PyObject *Camera_getLens(BPy_Camera *self)
"couldn't get Camera.lens attribute");
}
-/*!
- * \brief Camera PyMethod getClipStart
- *
- * \return float: The Camera Data clip start value.
- */
-
static PyObject *Camera_getClipStart(BPy_Camera *self)
{
PyObject *attr = PyFloat_FromDouble(self->camera->clipsta);
@@ -577,11 +273,6 @@ static PyObject *Camera_getClipStart(BPy_Camera *self)
"couldn't get Camera.clipStart attribute");
}
-/*!
- * \brief Camera PyMethod getClipEnd
- * \return float: The Camera Data clip end value.
- */
-
static PyObject *Camera_getClipEnd(BPy_Camera *self)
{
PyObject *attr = PyFloat_FromDouble(self->camera->clipend);
@@ -592,11 +283,6 @@ static PyObject *Camera_getClipEnd(BPy_Camera *self)
"couldn't get Camera.clipEnd attribute");
}
-/*!
- * \brief Camera method getDrawSize
- * \return float: The Camera Data draw size value.
- */
-
static PyObject *Camera_getDrawSize(BPy_Camera *self)
{
PyObject *attr = PyFloat_FromDouble(self->camera->drawsize);
@@ -607,11 +293,6 @@ static PyObject *Camera_getDrawSize(BPy_Camera *self)
"couldn't get Camera.drawSize attribute");
}
-/*!
- * \brief Camera PyMethod setName
- * \param name - string: The new Camera Data name.
- */
-
static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
{
char *name;
@@ -629,11 +310,6 @@ static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*!
- * \brief Camera PyMethod setType
- * \param type - string: The new Camera Data type: 'persp' or 'ortho'.
- */
-
static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
{
char *type;
@@ -660,13 +336,6 @@ static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
* the method setType expects a string ('persp' or 'ortho') or an empty
* argument, this function should receive an int (0 or 1). */
-/*!
- * \brief Internal helper function
- *
- * This one is not a PyMethod. It is just an internal helper function.
- * \param type - int: The Camera Data type as an int.
- */
-
static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args)
{
short value;
@@ -685,17 +354,6 @@ static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*!
- * \brief Camera PyMethod setMode
- *
- * There are two mode flags for Cameras: 'showLimits' and 'showMist'.
- * Both can be set at the same time, by providing two arguments to this
- * method. To clear a flag, call setMode without the respective flag string
- * in the argument list. For example: .setMode() clears both flags.
- * \param mode1 - <string>: The first mode flag to set;
- * \param mode2 - <string>: The second mode flag to set.
- */
-
static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
{
char *mode_str1 = NULL, *mode_str2 = NULL;
@@ -734,13 +392,6 @@ static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
/* Another helper function, for the same reason.
* (See comment before Camera_setIntType above). */
-/*!
- * \brief Internal helper function
- *
- * This one is not a PyMethod. It is just an internal helper function.
- * \param mode - int: The Camera Data mode as an int.
- */
-
static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args)
{
short value;
@@ -759,11 +410,6 @@ static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*!
- * \brief Camera PyMethod setLens
- * \param lens - float: The new Camera Data lens value.
- */
-
static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args)
{
float value;
@@ -779,11 +425,6 @@ static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*!
- * \brief Camera PyMethod setClipStart
- * \param clipStart - float: The new Camera Data clip start value.
- */
-
static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args)
{
float value;
@@ -799,11 +440,6 @@ static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*!
- * \brief Camera PyMethod setClipEnd
- * \param clipEnd - float: The new Camera Data clip end value.
- */
-
static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args)
{
float value;
@@ -819,11 +455,6 @@ static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*!
- * \brief Camera PyMethod setDrawSize
- * \param drawSize - float: The new Camera Data draw size value.
- */
-
static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
{
float value;
@@ -839,24 +470,11 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*@} Cam_Methods group */
-
-/*!
- * \brief The Camera PyType destructor
- */
-
static void Camera_DeAlloc (BPy_Camera *self)
{
PyObject_DEL (self);
}
-/*!
- * \brief The Camera PyType attribute getter
- *
- * This is the callback called when a user tries to retrieve the contents of
- * Camera PyObject data members. Ex. in Python: "print mycamera.lens".
- */
-
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
{
PyObject *attr = Py_None;
@@ -902,13 +520,6 @@ static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
}
-/*!
- * \brief The Camera PyType attribute setter
- *
- * This is the callback called when the user tries to change the value of some
- * Camera data member. Ex. in Python: "mycamera.lens = 45.0".
- */
-
static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
{
PyObject *valtuple;
@@ -968,43 +579,18 @@ static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
return 0; /* normal exit */
}
-/*!
- * \brief The Camera PyType compare function
- *
- * This function compares two given Camera PyObjects, returning 0 for equality
- * and -1 otherwise. In Python it becomes 1 if they are equal and 0 case not.
- * The comparison is done with their pointers to Blender Camera Data objects,
- * so any two wrappers pointing to the same Blender Camera Data will be
- * considered the same Camera PyObject. Currently, only the "==" and "!="
- * comparisons are meaninful -- the "<", "<=", ">" or ">=" are not.
- */
-
static int Camera_Compare (BPy_Camera *a, BPy_Camera *b)
{
Camera *pa = a->camera, *pb = b->camera;
return (pa == pb) ? 0:-1;
}
-/*!
- * \brief The Camera PyType print callback
- *
- * This function is called when the user tries to print a PyObject of type
- * Camera. It builds a string with the name of the wrapped Blender Camera.
- */
-
static int Camera_Print(BPy_Camera *self, FILE *fp, int flags)
{
fprintf(fp, "[Camera \"%s\"]", self->camera->id.name+2);
return 0;
}
-/*!
- * \brief The Camera PyType repr callback
- *
- * This function is called when the statement "repr(mycamera)" is executed in
- * Python. Repr gives a string representation of a PyObject.
- */
-
static PyObject *Camera_Repr (BPy_Camera *self)
{
return PyString_FromString(self->camera->id.name+2);
diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h
index 26e7fdfb889..d2257f6d28b 100644
--- a/source/blender/python/api2_2x/Camera.h
+++ b/source/blender/python/api2_2x/Camera.h
@@ -36,30 +36,149 @@
#include <DNA_camera_types.h>
#include "constant.h"
#include "gen_utils.h"
+#include "modules.h"
+#include "bpy_types.h" /* where the BPy_Camera struct is declared */
-/* The Camera PyType Object defined in Camera.c */
-extern PyTypeObject Camera_Type;
+/*****************************************************************************/
+/* Python BPy_Camera defaults: */
+/*****************************************************************************/
+
+/* Camera types */
+
+#define EXPP_CAM_TYPE_PERSP 0
+#define EXPP_CAM_TYPE_ORTHO 1
+
+/* Camera mode flags */
+
+#define EXPP_CAM_MODE_SHOWLIMITS 1
+#define EXPP_CAM_MODE_SHOWMIST 2
+
+/* Camera MIN, MAX values */
+
+#define EXPP_CAM_LENS_MIN 1.0
+#define EXPP_CAM_LENS_MAX 250.0
+#define EXPP_CAM_CLIPSTART_MIN 0.0
+#define EXPP_CAM_CLIPSTART_MAX 100.0
+#define EXPP_CAM_CLIPEND_MIN 1.0
+#define EXPP_CAM_CLIPEND_MAX 5000.0
+#define EXPP_CAM_DRAWSIZE_MIN 0.1
+#define EXPP_CAM_DRAWSIZE_MAX 10.0
+
+/*****************************************************************************/
+/* Python API function prototypes for the Camera module. */
+/*****************************************************************************/
+static PyObject *M_Camera_New (PyObject *self, PyObject *args,
+ PyObject *keywords);
+static PyObject *M_Camera_Get (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.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\
+ 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\
+ cur = Scene.getCurrent() # get current Scene\n\
+ ob = Object.New('Camera') # make camera object\n\
+ ob.link(c) # link camera data with this object\n\
+ cur.link(ob) # link object into scene\n\
+ cur.setCurrentCamera(ob) # make this camera the active";
+
+static char M_Camera_New_doc[] =
+"Camera.New (type = 'persp', name = 'CamData'):\n\
+ Return a new Camera Data object with the given type and name.";
-#define BPy_Camera_Check(v) \
- ((v)->ob_type == &Camera_Type) /* for type checking */
+static char M_Camera_Get_doc[] =
+"Camera.Get (name = None):\n\
+ Return the camera data with the given 'name', None if not found, or\n\
+ Return a list with all Camera Data objects in the current scene,\n\
+ if no argument was given.";
/*****************************************************************************/
-/* Python BPy_Camera structure definition: */
+/* Python method structure definition for Blender.Camera module: */
/*****************************************************************************/
-typedef struct {
- PyObject_HEAD
- Camera *camera;
+struct PyMethodDef M_Camera_methods[] = {
+ {"New",(PyCFunction)M_Camera_New, METH_VARARGS|METH_KEYWORDS,
+ M_Camera_New_doc},
+ {"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
+ {"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
+ {NULL, NULL, 0, NULL}
+};
-} BPy_Camera;
+/*****************************************************************************/
+/* Python BPy_Camera methods declarations: */
+/*****************************************************************************/
+static PyObject *Camera_getName(BPy_Camera *self);
+static PyObject *Camera_getType(BPy_Camera *self);
+static PyObject *Camera_getMode(BPy_Camera *self);
+static PyObject *Camera_getLens(BPy_Camera *self);
+static PyObject *Camera_getClipStart(BPy_Camera *self);
+static PyObject *Camera_getClipEnd(BPy_Camera *self);
+static PyObject *Camera_getDrawSize(BPy_Camera *self);
+static PyObject *Camera_setName(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setType(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args);
+
+/*****************************************************************************/
+/* Python BPy_Camera methods table: */
+/*****************************************************************************/
+static PyMethodDef BPy_Camera_methods[] = {
+ /* name, method, flags, doc */
+ {"getName", (PyCFunction)Camera_getName, METH_NOARGS,
+ "() - Return Camera Data name"},
+ {"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"
+ " 'showLimits':1, 'showMist':2"},
+ {"getLens", (PyCFunction)Camera_getLens, METH_NOARGS,
+ "() - Return Camera lens value"},
+ {"getClipStart", (PyCFunction)Camera_getClipStart, METH_NOARGS,
+ "() - Return Camera clip start value"},
+ {"getClipEnd", (PyCFunction)Camera_getClipEnd, METH_NOARGS,
+ "() - Return Camera clip end value"},
+ {"getDrawSize", (PyCFunction)Camera_getDrawSize, METH_NOARGS,
+ "() - Return Camera draw size value"},
+ {"setName", (PyCFunction)Camera_setName, METH_VARARGS,
+ "(s) - Set Camera Data name"},
+ {"setType", (PyCFunction)Camera_setType, METH_VARARGS,
+ "(s) - Set Camera type, which can be 'persp' or 'ortho'"},
+ {"setMode", (PyCFunction)Camera_setMode, METH_VARARGS,
+ "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
+ {"setLens", (PyCFunction)Camera_setLens, METH_VARARGS,
+ "(f) - Set Camera lens value"},
+ {"setClipStart", (PyCFunction)Camera_setClipStart, METH_VARARGS,
+ "(f) - Set Camera clip start value"},
+ {"setClipEnd", (PyCFunction)Camera_setClipEnd, METH_VARARGS,
+ "(f) - Set Camera clip end value"},
+ {"setDrawSize", (PyCFunction)Camera_setDrawSize, METH_VARARGS,
+ "(f) - Set Camera draw size value"},
+ {0}
+};
/*****************************************************************************/
-/* Python Camera_Type helper functions needed by Blender (the Init function) */
-/* and Object modules. */
+/* Python Camera_Type callback function prototypes: */
/*****************************************************************************/
-PyObject *M_Camera_Init (void);
-PyObject *Camera_CreatePyObject (Camera *cam);
-Camera *Camera_FromPyObject (PyObject *pyobj);
-int Camera_CheckPyObject (PyObject *pyobj);
+static void Camera_DeAlloc (BPy_Camera *self);
+static int Camera_Print (BPy_Camera *self, FILE *fp, int flags);
+static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *v);
+static int Camera_Compare (BPy_Camera *a, BPy_Camera *b);
+static PyObject *Camera_GetAttr (BPy_Camera *self, char *name);
+static PyObject *Camera_Repr (BPy_Camera *self);
#endif /* EXPP_CAMERA_H */
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index ac5c2f2bb03..a70339b78ca 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -634,7 +634,7 @@ static PyObject *Method_Text (PyObject *self, PyObject *args)
return EXPP_incr_ret(Py_None);
}
-PyObject *M_Draw_Init (void)
+PyObject *Draw_Init (void)
{
PyObject *submodule, *dict;
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index 0758b606fc7..e88d887412a 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -204,9 +204,9 @@ static PyObject *M_Image_Load(PyObject *self, PyObject *args)
}
/*****************************************************************************/
-/* Function: M_Image_Init */
+/* Function: Image_Init */
/*****************************************************************************/
-PyObject *M_Image_Init (void)
+PyObject *Image_Init (void)
{
PyObject *submodule;
diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c
index b267df09455..4018871a242 100644
--- a/source/blender/python/api2_2x/Lamp.c
+++ b/source/blender/python/api2_2x/Lamp.c
@@ -32,6 +32,34 @@
#include "Lamp.h"
/*****************************************************************************/
+/* Python TypeLamp structure definition: */
+/*****************************************************************************/
+PyTypeObject Lamp_Type =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "Blender Lamp", /* tp_name */
+ sizeof (BPy_Lamp), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)Lamp_dealloc, /* tp_dealloc */
+ (printfunc)Lamp_print, /* tp_print */
+ (getattrfunc)Lamp_getAttr, /* tp_getattr */
+ (setattrfunc)Lamp_setAttr, /* tp_setattr */
+ (cmpfunc)Lamp_compare, /* tp_compare */
+ (reprfunc)Lamp_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0,0,0,0,0,0,
+ 0, /* tp_doc */
+ 0,0,0,0,0,0,
+ BPy_Lamp_methods, /* tp_methods */
+ 0, /* tp_members */
+};
+
+/*****************************************************************************/
/* Function: M_Lamp_New */
/* Python equivalent: Blender.Lamp.New */
/*****************************************************************************/
@@ -40,7 +68,7 @@ static PyObject *M_Lamp_New(PyObject *self, PyObject *args, PyObject *keywords)
char *type_str = "Lamp";
char *name_str = "LampData";
static char *kwlist[] = {"type_str", "name_str", NULL};
- C_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
+ BPy_Lamp *py_lamp; /* for Lamp Data object wrapper in Python */
Lamp *bl_lamp; /* for actual Lamp Data we create in Blender */
char buf[21];
@@ -53,17 +81,18 @@ static PyObject *M_Lamp_New(PyObject *self, PyObject *args, PyObject *keywords)
bl_lamp = add_lamp(); /* first create in Blender */
if (bl_lamp) /* now create the wrapper obj in Python */
- py_lamp = (C_Lamp *)Lamp_CreatePyObject(bl_lamp);
+ py_lamp = (BPy_Lamp *)Lamp_CreatePyObject(bl_lamp);
else
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't create Lamp Data in Blender"));
+ /* let's return user count to zero, because ... */
+ bl_lamp->id.us = 0; /* ... add_lamp() incref'ed it */
+
if (py_lamp == NULL)
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
"couldn't create Lamp Data object"));
- py_lamp->lamp = bl_lamp; /* link Python lamp wrapper with Blender Lamp */
-
if (strcmp (type_str, "Lamp") == 0)
bl_lamp->type = (short)EXPP_LAMP_TYPE_LAMP;
else if (strcmp (type_str, "Sun") == 0)
@@ -107,12 +136,12 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args)
if (name) { /* (name) - Search lamp by name */
- C_Lamp *wanted_lamp = NULL;
+ BPy_Lamp *wanted_lamp = NULL;
while ((lamp_iter) && (wanted_lamp == NULL)) {
if (strcmp (name, lamp_iter->id.name+2) == 0)
- wanted_lamp = (C_Lamp *)Lamp_CreatePyObject(lamp_iter);
+ wanted_lamp = (BPy_Lamp *)Lamp_CreatePyObject(lamp_iter);
lamp_iter = lamp_iter->id.next;
}
@@ -193,10 +222,10 @@ static PyObject *M_Lamp_ModesDict (void)
}
/*****************************************************************************/
-/* Function: M_Lamp_Init */
+/* Function: Lamp_Init */
/*****************************************************************************/
/* Needed by the Blender module, to register the Blender.Lamp submodule */
-PyObject *M_Lamp_Init (void)
+PyObject *Lamp_Init (void)
{
PyObject *submodule, *Types, *Modes;
@@ -217,19 +246,19 @@ PyObject *M_Lamp_Init (void)
/*****************************************************************************/
/* Function: Lamp_CreatePyObject */
-/* Description: This function will create a new C_Lamp from an existing */
+/* Description: This function will create a new BPy_Lamp from an existing */
/* Blender lamp structure. */
/*****************************************************************************/
PyObject *Lamp_CreatePyObject (Lamp *lamp)
{
- C_Lamp *pylamp;
+ BPy_Lamp *pylamp;
float *rgb[3];
- pylamp = (C_Lamp *)PyObject_NEW (C_Lamp, &Lamp_Type);
+ pylamp = (BPy_Lamp *)PyObject_NEW (BPy_Lamp, &Lamp_Type);
if (!pylamp)
return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create C_Lamp object");
+ "couldn't create BPy_Lamp object");
pylamp->lamp = lamp;
@@ -237,7 +266,7 @@ PyObject *Lamp_CreatePyObject (Lamp *lamp)
rgb[1] = &lamp->g;
rgb[2] = &lamp->b;
- pylamp->color = (C_rgbTuple *)rgbTuple_New(rgb);
+ pylamp->color = (BPy_rgbTuple *)rgbTuple_New(rgb);
return (PyObject *)pylamp;
}
@@ -259,13 +288,13 @@ int Lamp_CheckPyObject (PyObject *pyobj)
/*****************************************************************************/
Lamp *Lamp_FromPyObject (PyObject *pyobj)
{
- return ((C_Lamp *)pyobj)->lamp;
+ return ((BPy_Lamp *)pyobj)->lamp;
}
/*****************************************************************************/
-/* Python C_Lamp methods: */
+/* Python BPy_Lamp methods: */
/*****************************************************************************/
-static PyObject *Lamp_getName(C_Lamp *self)
+static PyObject *Lamp_getName(BPy_Lamp *self)
{
PyObject *attr = PyString_FromString(self->lamp->id.name+2);
@@ -275,7 +304,7 @@ static PyObject *Lamp_getName(C_Lamp *self)
"couldn't get Lamp.name attribute"));
}
-static PyObject *Lamp_getType(C_Lamp *self)
+static PyObject *Lamp_getType(BPy_Lamp *self)
{
PyObject *attr = PyInt_FromLong(self->lamp->type);
@@ -285,7 +314,7 @@ static PyObject *Lamp_getType(C_Lamp *self)
"couldn't get Lamp.type attribute"));
}
-static PyObject *Lamp_getMode(C_Lamp *self)
+static PyObject *Lamp_getMode(BPy_Lamp *self)
{
PyObject *attr = PyInt_FromLong(self->lamp->mode);
@@ -295,7 +324,7 @@ static PyObject *Lamp_getMode(C_Lamp *self)
"couldn't get Lamp.mode attribute"));
}
-static PyObject *Lamp_getSamples(C_Lamp *self)
+static PyObject *Lamp_getSamples(BPy_Lamp *self)
{
PyObject *attr = PyInt_FromLong(self->lamp->samp);
@@ -305,7 +334,7 @@ static PyObject *Lamp_getSamples(C_Lamp *self)
"couldn't get Lamp.samples attribute"));
}
-static PyObject *Lamp_getBufferSize(C_Lamp *self)
+static PyObject *Lamp_getBufferSize(BPy_Lamp *self)
{
PyObject *attr = PyInt_FromLong(self->lamp->bufsize);
@@ -315,7 +344,7 @@ static PyObject *Lamp_getBufferSize(C_Lamp *self)
"couldn't get Lamp.bufferSize attribute"));
}
-static PyObject *Lamp_getHaloStep(C_Lamp *self)
+static PyObject *Lamp_getHaloStep(BPy_Lamp *self)
{
PyObject *attr = PyInt_FromLong(self->lamp->shadhalostep);
@@ -325,7 +354,7 @@ static PyObject *Lamp_getHaloStep(C_Lamp *self)
"couldn't get Lamp.haloStep attribute"));
}
-static PyObject *Lamp_getEnergy(C_Lamp *self)
+static PyObject *Lamp_getEnergy(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->energy);
@@ -335,7 +364,7 @@ static PyObject *Lamp_getEnergy(C_Lamp *self)
"couldn't get Lamp.energy attribute"));
}
-static PyObject *Lamp_getDist(C_Lamp *self)
+static PyObject *Lamp_getDist(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->dist);
@@ -345,7 +374,7 @@ static PyObject *Lamp_getDist(C_Lamp *self)
"couldn't get Lamp.dist attribute"));
}
-static PyObject *Lamp_getSpotSize(C_Lamp *self)
+static PyObject *Lamp_getSpotSize(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->spotsize);
@@ -355,7 +384,7 @@ static PyObject *Lamp_getSpotSize(C_Lamp *self)
"couldn't get Lamp.spotSize attribute"));
}
-static PyObject *Lamp_getSpotBlend(C_Lamp *self)
+static PyObject *Lamp_getSpotBlend(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->spotblend);
@@ -365,7 +394,7 @@ static PyObject *Lamp_getSpotBlend(C_Lamp *self)
"couldn't get Lamp.spotBlend attribute"));
}
-static PyObject *Lamp_getClipStart(C_Lamp *self)
+static PyObject *Lamp_getClipStart(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->clipsta);
@@ -375,7 +404,7 @@ static PyObject *Lamp_getClipStart(C_Lamp *self)
"couldn't get Lamp.clipStart attribute"));
}
-static PyObject *Lamp_getClipEnd(C_Lamp *self)
+static PyObject *Lamp_getClipEnd(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->clipend);
@@ -385,7 +414,7 @@ static PyObject *Lamp_getClipEnd(C_Lamp *self)
"couldn't get Lamp.clipEnd attribute"));
}
-static PyObject *Lamp_getBias(C_Lamp *self)
+static PyObject *Lamp_getBias(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->bias);
@@ -395,7 +424,7 @@ static PyObject *Lamp_getBias(C_Lamp *self)
"couldn't get Lamp.bias attribute"));
}
-static PyObject *Lamp_getSoftness(C_Lamp *self)
+static PyObject *Lamp_getSoftness(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->soft);
@@ -405,7 +434,7 @@ static PyObject *Lamp_getSoftness(C_Lamp *self)
"couldn't get Lamp.softness attribute"));
}
-static PyObject *Lamp_getHaloInt(C_Lamp *self)
+static PyObject *Lamp_getHaloInt(BPy_Lamp *self)
{
PyObject *attr = PyFloat_FromDouble(self->lamp->haint);
@@ -415,7 +444,7 @@ static PyObject *Lamp_getHaloInt(C_Lamp *self)
"couldn't get Lamp.haloInt attribute"));
}
-static PyObject *Lamp_getQuad1(C_Lamp *self)
+static PyObject *Lamp_getQuad1(BPy_Lamp *self)
{ /* should we complain if Lamp is not of type Quad? */
PyObject *attr = PyFloat_FromDouble(self->lamp->att1);
@@ -425,7 +454,7 @@ static PyObject *Lamp_getQuad1(C_Lamp *self)
"couldn't get Lamp.quad1 attribute"));
}
-static PyObject *Lamp_getQuad2(C_Lamp *self)
+static PyObject *Lamp_getQuad2(BPy_Lamp *self)
{ /* should we complain if Lamp is not of type Quad? */
PyObject *attr = PyFloat_FromDouble(self->lamp->att2);
@@ -435,12 +464,12 @@ static PyObject *Lamp_getQuad2(C_Lamp *self)
"couldn't get Lamp.quad2 attribute"));
}
-static PyObject *Lamp_getCol(C_Lamp *self)
+static PyObject *Lamp_getCol(BPy_Lamp *self)
{
return rgbTuple_getCol(self->color);
}
-static PyObject *Lamp_setName(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args)
{
char *name = NULL;
char buf[21];
@@ -457,7 +486,7 @@ static PyObject *Lamp_setName(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setType(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args)
{
char *type;
@@ -486,7 +515,7 @@ static PyObject *Lamp_setType(C_Lamp *self, PyObject *args)
* the first case t shoud be an int and in the second it should be a string. So
* while the method setType expects a string ('persp' or 'ortho') or an empty
* argument, this function should receive an int (0 or 1). */
-static PyObject *Lamp_setIntType(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args)
{
short value;
@@ -504,7 +533,7 @@ static PyObject *Lamp_setIntType(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setMode(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setMode(BPy_Lamp *self, PyObject *args)
{
char *m[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
short i, flag = 0;
@@ -545,7 +574,7 @@ static PyObject *Lamp_setMode(C_Lamp *self, PyObject *args)
/* Another helper function, for the same reason.
* (See comment before Lamp_setIntType above). */
-static PyObject *Lamp_setIntMode(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setIntMode(BPy_Lamp *self, PyObject *args)
{
short value;
@@ -560,7 +589,7 @@ static PyObject *Lamp_setIntMode(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setSamples(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSamples(BPy_Lamp *self, PyObject *args)
{
short value;
@@ -575,7 +604,7 @@ static PyObject *Lamp_setSamples(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setBufferSize(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setBufferSize(BPy_Lamp *self, PyObject *args)
{
short value;
@@ -590,7 +619,7 @@ static PyObject *Lamp_setBufferSize(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setHaloStep(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setHaloStep(BPy_Lamp *self, PyObject *args)
{
short value;
@@ -605,7 +634,7 @@ static PyObject *Lamp_setHaloStep(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setEnergy(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setEnergy(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -620,7 +649,7 @@ static PyObject *Lamp_setEnergy(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setDist(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setDist(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -635,7 +664,7 @@ static PyObject *Lamp_setDist(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setSpotSize(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSpotSize(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -650,7 +679,7 @@ static PyObject *Lamp_setSpotSize(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setSpotBlend(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSpotBlend(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -665,7 +694,7 @@ static PyObject *Lamp_setSpotBlend(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setClipStart(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setClipStart(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -680,7 +709,7 @@ static PyObject *Lamp_setClipStart(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setClipEnd(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setClipEnd(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -695,7 +724,7 @@ static PyObject *Lamp_setClipEnd(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setBias(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setBias(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -710,7 +739,7 @@ static PyObject *Lamp_setBias(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setSoftness(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setSoftness(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -725,7 +754,7 @@ static PyObject *Lamp_setSoftness(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setHaloInt(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setHaloInt(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -740,7 +769,7 @@ static PyObject *Lamp_setHaloInt(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setQuad1(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setQuad1(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -755,7 +784,7 @@ static PyObject *Lamp_setQuad1(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setQuad2(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setQuad2(BPy_Lamp *self, PyObject *args)
{
float value;
@@ -770,7 +799,7 @@ static PyObject *Lamp_setQuad2(C_Lamp *self, PyObject *args)
return Py_None;
}
-static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key,
+static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
PyObject *args)
{ /* for compatibility with old bpython */
float value;
@@ -793,28 +822,29 @@ static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key,
return Py_None;
}
-static PyObject *Lamp_setCol(C_Lamp *self, PyObject *args)
+static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args)
{
return rgbTuple_setCol(self->color, args);
}
/*****************************************************************************/
-/* Function: LampDeAlloc */
-/* Description: This is a callback function for the C_Lamp type. It is */
+/* Function: Lamp_dealloc */
+/* Description: This is a callback function for the BPy_Lamp type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void LampDeAlloc (C_Lamp *self)
+static void Lamp_dealloc (BPy_Lamp *self)
{
+ Py_DECREF (self->color);
PyObject_DEL (self);
}
/*****************************************************************************/
-/* Function: LampGetAttr */
-/* Description: This is a callback function for the C_Lamp type. It is */
-/* the function that accesses C_Lamp member variables and */
+/* Function: Lamp_getAttr */
+/* Description: This is a callback function for the BPy_Lamp type. It is */
+/* the function that accesses BPy_Lamp member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject *LampGetAttr (C_Lamp *self, char *name)
+static PyObject *Lamp_getAttr (BPy_Lamp *self, char *name)
{
PyObject *attr = Py_None;
@@ -898,21 +928,21 @@ static PyObject *LampGetAttr (C_Lamp *self, char *name)
if (attr != Py_None) return attr; /* member attribute found, return it */
/* not an attribute, search the methods table */
- return Py_FindMethod(C_Lamp_methods, (PyObject *)self, name);
+ return Py_FindMethod(BPy_Lamp_methods, (PyObject *)self, name);
}
/*****************************************************************************/
-/* Function: LampSetAttr */
-/* Description: This is a callback function for the C_Lamp type. It is the */
+/* Function: Lamp_setAttr */
+/* Description: This is a callback function for the BPy_Lamp type. It is the */
/* function that changes Lamp Data members values. If this */
/* data is linked to a Blender Lamp, it also gets updated. */
/*****************************************************************************/
-static int LampSetAttr (C_Lamp *self, char *name, PyObject *value)
+static int Lamp_setAttr (BPy_Lamp *self, char *name, PyObject *value)
{
PyObject *valtuple;
PyObject *error = NULL;
- valtuple = Py_BuildValue("(O)", value); /* the set* functions expect a tuple */
+ valtuple = Py_BuildValue("(O)", value); /*the set* functions expect a tuple*/
if (!valtuple)
return EXPP_ReturnIntError(PyExc_MemoryError,
@@ -983,36 +1013,36 @@ static int LampSetAttr (C_Lamp *self, char *name, PyObject *value)
}
/*****************************************************************************/
-/* Function: LampCompare */
-/* Description: This is a callback function for the C_Lamp type. It */
+/* Function: Lamp_compare */
+/* Description: This is a callback function for the BPy_Lamp type. It */
/* compares two Lamp_Type objects. Only the "==" and "!=" */
/* comparisons are meaninful. Returns 0 for equality and -1 if */
/* they don't point to the same Blender Lamp struct. */
/* In Python it becomes 1 if they are equal, 0 otherwise. */
/*****************************************************************************/
-static int LampCompare (C_Lamp *a, C_Lamp *b)
+static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b)
{
Lamp *pa = a->lamp, *pb = b->lamp;
return (pa == pb) ? 0:-1;
}
/*****************************************************************************/
-/* Function: LampPrint */
-/* Description: This is a callback function for the C_Lamp type. It */
+/* Function: Lamp_print */
+/* Description: This is a callback function for the BPy_Lamp type. It */
/* builds a meaninful string to 'print' lamp objects. */
/*****************************************************************************/
-static int LampPrint(C_Lamp *self, FILE *fp, int flags)
+static int Lamp_print(BPy_Lamp *self, FILE *fp, int flags)
{
fprintf(fp, "[Lamp \"%s\"]", self->lamp->id.name+2);
return 0;
}
/*****************************************************************************/
-/* Function: LampRepr */
-/* Description: This is a callback function for the C_Lamp type. It */
+/* Function: Lamp_repr */
+/* Description: This is a callback function for the BPy_Lamp type. It */
/* builds a meaninful string to represent lamp objects. */
/*****************************************************************************/
-static PyObject *LampRepr (C_Lamp *self)
+static PyObject *Lamp_repr (BPy_Lamp *self)
{
return PyString_FromString(self->lamp->id.name+2);
}
diff --git a/source/blender/python/api2_2x/Lamp.h b/source/blender/python/api2_2x/Lamp.h
index ddb8f87b29e..50451ed7bb7 100644
--- a/source/blender/python/api2_2x/Lamp.h
+++ b/source/blender/python/api2_2x/Lamp.h
@@ -46,9 +46,10 @@
#include "rgbTuple.h"
#include "gen_utils.h"
#include "modules.h"
+#include "bpy_types.h" /* for the BPy_Lamp declaration */
/*****************************************************************************/
-/* Python C_Lamp defaults: */
+/* Python BPy_Lamp defaults: */
/*****************************************************************************/
/* Lamp types */
@@ -121,19 +122,20 @@ char M_Lamp_doc[] =
This module provides control over **Lamp Data** objects in Blender.\n\n\
Example::\n\n\
from Blender import Lamp\n\
- l = Lamp.New('Spot')\n\
- l.setMode('square', 'shadow')\n\
- ob = Object.New('Lamp')\n\
- ob.link(l)\n";
+ l = Lamp.New('Spot') # create new 'Spot' lamp data\n\
+ l.setMode('square', 'shadow') # set these two lamp mode flags\n\
+ ob = Object.New('Lamp') # create new lamp object\n\
+ ob.link(l) # link lamp obj with lamp data\n";
char M_Lamp_New_doc[] =
-"(type, name) - return a new Lamp datablock of type 'type'\n\
- and optional name 'name'.";
+"Lamp.New (type = 'Lamp', name = 'LampData'):\n\
+ Return a new Lamp Data object with the given type and name.";
char M_Lamp_Get_doc[] =
-"(name) - return the lamp with the name 'name', \
-returns None if not found.\n If 'name' is not specified, \
-it returns a list of all lamps in the\ncurrent scene.";
+"Lamp.Get (name = None):\n\
+ Return the Lamp Data with the given name, None if not found, or\n\
+ Return a list with all Lamp Data objects in the current scene,\n\
+ if no argument was given.";
/*****************************************************************************/
/* Python method structure definition for Blender.Lamp module: */
@@ -147,64 +149,54 @@ struct PyMethodDef M_Lamp_methods[] = {
};
/*****************************************************************************/
-/* Python C_Lamp structure definition: */
+/* Python BPy_Lamp methods declarations: */
/*****************************************************************************/
-typedef struct {
- PyObject_HEAD
- Lamp *lamp;
- C_rgbTuple *color;
+static PyObject *Lamp_getName(BPy_Lamp *self);
+static PyObject *Lamp_getType(BPy_Lamp *self);
+static PyObject *Lamp_getMode(BPy_Lamp *self);
+static PyObject *Lamp_getSamples(BPy_Lamp *self);
+static PyObject *Lamp_getBufferSize(BPy_Lamp *self);
+static PyObject *Lamp_getHaloStep(BPy_Lamp *self);
+static PyObject *Lamp_getEnergy(BPy_Lamp *self);
+static PyObject *Lamp_getDist(BPy_Lamp *self);
+static PyObject *Lamp_getSpotSize(BPy_Lamp *self);
+static PyObject *Lamp_getSpotBlend(BPy_Lamp *self);
+static PyObject *Lamp_getClipStart(BPy_Lamp *self);
+static PyObject *Lamp_getClipEnd(BPy_Lamp *self);
+static PyObject *Lamp_getBias(BPy_Lamp *self);
+static PyObject *Lamp_getSoftness(BPy_Lamp *self);
+static PyObject *Lamp_getHaloInt(BPy_Lamp *self);
+static PyObject *Lamp_getQuad1(BPy_Lamp *self);
+static PyObject *Lamp_getQuad2(BPy_Lamp *self);
+static PyObject *Lamp_getCol(BPy_Lamp *self);
+static PyObject *Lamp_setName(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setType(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setIntType(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setMode(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setIntMode(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setSamples(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setBufferSize(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setHaloStep(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setEnergy(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setDist(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setSpotSize(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setSpotBlend(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setClipStart(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setClipEnd(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setBias(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setSoftness(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setHaloInt(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setQuad1(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setQuad2(BPy_Lamp *self, PyObject *args);
+static PyObject *Lamp_setCol(BPy_Lamp *self, PyObject *args);
-} C_Lamp;
-
-/*****************************************************************************/
-/* Python C_Lamp methods declarations: */
-/*****************************************************************************/
-static PyObject *Lamp_getName(C_Lamp *self);
-static PyObject *Lamp_getType(C_Lamp *self);
-static PyObject *Lamp_getMode(C_Lamp *self);
-static PyObject *Lamp_getSamples(C_Lamp *self);
-static PyObject *Lamp_getBufferSize(C_Lamp *self);
-static PyObject *Lamp_getHaloStep(C_Lamp *self);
-static PyObject *Lamp_getEnergy(C_Lamp *self);
-static PyObject *Lamp_getDist(C_Lamp *self);
-static PyObject *Lamp_getSpotSize(C_Lamp *self);
-static PyObject *Lamp_getSpotBlend(C_Lamp *self);
-static PyObject *Lamp_getClipStart(C_Lamp *self);
-static PyObject *Lamp_getClipEnd(C_Lamp *self);
-static PyObject *Lamp_getBias(C_Lamp *self);
-static PyObject *Lamp_getSoftness(C_Lamp *self);
-static PyObject *Lamp_getHaloInt(C_Lamp *self);
-static PyObject *Lamp_getQuad1(C_Lamp *self);
-static PyObject *Lamp_getQuad2(C_Lamp *self);
-static PyObject *Lamp_getCol(C_Lamp *self);
-static PyObject *Lamp_setName(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setType(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setIntType(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setMode(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setIntMode(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSamples(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setBufferSize(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setHaloStep(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setEnergy(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setDist(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSpotSize(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSpotBlend(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setClipStart(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setClipEnd(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setBias(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setSoftness(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setHaloInt(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setQuad1(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setQuad2(C_Lamp *self, PyObject *args);
-static PyObject *Lamp_setCol(C_Lamp *self, PyObject *args);
-
-static PyObject *Lamp_setColorComponent(C_Lamp *self, char *key,
+static PyObject *Lamp_setColorComponent(BPy_Lamp *self, char *key,
PyObject *args);
/*****************************************************************************/
-/* Python C_Lamp methods table: */
+/* Python BPy_Lamp methods table: */
/*****************************************************************************/
-static PyMethodDef C_Lamp_methods[] = {
+static PyMethodDef BPy_Lamp_methods[] = {
/* name, method, flags, doc */
{"getName", (PyCFunction)Lamp_getName, METH_NOARGS,
"() - return Lamp name"},
@@ -258,7 +250,7 @@ static PyMethodDef C_Lamp_methods[] = {
"(float) - change Lamp energy value"},
{"setSpotSize", (PyCFunction)Lamp_setSpotSize, METH_VARARGS,
"(float) - change Lamp spot size value"},
- {"setSpotBlend", (PyCFunction)Lamp_setHaloStep, METH_VARARGS,
+ {"setSpotBlend", (PyCFunction)Lamp_setSpotBlend, METH_VARARGS,
"(float) - change Lamp spot blend value"},
{"setClipStart", (PyCFunction)Lamp_setClipStart, METH_VARARGS,
"(float) - change Lamp clip start value"},
@@ -282,48 +274,12 @@ static PyMethodDef C_Lamp_methods[] = {
/*****************************************************************************/
/* Python TypeLamp callback function prototypes: */
/*****************************************************************************/
-static void LampDeAlloc (C_Lamp *lamp);
-static PyObject *LampGetAttr (C_Lamp *lamp, char *name);
-static int LampSetAttr (C_Lamp *lamp, char *name, PyObject *v);
-static int LampCompare (C_Lamp *a, C_Lamp *b);
-static PyObject *LampRepr (C_Lamp *lamp);
-static int LampPrint (C_Lamp *lamp, FILE *fp, int flags);
-
-/*****************************************************************************/
-/* Python Lamp_Type helper functions needed by Blender (the Init function) */
-/* and Object modules. */
-/*****************************************************************************/
-PyObject *M_Lamp_Init (void);
-PyObject *LampCreatePyObject (Lamp *lamp);
-Lamp *LampFromPyObject (PyObject *pyobj);
-int LampCheckPyObject (PyObject *pyobj);
+static void Lamp_dealloc (BPy_Lamp *lamp);
+static PyObject *Lamp_getAttr (BPy_Lamp *lamp, char *name);
+static int Lamp_setAttr (BPy_Lamp *lamp, char *name, PyObject *v);
+static int Lamp_compare (BPy_Lamp *a, BPy_Lamp *b);
+static PyObject *Lamp_repr (BPy_Lamp *lamp);
+static int Lamp_print (BPy_Lamp *lamp, FILE *fp, int flags);
-/*****************************************************************************/
-/* Python TypeLamp structure definition: */
-/*****************************************************************************/
-PyTypeObject Lamp_Type =
-{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Lamp", /* tp_name */
- sizeof (C_Lamp), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)LampDeAlloc, /* tp_dealloc */
- (printfunc)LampPrint, /* tp_print */
- (getattrfunc)LampGetAttr, /* tp_getattr */
- (setattrfunc)LampSetAttr, /* tp_setattr */
- (cmpfunc)LampCompare, /* tp_compare */
- (reprfunc)LampRepr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0,0,0,0,0,0,
- 0, /* tp_doc */
- 0,0,0,0,0,0,
- C_Lamp_methods, /* tp_methods */
- 0, /* tp_members */
-};
#endif /* EXPP_LAMP_H */
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index 456dc2c9b69..9d9a2cfe25c 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -42,7 +42,7 @@
#include "Material.h"
/*****************************************************************************/
-/* Python C_Material defaults: */
+/* Python BPy_Material defaults: */
/*****************************************************************************/
#define EXPP_MAT_MODE_TRACEABLE MA_TRACEBLE
#define EXPP_MAT_MODE_SHADOW MA_SHADOW
@@ -73,16 +73,14 @@
#define EXPP_MAT_ALPHA_MAX 1.0
#define EXPP_MAT_AMB_MIN 0.0
#define EXPP_MAT_AMB_MAX 1.0
-#define EXPP_MAT_ANG_MIN 0.0 /* XXX Confirm these two */
-#define EXPP_MAT_ANG_MAX 1.0
#define EXPP_MAT_COL_MIN 0.0 /* min/max for all ... */
#define EXPP_MAT_COL_MAX 1.0 /* ... color triplets */
#define EXPP_MAT_EMIT_MIN 0.0
#define EXPP_MAT_EMIT_MAX 1.0
#define EXPP_MAT_REF_MIN 0.0
#define EXPP_MAT_REF_MAX 1.0
-#define EXPP_MAT_SPEC_MIN 0.0
-#define EXPP_MAT_SPEC_MAX 2.0
+#define EXPP_MAT_SPEBPy_MIN 0.0
+#define EXPP_MAT_SPEBPy_MAX 2.0
#define EXPP_MAT_SPECTRA_MIN 0.0
#define EXPP_MAT_SPECTRA_MAX 1.0
#define EXPP_MAT_ZOFFS_MIN 0.0
@@ -149,7 +147,7 @@ static PyObject *M_Material_New(PyObject *self, PyObject *args, PyObject *keywor
{
char *name = "Mat";
static char *kwlist[] = {"name", NULL};
- C_Material *pymat; /* for Material Data object wrapper in Python */
+ BPy_Material *pymat; /* for Material Data object wrapper in Python */
Material *blmat; /* for actual Material Data we create in Blender */
char buf[21];
@@ -163,7 +161,7 @@ static PyObject *M_Material_New(PyObject *self, PyObject *args, PyObject *keywor
blmat = add_material(name); /* first create the Material Data in Blender */
if (blmat) /* now create the wrapper obj in Python */
- pymat = (C_Material *)Material_CreatePyObject (blmat);
+ pymat = (BPy_Material *)Material_CreatePyObject (blmat);
else
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't create Material Data in Blender"));
@@ -180,7 +178,7 @@ static PyObject *M_Material_New(PyObject *self, PyObject *args, PyObject *keywor
/* Python equivalent: Blender.Material.Get */
/* Description: Receives a string and returns the material whose */
/* name matches the string. If no argument is */
-/* passed in, a list of all materials in the */
+/* passed in, a list with all materials in the */
/* current scene is returned. */
/*****************************************************************************/
static PyObject *M_Material_Get(PyObject *self, PyObject *args)
@@ -188,20 +186,20 @@ static PyObject *M_Material_Get(PyObject *self, PyObject *args)
char *name = NULL;
Material *mat_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
+ if (!PyArg_ParseTuple(args, "|s", &name))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string argument (or nothing)"));
mat_iter = G.main->mat.first;
- if (name) { /* (name) - Search material by name */
+ if (name) { /* (name) - Search material by name */
- C_Material *wanted_mat = NULL;
+ BPy_Material *wanted_mat = NULL;
while ((mat_iter) && (wanted_mat == NULL)) {
if (strcmp (name, mat_iter->id.name+2) == 0)
- wanted_mat = (C_Material *)Material_CreatePyObject (mat_iter);
+ wanted_mat = (BPy_Material *)Material_CreatePyObject (mat_iter);
mat_iter = mat_iter->id.next;
}
@@ -214,39 +212,39 @@ static PyObject *M_Material_Get(PyObject *self, PyObject *args)
}
return (PyObject *)wanted_mat;
- }
+ }
- else { /* () - return a list of all materials in the scene */
+ else { /* () - return a list with all materials in the scene */
int index = 0;
- PyObject *matlist, *pystr;
+ PyObject *matlist, *pyobj;
matlist = PyList_New (BLI_countlist (&(G.main->mat)));
- if (matlist == NULL)
+ if (!matlist)
return (PythonReturnErrorObject (PyExc_MemoryError,
"couldn't create PyList"));
- while (mat_iter) {
- pystr = PyString_FromString (mat_iter->id.name+2);
+ while (mat_iter) {
+ pyobj = Material_CreatePyObject (mat_iter);
- if (!pystr)
- return (PythonReturnErrorObject (PyExc_MemoryError,
- "couldn't create PyString"));
+ if (!pyobj)
+ return (PythonReturnErrorObject (PyExc_MemoryError,
+ "couldn't create PyObject"));
- PyList_SET_ITEM (matlist, index, pystr);
+ PyList_SET_ITEM (matlist, index, pyobj);
mat_iter = mat_iter->id.next;
index++;
- }
+ }
- return (matlist);
- }
+ return matlist;
+ }
}
/*****************************************************************************/
-/* Function: M_Material_Init */
+/* Function: Material_Init */
/*****************************************************************************/
-PyObject *M_Material_Init (void)
+PyObject *Material_Init (void)
{
PyObject *submodule;
@@ -263,65 +261,63 @@ PyObject *M_Material_Init (void)
/***************************/
/*****************************************************************************/
-/* Python C_Material methods declarations: */
+/* Python BPy_Material methods declarations: */
/*****************************************************************************/
-static PyObject *Material_getName(C_Material *self);
-static PyObject *Material_getMode(C_Material *self);
-static PyObject *Material_getRGBCol(C_Material *self);
-static PyObject *Material_getAmbCol(C_Material *self);
-static PyObject *Material_getSpecCol(C_Material *self);
-static PyObject *Material_getMirCol(C_Material *self);
-static PyObject *Material_getAmb(C_Material *self);
-static PyObject *Material_getAng(C_Material *self);
-static PyObject *Material_getEmit(C_Material *self);
-static PyObject *Material_getAlpha(C_Material *self);
-static PyObject *Material_getRef(C_Material *self);
-static PyObject *Material_getSpec(C_Material *self);
-static PyObject *Material_getSpecTransp(C_Material *self);
-static PyObject *Material_getAdd(C_Material *self);
-static PyObject *Material_getZOffset(C_Material *self);
-static PyObject *Material_getHaloSize(C_Material *self);
-static PyObject *Material_getFlareSize(C_Material *self);
-static PyObject *Material_getFlareBoost(C_Material *self);
-static PyObject *Material_getSubSize(C_Material *self);
-static PyObject *Material_getHardness(C_Material *self);
-static PyObject *Material_getNFlares(C_Material *self);
-static PyObject *Material_getNStars(C_Material *self);
-static PyObject *Material_getNLines(C_Material *self);
-static PyObject *Material_getNRings(C_Material *self);
-static PyObject *Material_setName(C_Material *self, PyObject *args);
-static PyObject *Material_setMode(C_Material *self, PyObject *args);
-static PyObject *Material_setIntMode(C_Material *self, PyObject *args);
-static PyObject *Material_setRGBCol(C_Material *self, PyObject *args);
-static PyObject *Material_setAmbCol(C_Material *self, PyObject *args);
-static PyObject *Material_setSpecCol(C_Material *self, PyObject *args);
-static PyObject *Material_setMirCol(C_Material *self, PyObject *args);
-static PyObject *Material_setAmb(C_Material *self, PyObject *args);
-static PyObject *Material_setEmit(C_Material *self, PyObject *args);
-static PyObject *Material_setAng(C_Material *self, PyObject *args);
-static PyObject *Material_setAlpha(C_Material *self, PyObject *args);
-static PyObject *Material_setRef(C_Material *self, PyObject *args);
-static PyObject *Material_setSpec(C_Material *self, PyObject *args);
-static PyObject *Material_setSpecTransp(C_Material *self, PyObject *args);
-static PyObject *Material_setAdd(C_Material *self, PyObject *args);
-static PyObject *Material_setZOffset(C_Material *self, PyObject *args);
-static PyObject *Material_setHaloSize(C_Material *self, PyObject *args);
-static PyObject *Material_setFlareSize(C_Material *self, PyObject *args);
-static PyObject *Material_setFlareBoost(C_Material *self, PyObject *args);
-static PyObject *Material_setSubSize(C_Material *self, PyObject *args);
-static PyObject *Material_setHardness(C_Material *self, PyObject *args);
-static PyObject *Material_setNFlares(C_Material *self, PyObject *args);
-static PyObject *Material_setNStars(C_Material *self, PyObject *args);
-static PyObject *Material_setNLines(C_Material *self, PyObject *args);
-static PyObject *Material_setNRings(C_Material *self, PyObject *args);
-
-static PyObject *Material_setColorComponent(C_Material *self, char *key,
- PyObject *args);
+static PyObject *Material_getName(BPy_Material *self);
+static PyObject *Material_getMode(BPy_Material *self);
+static PyObject *Material_getRGBCol(BPy_Material *self);
+static PyObject *Material_getAmbCol(BPy_Material *self);
+static PyObject *Material_getSpecCol(BPy_Material *self);
+static PyObject *Material_getMirCol(BPy_Material *self);
+static PyObject *Material_getAmb(BPy_Material *self);
+static PyObject *Material_getEmit(BPy_Material *self);
+static PyObject *Material_getAlpha(BPy_Material *self);
+static PyObject *Material_getRef(BPy_Material *self);
+static PyObject *Material_getSpec(BPy_Material *self);
+static PyObject *Material_getSpecTransp(BPy_Material *self);
+static PyObject *Material_getAdd(BPy_Material *self);
+static PyObject *Material_getZOffset(BPy_Material *self);
+static PyObject *Material_getHaloSize(BPy_Material *self);
+static PyObject *Material_getFlareSize(BPy_Material *self);
+static PyObject *Material_getFlareBoost(BPy_Material *self);
+static PyObject *Material_getSubSize(BPy_Material *self);
+static PyObject *Material_getHardness(BPy_Material *self);
+static PyObject *Material_getNFlares(BPy_Material *self);
+static PyObject *Material_getNStars(BPy_Material *self);
+static PyObject *Material_getNLines(BPy_Material *self);
+static PyObject *Material_getNRings(BPy_Material *self);
+static PyObject *Material_setName(BPy_Material *self, PyObject *args);
+static PyObject *Material_setMode(BPy_Material *self, PyObject *args);
+static PyObject *Material_setIntMode(BPy_Material *self, PyObject *args);
+static PyObject *Material_setRGBCol(BPy_Material *self, PyObject *args);
+static PyObject *Material_setAmbCol(BPy_Material *self, PyObject *args);
+static PyObject *Material_setSpecCol(BPy_Material *self, PyObject *args);
+static PyObject *Material_setMirCol(BPy_Material *self, PyObject *args);
+static PyObject *Material_setAmb(BPy_Material *self, PyObject *args);
+static PyObject *Material_setEmit(BPy_Material *self, PyObject *args);
+static PyObject *Material_setAlpha(BPy_Material *self, PyObject *args);
+static PyObject *Material_setRef(BPy_Material *self, PyObject *args);
+static PyObject *Material_setSpec(BPy_Material *self, PyObject *args);
+static PyObject *Material_setSpecTransp(BPy_Material *self, PyObject *args);
+static PyObject *Material_setAdd(BPy_Material *self, PyObject *args);
+static PyObject *Material_setZOffset(BPy_Material *self, PyObject *args);
+static PyObject *Material_setHaloSize(BPy_Material *self, PyObject *args);
+static PyObject *Material_setFlareSize(BPy_Material *self, PyObject *args);
+static PyObject *Material_setFlareBoost(BPy_Material *self, PyObject *args);
+static PyObject *Material_setSubSize(BPy_Material *self, PyObject *args);
+static PyObject *Material_setHardness(BPy_Material *self, PyObject *args);
+static PyObject *Material_setNFlares(BPy_Material *self, PyObject *args);
+static PyObject *Material_setNStars(BPy_Material *self, PyObject *args);
+static PyObject *Material_setNLines(BPy_Material *self, PyObject *args);
+static PyObject *Material_setNRings(BPy_Material *self, PyObject *args);
+
+static PyObject *Material_setColorComponent(BPy_Material *self, char *key,
+ PyObject *args);
/*****************************************************************************/
-/* Python C_Material methods table: */
+/* Python BPy_Material methods table: */
/*****************************************************************************/
-static PyMethodDef C_Material_methods[] = {
+static PyMethodDef BPy_Material_methods[] = {
/* name, method, flags, doc */
{"getName", (PyCFunction)Material_getName, METH_NOARGS,
"() - Return Material Data name"},
@@ -337,8 +333,6 @@ static PyMethodDef C_Material_methods[] = {
"() - Return Material's mirror color"},
{"getAmb", (PyCFunction)Material_getAmb, METH_NOARGS,
"() - Return Material's ambient color blend factor"},
- {"getAng", (PyCFunction)Material_getAng, METH_NOARGS,
- "() - Return Material's ????"},
{"getEmit", (PyCFunction)Material_getEmit, METH_NOARGS,
"() - Return Material's emitting light intensity"},
{"getAlpha", (PyCFunction)Material_getAlpha, METH_NOARGS,
@@ -375,19 +369,17 @@ static PyMethodDef C_Material_methods[] = {
"(s) - Change Material Data name"},
{"setMode", (PyCFunction)Material_setMode, METH_VARARGS,
"([s[,s]]) - Set Material mode flag(s)"},
- {"setRGBCol", (PyCFunction)Material_setMode, METH_VARARGS,
+ {"setRGBCol", (PyCFunction)Material_setRGBCol, METH_VARARGS,
"([s[,s]]) - Set Material's rgb color triplet"},
- {"setAmbCol", (PyCFunction)Material_setMode, METH_VARARGS,
+ {"setAmbCol", (PyCFunction)Material_setAmbCol, METH_VARARGS,
"([s[,s]]) - Set Material's ambient color"},
- {"setSpecCol", (PyCFunction)Material_setMode, METH_VARARGS,
+ {"setSpecCol", (PyCFunction)Material_setSpecCol, METH_VARARGS,
"([s[,s]]) - Set Material's specular color"},
- {"setMirCol", (PyCFunction)Material_setMode, METH_VARARGS,
+ {"setMirCol", (PyCFunction)Material_setMirCol, METH_VARARGS,
"([s[,s]]) - Set Material's mirror color"},
{"setAmb", (PyCFunction)Material_setAmb, METH_VARARGS,
"(f) - Set how much the Material's color is affected"
- " by \nthe global ambient colors - [0.0, 1.0]"},
- {"setAng", (PyCFunction)Material_setAng, METH_VARARGS,
- "(f) - Set Material's ?????"},
+ " by \nthe global ambient colors - [0.0, 1.0]"},
{"setEmit", (PyCFunction)Material_setEmit, METH_VARARGS,
"(f) - Set Material's emitting light intensity - [0.0, 1.0]"},
{"setAlpha", (PyCFunction)Material_setAlpha, METH_VARARGS,
@@ -410,14 +402,14 @@ static PyMethodDef C_Material_methods[] = {
"(f) - Set Material's flare boost - [0.1, 10.0]"},
{"setSubSize", (PyCFunction)Material_setSubSize, METH_VARARGS,
"(f) - Set Material's dimension of subflare,"
- " dots and circles - [0.1, 25.0]"},
- {"setHardness", (PyCFunction)Material_setFlareBoost, METH_VARARGS,
+ " dots and circles - [0.1, 25.0]"},
+ {"setHardness", (PyCFunction)Material_setHardness, METH_VARARGS,
"(f) - Set Material's hardness - [1, 255 (127 if halo mode is ON)]"},
- {"setNFlares", (PyCFunction)Material_setFlareBoost, METH_VARARGS,
+ {"setNFlares", (PyCFunction)Material_setNFlares, METH_VARARGS,
"(f) - Set Material's number of flares in halo - [1, 32]"},
- {"setNStars", (PyCFunction)Material_setFlareBoost, METH_VARARGS,
+ {"setNStars", (PyCFunction)Material_setNStars, METH_VARARGS,
"(f) - Set Material's number of stars in halo - [3, 50]"},
- {"setNLines", (PyCFunction)Material_setFlareBoost, METH_VARARGS,
+ {"setNLines", (PyCFunction)Material_setNLines, METH_VARARGS,
"(f) - Set Material's number of lines in halo - [0, 250]"},
{"setNRings", (PyCFunction)Material_setNRings, METH_VARARGS,
"(f) - Set Material's number of rings in halo - [0, 24]"},
@@ -427,11 +419,11 @@ static PyMethodDef C_Material_methods[] = {
/*****************************************************************************/
/* Python Material_Type callback function prototypes: */
/*****************************************************************************/
-static void Material_Dealloc (C_Material *self);
-static int Material_Print (C_Material *self, FILE *fp, int flags);
-static int Material_SetAttr (C_Material *self, char *name, PyObject *v);
-static PyObject *Material_GetAttr (C_Material *self, char *name);
-static PyObject *Material_Repr (C_Material *self);
+static void Material_Dealloc (BPy_Material *self);
+static int Material_Print (BPy_Material *self, FILE *fp, int flags);
+static int Material_SetAttr (BPy_Material *self, char *name, PyObject *v);
+static PyObject *Material_GetAttr (BPy_Material *self, char *name);
+static PyObject *Material_Repr (BPy_Material *self);
/*****************************************************************************/
/* Python Material_Type structure definition: */
@@ -440,8 +432,8 @@ PyTypeObject Material_Type =
{
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
- "Material", /* tp_name */
- sizeof (C_Material), /* tp_basicsize */
+ "Blender Material", /* tp_name */
+ sizeof (BPy_Material), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)Material_Dealloc, /* tp_dealloc */
@@ -457,64 +449,64 @@ PyTypeObject Material_Type =
0,0,0,0,0,0,
0, /* tp_doc */
0,0,0,0,0,0,
- C_Material_methods, /* tp_methods */
+ BPy_Material_methods, /* tp_methods */
0, /* tp_members */
};
/*****************************************************************************/
/* Function: Material_Dealloc */
-/* Description: This is a callback function for the C_Material type. It is */
+/* Description: This is a callback function for the BPy_Material type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void Material_Dealloc (C_Material *self)
+static void Material_Dealloc (BPy_Material *self)
{
- Py_DECREF (self->rgb);
- Py_DECREF (self->amb);
- Py_DECREF (self->spec);
- Py_DECREF (self->mir);
+ Py_DECREF (self->col);
+ Py_DECREF (self->amb);
+ Py_DECREF (self->spec);
+ Py_DECREF (self->mir);
PyObject_DEL (self);
}
/*****************************************************************************/
/* Function: Material_CreatePyObject */
-/* Description: This function will create a new C_Material from an existing */
+/* Description: This function will create a new BPy_Material from an existing*/
/* Blender material structure. */
/*****************************************************************************/
PyObject *Material_CreatePyObject (Material *mat)
{
- C_Material *pymat;
- float *rgb[3], *amb[3], *spec[3], *mir[3];
+ BPy_Material *pymat;
+ float *col[3], *amb[3], *spec[3], *mir[3];
- pymat = (C_Material *)PyObject_NEW (C_Material, &Material_Type);
+ pymat = (BPy_Material *)PyObject_NEW (BPy_Material, &Material_Type);
- if (!pymat)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create C_Material object");
+ if (!pymat)
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,
+ "couldn't create BPy_Material object");
- pymat->material = mat;
+ pymat->material = mat;
- rgb[0] = &mat->r;
- rgb[1] = &mat->g;
- rgb[2] = &mat->b;
+ col[0] = &mat->r;
+ col[1] = &mat->g;
+ col[2] = &mat->b;
- amb[0] = &mat->ambr;
- amb[1] = &mat->ambg;
- amb[2] = &mat->ambb;
+ amb[0] = &mat->ambr;
+ amb[1] = &mat->ambg;
+ amb[2] = &mat->ambb;
- spec[0] = &mat->specr;
- spec[1] = &mat->specg;
- spec[2] = &mat->specb;
+ spec[0] = &mat->specr;
+ spec[1] = &mat->specg;
+ spec[2] = &mat->specb;
- mir[0] = &mat->mirr;
- mir[1] = &mat->mirg;
- mir[2] = &mat->mirb;
+ mir[0] = &mat->mirr;
+ mir[1] = &mat->mirg;
+ mir[2] = &mat->mirb;
- pymat->rgb = (C_rgbTuple *)rgbTuple_New(rgb);
- pymat->amb = (C_rgbTuple *)rgbTuple_New(amb);
- pymat->spec = (C_rgbTuple *)rgbTuple_New(spec);
- pymat->mir = (C_rgbTuple *)rgbTuple_New(mir);
+ pymat->col = (BPy_rgbTuple *)rgbTuple_New(col);
+ pymat->amb = (BPy_rgbTuple *)rgbTuple_New(amb);
+ pymat->spec = (BPy_rgbTuple *)rgbTuple_New(spec);
+ pymat->mir = (BPy_rgbTuple *)rgbTuple_New(mir);
- return (PyObject *)pymat;
+ return (PyObject *)pymat;
}
/*****************************************************************************/
@@ -528,9 +520,9 @@ int Material_CheckPyObject (PyObject *pyobj)
}
/*****************************************************************************/
-/* Python C_Material methods: */
+/* Python BPy_Material methods: */
/*****************************************************************************/
-static PyObject *Material_getName(C_Material *self)
+static PyObject *Material_getName(BPy_Material *self)
{
PyObject *attr = PyString_FromString(self->material->id.name+2);
@@ -540,7 +532,7 @@ static PyObject *Material_getName(C_Material *self)
"couldn't get Material.name attribute"));
}
-static PyObject *Material_getMode(C_Material *self)
+static PyObject *Material_getMode(BPy_Material *self)
{
PyObject *attr = PyInt_FromLong((long)self->material->mode);
@@ -550,27 +542,27 @@ static PyObject *Material_getMode(C_Material *self)
"couldn't get Material.Mode attribute");
}
-static PyObject *Material_getRGBCol(C_Material *self)
+static PyObject *Material_getRGBCol(BPy_Material *self)
{
- return rgbTuple_getCol(self->rgb);
+ return rgbTuple_getCol(self->col);
}
-static PyObject *Material_getAmbCol(C_Material *self)
+static PyObject *Material_getAmbCol(BPy_Material *self)
{
- return rgbTuple_getCol(self->amb);
+ return rgbTuple_getCol(self->amb);
}
-static PyObject *Material_getSpecCol(C_Material *self)
+static PyObject *Material_getSpecCol(BPy_Material *self)
{
- return rgbTuple_getCol(self->spec);
+ return rgbTuple_getCol(self->spec);
}
-static PyObject *Material_getMirCol(C_Material *self)
+static PyObject *Material_getMirCol(BPy_Material *self)
{
- return rgbTuple_getCol(self->mir);
+ return rgbTuple_getCol(self->mir);
}
-static PyObject *Material_getAmb(C_Material *self)
+static PyObject *Material_getAmb(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->amb);
@@ -580,7 +572,7 @@ static PyObject *Material_getAmb(C_Material *self)
"couldn't get Material.amb attribute");
}
-static PyObject *Material_getEmit(C_Material *self)
+static PyObject *Material_getEmit(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->emit);
@@ -590,17 +582,7 @@ static PyObject *Material_getEmit(C_Material *self)
"couldn't get Material.emit attribute");
}
-static PyObject *Material_getAng(C_Material *self)
-{
- PyObject *attr = PyFloat_FromDouble((double)self->material->ang);
-
- if (attr) return attr;
-
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Material.ang attribute");
-}
-
-static PyObject *Material_getAlpha(C_Material *self)
+static PyObject *Material_getAlpha(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->alpha);
@@ -610,7 +592,7 @@ static PyObject *Material_getAlpha(C_Material *self)
"couldn't get Material.alpha attribute");
}
-static PyObject *Material_getRef(C_Material *self)
+static PyObject *Material_getRef(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->ref);
@@ -620,7 +602,7 @@ static PyObject *Material_getRef(C_Material *self)
"couldn't get Material.ref attribute");
}
-static PyObject *Material_getSpec(C_Material *self)
+static PyObject *Material_getSpec(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->spec);
@@ -630,7 +612,7 @@ static PyObject *Material_getSpec(C_Material *self)
"couldn't get Material.spec attribute");
}
-static PyObject *Material_getSpecTransp(C_Material *self)
+static PyObject *Material_getSpecTransp(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->spectra);
@@ -640,7 +622,7 @@ static PyObject *Material_getSpecTransp(C_Material *self)
"couldn't get Material.specTransp attribute");
}
-static PyObject *Material_getAdd(C_Material *self)
+static PyObject *Material_getAdd(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->add);
@@ -650,7 +632,7 @@ static PyObject *Material_getAdd(C_Material *self)
"couldn't get Material.add attribute");
}
-static PyObject *Material_getZOffset(C_Material *self)
+static PyObject *Material_getZOffset(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->zoffs);
@@ -660,7 +642,7 @@ static PyObject *Material_getZOffset(C_Material *self)
"couldn't get Material.zOffset attribute");
}
-static PyObject *Material_getHaloSize(C_Material *self)
+static PyObject *Material_getHaloSize(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->hasize);
@@ -670,7 +652,7 @@ static PyObject *Material_getHaloSize(C_Material *self)
"couldn't get Material.haloSize attribute");
}
-static PyObject *Material_getFlareSize(C_Material *self)
+static PyObject *Material_getFlareSize(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->flaresize);
@@ -680,7 +662,7 @@ static PyObject *Material_getFlareSize(C_Material *self)
"couldn't get Material.flareSize attribute");
}
-static PyObject *Material_getFlareBoost(C_Material *self)
+static PyObject *Material_getFlareBoost(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->flareboost);
@@ -690,7 +672,7 @@ static PyObject *Material_getFlareBoost(C_Material *self)
"couldn't get Material.flareBoost attribute");
}
-static PyObject *Material_getSubSize(C_Material *self)
+static PyObject *Material_getSubSize(BPy_Material *self)
{
PyObject *attr = PyFloat_FromDouble((double)self->material->subsize);
@@ -700,7 +682,7 @@ static PyObject *Material_getSubSize(C_Material *self)
"couldn't get Material.subSize attribute");
}
-static PyObject *Material_getHardness(C_Material *self)
+static PyObject *Material_getHardness(BPy_Material *self)
{
PyObject *attr = PyInt_FromLong((long)self->material->har);
@@ -710,7 +692,7 @@ static PyObject *Material_getHardness(C_Material *self)
"couldn't get Material.hard attribute");
}
-static PyObject *Material_getNFlares(C_Material *self)
+static PyObject *Material_getNFlares(BPy_Material *self)
{
PyObject *attr = PyInt_FromLong((long)self->material->flarec);
@@ -720,7 +702,7 @@ static PyObject *Material_getNFlares(C_Material *self)
"couldn't get Material.nFlares attribute");
}
-static PyObject *Material_getNStars(C_Material *self)
+static PyObject *Material_getNStars(BPy_Material *self)
{
PyObject *attr = PyInt_FromLong((long)self->material->starc);
@@ -730,7 +712,7 @@ static PyObject *Material_getNStars(C_Material *self)
"couldn't get Material.nStars attribute");
}
-static PyObject *Material_getNLines(C_Material *self)
+static PyObject *Material_getNLines(BPy_Material *self)
{
PyObject *attr = PyInt_FromLong((long)self->material->linec);
@@ -740,7 +722,7 @@ static PyObject *Material_getNLines(C_Material *self)
"couldn't get Material.nLines attribute");
}
-static PyObject *Material_getNRings(C_Material *self)
+static PyObject *Material_getNRings(BPy_Material *self)
{
PyObject *attr = PyInt_FromLong((long)self->material->ringc);
@@ -750,7 +732,7 @@ static PyObject *Material_getNRings(C_Material *self)
"couldn't get Material.nRings attribute");
}
-static PyObject *Material_setName(C_Material *self, PyObject *args)
+static PyObject *Material_setName(BPy_Material *self, PyObject *args)
{
char *name;
char buf[21];
@@ -771,21 +753,21 @@ static PyObject *Material_setName(C_Material *self, PyObject *args)
* vcolPaint, halo, ztransp, zinvert, haloRings, env, haloLines,
* onlyShadow, xalpha, star, faceTexture, haloTex, haloPuno, noMist,
* haloShade, haloFlare */
-static PyObject *Material_setMode(C_Material *self, PyObject *args)
+static PyObject *Material_setMode(BPy_Material *self, PyObject *args)
{
int i, flag = 0;
char *m[21] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL};
if (!PyArg_ParseTuple(args, "|sssssssssssssssssssss",
- &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6],
- &m[7], &m[8], &m[9], &m[10], &m[11], &m[12], &m[13],
- &m[14], &m[15], &m[16], &m[17], &m[18], &m[19], &m[20]))
- {
+ &m[0], &m[1], &m[2], &m[3], &m[4], &m[5], &m[6],
+ &m[7], &m[8], &m[9], &m[10], &m[11], &m[12], &m[13],
+ &m[14], &m[15], &m[16], &m[17], &m[18], &m[19], &m[20]))
+ {
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
"expected from none to 21 string argument(s)"));
- }
+ }
for (i = 0; i < 21; i++) {
if (m[i] == NULL) break;
@@ -844,7 +826,7 @@ static PyObject *Material_setMode(C_Material *self, PyObject *args)
/* Another helper function, for the same reason.
* (See comment before Material_setIntType above). */
-static PyObject *Material_setIntMode(C_Material *self, PyObject *args)
+static PyObject *Material_setIntMode(BPy_Material *self, PyObject *args)
{
int value;
@@ -858,28 +840,28 @@ static PyObject *Material_setIntMode(C_Material *self, PyObject *args)
return Py_None;
}
-static PyObject *Material_setRGBCol (C_Material *self, PyObject *args)
+static PyObject *Material_setRGBCol (BPy_Material *self, PyObject *args)
{
- return rgbTuple_setCol(self->rgb, args);
+ return rgbTuple_setCol(self->col, args);
}
-static PyObject *Material_setAmbCol (C_Material *self, PyObject *args)
+static PyObject *Material_setAmbCol (BPy_Material *self, PyObject *args)
{
- return rgbTuple_setCol(self->amb, args);
+ return rgbTuple_setCol(self->amb, args);
}
-static PyObject *Material_setSpecCol (C_Material *self, PyObject *args)
+static PyObject *Material_setSpecCol (BPy_Material *self, PyObject *args)
{
- return rgbTuple_setCol(self->spec, args);
+ return rgbTuple_setCol(self->spec, args);
}
-static PyObject *Material_setMirCol (C_Material *self, PyObject *args)
+static PyObject *Material_setMirCol (BPy_Material *self, PyObject *args)
{
- return rgbTuple_setCol(self->mir, args);
+ return rgbTuple_setCol(self->mir, args);
}
-static PyObject *Material_setColorComponent(C_Material *self, char *key,
- PyObject *args)
+static PyObject *Material_setColorComponent(BPy_Material *self, char *key,
+ PyObject *args)
{ /* for compatibility with old bpython */
float value;
@@ -888,7 +870,7 @@ static PyObject *Material_setColorComponent(C_Material *self, char *key,
"expected float argument in [0.0, 1.0]"));
value = EXPP_ClampFloat (value, EXPP_MAT_COL_MIN,
- EXPP_MAT_COL_MAX);
+ EXPP_MAT_COL_MAX);
if (!strcmp(key, "R"))
self->material->r = value;
@@ -897,10 +879,10 @@ static PyObject *Material_setColorComponent(C_Material *self, char *key,
else if (!strcmp(key, "B"))
self->material->b = value;
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setAmb(C_Material *self, PyObject *args)
+static PyObject *Material_setAmb(BPy_Material *self, PyObject *args)
{
float value;
@@ -909,12 +891,12 @@ static PyObject *Material_setAmb(C_Material *self, PyObject *args)
"expected float argument in [0.0, 1.0]"));
self->material->amb = EXPP_ClampFloat (value, EXPP_MAT_AMB_MIN,
- EXPP_MAT_AMB_MAX);
+ EXPP_MAT_AMB_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setEmit(C_Material *self, PyObject *args)
+static PyObject *Material_setEmit(BPy_Material *self, PyObject *args)
{
float value;
@@ -923,26 +905,12 @@ static PyObject *Material_setEmit(C_Material *self, PyObject *args)
"expected float argument in [0.0, 1.0]"));
self->material->emit = EXPP_ClampFloat (value, EXPP_MAT_EMIT_MIN,
- EXPP_MAT_EMIT_MAX);
-
- return EXPP_incr_ret (Py_None);
-}
+ EXPP_MAT_EMIT_MAX);
-static PyObject *Material_setAng(C_Material *self, PyObject *args)
-{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument in [0.0, 1.0]"));
-
- self->material->ang = EXPP_ClampFloat (value, EXPP_MAT_ANG_MIN,
- EXPP_MAT_ANG_MAX);
-
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setSpecTransp(C_Material *self, PyObject *args)
+static PyObject *Material_setSpecTransp(BPy_Material *self, PyObject *args)
{
float value;
@@ -951,12 +919,12 @@ static PyObject *Material_setSpecTransp(C_Material *self, PyObject *args)
"expected float argument in [0.0, 1.0]"));
self->material->spectra = EXPP_ClampFloat (value, EXPP_MAT_SPECTRA_MIN,
- EXPP_MAT_SPECTRA_MAX);
+ EXPP_MAT_SPECTRA_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setAlpha(C_Material *self, PyObject *args)
+static PyObject *Material_setAlpha(BPy_Material *self, PyObject *args)
{
float value;
@@ -965,12 +933,12 @@ static PyObject *Material_setAlpha(C_Material *self, PyObject *args)
"expected float argument in [0.0, 1.0]"));
self->material->alpha = EXPP_ClampFloat (value, EXPP_MAT_ALPHA_MIN,
- EXPP_MAT_ALPHA_MAX);
+ EXPP_MAT_ALPHA_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setRef(C_Material *self, PyObject *args)
+static PyObject *Material_setRef(BPy_Material *self, PyObject *args)
{
float value;
@@ -979,12 +947,12 @@ static PyObject *Material_setRef(C_Material *self, PyObject *args)
"expected float argument in [0.0, 1.0]"));
self->material->ref = EXPP_ClampFloat (value, EXPP_MAT_REF_MIN,
- EXPP_MAT_REF_MAX);
+ EXPP_MAT_REF_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setSpec(C_Material *self, PyObject *args)
+static PyObject *Material_setSpec(BPy_Material *self, PyObject *args)
{
float value;
@@ -992,13 +960,13 @@ static PyObject *Material_setSpec(C_Material *self, PyObject *args)
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected float argument in [0.0, 1.0]"));
- self->material->spec = EXPP_ClampFloat (value, EXPP_MAT_SPEC_MIN,
- EXPP_MAT_SPEC_MAX);
+ self->material->spec = EXPP_ClampFloat (value, EXPP_MAT_SPEBPy_MIN,
+ EXPP_MAT_SPEBPy_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setZOffset(C_Material *self, PyObject *args)
+static PyObject *Material_setZOffset(BPy_Material *self, PyObject *args)
{
float value;
@@ -1007,12 +975,12 @@ static PyObject *Material_setZOffset(C_Material *self, PyObject *args)
"expected float argument in [0.0, 10.0]"));
self->material->zoffs = EXPP_ClampFloat (value, EXPP_MAT_ZOFFS_MIN,
- EXPP_MAT_ZOFFS_MAX);
+ EXPP_MAT_ZOFFS_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setAdd(C_Material *self, PyObject *args)
+static PyObject *Material_setAdd(BPy_Material *self, PyObject *args)
{
float value;
@@ -1021,144 +989,144 @@ static PyObject *Material_setAdd(C_Material *self, PyObject *args)
"expected float argument in [0.0, 1.0]"));
self->material->add = EXPP_ClampFloat (value, EXPP_MAT_ADD_MIN,
- EXPP_MAT_ADD_MAX);
+ EXPP_MAT_ADD_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setHaloSize(C_Material *self, PyObject *args)
+static PyObject *Material_setHaloSize(BPy_Material *self, PyObject *args)
{
- float value;
+ float value;
if (!PyArg_ParseTuple(args, "f", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected float argument in [0.0, 100.0]"));
self->material->hasize = EXPP_ClampFloat (value, EXPP_MAT_HALOSIZE_MIN,
- EXPP_MAT_HALOSIZE_MAX);
+ EXPP_MAT_HALOSIZE_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setFlareSize(C_Material *self, PyObject *args)
+static PyObject *Material_setFlareSize(BPy_Material *self, PyObject *args)
{
- float value;
+ float value;
if (!PyArg_ParseTuple(args, "f", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected float argument in [0.1, 25.0]"));
self->material->flaresize = EXPP_ClampFloat (value, EXPP_MAT_FLARESIZE_MIN,
- EXPP_MAT_FLARESIZE_MAX);
+ EXPP_MAT_FLARESIZE_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setFlareBoost(C_Material *self, PyObject *args)
+static PyObject *Material_setFlareBoost(BPy_Material *self, PyObject *args)
{
- float value;
+ float value;
if (!PyArg_ParseTuple(args, "f", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected float argument in [0.1, 10.0]"));
self->material->flareboost = EXPP_ClampFloat(value, EXPP_MAT_FLAREBOOST_MIN,
- EXPP_MAT_FLAREBOOST_MAX);
+ EXPP_MAT_FLAREBOOST_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setSubSize(C_Material *self, PyObject *args)
+static PyObject *Material_setSubSize(BPy_Material *self, PyObject *args)
{
- float value;
+ float value;
if (!PyArg_ParseTuple(args, "f", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected float argument in [0.1, 25.0]"));
self->material->subsize = EXPP_ClampFloat (value, EXPP_MAT_SUBSIZE_MIN,
- EXPP_MAT_SUBSIZE_MAX);
+ EXPP_MAT_SUBSIZE_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setHardness(C_Material *self, PyObject *args)
+static PyObject *Material_setHardness(BPy_Material *self, PyObject *args)
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
+ if (!PyArg_ParseTuple(args, "h", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected int argument in [1, 255]"));
self->material->har = EXPP_ClampInt (value, EXPP_MAT_HARD_MIN,
- EXPP_MAT_HARD_MAX);
+ EXPP_MAT_HARD_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setNFlares(C_Material *self, PyObject *args)
+static PyObject *Material_setNFlares(BPy_Material *self, PyObject *args)
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
+ if (!PyArg_ParseTuple(args, "h", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected int argument in [1, 32]"));
self->material->flarec = EXPP_ClampInt (value, EXPP_MAT_NFLARES_MIN,
- EXPP_MAT_NFLARES_MAX);
+ EXPP_MAT_NFLARES_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setNStars(C_Material *self, PyObject *args)
+static PyObject *Material_setNStars(BPy_Material *self, PyObject *args)
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
+ if (!PyArg_ParseTuple(args, "h", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected int argument in [3, 50]"));
self->material->starc = EXPP_ClampInt (value, EXPP_MAT_NSTARS_MIN,
- EXPP_MAT_NSTARS_MAX);
+ EXPP_MAT_NSTARS_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setNLines(C_Material *self, PyObject *args)
+static PyObject *Material_setNLines(BPy_Material *self, PyObject *args)
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
+ if (!PyArg_ParseTuple(args, "h", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected int argument in [0, 250]"));
self->material->linec = EXPP_ClampInt (value, EXPP_MAT_NLINES_MIN,
- EXPP_MAT_NLINES_MAX);
+ EXPP_MAT_NLINES_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
-static PyObject *Material_setNRings(C_Material *self, PyObject *args)
+static PyObject *Material_setNRings(BPy_Material *self, PyObject *args)
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
+ if (!PyArg_ParseTuple(args, "h", &value))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected int argument in [0, 24]"));
self->material->ringc = EXPP_ClampInt (value, EXPP_MAT_NRINGS_MIN,
- EXPP_MAT_NRINGS_MAX);
+ EXPP_MAT_NRINGS_MAX);
- return EXPP_incr_ret (Py_None);
+ return EXPP_incr_ret (Py_None);
}
/*****************************************************************************/
/* Function: Material_GetAttr */
-/* Description: This is a callback function for the C_Material type. It is */
-/* the function that accesses C_Material "member variables" and */
-/* methods. */
+/* Description: This is a callback function for the BPy_Material type. It is */
+/* the function that accesses BPy_Material "member variables" */
+/* and methods. */
/*****************************************************************************/
-static PyObject *Material_GetAttr (C_Material *self, char *name)
+static PyObject *Material_GetAttr (BPy_Material *self, char *name)
{
PyObject *attr = Py_None;
@@ -1182,8 +1150,6 @@ static PyObject *Material_GetAttr (C_Material *self, char *name)
attr = PyFloat_FromDouble((double)self->material->b);
else if (strcmp(name, "amb") == 0)
attr = PyFloat_FromDouble((double)self->material->amb);
- else if (strcmp(name, "ang") == 0)
- attr = PyFloat_FromDouble((double)self->material->ang);
else if (strcmp(name, "emit") == 0)
attr = PyFloat_FromDouble((double)self->material->emit);
else if (strcmp(name, "alpha") == 0)
@@ -1218,13 +1184,13 @@ static PyObject *Material_GetAttr (C_Material *self, char *name)
attr = PyInt_FromLong((long)self->material->ringc);
else if (strcmp(name, "__members__") == 0) {
- attr = /* 27 items */
- Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
+ attr = /* 26 items */
+ Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
"name", "mode", "rgbCol", "ambCol", "specCol", "mirCol",
- "R", "G", "B", "alpha", "amb", "ang", "emit", "ref",
- "spec", "specTransp", "add", "zOffset", "haloSize",
- "flareSize", "flareBoost", "subSize", "hard", "nFlares",
- "nStars", "nLines", "nRings");
+ "R", "G", "B", "alpha", "amb", "emit", "ref",
+ "spec", "specTransp", "add", "zOffset", "haloSize",
+ "flareSize", "flareBoost", "subSize", "hard", "nFlares",
+ "nStars", "nLines", "nRings");
}
if (!attr)
@@ -1234,16 +1200,16 @@ static PyObject *Material_GetAttr (C_Material *self, char *name)
if (attr != Py_None) return attr; /* member attribute found, return it */
/* not an attribute, search the methods table */
- return Py_FindMethod(C_Material_methods, (PyObject *)self, name);
+ return Py_FindMethod(BPy_Material_methods, (PyObject *)self, name);
}
/****************************************************************************/
/* Function: Material_SetAttr */
-/* Description: This is a callback function for the C_Material type. */
+/* Description: This is a callback function for the BPy_Material type. */
/* It is the function that sets Material attributes (member */
/* variables). */
/****************************************************************************/
-static int Material_SetAttr (C_Material *self, char *name, PyObject *value)
+static int Material_SetAttr (BPy_Material *self, char *name, PyObject *value)
{
PyObject *valtuple;
PyObject *error = NULL;
@@ -1261,7 +1227,7 @@ static int Material_SetAttr (C_Material *self, char *name, PyObject *value)
return EXPP_ReturnIntError(PyExc_MemoryError,
"MaterialSetAttr: couldn't create PyTuple");
-/* Now we just compare "name" with all possible C_Material member variables */
+/* Now we just compare "name" with all possible BPy_Material member variables */
if (strcmp (name, "name") == 0)
error = Material_setName (self, valtuple);
else if (strcmp (name, "mode") == 0)
@@ -1282,8 +1248,6 @@ static int Material_SetAttr (C_Material *self, char *name, PyObject *value)
error = Material_setColorComponent (self, "B", valtuple);
else if (strcmp (name, "amb") == 0)
error = Material_setAmb (self, valtuple);
- else if (strcmp (name, "ang") == 0)
- error = Material_setAng (self, valtuple);
else if (strcmp (name, "emit") == 0)
error = Material_setEmit (self, valtuple);
else if (strcmp (name, "alpha") == 0)
@@ -1336,10 +1300,10 @@ static int Material_SetAttr (C_Material *self, char *name, PyObject *value)
/*****************************************************************************/
/* Function: Material_Print */
-/* Description: This is a callback function for the C_Material type. It */
+/* Description: This is a callback function for the BPy_Material type. It */
/* builds a meaninful string to 'print' material objects. */
/*****************************************************************************/
-static int Material_Print(C_Material *self, FILE *fp, int flags)
+static int Material_Print(BPy_Material *self, FILE *fp, int flags)
{
fprintf(fp, "[Material \"%s\"]", self->material->id.name+2);
return 0;
@@ -1347,17 +1311,17 @@ static int Material_Print(C_Material *self, FILE *fp, int flags)
/*****************************************************************************/
/* Function: Material_Repr */
-/* Description: This is a callback function for the C_Material type. It */
+/* Description: This is a callback function for the BPy_Material type. It */
/* builds a meaninful string to represent material objects. */
/*****************************************************************************/
-static PyObject *Material_Repr (C_Material *self)
+static PyObject *Material_Repr (BPy_Material *self)
{
- char buf[40];
+ char buf[40];
- PyOS_snprintf(buf, sizeof(buf), "[Material \"%s\"]",
- self->material->id.name+2);
+ PyOS_snprintf(buf, sizeof(buf), "[Material \"%s\"]",
+ self->material->id.name+2);
- return PyString_FromString(buf);
+ return PyString_FromString(buf);
}
@@ -1366,63 +1330,63 @@ static PyObject *Material_Repr (C_Material *self)
/*****************************************************************************/
PyObject *EXPP_PyList_fromMaterialList (Material **matlist, int len)
{
- PyObject *list;
- int i;
+ PyObject *list;
+ int i;
- list = PyList_New(0);
- if (!matlist) return list;
+ list = PyList_New(0);
+ if (!matlist) return list;
- for (i = 0; i < len; i++) {
- Material *mat = matlist[i];
- PyObject *ob;
+ for (i = 0; i < len; i++) {
+ Material *mat = matlist[i];
+ PyObject *ob;
- if (mat) {
- ob = Material_CreatePyObject (mat);
- PyList_Append (list, ob);
- Py_DECREF (ob); /* because Append increfs */
- }
- }
+ if (mat) {
+ ob = Material_CreatePyObject (mat);
+ PyList_Append (list, ob);
+ Py_DECREF (ob); /* because Append increfs */
+ }
+ }
- return list;
+ return list;
}
Material **EXPP_newMaterialList_fromPyList (PyObject *list)
{
- int i, len;
- C_Material *pymat = 0;
- Material *mat;
- Material **matlist;
+ int i, len;
+ BPy_Material *pymat = 0;
+ Material *mat;
+ Material **matlist;
- len = PySequence_Length (list);
- if (len > 16) len = 16;
+ len = PySequence_Length (list);
+ if (len > 16) len = 16;
- matlist = EXPP_newMaterialList (len);
+ matlist = EXPP_newMaterialList (len);
- for (i= 0; i < len; i++) {
+ for (i= 0; i < len; i++) {
- pymat = (C_Material *)PySequence_GetItem (list, i);
+ pymat = (BPy_Material *)PySequence_GetItem (list, i);
- if (Material_CheckPyObject ((PyObject *)pymat)) {
- mat = pymat->material;
- matlist[i] = mat;
- }
+ if (Material_CheckPyObject ((PyObject *)pymat)) {
+ mat = pymat->material;
+ matlist[i] = mat;
+ }
- else { /* error; illegal type in material list */
- Py_DECREF(pymat);
- MEM_freeN(matlist);
- return NULL;
- }
+ else { /* error; illegal type in material list */
+ Py_DECREF(pymat);
+ MEM_freeN(matlist);
+ return NULL;
+ }
- Py_DECREF(pymat);
- }
+ Py_DECREF(pymat);
+ }
- return matlist;
+ return matlist;
}
Material **EXPP_newMaterialList(int len)
{
- Material **matlist =
- (Material **)MEM_mallocN(len * sizeof(Material *), "MaterialList");
+ Material **matlist =
+ (Material **)MEM_mallocN(len * sizeof(Material *), "MaterialList");
- return matlist;
+ return matlist;
}
diff --git a/source/blender/python/api2_2x/Material.h b/source/blender/python/api2_2x/Material.h
index 437722fac37..6fd4c596618 100644
--- a/source/blender/python/api2_2x/Material.h
+++ b/source/blender/python/api2_2x/Material.h
@@ -39,18 +39,18 @@
#include "rgbTuple.h"
/*****************************************************************************/
-/* Python C_Material structure definition: */
+/* Python BPy_Material structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
Material *material;
- C_rgbTuple *rgb, *amb, *spec, *mir;
+ BPy_rgbTuple *col, *amb, *spec, *mir;
-} C_Material;
+} BPy_Material;
extern PyTypeObject Material_Type; /* The Material PyType Object */
-#define C_Material_Check(v) \
+#define BPy_Material_Check(v) \
((v)->ob_type == &Material_Type) /* for type checking */
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index 0142fd046bd..9e1639e9afc 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -1340,7 +1340,7 @@ Material **nmesh_updateMaterials(C_NMesh *nmesh)
PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
{
- C_Material *pymat;
+ BPy_Material *pymat;
Material *ma;
int i;
short old_matmask;
@@ -1349,7 +1349,7 @@ PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
ob->colbits = 0; /* make assign_material work on mesh linked material */
for (i = 0; i < PySequence_Length(nmesh->materials); i++) {
- pymat = (C_Material *)PySequence_GetItem(nmesh->materials, i);
+ pymat = (BPy_Material *)PySequence_GetItem(nmesh->materials, i);
if (Material_CheckPyObject ((PyObject *)pymat)) {
ma = pymat->material;
@@ -1659,7 +1659,7 @@ static PyObject *M_NMesh_FaceTranspModesDict (void)
return FTM;
}
-PyObject *M_NMesh_Init (void)
+PyObject *NMesh_Init (void)
{
PyObject *submodule;
diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c
index b1be2647874..201233ea298 100644
--- a/source/blender/python/api2_2x/Scene.c
+++ b/source/blender/python/api2_2x/Scene.c
@@ -29,12 +29,6 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-/**
- * \file Scene.c
- * \ingroup scripts
- * \brief Blender.Scene Module and Scene PyObject implementation.
- */
-
#include <BKE_main.h>
#include <BKE_global.h>
#include <BKE_scene.h>
@@ -47,8 +41,7 @@
#include <mydevice.h> /* for #define REDRAW */
#include "Object.h"
-#include "Camera.h"
-#include "modules.h"
+#include "bpy_types.h"
#include "Scene.h"
@@ -204,23 +197,6 @@ PyTypeObject Scene_Type =
0, /* tp_members */
};
-/**
- * \defgroup Scene_Module Blender.Scene module functions
- *
- */
-
-/*@{*/
-
-/**
- * \brief Python module function: Blender.Scene.New()
- *
- * This is the .New() function of the Blender.Scene submodule. It creates
- * new Scene in Blender and returns its Python wrapper object. The
- * parameter is optional and defaults to name = 'Scene'.
- * \param <name> - string: The Scene name.
- * \return A new Scene PyObject.
- */
-
static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
{
char *name = "Scene";
@@ -249,19 +225,6 @@ static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
return pyscene;
}
-/**
- * \brief Python module function: Blender.Scene.Get()
- *
- * This is the .Get() function of the Blender.Scene submodule. It searches
- * the list of current Scene 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 Scene object names in Blender.
- * \param <name> - string: The name of an existing Blender Scene object.
- * \return () - A list with the names of all current Scene objects;\n
- * \return (name) - A Python wrapper for the Scene called 'name'
- * in Blender.
- */
-
static PyObject *M_Scene_Get(PyObject *self, PyObject *args)
{
char *name = NULL;
@@ -322,29 +285,11 @@ static PyObject *M_Scene_Get(PyObject *self, PyObject *args)
}
}
-/**
- * \brief Python module function: Blender.Scene.getCurrent()
- *
- * \return A Python wrapper for the currently active scene.
- */
-
static PyObject *M_Scene_getCurrent (PyObject *self)
{
return Scene_CreatePyObject ((Scene *)G.scene);
}
-/**
- * \brief Python module function: Blender.Scene.unlink()
- *
- * This function actually frees the Blender Scene object linked to this
- * Python wrapper. It calls free_libblock(), which calls free_scene(),
- * where all objects linked to this scene have their user counts decremented.
- * But there's no garbage collecting of objects in Blender yet.
- * NOTE: a SystemError is raised if the user tries to remove the currently
- * active Scene. Letting it be done would crash Blender.
- * \param pyobj BPy_Scene*: A Scene PyObject wrapper.
- */
-
static PyObject *M_Scene_unlink (PyObject *self, PyObject *args)
{
PyObject *pyobj;
@@ -366,17 +311,7 @@ static PyObject *M_Scene_unlink (PyObject *self, PyObject *args)
return Py_None;
}
-/*@}*/
-
-/**
- * \brief Initializes the Blender.Scene submodule
- *
- * This function is used by Blender_Init() in Blender.c to register the
- * Blender.Scene submodule in the main Blender module.
- * \return PyObject*: The initialized submodule.
- */
-
-PyObject *M_Scene_Init (void)
+PyObject *Scene_Init (void)
{
PyObject *submodule;
@@ -390,13 +325,6 @@ PyObject *M_Scene_Init (void)
return submodule;
}
-/**
- * \brief Creates a new Python wrapper from an existing Blender Scene obj
- *
- * \param scene - Scene*: A pointer to an existing Blender Scene object.
- * \return PyObject*: The Scene wrapper created.
- */
-
PyObject *Scene_CreatePyObject (Scene *scene)
{
BPy_Scene *pyscene;
@@ -412,25 +340,11 @@ PyObject *Scene_CreatePyObject (Scene *scene)
return (PyObject *)pyscene;
}
-/**
- * \brief Checks if the given object is of type BPy_Scene
- *
- * \param pyobj - PyObject*: A pointer to a Scene PyObject.
- * \return int: True or false.
- */
-
int Scene_CheckPyObject (PyObject *pyobj)
{
return (pyobj->ob_type == &Scene_Type);
}
-/**
- * \brief Returns the Blender Scene object from the given PyObject
- *
- * \param pyobj - PyObject*: A pointer to a Scene PyObject.
- * \return Scene*: A pointer to the wrapped Blender Scene object.
- */
-
Scene *Scene_FromPyObject (PyObject *pyobj)
{
return ((BPy_Scene *)pyobj)->scene;
@@ -439,22 +353,6 @@ Scene *Scene_FromPyObject (PyObject *pyobj)
/*****************************************************************************/
/* Python BPy_Scene methods: */
/*****************************************************************************/
-
-/**
- * \defgroup Scene_Methods Scene Method Functions
- *
- * These are the Scene PyObject method functions. They are used to get and
- * set values for the Scene member variables.
- */
-
-/*@{*/
-
-/**
- * \brief Scene PyMethod getName
- *
- * \return string: The Scene name.
- */
-
static PyObject *Scene_getName(BPy_Scene *self)
{
PyObject *attr = PyString_FromString(self->scene->id.name+2);
@@ -465,11 +363,6 @@ static PyObject *Scene_getName(BPy_Scene *self)
"couldn't get Scene.name attribute"));
}
-/**
- * \brief Scene PyMethod setName
- * \param name - string: The new Scene name.
- */
-
static PyObject *Scene_setName(BPy_Scene *self, PyObject *args)
{
char *name;
@@ -487,15 +380,6 @@ static PyObject *Scene_setName(BPy_Scene *self, PyObject *args)
return Py_None;
}
-/**
- * \brief Scene PyMethod copy
- *
- * This function makes a copy of the scene (self). The optional argument
- * can be:\n 0: Link Objects \n1: Link Object Data (default)\n2: Full copy
- * \param dup_objs - int: how the scene children are duplicated.
- * \return PyObject*: A pointer to the created copy of the scene.
- */
-
static PyObject *Scene_copy (BPy_Scene *self, PyObject *args)
{
short dup_objs = 1;
@@ -512,14 +396,6 @@ static PyObject *Scene_copy (BPy_Scene *self, PyObject *args)
return Scene_CreatePyObject (copy_scene (scene, dup_objs));
}
-/**
- * \brief Scene PyMethod currentFrame
- *
- * If frame is given, the current frame is set and returned in any case.
- * \param frame int: The value for the current frame.
- * \return int: The current frame.
- */
-
/* Blender seems to accept any positive value up to 18000 for start, end and
* current frames, independently. */
@@ -537,14 +413,6 @@ static PyObject *Scene_currentFrame (BPy_Scene *self, PyObject *args)
return PyInt_FromLong (rd->cfra);
}
-/**
- * \brief Scene PyMethod startFrame
- *
- * If frame is given, the start frame is set and returned in any case.
- * \param frame int: The value for the start frame.
- * \return int: The start frame.
- */
-
static PyObject *Scene_startFrame (BPy_Scene *self, PyObject *args)
{
short frame = -1;
@@ -559,14 +427,6 @@ static PyObject *Scene_startFrame (BPy_Scene *self, PyObject *args)
return PyInt_FromLong (rd->sfra);
}
-/**
- * \brief Scene PyMethod endFrame
- *
- * If frame is given, the end frame is set and returned in any case.
- * \param frame int: The value for the end frame.
- * \return int: The end frame.
- */
-
static PyObject *Scene_endFrame (BPy_Scene *self, PyObject *args)
{
short frame = -1;
@@ -581,12 +441,6 @@ static PyObject *Scene_endFrame (BPy_Scene *self, PyObject *args)
return PyInt_FromLong (rd->efra);
}
-/**
- * \brief Scene PyMethod makeCurrent
- *
- * Make self the current scene.
- */
-
static PyObject *Scene_makeCurrent (BPy_Scene *self)
{
Scene *scene = self->scene;
@@ -597,13 +451,6 @@ static PyObject *Scene_makeCurrent (BPy_Scene *self)
return Py_None;
}
-/**
- * \brief Scene PyMethod update
- *
- * Updates scene self. This function explicitely resorts the base list of
- * a newly created object hierarchy.
- */
-
static PyObject *Scene_update (BPy_Scene *self)
{
Scene *scene = self->scene;
@@ -614,13 +461,6 @@ static PyObject *Scene_update (BPy_Scene *self)
return Py_None;
}
-/**
- * \brief Scene PyMethod link
- *
- * Link the given object to this scene.
- * \param object PyObject*: A pointer to an Object Python wrapper.
- */
-
static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
{
Scene *scene = self->scene;
@@ -669,14 +509,6 @@ static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
return Py_None;
}
-/**
- * \brief Scene PyMethod unlink
- *
- * Unlink (delete) the given object from this scene.
- * \param object PyObject*: A pointer to a Blender Object Python wrapper.
- * \return int: 1 for success, 0 for failure.
- */
-
static PyObject *Scene_unlink (BPy_Scene *self, PyObject *args)
{
C_Object *bpy_obj = NULL;
@@ -709,12 +541,6 @@ static PyObject *Scene_unlink (BPy_Scene *self, PyObject *args)
return Py_BuildValue ("i", PyInt_FromLong (retval));
}
-/**
- * \brief Scene PyMethod getRenderdir
- *
- * \return string: The directory where rendered images are saved to.
- */
-
static PyObject *Scene_getRenderdir (BPy_Scene *self)
{
if (self->scene)
@@ -724,12 +550,6 @@ static PyObject *Scene_getRenderdir (BPy_Scene *self)
"Blender Scene was deleted!");
}
-/**
- * \brief Scene PyMethod getBackbufdir
- *
- * \return string: The backbuffer image location
- */
-
static PyObject *Scene_getBackbufdir (BPy_Scene *self)
{
if (self->scene)
@@ -739,17 +559,6 @@ static PyObject *Scene_getBackbufdir (BPy_Scene *self)
"Blender Scene already deleted");
}
-/**
- * \brief Scene PyMethod frameSettings
- *
- * This method can be used to set (if the values are given) and in any case
- * get a tuple representing the start, end and current frame values.
- * \param start int: The optional start frame value;
- * \param end int: The optional end frame value;
- * \param current int: The optional current frame value.
- * \return tuple: (start, end, current) frame values.
- */
-
static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args)
{
int start = -1;
@@ -775,12 +584,6 @@ static PyObject *Scene_frameSettings (BPy_Scene *self, PyObject *args)
return Py_BuildValue("(iii)", rd->sfra, rd->efra, rd->cfra);
}
-/**
- * \brief Scene PyMethod getChildren
- *
- * \return PyList: a list of all objects linked to Scene self.
- */
-
static PyObject *Scene_getChildren (BPy_Scene *self)
{
Scene *scene = self->scene;
@@ -814,12 +617,6 @@ static PyObject *Scene_getChildren (BPy_Scene *self)
return pylist;
}
-/**
- * \brief Scene PyMethod getCurrentCamera
- *
- * \return PyObject*: A wrapper for the currently active camera
- */
-
static PyObject *Scene_getCurrentCamera (BPy_Scene *self)
{
Object *cam_obj;
@@ -838,13 +635,6 @@ static PyObject *Scene_getCurrentCamera (BPy_Scene *self)
return Py_None;
}
-/**
- * \brief Scene PyMethod setCurrentCamera
- *
- * Set the currently active Camera Object in Blender.
- * \param cam_obj PyObject*: A Camera PyObject.
- */
-
static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
{
Object *object;
@@ -873,33 +663,11 @@ static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
return Py_None;
}
-/*@}*/
-
-/**
- * \defgroup Scene_callbacks Callback functions for the Scene PyType
- *
- * These callbacks are called by the Python interpreter when dealing with
- * PyObjects of type Scene.
- */
-
-/*@{*/
-
-/**
- * \brief The Scene PyType destructor
- */
-
static void Scene_DeAlloc (BPy_Scene *self)
{
PyObject_DEL (self);
}
-/**
- * \brief The Scene PyType attribute getter
- *
- * This is the callback called when a user tries to retrieve the contents of
- * Scene PyObject data members. Ex. in Python: "print myscene.lens".
- */
-
static PyObject *Scene_GetAttr (BPy_Scene *self, char *name)
{
PyObject *attr = Py_None;
@@ -921,13 +689,6 @@ static PyObject *Scene_GetAttr (BPy_Scene *self, char *name)
return Py_FindMethod(BPy_Scene_methods, (PyObject *)self, name);
}
-/**
- * \brief The Scene PyType attribute setter
- *
- * This is the callback called when the user tries to change the value of some
- * Scene data member. Ex. in Python: "myscene.lens = 45.0".
- */
-
static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *value)
{
PyObject *valtuple;
@@ -967,61 +728,23 @@ static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *value)
return 0; /* normal exit */
}
-/**
- * \brief The Scene PyType compare function
- *
- * This function compares two given Scene PyObjects, returning 0 for equality
- * and -1 otherwise. In Python it becomes 1 if they are equal and 0 case not.
- * The comparison is done with their pointers to Blender Scene objects,
- * so any two wrappers pointing to the same Blender Scene will be
- * considered the same Scene PyObject. Currently, only the "==" and "!="
- * comparisons are meaninful -- the "<", "<=", ">" or ">=" are not.
- */
-
static int Scene_Compare (BPy_Scene *a, BPy_Scene *b)
{
Scene *pa = a->scene, *pb = b->scene;
return (pa == pb) ? 0:-1;
}
-/**
- * \brief The Scene PyType print callback
- *
- * This function is called when the user tries to print a PyObject of type
- * Scene. It builds a string with the name of the wrapped Blender Scene.
- */
-
static int Scene_Print(BPy_Scene *self, FILE *fp, int flags)
{
fprintf(fp, "[Scene \"%s\"]", self->scene->id.name+2);
return 0;
}
-/**
- * \brief The Scene PyType repr callback
- *
- * This function is called when the statement "repr(myscene)" is executed in
- * Python. Repr gives a string representation of a PyObject.
- */
-
static PyObject *Scene_Repr (BPy_Scene *self)
{
return PyString_FromString(self->scene->id.name+2);
}
-/*@}*/
-
-/**
- * \brief Internal helper function to search the Base of an Object
- *
- * This function looks up the linked list of Bases in a scene, searching
- * for a given object.
- * \param scene Scene*: A pointer to a Blender Scene;
- * \param object Object*: A pointer to a Blender Object.
- * \return The Base* to the Base where object was stored or NULL if the
- * object isn't linked to this scene.
- */
-
Base *EXPP_Scene_getObjectBase(Scene *scene, Object *object)
{
Base *base = scene->base.first;
diff --git a/source/blender/python/api2_2x/Text.c b/source/blender/python/api2_2x/Text.c
index c7e714f991f..90ae5f2fe07 100644
--- a/source/blender/python/api2_2x/Text.c
+++ b/source/blender/python/api2_2x/Text.c
@@ -201,9 +201,9 @@ static PyObject *M_Text_unlink(PyObject *self, PyObject *args)
}
/*****************************************************************************/
-/* Function: M_Text_Init */
+/* Function: Text_Init */
/*****************************************************************************/
-PyObject *M_Text_Init (void)
+PyObject *Text_Init (void)
{
PyObject *submodule;
diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c
index 28339c78134..ed78af7f4d6 100644
--- a/source/blender/python/api2_2x/Types.c
+++ b/source/blender/python/api2_2x/Types.c
@@ -34,9 +34,9 @@
struct PyMethodDef Null_methods[] = {{NULL, NULL}};
/*****************************************************************************/
-/* Function: M_Types_Init */
+/* Function: Types_Init */
/*****************************************************************************/
-PyObject *M_Types_Init (void)
+PyObject *Types_Init (void)
{
PyObject *submodule, *dict;
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c
index 8db05474ecf..24387b61557 100644
--- a/source/blender/python/api2_2x/Window.c
+++ b/source/blender/python/api2_2x/Window.c
@@ -169,10 +169,10 @@ static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
}
/*****************************************************************************/
-/* Function: M_Window_DrawProgressbar */
-/* Python equivalent: Blender.Window.DrawProgressbar */
+/* Function: M_Window_DrawProgressBar */
+/* Python equivalent: Blender.Window.DrawProgressBar */
/*****************************************************************************/
-static PyObject *M_Window_DrawProgressbar(PyObject *self, PyObject *args)
+static PyObject *M_Window_DrawProgressBar(PyObject *self, PyObject *args)
{
float done;
char *info = 0;
@@ -188,9 +188,9 @@ static PyObject *M_Window_DrawProgressbar(PyObject *self, PyObject *args)
}
/*****************************************************************************/
-/* Function: M_Window_Init */
+/* Function: Window_Init */
/*****************************************************************************/
-PyObject *M_Window_Init (void)
+PyObject *Window_Init (void)
{
PyObject *submodule, *Types;
diff --git a/source/blender/python/api2_2x/Window.h b/source/blender/python/api2_2x/Window.h
index b6ac60d7f36..758dd7f6996 100644
--- a/source/blender/python/api2_2x/Window.h
+++ b/source/blender/python/api2_2x/Window.h
@@ -67,7 +67,7 @@ static PyObject *M_Window_RedrawAll (PyObject *self, PyObject *args);
static PyObject *M_Window_QRedrawAll (PyObject *self, PyObject *args);
static PyObject *M_Window_FileSelector (PyObject *self, PyObject *args);
static PyObject *M_Window_ImageSelector (PyObject *self, PyObject *args);
-static PyObject *M_Window_DrawProgressbar (PyObject *self, PyObject *args);
+static PyObject *M_Window_DrawProgressBar (PyObject *self, PyObject *args);
/*****************************************************************************/
/* The following string definitions are used for documentation strings. */
@@ -106,7 +106,7 @@ def my_function(filename):\n\
print 'The selected image file was: ', filename\n\n\
Blender.Window.ImageSelector(my_function, 'LOAD IMAGE')\n";
-char M_Window_DrawProgressbar_doc[] =
+char M_Window_DrawProgressBar_doc[] =
"(done, text) - Draw a progressbar.\n\
'done' is a float value <= 1.0, 'text' contains info about what is\n\
currently being done.";
@@ -121,8 +121,10 @@ struct PyMethodDef M_Window_methods[] = {
{"FileSelector", M_Window_FileSelector, METH_VARARGS, M_Window_FileSelector_doc},
{"ImageSelector", M_Window_ImageSelector, METH_VARARGS,
M_Window_ImageSelector_doc},
- {"DrawProgressbar", M_Window_DrawProgressbar, METH_VARARGS,
- M_Window_DrawProgressbar_doc},
+ {"DrawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
+ M_Window_DrawProgressBar_doc},
+ {"drawProgressBar", M_Window_DrawProgressBar, METH_VARARGS,
+ M_Window_DrawProgressBar_doc},
{NULL, NULL, 0, NULL}
};
diff --git a/source/blender/python/api2_2x/bpy_types.h b/source/blender/python/api2_2x/bpy_types.h
new file mode 100644
index 00000000000..ff8ed8699b7
--- /dev/null
+++ b/source/blender/python/api2_2x/bpy_types.h
@@ -0,0 +1,76 @@
+/*
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * This is a new part of Blender.
+ *
+ * Contributor(s): Willian P. Germano
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+*/
+
+#ifndef EXPP_bpy_types_h
+#define EXPP_bpy_types_h
+
+#include <Python.h>
+
+#include <DNA_camera_types.h>
+#include <DNA_lamp_types.h>
+
+#include "rgbTuple.h" /* for BPy_rgbTuple */
+
+/*****************************************************************************/
+/* Camera Data */
+/*****************************************************************************/
+extern PyTypeObject Camera_Type;
+
+#define BPy_Camera_Check(v) \
+ ((v)->ob_type == &Camera_Type) /* for type checking */
+
+/* Python BPy_Camera structure definition */
+typedef struct {
+ PyObject_HEAD
+ Camera *camera;
+
+} BPy_Camera;
+/**/
+
+/*****************************************************************************/
+/* Lamp Data */
+/*****************************************************************************/
+extern PyTypeObject Lamp_Type;
+
+#define BPy_Lamp_Check(v) \
+ ((v)->ob_type == &Lamp_Type) /* for type checking */
+
+/* Python BPy_Lamp structure definition */
+typedef struct {
+ PyObject_HEAD
+ Lamp *lamp;
+ BPy_rgbTuple *color;
+
+} BPy_Lamp;
+/**/
+
+
+#endif /* EXPP_bpy_types_h */
diff --git a/source/blender/python/api2_2x/doc/Blender.py b/source/blender/python/api2_2x/doc/Blender.py
new file mode 100644
index 00000000000..cea2d0923bf
--- /dev/null
+++ b/source/blender/python/api2_2x/doc/Blender.py
@@ -0,0 +1,58 @@
+# The Blender Module
+
+"""
+Here goes the Introduction to Blender Python
+
+Let's see::
+ - What scripting is, why have it
+ - What is Python, links
+ - More about what scripting can give us
+ - Overview of the Blender Python modules
+ - Links to Blender, Blender Python, later: script lists
+@author: The Blender Python Team
+@requires: Blender 2.28 or newer, Python 2.? (2.0, 2.1, 2.2 ???) or newer
+@version: 0.1
+@see: U{www.blender.org<http://www.blender.org>}
+@see: U{projects.blender.org<http://projects.blender.org>}
+"""
+
+def Set (request, data):
+ """
+ Update settings in Blender
+ @type request: string
+ @param request: The setting to change:
+ - 'curframe': the current animation frame
+ @type data: int
+ @param data: The new value.
+ """
+
+def Get (request):
+ """
+ Retrieve settings from Blender.
+ @type request: string
+ @param request: The setting data to be returned:
+ - 'curframe': the current animation frame
+ - 'curtime' : the current animation time
+ - 'staframe': the start frame of the animation
+ - 'endframe': the end frame of the animation
+ - 'filename': the name of the last file read or written
+ - 'version' : the Blender version number
+ @return: The requested data.
+ """
+
+def Redraw ():
+ """
+ Redraw all 3D windows
+ """
+
+def ReleaseGlobalDict (bool = None):
+ """
+ Define whether the global Python Interpreter dictionary should be cleared
+ after the script is run. Default is to clear (non-zero bool).
+ @type bool: an int, actually
+ @param bool: The flag to release (non-zero bool) or not (bool = 0) the dict.
+ if no argument is passed, this function simply returns the current
+ behavior.
+ @rtype: int
+ @return: A bool value (0 or 1) telling the current behavior.
+ """
diff --git a/source/blender/python/api2_2x/doc/Camera.py b/source/blender/python/api2_2x/doc/Camera.py
index 21ac61c9518..adeee5aa731 100644
--- a/source/blender/python/api2_2x/doc/Camera.py
+++ b/source/blender/python/api2_2x/doc/Camera.py
@@ -9,8 +9,8 @@ Example::
from Blender import Camera, Object, Scene
c = Camera.New('ortho'). # create new ortho camera data
- c.lens = 35.0 # set lens value
- cur = Scene.getCurrent(). # get current Scene
+ c.lens = 35.0 # set lens value
+ cur = Scene.getCurrent(). # get current scene
ob = Object.New('Camera'). # make camera object
ob.link(c). # link camera data with this object
cur.link(ob). # link object into scene
@@ -24,19 +24,19 @@ def New (type = 'persp', name = 'CamData'):
@param type: The Camera type: 'persp' or 'ortho'.
@type name: string
@param name: The Camera Data name.
- @rtype: Camera
+ @rtype: Blender Camera
@return: The created Camera Data object.
"""
def Get (name = None):
"""
- Get the Camera Data object(s).rom Blender.
+ Get the Camera Data object(s) from Blender.
@type name: string
@param name: The name of the Camera Data.
- @rtype: Camera or a list of Cameras
+ @rtype: Blender Camera or a list of Blender Cameras
@return: It depends on the 'name' parameter:
- - (name).The Camera Data object with the given name;
- - (). A list with all Camera Data objects in the current Scene.
+ - (name): The Camera Data object with the given name;
+ - (): A list with all Camera Data objects in the current scene.
"""
class Camera:
@@ -45,42 +45,45 @@ class Camera:
======================
This object gives access to Camera-specific data in Blender.
@cvar name: The Camera Data name.
- @cvar type: The type: 'persp':0 or 'ortho':1.
+ @cvar type: The Camera type: 'persp':0 or 'ortho':1.
@cvar mode: The mode flags: B{or'ed value}: 'showLimits':1, 'showMist':2.
@cvar lens: The lens value in [1.0, 250.0].
@cvar clipStart: The clip start value in [0.0, 100.0].
@cvar clipEnd: The clip end value in [1.0, 5000.0].
@cvar drawSize: The draw size value in [0.1, 10.0].
+ @warning: Most member variables assume values in some [Min, Max] interval.
+ When trying to set them, the given parameter will be clamped to lie in
+ that range: if val < Min, then val = Min, if val > Max, then val = Max.
"""
- def getName(self):
+ def getName():
"""
Get the name of this Camera Data object.
@rtype: string
"""
- def setName(self, name):
+ def setName(name):
"""
Set the name of this Camera Data object.
@type name: string
@param name: The new name.
"""
- def getType(self):
+ def getType():
"""
Get this Camera's type.
@rtype: int
@return: 0 for 'persp' or 1 for 'ortho'.
"""
- def setType(self, type):
+ def setType(type):
"""
Set this Camera's type.
@type type: string
@param type: The Camera type: 'persp' or 'ortho'.
"""
- def getMode(self):
+ def getMode():
"""
Get this Camera's mode flags.
@rtype: int
@@ -88,10 +91,10 @@ class Camera:
resp. 01 and 10 in binary.
"""
- def setMode(self, mode1 = None, mode2 = None):
+ def setMode(mode1 = None, mode2 = None):
"""
Set this Camera's mode flags. Mode strings given are turned 'on'.
- Those not provided are turned 'off', so cam.setMode().- without
+ Those not provided are turned 'off', so cam.setMode() -- without
arguments -- turns off all mode flags for Camera cam.
@type mode1: string
@type mode2: string
@@ -99,58 +102,54 @@ class Camera:
@param mode2: A mode flag: 'showLimits' or 'showMist'.
"""
- def getLens(self):
+ def getLens():
"""
Get the lens value.
@rtype: float
"""
- def setLens(self, lens):
+ def setLens(lens):
"""
Set the lens value.
@type lens: float
@param lens: The new lens value.
- @warning: The value will be clamped to the min/max limits of this variable.
"""
- def getClipStart(self):
+ def getClipStart():
"""
Get the clip start value.
@rtype: float
"""
- def setClipStart(self, clipStart):
+ def setClipStart(clipstart):
"""
Set the clip start value.
- @type clipStart: float
- @param clipStart: The new lens value.
- @warning: The value will be clamped to the min/max limits of this variable.
+ @type clipstart: float
+ @param clipstart: The new lens value.
"""
- def getClipEnd(self):
+ def getClipEnd():
"""
Get the clip end value.
@rtype: float
"""
- def setClipEnd(self, clipEnd):
+ def setClipEnd(clipend):
"""
Set the clip end value.
- @type clipEnd: float
- @param clipEnd: The new clip end value.
- @warning: The value will be clamped to the min/max limits of this variable.
+ @type clipend: float
+ @param clipend: The new clip end value.
"""
- def getDrawSize(self):
+ def getDrawSize():
"""
Get the draw size value.
@rtype: float
"""
- def setDrawSize(self, drawSize):
+ def setDrawSize(drawsize):
"""
Set the draw size value.
- @type drawSize: float
- @param drawSize: The new draw size value.
- @warning: The value will be clamped to the min/max limits of this variable.
+ @type drawsize: float
+ @param drawsize: The new draw size value.
"""
diff --git a/source/blender/python/api2_2x/doc/Lamp.py b/source/blender/python/api2_2x/doc/Lamp.py
new file mode 100644
index 00000000000..190a20ead47
--- /dev/null
+++ b/source/blender/python/api2_2x/doc/Lamp.py
@@ -0,0 +1,319 @@
+# Blender.Lamp module and the Lamp PyType object
+
+"""
+The Blender.Lamp submodule
+
+This module provides control over B{Lamp Data} objects in Blender.
+
+Example::
+
+ from Blender import Lamp
+ l = Lamp.New('Spot') # create new 'Spot' lamp data
+ l.setMode('square', 'shadow') # set these two lamp mode flags
+ ob = Object.New('Lamp') # create new lamp object
+ ob.link(l) # link lamp obj with lamp data
+"""
+
+def New (type = 'Lamp', name = 'LampData'):
+ """
+ Create a new Lamp Data object.
+ @type type: string
+ @param type: The Lamp type: 'Lamp', 'Sun', 'Spot' or 'Hemi'.
+ @type name: string
+ @param name: The Lamp Data name.
+ @rtype: Blender Lamp
+ @return: The created Lamp Data object.
+ """
+
+def Get (name = None):
+ """
+ Get the Lamp Data object(s) from Blender.
+ @type name: string
+ @param name: The name of the Lamp Data.
+ @rtype: Blender Lamp or a list of Blender Lamps
+ @return: It depends on the 'name' parameter:
+ - (name): The Lamp Data object with the given name;
+ - (): A list with all Lamp Data objects in the current scene.
+ """
+
+class Lamp:
+ """
+ The Lamp Data object
+ ====================
+ This object gives access to Lamp-specific data in Blender.
+ @cvar name: The Lamp Data name.
+ @cvar type: The Lamp type (see the Types dict).
+ @cvar Types: The Types dictionary.
+ - 'Lamp': 0
+ - 'Sun' : 1
+ - 'Spot': 2
+ - 'Hemi': 3
+ @cvar mode: The mode flags: B{or'ed value} of the flags in the Modes dict.
+ @cvar Modes: The Modes dictionary.
+ - 'Shadows'
+ - 'Halo'
+ - 'Layer'
+ - 'Quad'
+ - 'Negative'
+ - 'OnlyShadow'
+ - 'Sphere'
+ - 'Square'
+ @cvar samples: The number of shadow map samples in [1, 16].
+ @cvar bufferSize: The size of the shadow buffer in [512, 5120].
+ @cvar haloStep: Volumetric halo sampling frequency in [0, 12].
+ @cvar energy: The intensity of the light in [0.0, 10.0].
+ @cvar dist: The distance value in [0.1, 5000.0].
+ @cvar spotSize: The angle of the spot beam in degrees in [1.0, 180.0].
+ @cvar spotBlend: The softness of the spot edge in [0.0, 1.0].
+ @cvar clipStart: The shadow map clip start in [0.1, 1000.0].
+ @cvar clipEnd: The shadow map clip end in [1.0, 5000.0].
+ @cvar bias: The shadow map sampling bias in [0.01, 5.00].
+ @cvar softness: The size of the shadow sample area in [1.0, 100.0].
+ @cvar haloInt: The intensity of the spot halo in [0.0, 5.0].
+ @cvar quad1: Light intensity value 1 for a Quad lamp in [0.0, 1.0].
+ @cvar quad2: Light intensity value 2 for a Quad lamp in [0.0, 1.0].
+ @cvar col: The color of the light, with each rgb component in [0.0, 1.0].
+ This is an rgb tuple whose values can be accessed in many ways:
+ - as a tuple: lamp.col, lamp.col[0], same for 1 and 2.
+ - as a dictionary: lamp.col['R'], same for 'G' and 'B'.
+ - as an object: lamp.col.R, same for G and B.
+ @warning: Most member variables assume values in some [Min, Max] interval.
+ When trying to set them, the given parameter will be clamped to lie in
+ that range: if val < Min, then val = Min, if val > Max, then val = Max.
+ """
+
+ def getName():
+ """
+ Get the name of this Lamp Data object.
+ @rtype: string
+ """
+
+ def setName(name):
+ """
+ Set the name of this Lamp Data object.
+ @type name: string
+ @param name: The new name.
+ """
+
+ def getType():
+ """
+ Get this Lamp's type.
+ @rtype: int
+ """
+
+ def setType(type):
+ """
+ Set this Lamp's type.
+ @type type: string
+ @param type: The Lamp type: 'Lamp', 'Sun', 'Spot' or 'Hemi'.
+ """
+
+ def getMode():
+ """
+ Get this Lamp's mode flags.
+ @rtype: int
+ @return: B{OR'ed value}. Use the Modes dictionary to check which flags
+ are 'on'.
+
+ Example::
+ flags = mylamp.getMode()
+ if flags & mylamp.Modes['Shadows']:
+ print "This lamp produces shadows"
+ else:
+ print "The 'Shadows' flag is off"
+ """
+
+ def setMode(m = None, m2 = None, m3 = None, m4 = None,
+ m5 = None, m6 = None, m7 = None, m8 = None):
+ """
+ Set this Lamp's mode flags. Mode strings given are turned 'on'.
+ Those not provided are turned 'off', so lamp.setMode() -- without
+ arguments -- turns off all mode flags for Lamp lamp.
+ @type m: string
+ @param m: A mode flag. From 1 to 8 can be set at the same time.
+ """
+
+ def getSamples():
+ """
+ Get this lamp's samples value.
+ @rtype: int
+ """
+
+ def setSamples(samples):
+ """
+ Set the samples value.
+ @type samples: int
+ @param samples: The new samples value.
+ """
+
+ def getBufferSize():
+ """
+ Get this lamp's buffer size.
+ @rtype: int
+ """
+
+ def setBufferSize(bufsize):
+ """
+ Set the buffer size value.
+ @type bufsize: int
+ @param bufsize: The new buffer size value.
+ """
+
+ def getHaloStep():
+ """
+ Get this lamp's halo step value.
+ @rtype: int
+ """
+
+ def setHaloStep(hastep):
+ """
+ Set the halo step value.
+ @type hastep: int
+ @param hastep: The new halo step value.
+ """
+
+ def getEnergy():
+ """
+ Get this lamp's energy intensity value.
+ @rtype: float
+ """
+
+ def setEnergy(energy):
+ """
+ Set the energy intensity value.
+ @type energy: float
+ @param energy: The new energy value.
+ """
+
+ def getDist():
+ """
+ Get this lamp's distance value.
+ @rtype: float
+ """
+
+ def setDist(distance):
+ """
+ Set the distance value.
+ @type distance: float
+ @param distance: The new distance value.
+ """
+
+ def getSpotSize():
+ """
+ Get this lamp's spot size value.
+ @rtype: float
+ """
+
+ def setSpotSize(spotsize):
+ """
+ Set the spot size value.
+ @type spotsize: float
+ @param spotsize: The new spot size value.
+ """
+
+ def getSpotBlend():
+ """
+ Get this lamp's spot blend value.
+ @rtype: float
+ """
+
+ def setSpotBlend(spotblend):
+ """
+ Set the spot blend value.
+ @type spotblend: float
+ @param spotblend: The new spot blend value.
+ """
+
+ def getClipStart():
+ """
+ Get this lamp's clip start value.
+ @rtype: float
+ """
+
+ def setClipStart(clipstart):
+ """
+ Set the clip start value.
+ @type clipstart: float
+ @param clipstart: The new clip start value.
+ """
+
+ def getClipEnd():
+ """
+ Get this lamp's clip end value.
+ @rtype: float
+ """
+
+ def setClipEnd(clipend):
+ """
+ Set the clip end value.
+ @type clipend: float
+ @param clipend: The new clip end value.
+ """
+
+ def getBias():
+ """
+ Get this lamp's bias value.
+ @rtype: float
+ """
+
+ def setBias(bias):
+ """
+ Set the bias value.
+ @type bias: float
+ @param bias: The new bias value.
+ """
+
+ def getSoftness():
+ """
+ Get this lamp's softness value.
+ @rtype: float
+ """
+
+ def setSoftness(softness):
+ """
+ Set the softness value.
+ @type softness: float
+ @param softness: The new softness value.
+ """
+
+ def getHaloInt():
+ """
+ Get this lamp's halo intensity value.
+ @rtype: float
+ """
+
+ def setHaloInt(haloint):
+ """
+ Set the halo intensity value.
+ @type haloint: float
+ @param haloint: The new halo intensity value.
+ """
+
+ def getQuad1():
+ """
+ Get this lamp's quad 1 value.
+ @rtype: float
+ @warning: this only applies to Lamps with the 'Quad' flag on.
+ """
+
+ def setQuad1(quad1):
+ """
+ Set the quad 1 value.
+ @type quad1: float
+ @warning: this only applies to Lamps with the 'Quad' flag on.
+ """
+
+ def getQuad2():
+ """
+ Get this lamp's quad 2 value.
+ @rtype: float
+ @warning: this only applies to Lamps with the 'Quad' flag on.
+ """
+
+ def setQuad2(quad2):
+ """
+ Set the quad 2 value.
+ @type quad2: float
+ @param quad2: The new quad 2 value.
+ @warning: this only applies to Lamps with the 'Quad' flag on.
+ """
diff --git a/source/blender/python/api2_2x/doc/testcamera.py b/source/blender/python/api2_2x/doc/testcamera.py
new file mode 100644
index 00000000000..a84b3ac5b15
--- /dev/null
+++ b/source/blender/python/api2_2x/doc/testcamera.py
@@ -0,0 +1,137 @@
+# Blender.Camera module and Camera PyType test file
+# This also works with Lamp and Material, simply uncomment the right
+# line below
+
+MODULE = "Camera"
+#MODULE = "Lamp"
+#MODULE = "Material"
+BPY_OBJECT = MODULE
+
+LONG_STRING = "Supercalifragilisticspialidous"
+
+import types, sys
+import Blender
+exec ("from Blender import %s" % MODULE)
+
+def PRINT_HEADER(header, sep):
+ print "\n", sep * 79
+ print header
+ print sep * 79
+
+def PRINT_UNDERLINED(str):
+ print "\n", str
+ print "-" * len(str)
+
+def PRINT_AND_RM(arg, branch, d):
+ for a in arg:
+ if a in d:
+ d.remove(a)
+ print "\n%s.%s:" % (branch, a),
+ exec("print %s.%s" % (branch, a))
+
+PRINT_HEADER("Testing the Blender.%s module" % MODULE, '=')
+
+exec ("Module_dir = dir (%s)" % MODULE)
+print "\ndir (%s):" % MODULE
+print Module_dir
+
+PRINT_AND_RM (["__name__", "__doc__"], MODULE, Module_dir)
+
+for item in Module_dir:
+ hooked = 0
+ branch = "%s.%s" % (MODULE, item)
+ PRINT_HEADER(branch, "-")
+ exec ("item_type = type (%s)" % branch)
+ print item_type
+ exec ("sub_dir = dir(%s)" % branch)
+ PRINT_AND_RM (["__name__", "__doc__"], branch, sub_dir)
+ if item_type == types.BuiltinFunctionType:
+ PRINT_UNDERLINED ("Executing %s:" % branch)
+ exec ("result = %s()" % branch)
+ print "Returned value is: ", result
+ if item in ["Get", "get"] and not hooked:
+ if len(result):
+ obj = result[0]
+ hooked = 1
+
+if hooked:
+ PRINT_HEADER(obj, "=")
+ exec ("obj_dir = dir(obj)")
+ print "\ndir():"
+ print obj_dir
+
+ methods = []
+ member_vars = []
+
+ for item in obj_dir:
+ exec ("item_type = type (obj.%s)" % item)
+ if item_type == types.BuiltinMethodType:
+ methods.append(item)
+ else:
+ member_vars.append(item)
+
+ PRINT_HEADER("%s Methods" % BPY_OBJECT, '-')
+ if methods: print methods
+ else: print "XXX No methods found in %s" % BPY_OBJECT
+
+ PRINT_HEADER("%s Member Variables" % BPY_OBJECT, '-')
+ if member_vars:
+ for m in member_vars:
+ PRINT_UNDERLINED(m)
+ exec ("mvalue = obj.%s" % m)
+ exec ("mtype = type (obj.%s)" % m)
+ mtype = str(mtype).split("'")[1]
+ print "%s: %s" % (mtype, mvalue)
+
+ M = m[0].upper() + m[1:]
+ setM = "set%s" % M
+ getM = "get%s" % M
+ if setM in methods:
+ print "There is a .%s() method." % setM
+ methods.remove(setM)
+ if mtype == 'str':
+ try:
+ print "Trying to set string to %s" % LONG_STRING
+ exec("obj.%s('%s')" % (setM, LONG_STRING))
+ exec("get_str = obj.%s()" % getM)
+ print "It returned:", get_str
+ len_str = len(get_str)
+ if len_str < 100:
+ print "It correctly clamped the string to %s chars." % len_str
+ except:
+ PRINT_HEADER("FAILED in .%s()" % setM, "X")
+ print sys.exc_info()[0]
+ elif mtype == 'float':
+ try:
+ exec("obj.%s(%d)" % (setM, -999999))
+ exec("result = obj.%s()" % getM)
+ print "%s's minimum value is %f" % (m, result)
+ exec("obj.%s(%d)" % (setM, 999999))
+ exec("result = obj.%s()" % getM)
+ print "%s's maximum value is %f" % (m, result)
+ except:
+ PRINT_HEADER("FAILED in %s or %s" % (setM, getM), "X")
+ print sys.exc_info()[0]
+ elif mtype == 'int':
+ try:
+ dict = M+"s"
+ if dict in member_vars:
+ exec("key = obj.%s.keys()[1]" % dict)
+ exec("obj.%s('%s')" % (setM, key))
+ exec("result = obj.%s()" % getM)
+ except:
+ PRINT_HEADER("FAILED in %s or %s" % (setM, getM), "X")
+ print sys.exc_info()[0]
+
+ if getM in methods:
+ print "There is a .%s() method." % getM,
+ methods.remove(getM)
+ exec("result = obj.%s()" % getM)
+ print "It returned:", result
+
+ else: print "XXX No member variables found in %s" % BPY_OBJECT
+
+else: # the module .Get() function found nothing
+ PRINT_HEADER("Failed trying to %s.Get() a %s object"
+ % (MODULE, BPY_OBJECT), 'X')
+
diff --git a/source/blender/python/api2_2x/modules.h b/source/blender/python/api2_2x/modules.h
index 0a444ed87f0..9f25f2815d5 100644
--- a/source/blender/python/api2_2x/modules.h
+++ b/source/blender/python/api2_2x/modules.h
@@ -55,7 +55,7 @@ extern PyObject *g_blenderdict;
/* Module Init functions and Data Object helper functions (used by the */
/* Object module to work with its .data field for the various Data objs */
/*****************************************************************************/
-void M_Blender_Init (void);
+void M_Blender_Init (void);
/* Object itself */
PyObject * M_Object_Init (void);
@@ -64,31 +64,31 @@ int M_ObjectCheckPyObject (PyObject *py_obj);
struct Object * M_ObjectFromPyObject (PyObject *py_obj);
/* Scene */
-PyObject * M_Scene_Init (void);
+PyObject * Scene_Init (void);
PyObject * Scene_CreatePyObject (struct Scene *sce);
Scene * Scene_FromPyObject (PyObject *pyobj);
int Scene_CheckPyObject (PyObject *pyobj);
/* Types */
-PyObject * M_Types_Init (void);
+PyObject * Types_Init (void);
/* NMesh Data */
-PyObject * M_NMesh_Init (void);
+PyObject * NMesh_Init (void);
PyObject * NMesh_CreatePyObject (struct Camera *cam);
Camera * NMesh_FromPyObject (PyObject *pyobj);
int NMesh_CheckPyObject (PyObject *pyobj);
/* Material */
-PyObject * M_Material_Init (void);
+PyObject * Material_Init (void);
/* Camera Data */
-PyObject * M_Camera_Init (void);
+PyObject * Camera_Init (void);
PyObject * Camera_CreatePyObject (struct Camera *cam);
Camera * Camera_FromPyObject (PyObject *pyobj);
int Camera_CheckPyObject (PyObject *pyobj);
/* Lamp Data */
-PyObject * M_Lamp_Init (void);
+PyObject * Lamp_Init (void);
PyObject * Lamp_CreatePyObject (struct Lamp *lamp);
Lamp * Lamp_FromPyObject (PyObject *pyobj);
int Lamp_CheckPyObject (PyObject *pyobj);
@@ -124,15 +124,15 @@ struct Effect * Effect_FromPyObject (PyObject *py_obj);
int Effect_CheckPyObject (PyObject *py_obj);
/* Image */
-PyObject * M_Image_Init (void);
+PyObject * Image_Init (void);
PyObject * Image_CreatePyObject (Image *image);
int Image_CheckPyObject (PyObject *pyobj);
/* Init functions for other modules */
-PyObject * M_Window_Init (void);
-PyObject * M_Draw_Init (void);
-PyObject * M_BGL_Init (void);
-PyObject * M_Text_Init (void);
+PyObject * Window_Init (void);
+PyObject * Draw_Init (void);
+PyObject * BGL_Init (void);
+PyObject * Text_Init (void);
PyObject * M_World_Init (void);
#endif /* EXPP_modules_h */
diff --git a/source/blender/python/api2_2x/rgbTuple.c b/source/blender/python/api2_2x/rgbTuple.c
index 7638b89eeed..356ca4145ed 100644
--- a/source/blender/python/api2_2x/rgbTuple.c
+++ b/source/blender/python/api2_2x/rgbTuple.c
@@ -37,22 +37,22 @@
/*****************************************************************************/
/* Python rgbTuple_Type callback function prototypes: */
/*****************************************************************************/
-static void rgbTupleDeAlloc (C_rgbTuple *self);
-static PyObject *rgbTupleGetAttr (C_rgbTuple *self, char *name);
-static int rgbTupleSetAttr (C_rgbTuple *self, char *name, PyObject *v);
-static int rgbTuplePrint(C_rgbTuple *self, FILE *fp, int flags);
-static PyObject *rgbTupleRepr (C_rgbTuple *self);
+static void rgbTupleDeAlloc (BPy_rgbTuple *self);
+static PyObject *rgbTupleGetAttr (BPy_rgbTuple *self, char *name);
+static int rgbTupleSetAttr (BPy_rgbTuple *self, char *name, PyObject *v);
+static int rgbTuplePrint(BPy_rgbTuple *self, FILE *fp, int flags);
+static PyObject *rgbTupleRepr (BPy_rgbTuple *self);
-static int rgbTupleLength(C_rgbTuple *self);
+static int rgbTupleLength(BPy_rgbTuple *self);
-static PyObject *rgbTupleSubscript(C_rgbTuple *self, PyObject *key);
-static int rgbTupleAssSubscript(C_rgbTuple *self, PyObject *who,
+static PyObject *rgbTupleSubscript(BPy_rgbTuple *self, PyObject *key);
+static int rgbTupleAssSubscript(BPy_rgbTuple *self, PyObject *who,
PyObject *cares);
-static PyObject *rgbTupleItem(C_rgbTuple *self, int i);
-static int rgbTupleAssItem(C_rgbTuple *self, int i, PyObject *ob);
-static PyObject *rgbTupleSlice(C_rgbTuple *self, int begin, int end);
-static int rgbTupleAssSlice(C_rgbTuple *self, int begin, int end, PyObject *seq);
+static PyObject *rgbTupleItem(BPy_rgbTuple *self, int i);
+static int rgbTupleAssItem(BPy_rgbTuple *self, int i, PyObject *ob);
+static PyObject *rgbTupleSlice(BPy_rgbTuple *self, int begin, int end);
+static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end, PyObject *seq);
/*****************************************************************************/
/* Python rgbTuple_Type Mapping Methods table: */
@@ -86,7 +86,7 @@ PyTypeObject rgbTuple_Type =
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"rgbTuple", /* tp_name */
- sizeof (C_rgbTuple), /* tp_basicsize */
+ sizeof (BPy_rgbTuple), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)rgbTupleDeAlloc, /* tp_dealloc */
@@ -111,13 +111,11 @@ PyTypeObject rgbTuple_Type =
/*****************************************************************************/
PyObject *rgbTuple_New(float *rgb[3])
{
- C_rgbTuple *rgbTuple;
-
- printf ("In rgbTuple_New()\n");
+ BPy_rgbTuple *rgbTuple;
rgbTuple_Type.ob_type = &PyType_Type;
- rgbTuple = (C_rgbTuple *)PyObject_NEW(C_rgbTuple, &rgbTuple_Type);
+ rgbTuple = (BPy_rgbTuple *)PyObject_NEW(BPy_rgbTuple, &rgbTuple_Type);
if (rgbTuple == NULL)
return EXPP_ReturnPyObjError (PyExc_MemoryError,
@@ -136,7 +134,7 @@ PyObject *rgbTuple_New(float *rgb[3])
/* get function returns a tuple, the set one accepts three */
/* floats (separated or in a tuple) as arguments. */
/*****************************************************************************/
-PyObject *rgbTuple_getCol (C_rgbTuple *self)
+PyObject *rgbTuple_getCol (BPy_rgbTuple *self)
{
PyObject *list = PyList_New (3);
@@ -144,13 +142,13 @@ PyObject *rgbTuple_getCol (C_rgbTuple *self)
"couldn't create PyList");
PyList_SET_ITEM (list, 0, Py_BuildValue ("f", *(self->rgb[0]) ));
- PyList_SET_ITEM (list, 1, Py_BuildValue ("f", *(self->rgb[0]) ));
- PyList_SET_ITEM (list, 2, Py_BuildValue ("f", *(self->rgb[0]) ));
+ PyList_SET_ITEM (list, 1, Py_BuildValue ("f", *(self->rgb[1]) ));
+ PyList_SET_ITEM (list, 2, Py_BuildValue ("f", *(self->rgb[2]) ));
return list;
}
-PyObject *rgbTuple_setCol (C_rgbTuple *self, PyObject *args)
+PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args)
{
int ok;
float r = 0, g = 0, b = 0;
@@ -173,21 +171,21 @@ PyObject *rgbTuple_setCol (C_rgbTuple *self, PyObject *args)
/*****************************************************************************/
/* Function: rgbTupleDeAlloc */
-/* Description: This is a callback function for the C_rgbTuple type. It is */
+/* Description: This is a callback function for the BPy_rgbTuple type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void rgbTupleDeAlloc (C_rgbTuple *self)
+static void rgbTupleDeAlloc (BPy_rgbTuple *self)
{
PyObject_DEL (self);
}
/*****************************************************************************/
/* Function: rgbTupleGetAttr */
-/* Description: This is a callback function for the C_rgbTuple type. It is */
-/* the function that accesses C_rgbTuple member variables and */
+/* Description: This is a callback function for the BPy_rgbTuple type. It is */
+/* the function that accesses BPy_rgbTuple member variables and */
/* methods. */
/*****************************************************************************/
-static PyObject* rgbTupleGetAttr (C_rgbTuple *self, char *name)
+static PyObject* rgbTupleGetAttr (BPy_rgbTuple *self, char *name)
{
int i;
@@ -206,10 +204,10 @@ static PyObject* rgbTupleGetAttr (C_rgbTuple *self, char *name)
/*****************************************************************************/
/* Function: rgbTupleSetAttr */
-/* Description: This is a callback function for the C_rgbTuple type. It is */
-/* the function that changes C_rgbTuple member variables. */
+/* Description: This is a callback function for the BPy_rgbTuple type. It is */
+/* the function that changes BPy_rgbTuple member variables. */
/*****************************************************************************/
-static int rgbTupleSetAttr (C_rgbTuple *self, char *name, PyObject *v)
+static int rgbTupleSetAttr (BPy_rgbTuple *self, char *name, PyObject *v)
{
float value;
@@ -239,12 +237,12 @@ static int rgbTupleSetAttr (C_rgbTuple *self, char *name, PyObject *v)
/* These functions provide code to access rgbTuple objects as */
/* mappings. */
/*****************************************************************************/
-static int rgbTupleLength(C_rgbTuple *self)
+static int rgbTupleLength(BPy_rgbTuple *self)
{
return 3;
}
-static PyObject *rgbTupleSubscript(C_rgbTuple *self, PyObject *key)
+static PyObject *rgbTupleSubscript(BPy_rgbTuple *self, PyObject *key)
{
char *name = NULL;
int i;
@@ -264,7 +262,7 @@ static PyObject *rgbTupleSubscript(C_rgbTuple *self, PyObject *key)
return Py_BuildValue("f", *(self->rgb[i]));
}
-static int rgbTupleAssSubscript(C_rgbTuple *self, PyObject *key, PyObject *v)
+static int rgbTupleAssSubscript(BPy_rgbTuple *self, PyObject *key, PyObject *v)
{
char *name = NULL;
int i;
@@ -295,7 +293,7 @@ static int rgbTupleAssSubscript(C_rgbTuple *self, PyObject *key, PyObject *v)
/* These functions provide code to access rgbTuple objects as */
/* sequences. */
/*****************************************************************************/
-static PyObject *rgbTupleItem(C_rgbTuple *self, int i)
+static PyObject *rgbTupleItem(BPy_rgbTuple *self, int i)
{
if (i < 0 || i >= 3)
return EXPP_ReturnPyObjError (PyExc_IndexError,
@@ -304,7 +302,7 @@ static PyObject *rgbTupleItem(C_rgbTuple *self, int i)
return Py_BuildValue("f", *(self->rgb[i]));
}
-static PyObject *rgbTupleSlice(C_rgbTuple *self, int begin, int end)
+static PyObject *rgbTupleSlice(BPy_rgbTuple *self, int begin, int end)
{
PyObject *list;
int count;
@@ -322,7 +320,7 @@ static PyObject *rgbTupleSlice(C_rgbTuple *self, int begin, int end)
return list;
}
-static int rgbTupleAssItem(C_rgbTuple *self, int i, PyObject *ob)
+static int rgbTupleAssItem(BPy_rgbTuple *self, int i, PyObject *ob)
{
if (i < 0 || i >= 3)
return EXPP_ReturnIntError(PyExc_IndexError,
@@ -337,7 +335,8 @@ static int rgbTupleAssItem(C_rgbTuple *self, int i, PyObject *ob)
return 0;
}
-static int rgbTupleAssSlice(C_rgbTuple *self, int begin, int end, PyObject *seq)
+static int rgbTupleAssSlice(BPy_rgbTuple *self, int begin, int end,
+ PyObject *seq)
{
int count;
@@ -372,10 +371,10 @@ static int rgbTupleAssSlice(C_rgbTuple *self, int begin, int end, PyObject *seq)
/*****************************************************************************/
/* Function: rgbTuplePrint */
-/* Description: This is a callback function for the C_rgbTuple type. It */
+/* Description: This is a callback function for the BPy_rgbTuple type. It */
/* builds a meaninful string to 'print' rgbTuple objects. */
/*****************************************************************************/
-static int rgbTuplePrint(C_rgbTuple *self, FILE *fp, int flags)
+static int rgbTuplePrint(BPy_rgbTuple *self, FILE *fp, int flags)
{
fprintf(fp, "[%f, %f, %f]",
*(self->rgb[0]), *(self->rgb[1]), *(self->rgb[2]));
@@ -384,10 +383,10 @@ static int rgbTuplePrint(C_rgbTuple *self, FILE *fp, int flags)
/*****************************************************************************/
/* Function: rgbTupleRepr */
-/* Description: This is a callback function for the C_rgbTuple type. It */
+/* Description: This is a callback function for the BPy_rgbTuple type. It */
/* builds a meaninful string to represent rgbTuple objects. */
/*****************************************************************************/
-static PyObject *rgbTupleRepr (C_rgbTuple *self)
+static PyObject *rgbTupleRepr (BPy_rgbTuple *self)
{
float r, g, b;
char buf[64];
diff --git a/source/blender/python/api2_2x/rgbTuple.h b/source/blender/python/api2_2x/rgbTuple.h
index a2ca43d3ae8..731c8904738 100644
--- a/source/blender/python/api2_2x/rgbTuple.h
+++ b/source/blender/python/api2_2x/rgbTuple.h
@@ -41,19 +41,19 @@
* objects, so this header file must contain only 'public' declarations */
/*****************************************************************************/
-/* Python C_rgbTuple structure definition: */
+/* Python BPy_rgbTuple structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
float *rgb[3]; /* array of three pointers to floats */
-} C_rgbTuple;
+} BPy_rgbTuple;
/*****************************************************************************/
/* Python API function prototypes for the rgbTuple helper module. */
/*****************************************************************************/
PyObject *rgbTuple_New (float *rgb[3]);
-PyObject *rgbTuple_getCol (C_rgbTuple *self);
-PyObject *rgbTuple_setCol (C_rgbTuple *self, PyObject *args);
+PyObject *rgbTuple_getCol (BPy_rgbTuple *self);
+PyObject *rgbTuple_setCol (BPy_rgbTuple *self, PyObject *args);
#endif /* EXPP_rgbTuple_H */