Commits

Tobias Oberstein committed ee25927

Implement all comparison ops.

Comments (0)

Files changed (1)

pypy/module/select/interp_kqueue.py

         r_fflags = other.event.c_fflags
         l_data = self.event.c_data
         r_data = other.event.c_data
-
-        # FIXME: here and below
-        #l_udata = ?
-        #r_udata = ?
+        l_udata = rffi.cast(lltype.Unsigned, self.event.c_udata)
+        r_udata = rffi.cast(lltype.Unsigned, other.event.c_udata)
 
         if op == "eq":
             return l_ident == r_ident and \
                    l_filter == r_filter and \
                    l_flags == r_flags and \
                    l_fflags == r_fflags and \
-                   l_data == r_data
+                   l_data == r_data and \
+                   l_udata == r_udata
         elif op == "lt":
             return (l_ident < r_ident) or \
                    (l_ident == r_ident and l_filter < r_filter) or \
                    (l_ident == r_ident and l_filter == r_filter and l_flags < r_flags) or \
                    (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags < r_fflags) or \
-                   (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags == r_fflags and l_data < r_data)
-        elif op == "ge":
+                   (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags == r_fflags and l_data < r_data) or \
+                   (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags == r_fflags and l_data == r_data and l_udata < r_udata)
+        elif op == "gt":
             return (l_ident > r_ident) or \
                    (l_ident == r_ident and l_filter > r_filter) or \
                    (l_ident == r_ident and l_filter == r_filter and l_flags > r_flags) or \
                    (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags > r_fflags) or \
-                   (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags == r_fflags and l_data > r_data)
+                   (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags == r_fflags and l_data > r_data) or \
+                   (l_ident == r_ident and l_filter == r_filter and l_flags == r_flags and l_fflags == r_fflags and l_data == r_data and l_udata > r_udata)
         else:
             assert False
 
     def compare_all_fields(self, space, other, op):
         if not space.interp_w(W_Kevent, other):
-            return space.w_NotImplemented
-        return space.wrap(self._compare_all_fields(space.interp_w(W_Kevent, other), op))
+            if op == "eq":
+                return False
+            elif op == "ne":
+                return True
+            else:
+                raise OperationError(space.w_TypeError, space.wrap('cannot compare kevent to incompatible type'))
+        return self._compare_all_fields(space.interp_w(W_Kevent, other), op)
 
     def descr__eq__(self, space, w_other):
-        return self.compare_all_fields(space, w_other, "eq")
+        return space.wrap(self.compare_all_fields(space, w_other, "eq"))
+
+    def descr__ne__(self, space, w_other):
+        return space.wrap(not self.compare_all_fields(space, w_other, "eq"))
+
+    def descr__le__(self, space, w_other):
+        return space.wrap(not self.compare_all_fields(space, w_other, "gt"))
 
     def descr__lt__(self, space, w_other):
-        return self.compare_all_fields(space, w_other, "lt")
+        return space.wrap(self.compare_all_fields(space, w_other, "lt"))
 
     def descr__ge__(self, space, w_other):
-        return self.compare_all_fields(space, w_other, "ge")
+        return space.wrap(not self.compare_all_fields(space, w_other, "lt"))
+
+    def descr__gt__(self, space, w_other):
+        return space.wrap(self.compare_all_fields(space, w_other, "gt"))
 
     def descr_get_ident(self, space):
         return space.wrap(self.event.c_ident)
     __new__ = generic_new_descr(W_Kevent),
     __init__ = interp2app(W_Kevent.descr__init__),
     __eq__ = interp2app(W_Kevent.descr__eq__),
+    __ne__ = interp2app(W_Kevent.descr__ne__),
+    __le__ = interp2app(W_Kevent.descr__le__),
     __lt__ = interp2app(W_Kevent.descr__lt__),
     __ge__ = interp2app(W_Kevent.descr__ge__),
+    __gt__ = interp2app(W_Kevent.descr__gt__),
 
     ident = GetSetProperty(W_Kevent.descr_get_ident),
     filter = GetSetProperty(W_Kevent.descr_get_filter),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.