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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-02-24 06:39:38 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2013-02-24 06:39:38 +0400
commit3df023ae82eef0ea105dc61c9730af87b59a07d1 (patch)
tree2d2a4e753c1129fc91f360f0457d30859cd38737 /source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
parentd38a335d47f1632000db5172877499ff0184d114 (diff)
Freestyle Python API improvements - part 8.
* Proper handling of keyword arguments was implemented in Operators and ContextFunctions, as well as in methods of Interface0D, Interface1D, Iterator, their subclasses, Noise and IntegrationType. * Operators' methods and functions in the ContextFunctions module were renamed from CamelCase to lower cases + underscores. Style modules were updated accordingly. * Additional code clean-up was also made.
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp')
-rw-r--r--source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp202
1 files changed, 93 insertions, 109 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
index e96df3fe762..af5085dc548 100644
--- a/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
+++ b/source/blender/freestyle/intern/python/BPy_ContextFunctions.cpp
@@ -37,13 +37,13 @@
#ifdef __cplusplus
extern "C" {
#endif
-
+
///////////////////////////////////////////////////////////////////////////////////////////
//------------------------ MODULE FUNCTIONS ----------------------------------
-static char ContextFunctions_GetTimeStampCF___doc__[] =
-".. function:: GetTimeStampCF()\n"
+static char ContextFunctions_get_time_stamp___doc__[] =
+".. function:: get_time_stamp()\n"
"\n"
" Returns the system time stamp.\n"
"\n"
@@ -51,13 +51,13 @@ static char ContextFunctions_GetTimeStampCF___doc__[] =
" :rtype: int\n";
static PyObject *
-ContextFunctions_GetTimeStampCF( PyObject* self )
+ContextFunctions_get_time_stamp(PyObject* self)
{
- return PyLong_FromLong( ContextFunctions::GetTimeStampCF() );
+ return PyLong_FromLong(ContextFunctions::GetTimeStampCF());
}
-static char ContextFunctions_GetCanvasWidthCF___doc__[] =
-".. method:: GetCanvasWidthCF()\n"
+static char ContextFunctions_get_canvas_width___doc__[] =
+".. method:: get_canvas_width()\n"
"\n"
" Returns the canvas width.\n"
"\n"
@@ -65,13 +65,13 @@ static char ContextFunctions_GetCanvasWidthCF___doc__[] =
" :rtype: int\n";
static PyObject *
-ContextFunctions_GetCanvasWidthCF( PyObject* self )
+ContextFunctions_get_canvas_width(PyObject* self)
{
- return PyLong_FromLong( ContextFunctions::GetCanvasWidthCF() );
+ return PyLong_FromLong(ContextFunctions::GetCanvasWidthCF());
}
-static char ContextFunctions_GetCanvasHeightCF___doc__[] =
-".. method:: GetCanvasHeightCF()\n"
+static char ContextFunctions_get_canvas_height___doc__[] =
+".. method:: get_canvas_height()\n"
"\n"
" Returns the canvas height.\n"
"\n"
@@ -79,49 +79,48 @@ static char ContextFunctions_GetCanvasHeightCF___doc__[] =
" :rtype: int\n";
static PyObject *
-ContextFunctions_GetCanvasHeightCF( PyObject* self )
+ContextFunctions_get_canvas_height(PyObject* self)
{
- return PyLong_FromLong( ContextFunctions::GetCanvasHeightCF() );
+ return PyLong_FromLong(ContextFunctions::GetCanvasHeightCF());
}
-static char ContextFunctions_LoadMapCF___doc__[] =
-".. function:: LoadMapCF(iFileName, iMapName, iNbLevels=4, iSigma=1.0)\n"
+static char ContextFunctions_load_map___doc__[] =
+".. function:: load_map(file_name, map_name, num_levels=4, sigma=1.0)\n"
"\n"
" Loads an image map for further reading.\n"
"\n"
-" :arg iFileName: The name of the image file.\n"
-" :type iFileName: str\n"
-" :arg iMapName: The name that will be used to access this image.\n"
-" :type iMapName: str\n"
-" :arg iNbLevels: The number of levels in the map pyramid\n"
-" (default = 4). If iNbLevels == 0, the complete pyramid is\n"
+" :arg file_name: The name of the image file.\n"
+" :type file_name: str\n"
+" :arg map_name: The name that will be used to access this image.\n"
+" :type map_name: str\n"
+" :arg num_levels: The number of levels in the map pyramid\n"
+" (default = 4). If num_levels == 0, the complete pyramid is\n"
" built.\n"
-" :type iNbLevels: int\n"
-" :arg iSigma: The sigma value of the gaussian function.\n"
-" :type iSigma: float\n";
+" :type num_levels: int\n"
+" :arg sigma: The sigma value of the gaussian function.\n"
+" :type sigma: float\n";
static PyObject *
-ContextFunctions_LoadMapCF( PyObject *self, PyObject *args )
+ContextFunctions_load_map(PyObject *self, PyObject *args, PyObject *kwds)
{
- char *fileName, *mapName;
- unsigned nbLevels;
- float sigma;
-
- if( !PyArg_ParseTuple(args, "ssIf", &fileName, &mapName, &nbLevels, &sigma) )
- return NULL;
-
- ContextFunctions::LoadMapCF(fileName, mapName, nbLevels, sigma);
-
- Py_RETURN_NONE;
+ static const char *kwlist[] = {"file_name", "map_name", "num_levels", "sigma", NULL};
+ char *fileName, *mapName;
+ unsigned nbLevels = 4;
+ float sigma = 1.0;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|If", (char **)kwlist, &fileName, &mapName, &nbLevels, &sigma))
+ return NULL;
+ ContextFunctions::LoadMapCF(fileName, mapName, nbLevels, sigma);
+ Py_RETURN_NONE;
}
-static char ContextFunctions_ReadMapPixelCF___doc__[] =
-".. function:: ReadMapPixelCF(iMapName, level, x, y)\n"
+static char ContextFunctions_read_map_pixel___doc__[] =
+".. function:: read_map_pixel(map_name, level, x, y)\n"
"\n"
" Reads a pixel in a user-defined map.\n"
"\n"
-" :arg iMapName: The name of the map.\n"
-" :type iMapName: str\n"
+" :arg map_name: The name of the map.\n"
+" :type map_name: str\n"
" :arg level: The level of the pyramid in which we wish to read the\n"
" pixel.\n"
" :type level: int\n"
@@ -135,22 +134,20 @@ static char ContextFunctions_ReadMapPixelCF___doc__[] =
" :rtype: float\n";
static PyObject *
-ContextFunctions_ReadMapPixelCF( PyObject *self, PyObject *args )
+ContextFunctions_read_map_pixel(PyObject *self, PyObject *args, PyObject *kwds)
{
- char *mapName;
- int level;
- unsigned x, y;
-
- if( !PyArg_ParseTuple(args, "siII", &mapName, &level, &x, &y) )
- return NULL;
-
- float f = ContextFunctions::ReadMapPixelCF(mapName, level, x, y);
-
- return PyFloat_FromDouble( f );
+ static const char *kwlist[] = {"map_name", "level", "x", "y", NULL};
+ char *mapName;
+ int level;
+ unsigned x, y;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "siII", (char **)kwlist, &mapName, &level, &x, &y))
+ return NULL;
+ return PyFloat_FromDouble(ContextFunctions::ReadMapPixelCF(mapName, level, x, y));
}
-static char ContextFunctions_ReadCompleteViewMapPixelCF___doc__[] =
-".. function:: ReadCompleteViewMapPixelCF(level, x, y)\n"
+static char ContextFunctions_read_complete_view_map_pixel___doc__[] =
+".. function:: read_complete_view_map_pixel(level, x, y)\n"
"\n"
" Reads a pixel in the complete view map.\n"
"\n"
@@ -167,27 +164,25 @@ static char ContextFunctions_ReadCompleteViewMapPixelCF___doc__[] =
" :rtype: float\n";
static PyObject *
-ContextFunctions_ReadCompleteViewMapPixelCF( PyObject *self, PyObject *args )
+ContextFunctions_read_complete_view_map_pixel(PyObject *self, PyObject *args, PyObject *kwds)
{
- int level;
- unsigned x, y;
+ static const char *kwlist[] = {"level", "x", "y", NULL};
+ int level;
+ unsigned x, y;
- if( !PyArg_ParseTuple(args, "iII", &level, &x, &y) )
- return NULL;
-
- float f = ContextFunctions::ReadCompleteViewMapPixelCF(level, x, y);
-
- return PyFloat_FromDouble( f );
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "iII", (char **)kwlist, &level, &x, &y))
+ return NULL;
+ return PyFloat_FromDouble(ContextFunctions::ReadCompleteViewMapPixelCF(level, x, y));
}
-static char ContextFunctions_ReadDirectionalViewMapPixelCF___doc__[] =
-".. function:: ReadDirectionalViewMapPixelCF(iOrientation, level, x, y)\n"
+static char ContextFunctions_read_directional_view_map_pixel___doc__[] =
+".. function:: read_directional_view_map_pixel(orientation, level, x, y)\n"
"\n"
" Reads a pixel in one of the oriented view map images.\n"
"\n"
-" :arg iOrientation: The number telling which orientation we want to\n"
+" :arg orientation: The number telling which orientation we want to\n"
" check.\n"
-" :type iOrientation: int\n"
+" :type orientation: int\n"
" :arg level: The level of the pyramid in which we wish to read the\n"
" pixel.\n"
" :type level: int\n"
@@ -201,21 +196,19 @@ static char ContextFunctions_ReadDirectionalViewMapPixelCF___doc__[] =
" :rtype: float\n";
static PyObject *
-ContextFunctions_ReadDirectionalViewMapPixelCF( PyObject *self, PyObject *args )
+ContextFunctions_read_directional_view_map_pixel(PyObject *self, PyObject *args, PyObject *kwds)
{
- int orientation, level;
- unsigned x, y;
-
- if( !PyArg_ParseTuple(args, "iiII", &orientation, &level, &x, &y) )
- return NULL;
-
- float f = ContextFunctions::ReadDirectionalViewMapPixelCF(orientation, level, x, y);
+ static const char *kwlist[] = {"orientation", "level", "x", "y", NULL};
+ int orientation, level;
+ unsigned x, y;
- return PyFloat_FromDouble( f );
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "iiII", (char **)kwlist, &orientation, &level, &x, &y))
+ return NULL;
+ return PyFloat_FromDouble(ContextFunctions::ReadDirectionalViewMapPixelCF(orientation, level, x, y));
}
-static char ContextFunctions_GetSelectedFEdgeCF___doc__[] =
-".. function:: GetSelectedFEdgeCF()\n"
+static char ContextFunctions_get_selected_fedge___doc__[] =
+".. function:: get_selected_fedge()\n"
"\n"
" Returns the selected FEdge.\n"
"\n"
@@ -223,13 +216,12 @@ static char ContextFunctions_GetSelectedFEdgeCF___doc__[] =
" :rtype: :class:`FEdge`\n";
static PyObject *
-ContextFunctions_GetSelectedFEdgeCF( PyObject *self )
+ContextFunctions_get_selected_fedge(PyObject *self)
{
- FEdge *fe = ContextFunctions::GetSelectedFEdgeCF();
- if( fe )
- return Any_BPy_FEdge_from_FEdge( *fe );
-
- Py_RETURN_NONE;
+ FEdge *fe = ContextFunctions::GetSelectedFEdgeCF();
+ if (fe)
+ return Any_BPy_FEdge_from_FEdge(*fe);
+ Py_RETURN_NONE;
}
/*-----------------------ContextFunctions module docstring-------------------------------*/
@@ -239,14 +231,14 @@ static char module_docstring[] = "The Blender Freestyle.ContextFunctions submodu
/*-----------------------ContextFunctions module functions definitions-------------------*/
static PyMethodDef module_functions[] = {
- {"GetTimeStampCF", (PyCFunction)ContextFunctions_GetTimeStampCF, METH_NOARGS, ContextFunctions_GetTimeStampCF___doc__},
- {"GetCanvasWidthCF", (PyCFunction)ContextFunctions_GetCanvasWidthCF, METH_NOARGS, ContextFunctions_GetCanvasWidthCF___doc__},
- {"GetCanvasHeightCF", (PyCFunction)ContextFunctions_GetCanvasHeightCF, METH_NOARGS, ContextFunctions_GetCanvasHeightCF___doc__},
- {"LoadMapCF", (PyCFunction)ContextFunctions_LoadMapCF, METH_VARARGS, ContextFunctions_LoadMapCF___doc__},
- {"ReadMapPixelCF", (PyCFunction)ContextFunctions_ReadMapPixelCF, METH_VARARGS, ContextFunctions_ReadMapPixelCF___doc__},
- {"ReadCompleteViewMapPixelCF", (PyCFunction)ContextFunctions_ReadCompleteViewMapPixelCF, METH_VARARGS, ContextFunctions_ReadCompleteViewMapPixelCF___doc__},
- {"ReadDirectionalViewMapPixelCF", (PyCFunction)ContextFunctions_ReadDirectionalViewMapPixelCF, METH_VARARGS, ContextFunctions_ReadDirectionalViewMapPixelCF___doc__},
- {"GetSelectedFEdgeCF", (PyCFunction)ContextFunctions_GetSelectedFEdgeCF, METH_NOARGS, ContextFunctions_GetSelectedFEdgeCF___doc__},
+ {"get_time_stamp", (PyCFunction)ContextFunctions_get_time_stamp, METH_NOARGS, ContextFunctions_get_time_stamp___doc__},
+ {"get_canvas_width", (PyCFunction)ContextFunctions_get_canvas_width, METH_NOARGS, ContextFunctions_get_canvas_width___doc__},
+ {"get_canvas_height", (PyCFunction)ContextFunctions_get_canvas_height, METH_NOARGS, ContextFunctions_get_canvas_height___doc__},
+ {"load_map", (PyCFunction)ContextFunctions_load_map, METH_VARARGS | METH_KEYWORDS, ContextFunctions_load_map___doc__},
+ {"read_map_pixel", (PyCFunction)ContextFunctions_read_map_pixel, METH_VARARGS | METH_KEYWORDS, ContextFunctions_read_map_pixel___doc__},
+ {"read_complete_view_map_pixel", (PyCFunction)ContextFunctions_read_complete_view_map_pixel, METH_VARARGS | METH_KEYWORDS, ContextFunctions_read_complete_view_map_pixel___doc__},
+ {"read_directional_view_map_pixel", (PyCFunction)ContextFunctions_read_directional_view_map_pixel, METH_VARARGS | METH_KEYWORDS, ContextFunctions_read_directional_view_map_pixel___doc__},
+ {"get_selected_fedge", (PyCFunction)ContextFunctions_get_selected_fedge, METH_NOARGS, ContextFunctions_get_selected_fedge___doc__},
{NULL, NULL, 0, NULL}
};
@@ -262,28 +254,20 @@ static PyModuleDef module_definition = {
//------------------- MODULE INITIALIZATION --------------------------------
-int ContextFunctions_Init( PyObject *module )
-{
- PyObject *m, *d, *f;
-
- if( module == NULL )
- return -1;
+int ContextFunctions_Init(PyObject *module)
+{
+ PyObject *m;
- m = PyModule_Create(&module_definition);
- if (m == NULL)
- return -1;
- Py_INCREF(m);
- PyModule_AddObject(module, "ContextFunctions", m);
+ if (module == NULL)
+ return -1;
- // from ContextFunctions import *
- d = PyModule_GetDict(m);
- for (PyMethodDef *p = module_functions; p->ml_name; p++) {
- f = PyDict_GetItemString(d, p->ml_name);
- Py_INCREF(f);
- PyModule_AddObject(module, p->ml_name, f);
- }
+ m = PyModule_Create(&module_definition);
+ if (m == NULL)
+ return -1;
+ Py_INCREF(m);
+ PyModule_AddObject(module, "ContextFunctions", m);
- return 0;
+ return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////