[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35325] trunk/blender/source/blender/ python/intern: set inter-reference from last commit as an option, will make build option next.

Campbell Barton ideasman42 at gmail.com
Thu Mar 3 11:34:05 CET 2011


Revision: 35325
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35325
Author:   campbellbarton
Date:     2011-03-03 10:34:04 +0000 (Thu, 03 Mar 2011)
Log Message:
-----------
set inter-reference from last commit as an option, will make build option next.

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_rna.c
    trunk/blender/source/blender/python/intern/bpy_rna.h

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2011-03-03 09:16:06 UTC (rev 35324)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2011-03-03 10:34:04 UTC (rev 35325)
@@ -900,6 +900,7 @@
 	return x;
 }
 
+#ifdef USE_PYRNA_STRUCT_REFERENCE
 static int pyrna_struct_traverse(BPy_StructRNA *self, visitproc visit, void *arg)
 {
 	Py_VISIT(self->reference);
@@ -911,6 +912,7 @@
 	Py_CLEAR(self->reference);
 	return 0;
 }
+#endif /* !USE_PYRNA_STRUCT_REFERENCE */
 
 /* use our own dealloc so we can free a property if we use one */
 static void pyrna_struct_dealloc(BPy_StructRNA *self)
@@ -927,16 +929,18 @@
 	}
 #endif
 
+#ifdef USE_PYRNA_STRUCT_REFERENCE
 	if(self->reference) {
 		PyObject_GC_UnTrack(self);
 		pyrna_struct_clear(self);
 	}
+#endif /* !USE_PYRNA_STRUCT_REFERENCE */
 
 	/* Note, for subclassed PyObjects we cant just call PyObject_DEL() directly or it will crash */
 	Py_TYPE(self)->tp_free(self);
 }
 
-/* internal use only */
+#ifdef USE_PYRNA_STRUCT_REFERENCE
 static void pyrna_struct_reference_set(BPy_StructRNA *self, PyObject *reference)
 {
 	if(self->reference) {
@@ -951,6 +955,7 @@
 //		PyObject_GC_Track(self);  /* INITIALIZED TRACKED? */
 	}
 }
+#endif /* !USE_PYRNA_STRUCT_REFERENCE */
 
 /* use our own dealloc so we can free a property if we use one */
 static void pyrna_prop_dealloc(BPy_PropertyRNA *self)
@@ -4350,11 +4355,18 @@
 	NULL,						/*  char *tp_doc;  Documentation string */
   /*** Assigned meaning in release 2.0 ***/
 	/* call function for all accessible objects */
+#ifdef USE_PYRNA_STRUCT_REFERENCE
 	(traverseproc) pyrna_struct_traverse,                       /* traverseproc tp_traverse; */
 
 	/* delete references to contained objects */
 	(inquiry )pyrna_struct_clear,                       /* inquiry tp_clear; */
+#else
+	NULL,                       /* traverseproc tp_traverse; */
 
+/* delete references to contained objects */
+	NULL,                       /* inquiry tp_clear; */
+#endif /* !USE_PYRNA_STRUCT_REFERENCE */
+
   /***  Assigned meaning in release 2.1 ***/
   /*** rich comparisons ***/
 	(richcmpfunc)pyrna_struct_richcmp,	/* richcmpfunc tp_richcompare; */
@@ -4850,6 +4862,7 @@
 	else {
 		BPy_StructRNA *pyrna= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&self->iter.ptr);
 
+#ifdef USE_PYRNA_STRUCT_REFERENCE
 		if(pyrna) { /* unlikely but may fail */
 			if((PyObject *)pyrna != Py_None) {
 				/* hold a reference to the iterator since it may have
@@ -4858,6 +4871,7 @@
 				pyrna_struct_reference_set(pyrna, (PyObject *)self);
 			}
 		}
+#endif /* !USE_PYRNA_STRUCT_REFERENCE */
 
 		RNA_property_collection_next(&self->iter);
 
@@ -5105,7 +5119,10 @@
 
 	pyrna->ptr= *ptr;
 	pyrna->freeptr= FALSE;
+
+#ifdef USE_PYRNA_STRUCT_REFERENCE
 	pyrna->reference= NULL;
+#endif
 
 	// PyC_ObSpit("NewStructRNA: ", (PyObject *)pyrna);
 

Modified: trunk/blender/source/blender/python/intern/bpy_rna.h
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.h	2011-03-03 09:16:06 UTC (rev 35324)
+++ trunk/blender/source/blender/python/intern/bpy_rna.h	2011-03-03 10:34:04 UTC (rev 35325)
@@ -40,6 +40,9 @@
 /* different method */
 //#define USE_PYRNA_INVALIDATE_WEAKREF
 
+/* support for inter references, currently only needed for corner case */
+// #define USE_PYRNA_STRUCT_REFERENCE
+
 /* use real collection iterators rather then faking with a list */
 #define USE_PYRNA_ITER
 
@@ -90,9 +93,11 @@
 	PyObject *in_weakreflist;
 #endif
 	PointerRNA ptr;
+#ifdef USE_PYRNA_STRUCT_REFERENCE
 	/* generic PyObject we hold a reference to, example use:
 	 * hold onto the collection iterator to prevent it from freeing allocated data we may use */
 	PyObject *reference;
+#endif /* !USE_PYRNA_STRUCT_REFERENCE */
 	int freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */
 } BPy_StructRNA;
 




More information about the Bf-blender-cvs mailing list