merge with 2.5 at r20783
[blender-staging.git] / source / blender / python / intern / bpy_rna.c
index 12c19bd34710b73b47249ac79790308bb9b32143..9fa7d1b669390aa8e3c9e42fe12640484c65c365 100644 (file)
 #include "BKE_global.h" /* evil G.* */
 #include "BKE_report.h"
 
+#if 0
+#define bpy_PyObject_New(type, typeobj) \
+( (type *) PyObject_Init( \
+       (PyObject *) MEM_callocN( _PyObject_SIZE(typeobj), "python memory from bpy_rna.c" ), (typeobj)) )
+#else
+#define bpy_PyObject_New(type, typeobj) PyObject_New(type, typeobj)
+#endif
+
 static int pyrna_struct_compare( BPy_StructRNA * a, BPy_StructRNA * b )
 {
        return (a->ptr.data==b->ptr.data) ? 0 : -1;
@@ -1367,7 +1375,7 @@ PyTypeObject pyrna_struct_Type = {
        NULL,                       /* allocfunc tp_alloc; */
        pyrna_struct_new,                       /* newfunc tp_new; */
        /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
+       NULL, //MEM_freeN,                       /* freefunc tp_free;  */
        /* For PyObject_IS_GC */
        NULL,                       /* inquiry tp_is_gc;  */
        NULL,                       /* PyObject *tp_bases; */
@@ -1393,7 +1401,7 @@ PyTypeObject pyrna_prop_Type = {
        sizeof( BPy_PropertyRNA ),                      /* tp_basicsize */
        0,                      /* tp_itemsize */
        /* methods */
-       NULL,                                           /* tp_dealloc */
+       NULL,                           /* tp_dealloc */
        NULL,                       /* printfunc tp_print; */
        NULL,                                           /* getattrfunc tp_getattr; */
        NULL,                       /* setattrfunc tp_setattr; */
@@ -1453,7 +1461,7 @@ PyTypeObject pyrna_prop_Type = {
        NULL,                       /* allocfunc tp_alloc; */
        pyrna_prop_new,                         /* newfunc tp_new; */
        /*  Low-level free-memory routine */
-       NULL,                       /* freefunc tp_free;  */
+       NULL, //MEM_freeN,                       /* freefunc tp_free;  */
        /* For PyObject_IS_GC */
        NULL,                       /* inquiry tp_is_gc;  */
        NULL,                       /* PyObject *tp_bases; */
@@ -1572,11 +1580,11 @@ PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr )
                }
                else {
                        fprintf(stderr, "Could not make type\n");
-                       pyrna = ( BPy_StructRNA * ) PyObject_NEW( BPy_StructRNA, &pyrna_struct_Type );
+                       pyrna = ( BPy_StructRNA * ) bpy_PyObject_New( BPy_StructRNA, &pyrna_struct_Type );
                }
        }
        else {
-               pyrna = ( BPy_StructRNA * ) PyObject_NEW( BPy_StructRNA, &pyrna_struct_Type );
+               pyrna = ( BPy_StructRNA * ) bpy_PyObject_New( BPy_StructRNA, &pyrna_struct_Type );
        }
        
        if( !pyrna ) {
@@ -1593,7 +1601,7 @@ PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop )
 {
        BPy_PropertyRNA *pyrna;
 
-       pyrna = ( BPy_PropertyRNA * ) PyObject_NEW( BPy_PropertyRNA, &pyrna_prop_Type );
+       pyrna = ( BPy_PropertyRNA * ) bpy_PyObject_New( BPy_PropertyRNA, &pyrna_prop_Type );
 
        if( !pyrna ) {
                PyErr_SetString( PyExc_MemoryError, "couldn't create BPy_rna object" );
@@ -1702,12 +1710,13 @@ PyObject *BPY_rna_types(void)
                pyrna_basetype_Type.tp_getattro = ( getattrofunc )pyrna_basetype_getattro;
                pyrna_basetype_Type.tp_flags = Py_TPFLAGS_DEFAULT;
                pyrna_basetype_Type.tp_methods = pyrna_basetype_methods;
+               //pyrna_basetype_Type.tp_free = MEM_freeN;
                
                if( PyType_Ready( &pyrna_basetype_Type ) < 0 )
                        return NULL;
        }
        
-       self= (BPy_BaseTypeRNA *)PyObject_NEW( BPy_BaseTypeRNA, &pyrna_basetype_Type );
+       self= (BPy_BaseTypeRNA *)bpy_PyObject_New( BPy_BaseTypeRNA, &pyrna_basetype_Type );
        
        /* avoid doing this lookup for every getattr */
        RNA_blender_rna_pointer_create(&self->ptr);