Author: Tim Felgentreff <[email protected]>
Branch: bitblt
Changeset: r183:48484c8a2361
Date: 2013-03-15 18:38 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/48484c8a2361/

Log:    just commit all

diff --git a/images/mini.image b/images/mini.image
index 
1bc58a0fd06c4079c4651f707226768f724e405e..a8cfbe28687d27aca4ab2d9dd0f37da338fd475d
GIT binary patch

[cut]

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -75,8 +75,9 @@
                 s_new_context = p.s_new_context
 
     def c_loop(self, s_context):
-        padding = ' ' * (self.max_stack_depth - self.remaining_stack_depth)
-        print padding + s_context.short_str()
+        # if self.max_stack_depth - self.remaining_stack_depth < 10:
+        #     padding = ' ' * (self.max_stack_depth - 
self.remaining_stack_depth)
+        #     print padding + s_context.short_str()
         old_pc = 0
         while True:
             pc = s_context._pc
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -4,10 +4,14 @@
 from rpython.rlib.rarithmetic import intmask, r_uint, int_between
 
 class ObjSpace(object):
+    _attrs_ = ["_display", "w_simulateCopyBits"]
+
     def __init__(self):
         self.classtable = {}
         self.make_bootstrap_classes()
         self.make_bootstrap_objects()
+        self._display = [None]
+        self.w_simulateCopyBits = [None]
 
     def make_bootstrap_classes(self):
         def define_core_cls(name, w_superclass, w_metaclass):
@@ -285,6 +289,17 @@
             closure.atput0(i0, copiedValues[i0])
         return w_closure
 
+    def set_display(self, interp, obj):
+        self._display[0] = obj
+        self.w_simulateCopyBits[0] = 
interp.perform(interp.space.wrap_string("simulateCopyBits"), "asSymbol")
+
+    def w_copyBitsSymbol(self):
+        return self.w_simulateCopyBits[0]
+
+    def display(self):
+        return self._display[0]
+        
+
 def bootstrap_class(space, instsize, w_superclass=None, w_metaclass=None,
                     name='?', format=shadow.POINTERS, varsized=False):
     from spyvm import model
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -4,6 +4,7 @@
 import operator
 from spyvm import model, shadow
 from spyvm import constants
+from spyvm import display
 from spyvm.error import PrimitiveFailedError, \
     PrimitiveNotYetWrittenError
 from spyvm import wrapper
@@ -545,17 +546,37 @@
 
 @expose_primitive(BITBLT_COPY_BITS, unwrap_spec=[object])
 def func(interp, s_frame, w_rcvr):
+    import time
+
     if not isinstance(w_rcvr, model.W_PointersObject) or w_rcvr.size() < 15:
         raise PrimitiveFailedError
+
+    start = time.time()
+    print "blitting"
+    interp.perform(w_rcvr, "simulateCopyBits")
+    print "blitting finshed after %d ms" % int((time.time() - start) * 1000)
+
+    w_display = interp.space.objtable['w_display']
+    w_dest_form = w_rcvr.fetch(interp.space, 0)
+    if w_dest_form.is_same_object(w_display):
+        w_bits = w_dest_form.fetch(interp.space, 0)
+        assert isinstance(w_bits, model.W_WordsObject)
+        bits = w_bits.words
+        print bits
+        interp.space.display().blit_bits(bits, 0, len(bits)) # TODO: draw only 
as necessary
     # See BlueBook p.356ff
-    s_bitblt = w_rcvr.as_bitblt_get_shadow(interp.space)
-    s_bitblt.clip_range()
-    if s_bitblt.w <= 0 or s_bitblt.h <= 0:
-        return w_rcvr # null range
-    s_bitblt.compute_masks()
-    s_bitblt.check_overlap()
-    s_bitblt.calculate_offsets()
-    s_bitblt.copy_loop()
+    # s_bitblt.clip_range()
+    # if s_bitblt.w < 0 or s_bitblt.h < 0:
+    #     return w_rcvr # null range
+    # s_bitblt.compute_masks()
+    # s_bitblt.check_overlap()
+    # s_bitblt.calculate_offsets()
+    # start_index = s_bitblt.dest_index
+    # if s_bitblt.dest_form.w_self().is_same_object(w_display):
+        # s_bitblt.copy_loop(interp.space.display())
+    # else:
+    #     s_bitblt.copy_loop()
+    # end_index = s_bitblt.dest_index
     return w_rcvr
 
 @expose_primitive(BE_CURSOR, unwrap_spec=[object])
@@ -570,6 +591,14 @@
         raise PrimitiveFailedError
     # the fields required are bits (a pointer to a Bitmap), width, height, 
depth
     interp.space.objtable['w_display'] = w_rcvr
+
+    # XXX: TODO get the initial image TODO: figure out whether we
+    # should decide the width an report it in the other SCREEN_SIZE
+    w = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 1))
+    h = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 2))
+    d = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 3))
+    interp.space.set_display(interp, display.SDLDisplay(w, h, d))
+
     return w_rcvr
 
 @expose_primitive(STRING_REPLACE, unwrap_spec=[object, index1_0, index1_0, 
object, index1_0])
@@ -673,6 +702,7 @@
 VALUE_UNINTERRUPTABLY = 123
 LOW_SPACE_SEMAPHORE = 124
 SIGNAL_AT_BYTES_LEFT = 125
+DEFER_UPDATES = 126
 DRAW_RECTANGLE = 127
 
 @expose_primitive(IMAGE_NAME)
@@ -695,9 +725,16 @@
     # dont know when the space runs out
     return w_reciver
 
+@expose_primitive(DEFER_UPDATES, unwrap_spec=[object, object])
+def func(interp, s_frame, w_receiver, w_bool):
+    if w_bool.is_same_object(interp.space.w_true):
+        interp.space.display().set_defer_updates()
+    else:
+        interp.space.display().set_defer_updates()
+
 @expose_primitive(DRAW_RECTANGLE, unwrap_spec=[object, int, int, int, int])
 def func(interp, s_frame, w_rcvr, left, right, top, bottom):
-    import pdb; pdb.set_trace()
+    # import pdb; pdb.set_trace()
     raise PrimitiveNotYetWrittenError()
 
 
@@ -1151,6 +1188,12 @@
 CTXT_SIZE = 212
 
 # ___________________________________________________________________________
+# Drawing
+
+FORCE_DISPLAY_UPDATE = 231
+
+
+# ___________________________________________________________________________
 # PrimitiveLoadInstVar
 #
 # These are some wacky bytecodes in squeak.  They are defined to do
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -1052,247 +1052,253 @@
     def update(self): pass
 
 
-class BitBltShadow(AbstractCachingShadow):
-    _attrs_ = [# From BitBlt
-               "dest_form", "source_form", "halftone_form",
-               "combination_rule", "dest_x", "dest_y", "width",
-               "height", "source_x", "source_y", "clip_x", "clip_y",
-               "clip_width", "clip_height", "color_map",
-               # From BitBltSimulation
-               "w", "h", "sx", "sy", "dx", "dy",
-               "dest_bits", "dest_raster", "source_bits", "source_raster",
-               "halftone_bits", "skew", "mask1", "mask2", "skew_mask",
-               "n_words", "h_dir", "v_dir", "preload", "source_index",
-               "dest_index", "source_delta", "dest_delta"]
+# class BitBltShadow(AbstractCachingShadow):
+#     _attrs_ = [# From BitBlt
+#                "dest_form", "source_form", "halftone_form",
+#                "combination_rule", "dest_x", "dest_y", "width",
+#                "height", "source_x", "source_y", "clip_x", "clip_y",
+#                "clip_width", "clip_height", "color_map",
+#                # From BitBltSimulation
+#                "w", "h", "sx", "sy", "dx", "dy",
+#                "dest_bits", "dest_raster", "source_bits", "source_raster",
+#                "halftone_bits", "skew", "mask1", "mask2", "skew_mask",
+#                "n_words", "h_dir", "v_dir", "preload", "source_index",
+#                "dest_index", "source_delta", "dest_delta"]
 
-    WordSize = 32
-    RightMasks = [0]
-    for i in xrange(WordSize):
-        RightMasks.append((2 ** (i + 1)) - 1)
-    AllOnes = (2 ** WordSize) - 1
+#     WordSize = 32
+#     RightMasks = [rarithmetic.r_uint(0)]
+#     for i in xrange(WordSize):
+#         RightMasks.append(rarithmetic.r_uint((2 ** (i + 1)) - 1))
+#     AllOnes = rarithmetic.r_uint((2 ** WordSize) - 1)
 
-    def sync_cache(self):
-        try:
-            self.dest_form = self.fetch(0).as_form_get_shadow(self.space)
-        except error.PrimitiveFailedError, e:
-            self.w_self()._shadow = None
-            raise e
-        w_source_form = self.fetch(1)
-        if w_source_form is self.space.w_nil:
-            self.source_form = self.dest_form
-        else:
-            try:
-                self.source_form = w_source_form.as_form_get_shadow(self.space)
-            except error.PrimitiveFailedError, e:
-                self.w_self()._shadow = None
-                raise e
-        w_halftone_form = self.fetch(2)
-        if w_halftone_form is not self.space.w_nil:
-            if isinstance(w_halftone_form, model.W_WordsObject):
-                # Already a bitmap
-                self.halftone_bits = w_halftone_form.words
-            else:
-                self.halftone_bits = 
w_halftone_form.as_form_get_shadow(self.space).bits
-        else:
-            self.halftone_bits = None
-        self.combination_rule = self.space.unwrap_int(self.fetch(3))
-        self.dest_x = self.space.unwrap_int(self.fetch(4))
-        self.dest_y = self.space.unwrap_int(self.fetch(5))
-        self.width = self.space.unwrap_int(self.fetch(6))
-        self.height = self.space.unwrap_int(self.fetch(7))
-        self.source_x = self.space.unwrap_int(self.fetch(8))
-        self.source_y = self.space.unwrap_int(self.fetch(9))
-        self.clip_x = self.space.unwrap_int(self.fetch(10))
-        self.clip_y = self.space.unwrap_int(self.fetch(11))
-        self.clip_width = self.space.unwrap_int(self.fetch(12))
-        self.clip_height = self.space.unwrap_int(self.fetch(13))
-        self.color_map = self.fetch(14)
+#     def sync_cache(self):
+#         try:
+#             self.dest_form = self.fetch(0).as_form_get_shadow(self.space)
+#         except error.PrimitiveFailedError, e:
+#             self.w_self()._shadow = None
+#             raise e
+#         w_source_form = self.fetch(1)
+#         if w_source_form is self.space.w_nil:
+#             self.source_form = self.dest_form
+#         else:
+#             try:
+#                 self.source_form = 
w_source_form.as_form_get_shadow(self.space)
+#             except error.PrimitiveFailedError, e:
+#                 self.w_self()._shadow = None
+#                 raise e
+#         w_halftone_form = self.fetch(2)
+#         if w_halftone_form is not self.space.w_nil:
+#             if isinstance(w_halftone_form, model.W_WordsObject):
+#                 # Already a bitmap
+#                 self.halftone_bits = w_halftone_form.words
+#             else:
+#                 self.halftone_bits = 
w_halftone_form.as_form_get_shadow(self.space).bits
+#         else:
+#             self.halftone_bits = None
+#         self.combination_rule = self.space.unwrap_int(self.fetch(3))
+#         self.dest_x = self.space.unwrap_int(self.fetch(4)) - 1
+#         self.dest_y = self.space.unwrap_int(self.fetch(5)) - 1
+#         self.width = self.space.unwrap_int(self.fetch(6))
+#         self.height = self.space.unwrap_int(self.fetch(7))
+#         self.source_x = self.space.unwrap_int(self.fetch(8)) - 1
+#         self.source_y = self.space.unwrap_int(self.fetch(9)) - 1
+#         self.clip_x = self.space.unwrap_int(self.fetch(10)) - 1
+#         self.clip_y = self.space.unwrap_int(self.fetch(11)) - 1
+#         self.clip_width = self.space.unwrap_int(self.fetch(12))
+#         self.clip_height = self.space.unwrap_int(self.fetch(13))
+#         self.color_map = self.fetch(14)
 
-    def clip_range(self):
-        if self.dest_x >= self.clip_x:
-            self.sx = self.source_x
-            self.dx = self.dest_x
-            self.w = self.width
-        else:
-            self.sx = self.source_x + (self.clip_x - self.dest_x)
-            self.w = self.width - (self.clip_x - self.dest_x)
-            self.dx = self.clip_x
-        if self.dx + self.w > self.clip_x + self.clip_width:
-            self.w = self.w - (self.dx + self.w - (self.clip_x + 
self.clip_width))
-        if self.dest_x >= self.clip_y:
-            self.sy = self.source_y
-            self.dy = self.dest_y
-            self.h = self.height
-        else:
-            self.sy = self.source_y + self.clip_y - self.dest_y
-            self.h = self.height - (self.clip_y - self.dest_y)
-            self.dy = self.clip_y
-        if self.dy + self.h > self.clip_y + self.clip_height:
-            self.h = self.h - (self.dy + self.h - (self.clip_y + 
self.clip_height))
-        if self.sx < 0:
-            self.dx = self.dx - self.sx
-            self.w = self.w + self.sx
-            self.sx = 0
-        if self.sx + self.w > self.source_form.width:
-            self.w = self.w - (self.sx + self.w - self.source_form.width)
-        if self.sy < 0:
-            self.dy = self.dy - self.sy
-            self.h = self.h + self.sy
-            self.sy = 0
-        if self.sy + self.h > self.source_form.height:
-            self.h = self.h - (self.sy + self.h - self.source_form.height)
+#     def clip_range(self):
+#         if self.dest_x >= self.clip_x:
+#             self.sx = self.source_x
+#             self.dx = self.dest_x
+#             self.w = self.width
+#         else:
+#             self.sx = self.source_x + (self.clip_x - self.dest_x)
+#             self.w = self.width - (self.clip_x - self.dest_x)
+#             self.dx = self.clip_x
+#         if self.dx + self.w > self.clip_x + self.clip_width:
+#             self.w = self.w - (self.dx + self.w - (self.clip_x + 
self.clip_width))
+#         if self.dest_x >= self.clip_y:
+#             self.sy = self.source_y
+#             self.dy = self.dest_y
+#             self.h = self.height
+#         else:
+#             self.sy = self.source_y + self.clip_y - self.dest_y
+#             self.h = self.height - (self.clip_y - self.dest_y)
+#             self.dy = self.clip_y
+#         if self.dy + self.h > self.clip_y + self.clip_height:
+#             self.h = self.h - (self.dy + self.h - (self.clip_y + 
self.clip_height))
+#         if self.sx < 0:
+#             self.dx = self.dx - self.sx
+#             self.w = self.w + self.sx
+#             self.sx = 0
+#         if self.sx + self.w > self.source_form.width:
+#             self.w = self.w - (self.sx + self.w - self.source_form.width)
+#         if self.sy < 0:
+#             self.dy = self.dy - self.sy
+#             self.h = self.h + self.sy
+#             self.sy = 0
+#         if self.sy + self.h > self.source_form.height:
+#             self.h = self.h - (self.sy + self.h - self.source_form.height)
 
-    def compute_masks(self):
-        self.dest_bits = self.dest_form.bits
-        self.dest_raster = (self.dest_form.width - 1) / BitBltShadow.WordSize 
+ 1
-        self.source_bits = self.source_form.bits
-        self.source_raster = (self.source_form.width - 1) / 
BitBltShadow.WordSize + 1
-        self.skew = (self.sx - self.dx) & (BitBltShadow.WordSize - 1)
-        start_bits = BitBltShadow.WordSize - (self.dx & (BitBltShadow.WordSize 
- 1))
-        self.mask1 = BitBltShadow.RightMasks[start_bits]
-        end_bits = (BitBltShadow.WordSize - 1) - ((self.dx + self.w - 1) & 
(BitBltShadow.WordSize - 1))
-        self.mask2 = ~BitBltShadow.RightMasks[end_bits]
-        if self.skew == 0:
-            self.skew_mask = 0
-        else:
-            self.skew_mask = BitBltShadow.RightMasks[BitBltShadow.WordSize - 
self.skew]
-        if self.w < start_bits:
-            self.mask1 = self.mask1 & self.mask2
-            self.mask2 = 0
-            self.n_words = 1
-        else:
-            self.n_words = (self.w - start_bits - 1) / BitBltShadow.WordSize + 
2
+#     def compute_masks(self):
+#         self.dest_bits = self.dest_form.bits
+#         self.dest_raster = (self.dest_form.width - 1) / 
BitBltShadow.WordSize + 1
+#         self.source_bits = self.source_form.bits
+#         self.source_raster = (self.source_form.width - 1) / 
BitBltShadow.WordSize + 1
+#         self.skew = (self.sx - self.dx) & (BitBltShadow.WordSize - 1)
+#         start_bits = BitBltShadow.WordSize - (self.dx & 
(BitBltShadow.WordSize - 1))
+#         self.mask1 = BitBltShadow.RightMasks[start_bits]
+#         end_bits = (BitBltShadow.WordSize - 1) - ((self.dx + self.w - 1) & 
(BitBltShadow.WordSize - 1))
+#         self.mask2 = ~BitBltShadow.RightMasks[end_bits]
+#         if self.skew == 0:
+#             self.skew_mask = rarithmetic.r_uint(0)
+#         else:
+#             self.skew_mask = BitBltShadow.RightMasks[BitBltShadow.WordSize - 
self.skew]
+#         if self.w < start_bits:
+#             self.mask1 = self.mask1 & self.mask2
+#             self.mask2 = 0
+#             self.n_words = 1
+#         else:
+#             self.n_words = (self.w - start_bits - 1) / BitBltShadow.WordSize 
+ 2
 
-    def check_overlap(self):
-        self.h_dir = 1
-        self.v_dir = 1
-        if (self.source_form.w_self().is_same_object(self.dest_form.w_self()) 
and
-            self.dy >= self.sy):
-            if self.dy > self.sy:
-                self.v_dir = -1
-                self.sy = self.sy + self.h - 1
-                self.dy = self.dy + self.h - 1
-            elif self.dx > self.sx:
-                self.h_dir = -1
-                self.sx = self.sx + self.w - 1
-                self.dx = self.dx + self.w - 1
-                self.skew_mask = ~self.skew_mask
-                self.mask1, self.mask2 = self.mask2, self.mask1
+#     def check_overlap(self):
+#         self.h_dir = 1
+#         self.v_dir = 1
+#         if 
(self.source_form.w_self().is_same_object(self.dest_form.w_self()) and
+#             self.dy >= self.sy):
+#             if self.dy > self.sy:
+#                 self.v_dir = -1
+#                 self.sy = self.sy + self.h - 1
+#                 self.dy = self.dy + self.h - 1
+#             elif self.dx > self.sx:
+#                 self.h_dir = -1
+#                 self.sx = self.sx + self.w - 1
+#                 self.dx = self.dx + self.w - 1
+#                 self.skew_mask = ~self.skew_mask
+#                 self.mask1, self.mask2 = self.mask2, self.mask1
 
-    def calculate_offsets(self):
-        self.preload = (self.skew_mask != 0 and
-                        self.skew <= (self.sx & (BitBltShadow.WordSize - 1)))
-        if self.h_dir < 0:
-            self.preload = not self.preload
-        self.source_index = self.sy * self.source_raster + self.sx / 
BitBltShadow.WordSize
-        self.dest_index = self.dy * self.dest_raster + self.dx / 
BitBltShadow.WordSize
-        self.source_delta = ((self.source_raster *
-                             self.v_dir -
-                             (self.n_words + (1 if self.preload else 0))) *
-                             self.h_dir)
-        self.dest_delta = self.dest_raster * self.v_dir - self.n_words * 
self.h_dir
+#     def calculate_offsets(self):
+#         self.preload = (self.skew_mask != 0 and
+#                         self.skew <= (self.sx & (BitBltShadow.WordSize - 1)))
+#         if self.h_dir < 0:
+#             self.preload = not self.preload
+#         self.source_index = self.sy * self.source_raster + self.sx / 
BitBltShadow.WordSize
+#         self.dest_index = self.dy * self.dest_raster + self.dx / 
BitBltShadow.WordSize
+#         self.source_delta = ((self.source_raster *
+#                              self.v_dir -
+#                              (self.n_words + (1 if self.preload else 0))) *
+#                              self.h_dir)
+#         self.dest_delta = self.dest_raster * self.v_dir - self.n_words * 
self.h_dir
 
-    def copy_loop(self):
-        for i in xrange(self.h - 1):
-            if self.halftone_bits:
-                halftone_word = self.halftone_bits[(self.dy & 
(BitBltShadow.WordSize - 1)) % len(self.halftone_bits)]
-                self.dy = self.dy + self.v_dir
-            else:
-                halftone_word = BitBltShadow.AllOnes
-            skew_word = halftone_word
-            if self.preload:
-                prev_word = self.source_bits[self.source_index]
-                self.source_index = self.source_index + self.h_dir
-            else:
-                prev_word = 0
-            merge_mask = self.mask1
-            for word in xrange(self.n_words - 1):
-                prev_word = prev_word & self.skew_mask
-                this_word = self.source_bits[self.source_index]
-                skew_word = prev_word | (this_word & ~self.skew_mask)
-                prev_word = this_word
-                skew_word = (self.bit_shift(skew_word, self.skew) |
-                             self.bit_shift(skew_word, self.skew - 16))
-                merge_word = self.merge(
-                    skew_word & halftone_word,
-                    self.dest_bits[self.dest_index]
-                )
-                self.dest_bits[self.dest_index] = (
-                    (merge_mask & merge_word) |
-                    (~merge_mask & self.dest_bits[self.dest_index])
-                )
-                self.source_index = self.source_index + self.h_dir
-                self.dest_index = self.dest_index + self.h_dir
-                if word == (self.n_words - 1):
-                    merge_mask = self.mask2
-                else:
-                    merge_mask = BitBltShadow.AllOnes
-            self.source_index = self.source_index + self.source_delta
-            self.dest_index = self.dest_index + self.dest_delta
-        self.dest_form.replace_bits(self.dest_bits)
+#     def copy_loop(self, dest_surface=None):
+#         for i in xrange(self.h):
+#             if self.halftone_bits:
+#                 halftone_word = self.halftone_bits[(self.dy & 
(BitBltShadow.WordSize - 1)) % len(self.halftone_bits)]
+#                 self.dy = self.dy + self.v_dir
+#             else:
+#                 halftone_word = BitBltShadow.AllOnes
+#             skew_word = halftone_word
+#             if self.preload:
+#                 prev_word = self.source_bits[self.source_index]
+#                 self.source_index = self.source_index + self.h_dir
+#             else:
+#                 prev_word = 0
+#             merge_mask = self.mask1
+#             for word in xrange(self.n_words):
+#                 prev_word = prev_word & self.skew_mask
+#                 this_word = self.source_bits[self.source_index]
+#                 skew_word = prev_word | (this_word & ~self.skew_mask)
+#                 prev_word = this_word
+#                 skew_word = (self.bit_shift(skew_word, self.skew) |
+#                              self.bit_shift(skew_word, self.skew - 16))
+#                 merge_word = rarithmetic.r_uint(self.merge(
+#                     skew_word & halftone_word,
+#                     self.dest_bits[self.dest_index]
+#                 ))
+#                 __prev = self.dest_bits[self.dest_index]
+#                 __new = (
+#                     (merge_mask & merge_word) |
+#                     (~merge_mask & self.dest_bits[self.dest_index])
+#                 )
+#                 self.dest_bits[self.dest_index] = __new
+#                 if dest_surface and __prev != __new:
+#                     dest_surface.lock()
+#                     dest_surface.draw_word(__new, self.dest_index)
+#                     dest_surface.flip()
+#                 self.source_index = self.source_index + self.h_dir
+#                 self.dest_index = self.dest_index + self.h_dir
+#                 if word == (self.n_words - 1):
+#                     merge_mask = self.mask2
+#                 else:
+#                     merge_mask = BitBltShadow.AllOnes
+#             self.source_index = self.source_index + self.source_delta
+#             self.dest_index = self.dest_index + self.dest_delta
+#         self.dest_form.replace_bits(self.dest_bits)
 
-    def bit_shift(self, target, amount):
-        if amount > 0:
-            return target << amount
-        else:
-            return target >> -amount
+#     def bit_shift(self, target, amount):
+#         if amount > 0:
+#             return rarithmetic.r_uint(target) << amount
+#         else:
+#             return rarithmetic.r_uint(target) >> -amount
 
-    def merge(self, source_word, dest_word):
-        if self.combination_rule == 0:
-            return 0
-        elif self.combination_rule == 1:
-            return source_word & dest_word
-        elif self.combination_rule == 2:
-            return source_word & ~dest_word
-        elif self.combination_rule == 3:
-            return source_word
-        elif self.combination_rule == 4:
-            return ~source_word & dest_word
-        elif self.combination_rule == 5:
-            return dest_word
-        elif self.combination_rule == 6:
-            return source_word ^ dest_word
-        elif self.combination_rule == 7:
-            return source_word | dest_word
-        elif self.combination_rule == 8:
-            return ~source_word & ~dest_word
-        elif self.combination_rule == 9:
-            return ~source_word ^ dest_word
-        elif self.combination_rule == 10:
-            return ~dest_word
-        elif self.combination_rule == 11:
-            return source_word | ~dest_word
-        elif self.combination_rule == 12:
-            return ~source_word
-        elif self.combination_rule == 13:
-            return ~source_word | dest_word
-        elif self.combination_rule == 14:
-            return ~source_word | ~dest_word
-        elif self.combination_rule == 15:
-            return BitBltShadow.AllOnes
+#     def merge(self, source_word, dest_word):
+#         if self.combination_rule == 0:
+#             return 0
+#         elif self.combination_rule == 1:
+#             return source_word & dest_word
+#         elif self.combination_rule == 2:
+#             return source_word & ~dest_word
+#         elif self.combination_rule == 3:
+#             return source_word
+#         elif self.combination_rule == 4:
+#             return ~source_word & dest_word
+#         elif self.combination_rule == 5:
+#             return dest_word
+#         elif self.combination_rule == 6:
+#             return source_word ^ dest_word
+#         elif self.combination_rule == 7:
+#             return source_word | dest_word
+#         elif self.combination_rule == 8:
+#             return ~source_word & ~dest_word
+#         elif self.combination_rule == 9:
+#             return ~source_word ^ dest_word
+#         elif self.combination_rule == 10:
+#             return ~dest_word
+#         elif self.combination_rule == 11:
+#             return source_word | ~dest_word
+#         elif self.combination_rule == 12:
+#             return ~source_word
+#         elif self.combination_rule == 13:
+#             return ~source_word | dest_word
+#         elif self.combination_rule == 14:
+#             return ~source_word | ~dest_word
+#         elif self.combination_rule == 15:
+#             return BitBltShadow.AllOnes
 
 
-class FormShadow(AbstractCachingShadow):
-    _attrs_ = ["bits", "width", "height", "depth", "offset_x", "offset_y"]
+# class FormShadow(AbstractCachingShadow):
+#     _attrs_ = ["bits", "width", "height", "depth", "offset_x", "offset_y"]
 
-    def sync_cache(self):
-        self.w_bits = self.fetch(0)
-        if isinstance(self.w_bits, model.W_WordsObject):
-            self.bits = self.w_bits.words
-        else:
-            self.w_self()._shadow = None
-            raise error.PrimitiveFailedError
-        self.width = self.space.unwrap_int(self.fetch(1))
-        self.height = self.space.unwrap_int(self.fetch(2))
-        self.depth = self.space.unwrap_int(self.fetch(3))
-        w_offset = self.fetch(4)
-        if not w_offset is self.space.w_nil:
-            self.offset_x = self.space.unwrap_int(w_offset._fetch(0))
-            self.offset_y = self.space.unwrap_int(w_offset._fetch(1))
+#     def sync_cache(self):
+#         self.w_bits = self.fetch(0)
+#         if isinstance(self.w_bits, model.W_WordsObject):
+#             self.bits = self.w_bits.words
+#         else:
+#             self.w_self()._shadow = None
+#             raise error.PrimitiveFailedError
+#         self.width = self.space.unwrap_int(self.fetch(1))
+#         self.height = self.space.unwrap_int(self.fetch(2))
+#         self.depth = self.space.unwrap_int(self.fetch(3))
+#         w_offset = self.fetch(4)
+#         if not w_offset is self.space.w_nil:
+#             self.offset_x = self.space.unwrap_int(w_offset._fetch(0)) - 1
+#             self.offset_y = self.space.unwrap_int(w_offset._fetch(1)) - 1
 
-    def replace_bits(self, bits):
-        if isinstance(self.w_bits, model.W_WordsObject):
-            self.w_bits.words[:] = bits
-        else:
-            self.w_self()._shadow = None
-            raise error.PrimitiveFailedError
+#     def replace_bits(self, bits):
+#         if isinstance(self.w_bits, model.W_WordsObject):
+#             self.w_bits.words[:] = bits
+#         else:
+#             self.w_self()._shadow = None
+#             raise error.PrimitiveFailedError
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to