[pypy-svn] r44304 - in pypy/dist/pypy/rpython: . lltypesystem ootypesystem

pedronis at codespeak.net pedronis at codespeak.net
Sat Jun 16 16:01:15 CEST 2007


Author: pedronis
Date: Sat Jun 16 16:01:14 2007
New Revision: 44304

Modified:
   pypy/dist/pypy/rpython/lltypesystem/typecache.py
   pypy/dist/pypy/rpython/ootypesystem/bltregistry.py
   pypy/dist/pypy/rpython/rexternalobj.py
Log:
sanity for order of definitions



Modified: pypy/dist/pypy/rpython/lltypesystem/typecache.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/typecache.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/typecache.py	Sat Jun 16 16:01:14 2007
@@ -1,2 +1,2 @@
 # this is automatically generated cache files for c types
-platforms = {('', ('32bit', 'ELF'), 'Linux'): {'short': 16, 'int': 32, 'unsigned char': 8, 'long': 32, 'char': 8, 'unsigned short': 16, 'unsigned long': 32, 'long long': 64, 'mode_t': 32, 'unsigned long long': 64, 'size_t': 32, 'unsigned int': 32}}
+platforms = {('', ('32bit', 'ELF'), 'Linux'): {'short': 16, 'int': 32, 'unsigned char': 8, 'long': 32, 'char': 8, 'unsigned short': 16, 'unsigned long': 32, 'long long': 64, 'mode_t': 32, 'unsigned long long': 64, 'size_t': 32, 'unsigned int': 32}, ('i386', ('32bit', ''), 'Darwin'): {'short': 16, 'int': 32, 'unsigned char': 8, 'long': 32, 'char': 8, 'unsigned short': 16, 'unsigned long': 32, 'long long': 64, 'mode_t': 16, 'unsigned long long': 64, 'size_t': 32, 'unsigned int': 32}}

Modified: pypy/dist/pypy/rpython/ootypesystem/bltregistry.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/bltregistry.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/bltregistry.py	Sat Jun 16 16:01:14 2007
@@ -212,6 +212,7 @@
     
     def compute_result_annotation(self):
         if self.bookkeeper is None:
+            # XXX diverges from the cache
             return annmodel.SomeExternalBuiltin(ExternalType(self.instance))
         return annmodel.SomeExternalBuiltin(self.bookkeeper.getexternaldesc(self.instance))
     

Modified: pypy/dist/pypy/rpython/rexternalobj.py
==============================================================================
--- pypy/dist/pypy/rpython/rexternalobj.py	(original)
+++ pypy/dist/pypy/rpython/rexternalobj.py	Sat Jun 16 16:01:14 2007
@@ -10,6 +10,8 @@
 from pypy.annotation.signature import annotation
 from pypy.annotation.pairtype import pairtype
 
+# ExternalObjects
+
 class __extend__(annmodel.SomeExternalObject):
 
     def rtyper_makerepr(self, rtyper):
@@ -28,7 +30,55 @@
         if 'const_box' in attrs:
             del attrs['const_box']
         return self.__class__, attrs
+    
+class ExternalObjRepr(Repr):
+    """Repr for the (obsolecent) extfunctable.declaretype() case.
+    If you use the extregistry instead you get to pick your own Repr.
+    """
+
+    def __init__(self, knowntype):
+        self.exttypeinfo = typetable[knowntype]
+        TYPE = self.exttypeinfo.get_lltype()
+        self.lowleveltype = lltype.Ptr(TYPE)
+        self.instance_cache = {}
+        # The set of methods supported depends on 'knowntype', so we
+        # cannot have rtype_method_xxx() methods directly on the
+        # ExternalObjRepr class.  But we can store them in 'self' now.
+        for name, extfuncinfo in self.exttypeinfo.methods.items():
+            methodname = 'rtype_method_' + name
+            bltintyper = rbuiltin.make_rtype_extfunc(extfuncinfo)
+            setattr(self, methodname, bltintyper)
 
+    def convert_const(self, value):
+        T = self.exttypeinfo.get_lltype()
+        if value is None:
+            return lltype.nullptr(T)
+        if not isinstance(value, self.exttypeinfo.typ):
+            raise TyperError("expected a %r: %r" % (self.exttypeinfo.typ,
+                                                    value))
+        key = Constant(value)
+        try:
+            p = self.instance_cache[key]
+        except KeyError:
+            p = lltype.malloc(T)
+            init_opaque_object(p.obj, value)
+            self.instance_cache[key] = p
+        return p
+
+    def rtype_is_true(self, hop):
+        vlist = hop.inputargs(self)
+        return hop.genop('ptr_nonzero', vlist, resulttype=lltype.Bool)
+
+# ExternalBuiltins
+
+class __extend__(annmodel.SomeExternalBuiltin):
+    
+    def rtyper_makerepr(self, rtyper):
+        return ExternalBuiltinRepr(self.knowntype)
+    
+    def rtyper_makekey(self):
+        return self.__class__, self.knowntype
+    
 class ExternalBuiltinRepr(Repr):
     def __init__(self, knowntype):
         self.knowntype = knowntype
@@ -92,51 +142,6 @@
         else:
             raise AttributeError(attr)
 
-class __extend__(annmodel.SomeExternalBuiltin):
-    
-    def rtyper_makerepr(self, rtyper):
-        return ExternalBuiltinRepr(self.knowntype)
-    
-    def rtyper_makekey(self):
-        return self.__class__, self.knowntype
-    
-class ExternalObjRepr(Repr):
-    """Repr for the (obsolecent) extfunctable.declaretype() case.
-    If you use the extregistry instead you get to pick your own Repr.
-    """
-
-    def __init__(self, knowntype):
-        self.exttypeinfo = typetable[knowntype]
-        TYPE = self.exttypeinfo.get_lltype()
-        self.lowleveltype = lltype.Ptr(TYPE)
-        self.instance_cache = {}
-        # The set of methods supported depends on 'knowntype', so we
-        # cannot have rtype_method_xxx() methods directly on the
-        # ExternalObjRepr class.  But we can store them in 'self' now.
-        for name, extfuncinfo in self.exttypeinfo.methods.items():
-            methodname = 'rtype_method_' + name
-            bltintyper = rbuiltin.make_rtype_extfunc(extfuncinfo)
-            setattr(self, methodname, bltintyper)
-
-    def convert_const(self, value):
-        T = self.exttypeinfo.get_lltype()
-        if value is None:
-            return lltype.nullptr(T)
-        if not isinstance(value, self.exttypeinfo.typ):
-            raise TyperError("expected a %r: %r" % (self.exttypeinfo.typ,
-                                                    value))
-        key = Constant(value)
-        try:
-            p = self.instance_cache[key]
-        except KeyError:
-            p = lltype.malloc(T)
-            init_opaque_object(p.obj, value)
-            self.instance_cache[key] = p
-        return p
-
-    def rtype_is_true(self, hop):
-        vlist = hop.inputargs(self)
-        return hop.genop('ptr_nonzero', vlist, resulttype=lltype.Bool)
 
 class __extend__(pairtype(ExternalBuiltinRepr, ExternalBuiltinRepr)):
     def convert_from_to((from_, to), v, llops):
@@ -146,5 +151,3 @@
             v.concretetype=to.knowntype
             return v
         return NotImplemented
-    
-        



More information about the Pypy-commit mailing list