Python.Runtime.DelegateObject.tp_richcompare C# (CSharp) Method

tp_richcompare() public static method

public static tp_richcompare ( IntPtr ob, IntPtr other, int op ) : IntPtr
ob System.IntPtr
other System.IntPtr
op int
return System.IntPtr
        public static new IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op)
        {
            if (op != Runtime.Py_EQ && op != Runtime.Py_NE)
            {
                Runtime.XIncref(Runtime.PyNotImplemented);
                return Runtime.PyNotImplemented;
            }

            IntPtr pytrue = Runtime.PyTrue;
            IntPtr pyfalse = Runtime.PyFalse;

            // swap true and false for NE
            if (op != Runtime.Py_EQ)
            {
                pytrue = Runtime.PyFalse;
                pyfalse = Runtime.PyTrue;
            }

            Delegate d1 = GetTrueDelegate(ob);
            Delegate d2 = GetTrueDelegate(other);
            if (d1 == d2)
            {
                Runtime.XIncref(pytrue);
                return pytrue;
            }

            Runtime.XIncref(pyfalse);
            return pyfalse;
        }