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>2009-08-02 20:23:18 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2009-08-02 20:23:18 +0400
commitacf97994bc9b5a9be1fc6cdd3907eaa198719b11 (patch)
treefeda501e6f4429e7eb2515bfeafdc4475e66b2b6 /source/blender/freestyle/intern/python/Interface1D
parent6d1ad351f3d619eb8c6b509292c3517c93afd51b (diff)
SWIG/directors dependency removal (cont'd)
* Added to python/BPy_Convert.{cpp,h} 4 utility converters below for better introspection-based automatic type conversion. PyObject * Any_BPy_Interface0D_from_Interface0D( Interface0D& if0D ); PyObject * Any_BPy_Interface1D_from_Interface1D( Interface1D& if1D ); PyObject * Any_BPy_FEdge_from_FEdge( FEdge& fe ); PyObject * Any_BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ); There are 4 corresponding converters without the "Any_" prefix. All calls of them in the code base were replaced with these new converters so that the introspection-based automatic conversion would take place universally. * python/BPy_Convert.{cpp,h}: Those C++ to Python converters having had a "_ptr" suffix were renamed to a name without the suffix, and their arguments were changed so as to take a reference (e.g., ViewVertex&) instead of a pointer (e.g., ViewVertex *). The changed converters and their new function prototypes are listed below. These converters now return a Python wrapper object that retains the passed reference, instead of retaining a newly created C++ object by the converters. // Interface0D converters PyObject * BPy_Interface0D_from_Interface0D( Interface0D& if0D ); PyObject * BPy_CurvePoint_from_CurvePoint( CurvePoint& cp ); PyObject * BPy_StrokeVertex_from_StrokeVertex( StrokeVertex& sv ); PyObject * BPy_SVertex_from_SVertex( SVertex& sv ); PyObject * BPy_ViewVertex_from_ViewVertex( ViewVertex& vv ); PyObject * BPy_TVertex_from_TVertex( TVertex& tv ); PyObject * BPy_NonTVertex_from_NonTVertex( NonTVertex& ntv ); // Interface1D converters PyObject * BPy_Interface1D_from_Interface1D( Interface1D& if1D ); PyObject * BPy_Chain_from_Chain( Chain& c ); PyObject * BPy_FEdge_from_FEdge( FEdge& fe ); PyObject * BPy_FEdgeSharp_from_FEdgeSharp( FEdgeSharp& fes ); PyObject * BPy_FEdgeSmooth_from_FEdgeSmooth( FEdgeSmooth& fes ); PyObject * BPy_Stroke_from_Stroke( Stroke& s ); PyObject * BPy_ViewEdge_from_ViewEdge( ViewEdge& ve ); PyObject * BPy_directedViewEdge_from_directedViewEdge( ViewVertex::directedViewEdge& dve ); // some other converters PyObject * BPy_ViewShape_from_ViewShape( ViewShape& vs ); PyObject * BPy_SShape_from_SShape( SShape& ss ); PyObject * BPy_FrsMaterial_from_FrsMaterial( FrsMaterial& m ); PyObject * BPy_StrokeAttribute_from_StrokeAttribute( StrokeAttribute& sa ); * Added a "borrowed" flag to the definitions of Python types being used to wrap C++ components of Freestyle's internal data structures. The flag indicates whether or not a Python wrapper object has a reference to a C++ object that comprises the internal data structures. The deallocation routines of the Python types check this flag and release a wrapped C++ object only when it is not part of the internal data structures. The following files were modified: python/BPy_FrsMaterial.{cpp,h} python/BPy_Interface0D.{cpp,h} python/BPy_Interface1D.{cpp,h} python/BPy_SShape.{cpp,h} python/BPy_StrokeAttribute.{cpp,h} python/BPy_ViewShape.{cpp,h} python/Interface0D/BPy_CurvePoint.cpp python/Interface0D/BPy_SVertex.cpp python/Interface0D/BPy_ViewVertex.cpp python/Interface0D/CurvePoint/BPy_StrokeVertex.cpp python/Interface0D/ViewVertex/BPy_NonTVertex.cpp python/Interface0D/ViewVertex/BPy_TVertex.cpp python/Interface1D/BPy_FEdge.cpp python/Interface1D/BPy_FrsCurve.cpp python/Interface1D/BPy_Stroke.cpp python/Interface1D/BPy_ViewEdge.cpp python/Interface1D/Curve/BPy_Chain.cpp python/Interface1D/FEdge/BPy_FEdgeSharp.cpp python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp * view_map/Interface[01]D.h, python/BPy_Interface[01]D.cpp: Removed from the Interface0D and Interface1D C++ classes a back pointer to a Python wrapper object and all "director" calls. These classes (and their subclasses) are used to build Freestyle's main data structures (such as a view map and strokes) and their class hierarchy is static. Python wrappers of these C++ classes are only used to access the data structures from the Python layer, and not intended to extend the data structures by subclassing the Python wrappers. Without the necessity of subclassing in the Python layer, the back pointer to a wrapping Python object and "director" calls would be useless (actually they were not used at all), so they were all removed. * python/Director.{cpp,h}: Removed the definitions of directors that were no longer used. * stroke/Stroke.{cpp,h}: Removed an (unused) back pointer to a Python wrapper object. * python/BPy_ViewMap.cpp: Fixed a possible null pointer reference. * python/Interface1D/BPy_FEdge.cpp: Fixed parameter checking in FEdge___init__().
Diffstat (limited to 'source/blender/freestyle/intern/python/Interface1D')
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp36
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp3
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp31
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp1
-rw-r--r--source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp1
7 files changed, 47 insertions, 27 deletions
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
index 4e646de18e6..ccdcbe98c69 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FEdge.cpp
@@ -155,12 +155,12 @@ int FEdge___init__(BPy_FEdge *self, PyObject *args, PyObject *kwds)
PyObject *obj1 = 0, *obj2 = 0;
- if (! PyArg_ParseTuple(args, "|OO", &obj1, &obj2) )
+ if (! PyArg_ParseTuple(args, "|O!O!", &SVertex_Type, &obj1, &SVertex_Type, &obj2) )
return -1;
if( !obj1 && !obj2 ){
self->fe = new FEdge();
- } else if( BPy_SVertex_Check(obj1) && BPy_SVertex_Check(obj2) ) {
+ } else if( obj1 && obj2 ) {
self->fe = new FEdge( ((BPy_SVertex *) obj1)->sv, ((BPy_SVertex *) obj2)->sv );
} else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
@@ -168,6 +168,7 @@ int FEdge___init__(BPy_FEdge *self, PyObject *args, PyObject *kwds)
}
self->py_if1D.if1D = self->fe;
+ self->py_if1D.borrowed = 0;
return 0;
}
@@ -180,21 +181,24 @@ PyObject * FEdge___copy__( BPy_FEdge *self ) {
py_fe->fe = new FEdge( *(self->fe) );
py_fe->py_if1D.if1D = py_fe->fe;
+ py_fe->py_if1D.borrowed = 0;
return (PyObject *) py_fe;
}
PyObject * FEdge_vertexA( BPy_FEdge *self ) {
- if( self->fe->vertexA() ){
- return BPy_SVertex_from_SVertex_ptr( self->fe->vertexA() );
+ SVertex *A = self->fe->vertexA();
+ if( A ){
+ return BPy_SVertex_from_SVertex( *A );
}
Py_RETURN_NONE;
}
PyObject * FEdge_vertexB( BPy_FEdge *self ) {
- if( self->fe->vertexB() ){
- return BPy_SVertex_from_SVertex_ptr( self->fe->vertexB() );
+ SVertex *B = self->fe->vertexB();
+ if( B ){
+ return BPy_SVertex_from_SVertex( *B );
}
Py_RETURN_NONE;
@@ -211,29 +215,33 @@ PyObject * FEdge___getitem__( BPy_FEdge *self, PyObject *args ) {
return NULL;
}
- if( SVertex *v = self->fe->operator[](i) )
- return BPy_SVertex_from_SVertex_ptr( v );
+ SVertex *v = self->fe->operator[](i);
+ if( v )
+ return BPy_SVertex_from_SVertex( *v );
Py_RETURN_NONE;
}
PyObject * FEdge_nextEdge( BPy_FEdge *self ) {
- if( FEdge *fe = self->fe->nextEdge() )
- return BPy_FEdge_from_FEdge( *fe );
+ FEdge *fe = self->fe->nextEdge();
+ if( fe )
+ return Any_BPy_FEdge_from_FEdge( *fe );
Py_RETURN_NONE;
}
PyObject * FEdge_previousEdge( BPy_FEdge *self ) {
- if( FEdge *fe = self->fe->previousEdge() )
- return BPy_FEdge_from_FEdge( *fe );
+ FEdge *fe = self->fe->previousEdge();
+ if( fe )
+ return Any_BPy_FEdge_from_FEdge( *fe );
Py_RETURN_NONE;
}
PyObject * FEdge_viewedge( BPy_FEdge *self ) {
- if( ViewEdge *ve = self->fe->viewedge() )
- return BPy_ViewEdge_from_ViewEdge_ptr( ve );
+ ViewEdge *ve = self->fe->viewedge();
+ if( ve )
+ return BPy_ViewEdge_from_ViewEdge( *ve );
Py_RETURN_NONE;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
index a44e2feed5b..2194748ef4e 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_FrsCurve.cpp
@@ -149,6 +149,7 @@ int FrsCurve___init__(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
}
self->py_if1D.if1D = self->c;
+ self->py_if1D.borrowed = 0;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
index 89b9478212f..38cba3f1275 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_Stroke.cpp
@@ -198,6 +198,7 @@ int Stroke___init__(BPy_Stroke *self, PyObject *args, PyObject *kwds)
}
self->py_if1D.if1D = self->s;
+ self->py_if1D.borrowed = 0;
return 0;
}
@@ -216,7 +217,7 @@ PyObject * Stroke_item( BPy_Stroke *self, Py_ssize_t i ) {
PyErr_SetString(PyExc_IndexError, "subscript index out of range");
return NULL;
}
- return BPy_StrokeVertex_from_StrokeVertex_ptr( self->s->strokeVerticeAt(i) );
+ return BPy_StrokeVertex_from_StrokeVertex( self->s->strokeVerticeAt(i) );
}
PyObject * Stroke___getitem__( BPy_Stroke *self, PyObject *item ) {
diff --git a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
index 958d96031e3..ba0c4756b9b 100644
--- a/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/BPy_ViewEdge.cpp
@@ -163,54 +163,61 @@ int ViewEdge___init__(BPy_ViewEdge *self, PyObject *args, PyObject *kwds)
{
self->ve = new ViewEdge();
self->py_if1D.if1D = self->ve;
+ self->py_if1D.borrowed = 0;
return 0;
}
PyObject * ViewEdge_A( BPy_ViewEdge *self ) {
- if( self->ve->A() ){
- return BPy_ViewVertex_from_ViewVertex_ptr( self->ve->A() );
+ ViewVertex *v = self->ve->A();
+ if( v ){
+ return Any_BPy_ViewVertex_from_ViewVertex( *v );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_B( BPy_ViewEdge *self ) {
- if( self->ve->B() ){
- return BPy_ViewVertex_from_ViewVertex_ptr( self->ve->B() );
+ ViewVertex *v = self->ve->B();
+ if( v ){
+ return Any_BPy_ViewVertex_from_ViewVertex( *v );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_fedgeA( BPy_ViewEdge *self ) {
- if( self->ve->fedgeA() ){
- return BPy_FEdge_from_FEdge(*( self->ve->fedgeA() ));
+ FEdge *A = self->ve->fedgeA();
+ if( A ){
+ return Any_BPy_FEdge_from_FEdge( *A );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_fedgeB( BPy_ViewEdge *self ) {
- if( self->ve->fedgeB() ){
- return BPy_FEdge_from_FEdge(*( self->ve->fedgeB() ));
+ FEdge *B = self->ve->fedgeB();
+ if( B ){
+ return Any_BPy_FEdge_from_FEdge( *B );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_viewShape( BPy_ViewEdge *self ) {
- if( self->ve->viewShape() ){
- return BPy_ViewShape_from_ViewShape(*( self->ve->viewShape() ));
+ ViewShape *vs = self->ve->viewShape();
+ if( vs ){
+ return BPy_ViewShape_from_ViewShape( *vs );
}
Py_RETURN_NONE;
}
PyObject * ViewEdge_aShape( BPy_ViewEdge *self ) {
- if( self->ve->aShape() ){
- return BPy_ViewShape_from_ViewShape(*( self->ve->aShape() ));
+ ViewShape *vs = self->ve->aShape();
+ if( vs ){
+ return BPy_ViewShape_from_ViewShape( *vs );
}
Py_RETURN_NONE;
diff --git a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
index 5714f415d80..a80388bd76c 100644
--- a/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/Curve/BPy_Chain.cpp
@@ -137,6 +137,7 @@ int Chain___init__(BPy_Chain *self, PyObject *args, PyObject *kwds)
self->py_c.c = self->c;
self->py_c.py_if1D.if1D = self->c;
+ self->py_c.py_if1D.borrowed = 0;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
index aa0ba7dfc46..7f60098a4d1 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSharp.cpp
@@ -148,6 +148,7 @@ int FEdgeSharp___init__(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds)
self->py_fe.fe = self->fes;
self->py_fe.py_if1D.if1D = self->fes;
+ self->py_fe.py_if1D.borrowed = 0;
return 0;
}
diff --git a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
index 9913503db58..c19ef463f22 100644
--- a/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
+++ b/source/blender/freestyle/intern/python/Interface1D/FEdge/BPy_FEdgeSmooth.cpp
@@ -140,6 +140,7 @@ int FEdgeSmooth___init__(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwds)
self->py_fe.fe = self->fes;
self->py_fe.py_if1D.if1D = self->fes;
+ self->py_fe.py_if1D.borrowed = 0;
return 0;
}