]> granicus.if.org Git - python/commitdiff
Added hash() and compare() functions. Needed because multiple WinObj's can now refer...
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 19 Dec 2000 21:34:55 +0000 (21:34 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 19 Dec 2000 21:34:55 +0000 (21:34 +0000)
Mac/Modules/win/Winmodule.c
Mac/Modules/win/winsupport.py

index 800bad01ad379b6289f4136b042b518305713cd6..4dce0e8f2e47bff44b78637fbcc14031f3ed6b34 100644 (file)
@@ -2165,11 +2165,21 @@ static PyObject *WinObj_getattr(self, name)
 
 #define WinObj_setattr NULL
 
-#define WinObj_compare NULL
+static int WinObj_compare(self, other)
+       WindowObject *self, *other;
+{
+       if ( self->ob_itself > other->ob_itself ) return 1;
+       if ( self->ob_itself < other->ob_itself ) return -1;
+       return 0;
+}
 
 #define WinObj_repr NULL
 
-#define WinObj_hash NULL
+static int WinObj_hash(self)
+       WindowObject *self;
+{
+       return (int)self->ob_itself;
+}
 
 PyTypeObject Window_Type = {
        PyObject_HEAD_INIT(&PyType_Type)
index cbc5246a729dd2cca14d202f34033ecd89bce3e1..74b3bfdb53b41f231badda7365d5bc0fa770c2bb 100644 (file)
@@ -126,6 +126,29 @@ class MyObjectDefinition(GlobalObjectDefinition):
                OutRbrace()
                Output("self->ob_itself = NULL;")
                Output("self->ob_freeit = NULL;")
+               
+       def outputCompare(self):
+               Output()
+               Output("static int %s_compare(self, other)", self.prefix)
+               IndentLevel()
+               Output("%s *self, *other;", self.objecttype)
+               DedentLevel()
+               OutLbrace()
+               Output("if ( self->ob_itself > other->ob_itself ) return 1;")
+               Output("if ( self->ob_itself < other->ob_itself ) return -1;")
+               Output("return 0;")
+               OutRbrace()
+               
+       def outputHash(self):
+               Output()
+               Output("static int %s_hash(self)", self.prefix)
+               IndentLevel()
+               Output("%s *self;", self.objecttype)
+               DedentLevel()
+               OutLbrace()
+               Output("return (int)self->ob_itself;")
+               OutRbrace()
+               
 ##     def outputFreeIt(self, itselfname):
 ##             Output("DisposeWindow(%s);", itselfname)
 # From here on it's basically all boiler plate...