Commits

Brian Kearns  committed b0ba9ef

kill unused StringLikeBuffer

  • Participants
  • Parent commits 95ca8c3

Comments (0)

Files changed (1)

File pypy/interpreter/buffer.py

 
 class Buffer(object):
     """Abstract base class for buffers."""
-
-    __slots__ = ()     # no extra slot here
+    __slots__ = []
 
     def getlength(self):
         raise NotImplementedError
     def get_raw_address(self):
         raise ValueError("no raw buffer")
 
-
     def is_writable(self):
         return False
 
+
 class RWBuffer(Buffer):
     """Abstract base class for read-write buffers."""
-
-    __slots__ = ()     # no extra slot here
+    __slots__ = []
 
     def is_writable(self):
         return True
             self.setitem(start + i, string[i])
 
 
-
-# ____________________________________________________________
-
 class StringBuffer(Buffer):
+    __slots__ = ['value']
 
     def __init__(self, value):
         self.value = value
             return self.value[start:stop]
         return "".join([self.value[start + i*step] for i in xrange(size)])
 
-
-class StringLikeBuffer(Buffer):
-    """For app-level objects that already have a string-like interface
-    with __len__ and a __getitem__ that returns characters or (with
-    slicing) substrings."""
-    # XXX this is inefficient, it should only be used temporarily
-
-    def __init__(self, space, w_obj):
-        self.space = space
-        self.w_obj = w_obj
-
-    def getlength(self):
-        space = self.space
-        return space.len_w(self.w_obj)
-
-    def getitem(self, index):
-        space = self.space
-        s = space.str_w(space.getitem(self.w_obj, space.wrap(index)))
-        if len(s) != 1:
-            raise OperationError(space.w_ValueError,
-                                 space.wrap("character expected, got string"))
-        char = s[0]   # annotator hint
-        return char
-
-    def getslice(self, start, stop, step, size):
-        space = self.space
-        if step != 1:
-            raise OperationError(space.w_ValueError, space.wrap(
-                "buffer object does not support slicing with a step"))
-        s = space.str_w(space.getslice(self.w_obj, space.wrap(start),
-                                                   space.wrap(stop)))
-        return s
-
 # ____________________________________________________________
 
 class SubBufferMixin(object):
+    _attrs_ = ['buffer', 'offset', 'size']
+
     def __init__(self, buffer, offset, size):
         self.buffer = buffer
         self.offset = offset
                           # out of bounds
         return self.buffer.getslice(self.offset + start, self.offset + stop, step, size)
 
+
 class SubBuffer(Buffer):
     import_from_mixin(SubBufferMixin)
 
+
 class RWSubBuffer(RWBuffer):
     import_from_mixin(SubBufferMixin)