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:
authorKen Hughes <khughes@pacific.edu>2005-12-01 07:50:04 +0300
committerKen Hughes <khughes@pacific.edu>2005-12-01 07:50:04 +0300
commit95e94b4630b1ac7ca4369db626bcfbc02964bf90 (patch)
treef303dab91bd7057f961b16f5b04f1d6946cdaddd
parentd369a44dde48f048be913d7e758d625c64628a5b (diff)
Make curnurb.flagU and curnurb.flagV range check their inputs, plus make
the documentation correctly describe how the attributes and methods work.
-rw-r--r--source/blender/python/api2_2x/CurNurb.c21
-rw-r--r--source/blender/python/api2_2x/doc/Curve.py32
2 files changed, 31 insertions, 22 deletions
diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c
index 0b5f09c0efc..922178f7662 100644
--- a/source/blender/python/api2_2x/CurNurb.c
+++ b/source/blender/python/api2_2x/CurNurb.c
@@ -638,7 +638,8 @@ static PyObject *CurNurb_getFlagU( BPy_CurNurb * self )
*
* set curve's flagu and recalculate the knots
*
- * Possible values: 0 - uniform, 1 - endpoints, 2 - bezier
+ * Possible values: 0 - uniform, 2 - endpoints, 4 - bezier
+ * bit 0 controls CU_CYCLIC
*/
static PyObject *CurNurb_setFlagU( BPy_CurNurb * self, PyObject * args )
@@ -646,9 +647,12 @@ static PyObject *CurNurb_setFlagU( BPy_CurNurb * self, PyObject * args )
int flagu;
if( !PyArg_ParseTuple( args, "i", &( flagu ) ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected integer argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected integer argument in range [0,5]" );
+
+ if( flagu < 0 || flagu > 5 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected integer argument in range [0,5]" );
if( self->nurb->flagu != flagu ) {
self->nurb->flagu = (short)flagu;
@@ -689,9 +693,12 @@ static PyObject *CurNurb_setFlagV( BPy_CurNurb * self, PyObject * args )
int flagv;
if( !PyArg_ParseTuple( args, "i", &( flagv ) ) )
- return ( EXPP_ReturnPyObjError
- ( PyExc_AttributeError,
- "expected integer argument" ) );
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected integer argument in range [0,5]" );
+
+ if( flagv < 0 || flagv > 5 )
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected integer argument in range [0,5]" );
if( self->nurb->flagv != flagv ) {
self->nurb->flagv = (short)flagv;
diff --git a/source/blender/python/api2_2x/doc/Curve.py b/source/blender/python/api2_2x/doc/Curve.py
index 72ed08456e6..91396a2eccf 100644
--- a/source/blender/python/api2_2x/doc/Curve.py
+++ b/source/blender/python/api2_2x/doc/Curve.py
@@ -418,8 +418,8 @@ class CurNurb:
The CurNurb also supports the sequence protocol which means you can access the control points of a CurNurb using the [] operator.
- @ivar flagU: The CurNurb knot flag U. See L{setFlagU} for bit definitions.
- @ivar flagV: The CurNurb knot flag V (0: uniform, 1: endpoints, 2: bezier)
+ @ivar flagU: The CurNurb knot flag U. See L{setFlagU} for description.
+ @ivar flagV: The CurNurb knot flag V. See L{setFlagU} for description.
@ivar type: The type of the curve (Poly: 0, Bezier: 1, NURBS: 4)
"""
@@ -484,35 +484,37 @@ class CurNurb:
def getFlagU():
"""
- Get the CurNurb knot flag U. This flag is a bitfield. See L{setFlagU} for bit definitions.
+ Get the CurNurb knot flag U.
@rtype: integer
- @return: 0 - uniform, 2 - endpoints, 4 - bezier
+ @return: See L{setFlagU} for description of return value.
"""
- def setFlagU( value ):
+ def setFlagU( flag ):
"""
- Set the entire CurNurb knot flag U (knots are recalculated automatically). Another of Blender's bitfields.
- - bit 0: continuous.
- - bit 1: endpoints.
- - bit 2: bezier.
- @type value: integer
- @param value: CurNurb knot flag (0 - uniform, 2 - endpoints, 4 - bezier)
+ Set the entire CurNurb knot flag U (knots are recalculated automatically).
+ The flag can be one of six values:
+ - 0 or 1: uniform knots
+ - 2 or 3: endpoints knots
+ - 4 or 5: bezier knots
+ Bit 0 controls whether or not the curve is cyclic (1 = cyclic).
+ @type flag: integer
+ @param flag: CurNurb knot flag
@rtype: PyNone
@return: PyNone
"""
def getFlagV():
"""
- Get the CurNurb knot flag V
+ Get the CurNurb knot flag V.
@rtype: integer
- @return: 0 - uniform, 1 - endpoints, 2 - bezier
+ @return: See L{setFlagU} for description of return value.
"""
def setFlagV( value ):
"""
- Set the CurNurb knot flag V (knots are recalculated automatically)
+ Set the CurNurb knot flag V (knots are recalculated automatically).
@type value: integer
- @param value: CurNurb knot flag (0 - uniform, 1 - endpoints, 2 - bezier)
+ @param value: See L{setFlagU} for description of return.
@rtype: PyNone
@return: PyNone
"""