Freestyle Python API improvements - part 7.

Fix for PyGetSetDef and proper handling of keyword arguments were done in
UnaryPredicate0D, UnaryPredicate1D, BinaryPredicate1D, and StrokeShader classes.
Style modules were updated accordingly.  Additional code clean-up was also made.
This commit is contained in:
2013-02-23 01:12:23 +00:00
parent 0fb83d78fa
commit 68b0a8e390
51 changed files with 654 additions and 615 deletions

View File

@@ -21,9 +21,11 @@ static char ContourUP1D___doc__[] =
" :return: True if the Interface1D is a contour, false otherwise.\n"
" :rtype: bool\n";
static int ContourUP1D___init__( BPy_ContourUP1D* self, PyObject *args )
static int ContourUP1D___init__(BPy_ContourUP1D* self, PyObject *args, PyObject *kwds)
{
if(!( PyArg_ParseTuple(args, "") ))
static const char *kwlist[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
return -1;
self->py_up1D.up1D = new Predicates1D::ContourUP1D();
return 0;

View File

@@ -34,14 +34,14 @@ static char DensityLowerThanUP1D___doc__[] =
" :return: True if the density is lower than a threshold.\n"
" :rtype: bool\n";
static int DensityLowerThanUP1D___init__( BPy_DensityLowerThanUP1D* self, PyObject *args )
static int DensityLowerThanUP1D___init__(BPy_DensityLowerThanUP1D* self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"threshold", "sigma", NULL};
double d1, d2 = 2.0;
if( !PyArg_ParseTuple(args, "d|d", &d1, &d2) )
if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|d", (char **)kwlist, &d1, &d2))
return -1;
self->py_up1D.up1D = new Predicates1D::DensityLowerThanUP1D(d1,d2);
self->py_up1D.up1D = new Predicates1D::DensityLowerThanUP1D(d1, d2);
return 0;
}

View File

@@ -28,13 +28,13 @@ static char EqualToChainingTimeStampUP1D___doc__[] =
" :return: True if the time stamp is equal to a user-defined value.\n"
" :rtype: bool\n";
static int EqualToChainingTimeStampUP1D___init__( BPy_EqualToChainingTimeStampUP1D* self, PyObject *args )
static int EqualToChainingTimeStampUP1D___init__(BPy_EqualToChainingTimeStampUP1D* self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"ts", NULL};
unsigned u;
if( !PyArg_ParseTuple(args, "I", &u) )
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &u))
return -1;
self->py_up1D.up1D = new Predicates1D::EqualToChainingTimeStampUP1D(u);
return 0;
}

View File

@@ -28,13 +28,13 @@ static char EqualToTimeStampUP1D___doc__[] =
" :return: True if the time stamp is equal to a user-defined value.\n"
" :rtype: bool\n";
static int EqualToTimeStampUP1D___init__( BPy_EqualToTimeStampUP1D* self, PyObject *args )
static int EqualToTimeStampUP1D___init__(BPy_EqualToTimeStampUP1D* self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"ts", NULL};
unsigned u;
if( !PyArg_ParseTuple(args, "I", &u) )
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &u))
return -1;
self->py_up1D.up1D = new Predicates1D::EqualToTimeStampUP1D(u);
return 0;
}

View File

@@ -23,9 +23,11 @@ static char ExternalContourUP1D___doc__[] =
" otherwise.\n"
" :rtype: bool\n";
static int ExternalContourUP1D___init__( BPy_ExternalContourUP1D* self, PyObject *args )
static int ExternalContourUP1D___init__(BPy_ExternalContourUP1D* self, PyObject *args, PyObject *kwds)
{
if(!( PyArg_ParseTuple(args, "") ))
static const char *kwlist[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
return -1;
self->py_up1D.up1D = new Predicates1D::ExternalContourUP1D();
return 0;

View File

@@ -20,9 +20,11 @@ static char FalseUP1D___doc__[] =
" :return: False.\n"
" :rtype: bool\n";
static int FalseUP1D___init__( BPy_FalseUP1D* self, PyObject *args )
static int FalseUP1D___init__(BPy_FalseUP1D* self, PyObject *args, PyObject *kwds)
{
if(!( PyArg_ParseTuple(args, "") ))
static const char *kwlist[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
return -1;
self->py_up1D.up1D = new Predicates1D::FalseUP1D();
return 0;

View File

@@ -31,13 +31,13 @@ static char QuantitativeInvisibilityUP1D___doc__[] =
" value.\n"
" :rtype: bool\n";
static int QuantitativeInvisibilityUP1D___init__( BPy_QuantitativeInvisibilityUP1D* self, PyObject *args )
static int QuantitativeInvisibilityUP1D___init__(BPy_QuantitativeInvisibilityUP1D* self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"qi", NULL};
int i = 0;
if( !PyArg_ParseTuple(args, "|i", &i) )
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", (char **)kwlist, &i))
return -1;
self->py_up1D.up1D = new Predicates1D::QuantitativeInvisibilityUP1D(i);
return 0;
}

View File

@@ -11,14 +11,14 @@ extern "C" {
static char ShapeUP1D___doc__[] =
"Class hierarchy: :class:`UnaryPredicate1D` > :class:`ShapeUP1D`\n"
"\n"
".. method:: __init__(idFirst, idSecond=0)\n"
".. method:: __init__(first, second=0)\n"
"\n"
" Builds a ShapeUP1D object.\n"
"\n"
" :arg idFirst: The first Id component.\n"
" :type idFirst: int\n"
" :arg idSecond: The second Id component.\n"
" :type idSecond: int\n"
" :arg first: The first Id component.\n"
" :type first: int\n"
" :arg second: The second Id component.\n"
" :type second: int\n"
"\n"
".. method:: __call__(inter)\n"
"\n"
@@ -31,14 +31,14 @@ static char ShapeUP1D___doc__[] =
" user-specified Id.\n"
" :rtype: bool\n";
static int ShapeUP1D___init__( BPy_ShapeUP1D* self, PyObject *args )
static int ShapeUP1D___init__(BPy_ShapeUP1D* self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"first", "second", NULL};
unsigned u1, u2 = 0;
if( !PyArg_ParseTuple(args, "I|I", &u1, &u2) )
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I|I", (char **)kwlist, &u1, &u2))
return -1;
self->py_up1D.up1D = new Predicates1D::ShapeUP1D(u1,u2);
self->py_up1D.up1D = new Predicates1D::ShapeUP1D(u1, u2);
return 0;
}

View File

@@ -20,9 +20,11 @@ static char TrueUP1D___doc__[] =
" :return: True.\n"
" :rtype: bool\n";
static int TrueUP1D___init__( BPy_TrueUP1D* self, PyObject *args )
static int TrueUP1D___init__(BPy_TrueUP1D* self, PyObject *args, PyObject *kwds)
{
if(!( PyArg_ParseTuple(args, "") ))
static const char *kwlist[] = {NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
return -1;
self->py_up1D.up1D = new Predicates1D::TrueUP1D();
return 0;

View File

@@ -28,11 +28,12 @@ static char WithinImageBoundaryUP1D___doc__[] =
"\n"
" Returns true if the Interface1D intersects with image boundary.\n";
static int WithinImageBoundaryUP1D___init__( BPy_WithinImageBoundaryUP1D* self, PyObject *args )
static int WithinImageBoundaryUP1D___init__(BPy_WithinImageBoundaryUP1D* self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"xmin", "ymin", "xmax", "ymax", NULL};
double xmin, ymin, xmax, ymax;
if(!( PyArg_ParseTuple(args, "dddd", &xmin, &ymin, &xmax, &ymax) ))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "dddd", (char **)kwlist, &xmin, &ymin, &xmax, &ymax))
return -1;
self->py_up1D.up1D = new Predicates1D::WithinImageBoundaryUP1D(xmin, ymin, xmax, ymax);
return 0;