| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f8db1b8 commit 4527dc9
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -290,8 +290,11 @@ internal static int AtExit() { | |||
| 290 | 290 | #if (PYTHON32 || PYTHON33 || PYTHON34) | |
| 291 | 291 | internal static IntPtr PyBytesType; | |
| 292 | 292 | internal static IntPtr PyNotImplemented; | |
| 293 | - internal static int Py_EQ = 2; | ||
| 294 | - internal static int Py_NE = 3; | ||
| 293 | + internal const int Py_LT = 0; | ||
| 294 | + internal const int Py_LE = 1; | ||
| 295 | + internal const int Py_EQ = 2; | ||
| 296 | + internal const int Py_NE = 3; | ||
| 297 | + internal const int Py_GT = 4; | ||
| 295 | 298 | internal static IntPtr _PyObject_NextNotImplemented; | |
| 296 | 299 | #endif | |
| 297 | 300 | ||
@@ -849,10 +852,42 @@ internal unsafe static extern IntPtr | |||
| 849 | 852 | internal unsafe static extern IntPtr | |
| 850 | 853 | PyObject_CallObject(IntPtr pointer, IntPtr args); | |
| 851 | 854 | ||
| 855 | + #if (PYTHON32 || PYTHON33 || PYTHON34) | ||
| 856 | + [DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl, | ||
| 857 | + ExactSpelling=true, CharSet=CharSet.Ansi)] | ||
| 858 | + internal unsafe static extern int | ||
| 859 | + PyObject_RichCompareBool(IntPtr value1, IntPtr value2, int opid); | ||
| 860 | + | ||
| 861 | + internal static int PyObject_Compare(IntPtr value1, IntPtr value2) { | ||
| 862 | + int res; | ||
| 863 | + res = PyObject_RichCompareBool(value1, value2, Py_LT); | ||
| 864 | + if (-1 == res) | ||
| 865 | + return -1; | ||
| 866 | + else if (1 == res) | ||
| 867 | + return -1; | ||
| 868 | + | ||
| 869 | + res = PyObject_RichCompareBool(value1, value2, Py_EQ); | ||
| 870 | + if (-1 == res) | ||
| 871 | + return -1; | ||
| 872 | + else if (1 == res) | ||
| 873 | + return 0; | ||
| 874 | + | ||
| 875 | + res = PyObject_RichCompareBool(value1, value2, Py_GT); | ||
| 876 | + if (-1 == res) | ||
| 877 | + return -1; | ||
| 878 | + else if (1 == res) | ||
| 879 | + return 1; | ||
| 880 | + | ||
| 881 | + Exceptions.SetError(Exceptions.SystemError, "Error comparing objects"); | ||
| 882 | + return -1; | ||
| 883 | + } | ||
| 884 | + #else | ||
| 852 | 885 | [DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl, | |
| 853 | 886 | ExactSpelling=true, CharSet=CharSet.Ansi)] | |
| 854 | 887 | internal unsafe static extern int | |
| 855 | 888 | PyObject_Compare(IntPtr value1, IntPtr value2); | |
| 889 | + #endif | ||
| 890 | + | ||
| 856 | 891 | ||
| 857 | 892 | [DllImport(Runtime.dll, CallingConvention=CallingConvention.Cdecl, | |
| 858 | 893 | ExactSpelling=true, CharSet=CharSet.Ansi)] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments