[pypy-svn] r25028 - pypy/dist/pypy/rpython/ootypesystem
arigo at codespeak.net
arigo at codespeak.net
Mon Mar 27 13:59:39 CEST 2006
Author: arigo
Date: Mon Mar 27 13:59:38 2006
New Revision: 25028
Modified:
pypy/dist/pypy/rpython/ootypesystem/ootype.py
Log:
Some useful __repr__.
Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py Mon Mar 27 13:59:38 2006
@@ -2,6 +2,7 @@
from pypy.rpython.lltypesystem.lltype import Bool, Void, UniChar, typeOf, \
Primitive, isCompatibleType, enforce
from pypy.rpython.lltypesystem.lltype import frozendict, isCompatibleType
+from pypy.tool.uid import uid
STATICNESS = True
@@ -182,7 +183,13 @@
def __init__(self, INSTANCE):
self.__dict__["_TYPE"] = INSTANCE
INSTANCE._init_instance(self)
-
+
+ def __repr__(self):
+ return '<%s>' % (self,)
+
+ def __str__(self):
+ return '%r inst at 0x%x' % (self._TYPE._name, uid(self))
+
def __getattr__(self, name):
DEFINST, meth = self._TYPE._lookup(name)
if meth is not None:
@@ -244,6 +251,9 @@
def __init__(self, INSTANCE):
self.__dict__["_TYPE"] = INSTANCE
+ def __str__(self):
+ return '%r null inst' % (self._TYPE._name,)
+
def __getattribute__(self, name):
if name.startswith("_"):
return object.__getattribute__(self, name)
@@ -274,6 +284,12 @@
assert isSubclass(inst._TYPE, INSTANCE)
self.__dict__['_inst'] = inst
+ def __repr__(self):
+ if self._TYPE == self._inst._TYPE:
+ return repr(self._inst)
+ else:
+ return '<%r view of %s>' % (self._TYPE._name, self._inst)
+
def __ne__(self, other):
return not (self == other)
More information about the Pypy-commit
mailing list