[pypy-svn] r49056 - pypy/dist/pypy/annotation

pedronis at codespeak.net pedronis at codespeak.net
Sat Nov 24 19:42:04 CET 2007


Author: pedronis
Date: Sat Nov 24 19:42:03 2007
New Revision: 49056

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/annotation/model.py
   pypy/dist/pypy/annotation/unaryop.py
Log:
remove rctypes annotations



Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Sat Nov 24 19:42:03 2007
@@ -13,7 +13,7 @@
 from pypy.annotation.model import SomePBC, SomeSlice, SomeFloat, s_None
 from pypy.annotation.model import SomeExternalObject, SomeWeakRef
 from pypy.annotation.model import SomeAddress, SomeTypedAddressAccess
-from pypy.annotation.model import SomeCTypesObject, SomeSingleFloat
+from pypy.annotation.model import SomeSingleFloat
 from pypy.annotation.model import unionof, UnionError, set, missing_operation, TLS
 from pypy.annotation.model import read_can_only_throw
 from pypy.annotation.model import add_knowntypedata, merge_knowntypedata
@@ -1011,53 +1011,3 @@
 class __extend__(pairtype(SomeObject, SomeAddress)):
     def union((s_obj, s_addr)):
         raise UnionError, "union of address and anything else makes no sense"
-
-
-
-class __extend__(pairtype(SomeCTypesObject, SomeInteger)):
-    def setitem((s_cto, s_index), s_value):
-        pass
-
-    def getitem((s_cto, s_index)):
-        # Note: The following works for index either pointers and arrays,
-        # because both have a _type_ attribute that contains the type of the
-        # object pointed to or in the case of an array the element type.
-        result_ctype = s_cto.knowntype._type_
-        s_result = SomeCTypesObject(result_ctype, ownsmemory=False)
-        return s_result.return_annotation()
-
-class __extend__(pairtype(SomeCTypesObject, SomeSlice)):
-    def setitem((s_cto, s_slice), s_iterable):
-        raise NotImplementedError("ctypes array slice assignment")
-
-    def getitem((s_cto, s_slice)):
-        result_ctype = s_cto.knowntype._type_
-        s_result = SomeCTypesObject(result_ctype, ownsmemory=False)
-        list_item = s_result.return_annotation()
-        if isinstance(list_item, SomeChar):
-            return SomeString()
-        raise NotImplementedError("ctypes array slicing: "
-                                  "only for arrays of char")
-
-class __extend__(pairtype(SomeCTypesObject, SomeCTypesObject)):
-    def union((s_cto1, s_cto2)):
-        if s_cto1.knowntype == s_cto2.knowntype:
-            return SomeCTypesObject(s_cto1.knowntype,
-                                    ownsmemory = (s_cto1.ownsmemory and
-                                                  s_cto2.ownsmemory))
-        else:
-            return SomeObject()
-
-class __extend__(pairtype(SomeCTypesObject, SomePBC)):
-    def union((obj, pbc)):
-        if pbc.isNone() and obj.can_be_none():
-            return obj
-        else:
-            return SomeObject()
-
-class __extend__(pairtype(SomePBC, SomeCTypesObject)):
-    def union((pbc, obj)):
-        if pbc.isNone() and obj.can_be_none():
-            return obj
-        else:
-            return SomeObject()

Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py	(original)
+++ pypy/dist/pypy/annotation/model.py	Sat Nov 24 19:42:03 2007
@@ -473,34 +473,6 @@
     attributes as well as methods
     """
 
-class SomeCTypesObject(SomeExternalObject):
-    """Stands for an object of the ctypes module."""
-
-    def __init__(self, knowntype, ownsmemory):
-        self.knowntype = knowntype
-        self.ownsmemory = ownsmemory
-        # 'ownsmemory' specifies if the object is *statically known* to own
-        # its C memory.  If it is False, it will be rtyped as an alias object.
-        # Alias objects are allowed, at run-time, to have keepalives, so
-        # that they can indirectly own their memory too (it's just less
-        # efficient).
-
-    def can_be_none(self):
-        # only 'py_object' can also be None
-        import ctypes
-        return issubclass(self.knowntype, ctypes.py_object)
-
-    def return_annotation(self):
-        """Returns either 'self' or the annotation of the unwrapped version
-        of this ctype, following the logic used when ctypes operations
-        return a value.
-        """
-        from pypy.rpython import extregistry
-        assert extregistry.is_registered_type(self.knowntype)
-        entry = extregistry.lookup_type(self.knowntype)
-        # special case for returning primitives or c_char_p
-        return getattr(entry, 's_return_trick', self)
-
 class SomeImpossibleValue(SomeObject):
     """The empty set.  Instances are placeholders for objects that
     will never show up at run-time, e.g. elements of an empty list."""

Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py	(original)
+++ pypy/dist/pypy/annotation/unaryop.py	Sat Nov 24 19:42:03 2007
@@ -7,7 +7,7 @@
      SomeDict, SomeUnicodeCodePoint, SomeTuple, SomeImpossibleValue, \
      SomeInstance, SomeBuiltin, SomeFloat, SomeIterator, SomePBC, \
      SomeExternalObject, SomeTypedAddressAccess, SomeAddress, \
-     SomeCTypesObject, s_ImpossibleValue, s_Bool, s_None, \
+     s_ImpossibleValue, s_Bool, s_None, \
      unionof, set, missing_operation, add_knowntypedata, HarmlesslyBlocked, \
      SomeGenericCallable, SomeWeakRef, SomeUnicodeString
 from pypy.annotation.bookkeeper import getbookkeeper
@@ -735,27 +735,6 @@
         v = smeth(*llargs)
         return ll_to_annotation(v)
 
-class __extend__(SomeCTypesObject):
-    def setattr(cto, s_attr, s_value):
-        pass
-
-    def getattr(cto, s_attr):
-        if s_attr.is_constant() and isinstance(s_attr.const, str):
-            attr = s_attr.const
-            entry = extregistry.lookup_type(cto.knowntype)
-            s_value = entry.get_field_annotation(cto, attr)
-            return s_value
-        else:
-            return SomeObject()
-
-    def is_true(cto):
-        return s_Bool
-
-    def simple_call(cto, *args_s):
-        # for variables containing ctypes function pointers
-        entry = extregistry.lookup_type(cto.knowntype)
-        return entry.compute_result_annotation(*args_s)
-
 #_________________________________________
 # weakrefs
 



More information about the Pypy-commit mailing list