Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / blender / python / intern / bpy_util.c
index 1766be6..924d1db 100644 (file)
 #include "DNA_listBase.h"
 #include "RNA_access.h"
 #include "bpy_util.h"
-#include "BLI_dynstr.h"
+#include "bpy_rna.h"
+
 #include "MEM_guardedalloc.h"
-#include "BKE_report.h"
 
+#include "BLI_dynstr.h"
+#include "BLI_listbase.h"
 
+#include "BKE_report.h"
+#include "BKE_image.h"
 #include "BKE_context.h"
+
 bContext*      __py_context = NULL;
 bContext*      BPy_GetContext(void) { return __py_context; };
 void           BPy_SetContext(bContext *C) { __py_context= C; };
@@ -122,6 +127,44 @@ int BPY_flag_from_seq(BPY_flag_def *flagdef, PyObject *seq, int *flag)
        return 0; /* ok */
 }
 
+
+/* Copied from pythons 3's Object.c */
+PyObject *
+Py_CmpToRich(int op, int cmp)
+{
+       PyObject *res;
+       int ok;
+
+       if (PyErr_Occurred())
+               return NULL;
+       switch (op) {
+       case Py_LT:
+               ok = cmp <  0;
+               break;
+       case Py_LE:
+               ok = cmp <= 0;
+               break;
+       case Py_EQ:
+               ok = cmp == 0;
+               break;
+       case Py_NE:
+               ok = cmp != 0;
+               break;
+       case Py_GT:
+               ok = cmp >  0;
+               break;
+       case Py_GE:
+               ok = cmp >= 0;
+               break;
+       default:
+               PyErr_BadArgument();
+               return NULL;
+       }
+       res = ok ? Py_True : Py_False;
+       Py_INCREF(res);
+       return res;
+}
+
 /* for debugging */
 void PyObSpit(char *name, PyObject *var) {
        fprintf(stderr, "<%s> : ", name);