diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-01-29 12:38:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-01-29 12:38:52 +0300 |
commit | ca36e04362d1140fdc61bc052dd7b3dcc81545a0 (patch) | |
tree | 58fe681cacd04c34b54cfd0df15fd44827166e7b | |
parent | 12616b7e247c721b33aff133f39cad44c96056a8 (diff) |
python3 couldn't generate epydocs because python3 needs richcompare functions for C defined PyTypes (it seems).
-rw-r--r-- | source/blender/python/intern/bpy_operator.c | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_operator.h | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 32 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.h | 7 |
4 files changed, 36 insertions, 11 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index fb1040fac18..72f4d7fb11e 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -278,7 +278,7 @@ PyObject *pyop_base_dir(PyObject *self) /*-----------------------BPy_OperatorBase method def------------------------------*/ PyTypeObject pyop_base_Type = { #if (PY_VERSION_HEX >= 0x02060000) - PyVarObject_HEAD_INIT(&PyType_Type, 0) + PyVarObject_HEAD_INIT(NULL, 0) #else /* python 2.5 and below */ PyObject_HEAD_INIT( NULL ) /* required py macro */ @@ -364,7 +364,7 @@ PyTypeObject pyop_base_Type = { /*-----------------------BPy_OperatorBase method def------------------------------*/ PyTypeObject pyop_func_Type = { #if (PY_VERSION_HEX >= 0x02060000) - PyVarObject_HEAD_INIT(&PyType_Type, 0) + PyVarObject_HEAD_INIT(NULL, 0) #else /* python 2.5 and below */ PyObject_HEAD_INIT( NULL ) /* required py macro */ diff --git a/source/blender/python/intern/bpy_operator.h b/source/blender/python/intern/bpy_operator.h index 19c503c1e8c..5cc3ba64e0e 100644 --- a/source/blender/python/intern/bpy_operator.h +++ b/source/blender/python/intern/bpy_operator.h @@ -36,12 +36,12 @@ extern PyTypeObject pyop_base_Type; extern PyTypeObject pyop_func_Type; typedef struct { - PyObject_VAR_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ bContext *C; } BPy_OperatorBase; typedef struct { - PyObject_VAR_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ char name[OP_MAX_TYPENAME]; bContext *C; } BPy_OperatorFunc; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 5ecab0ddbb5..4156db21507 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -34,7 +34,7 @@ #define MAXFLOAT_DOC 10000000 static int pyrna_struct_compare( BPy_StructRNA * a, BPy_StructRNA * b ) -{ +{ return (a->ptr.data==b->ptr.data) ? 0 : -1; } @@ -43,6 +43,28 @@ static int pyrna_prop_compare( BPy_PropertyRNA * a, BPy_PropertyRNA * b ) return (a->prop==b->prop && a->ptr.data==b->ptr.data ) ? 0 : -1; } + +/* For some reason python3 needs these :/ */ +static PyObject *pyrna_struct_richcmp(BPy_StructRNA * a, BPy_StructRNA * b, int op) +{ + int cmp_result= -1; /* assume false */ + if (BPy_StructRNA_Check(a) && BPy_StructRNA_Check(b)) { + cmp_result= pyrna_struct_compare(a, b); + } + + return Py_CmpToRich(op, cmp_result); +} + +static PyObject *pyrna_prop_richcmp(BPy_PropertyRNA * a, BPy_PropertyRNA * b, int op) +{ + int cmp_result= -1; /* assume false */ + if (BPy_PropertyRNA_Check(a) && BPy_PropertyRNA_Check(b)) { + cmp_result= pyrna_prop_compare(a, b); + } + + return Py_CmpToRich(op, cmp_result); +} + /*----------------------repr--------------------------------------------*/ static PyObject *pyrna_struct_repr( BPy_StructRNA * self ) { @@ -954,7 +976,7 @@ static PyObject * pyrna_prop_new(PyTypeObject *type, PyObject *args, PyObject *k /*-----------------------BPy_StructRNA method def------------------------------*/ PyTypeObject pyrna_struct_Type = { #if (PY_VERSION_HEX >= 0x02060000) - PyVarObject_HEAD_INIT(&PyType_Type, 0) + PyVarObject_HEAD_INIT(NULL, 0) #else /* python 2.5 and below */ PyObject_HEAD_INIT( NULL ) /* required py macro */ @@ -1001,7 +1023,7 @@ PyTypeObject pyrna_struct_Type = { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* richcmpfunc tp_richcompare; */ + (richcmpfunc)pyrna_struct_richcmp, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ 0, /* long tp_weaklistoffset; */ @@ -1039,7 +1061,7 @@ PyTypeObject pyrna_struct_Type = { /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_prop_Type = { #if (PY_VERSION_HEX >= 0x02060000) - PyVarObject_HEAD_INIT(&PyType_Type, 0) + PyVarObject_HEAD_INIT(NULL, 0) #else /* python 2.5 and below */ PyObject_HEAD_INIT( NULL ) /* required py macro */ @@ -1087,7 +1109,7 @@ PyTypeObject pyrna_prop_Type = { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* richcmpfunc tp_richcompare; */ + (richcmpfunc)pyrna_prop_richcmp, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ 0, /* long tp_weaklistoffset; */ diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 73272eac6e8..fc16ad6ea9a 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -33,14 +33,17 @@ extern PyTypeObject pyrna_struct_Type; extern PyTypeObject pyrna_prop_Type; +#define BPy_StructRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_struct_Type)) +#define BPy_PropertyRNA_Check(v) (PyObject_TypeCheck(v, &pyrna_prop_Type)) + typedef struct { - PyObject_VAR_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ PointerRNA ptr; int freeptr; /* needed in some cases if ptr.data is created on the fly, free when deallocing */ } BPy_StructRNA; typedef struct { - PyObject_VAR_HEAD /* required python macro */ + PyObject_HEAD /* required python macro */ PointerRNA ptr; PropertyRNA *prop; } BPy_PropertyRNA; |