Oops, repr didn't allocate the memory it used...

This commit is contained in:
Jack Jansen 2001-02-11 01:12:53 +00:00
parent 8a38714ba0
commit 3f49e4d064
2 changed files with 19 additions and 1 deletions

View File

@ -2310,7 +2310,13 @@ static int WinObj_compare(self, other)
return 0;
}
#define WinObj_repr NULL
static PyObject * WinObj_repr(self)
WindowObject *self;
{
char buf[100];
sprintf(buf, "<Window object at 0x%08.8x for 0x%08.8x>", self, self->ob_itself);
return PyString_FromString(buf);
}
static int WinObj_hash(self)
WindowObject *self;

View File

@ -156,6 +156,18 @@ class MyObjectDefinition(GlobalObjectDefinition):
Output("return (int)self->ob_itself;")
OutRbrace()
def outputRepr(self):
Output()
Output("static PyObject * %s_repr(self)", self.prefix)
IndentLevel()
Output("%s *self;", self.objecttype)
DedentLevel()
OutLbrace()
Output("char buf[100];")
Output("""sprintf(buf, "<Window object at 0x%%08.8x for 0x%%08.8x>", self, self->ob_itself);""")
Output("return PyString_FromString(buf);")
OutRbrace()
## def outputFreeIt(self, itselfname):
## Output("DisposeWindow(%s);", itselfname)
# From here on it's basically all boiler plate...