Author: chromatic
Date: Wed Mar 26 21:59:27 2008
New Revision: 26574

Modified:
   trunk/runtime/parrot/library/SDL/Button.pir
   trunk/runtime/parrot/library/SDL/LCD.pir
   trunk/runtime/parrot/library/SDL/StopWatch.pir

Log:
[SDL] Refactored away deprecated classoffset attribute access.

Modified: trunk/runtime/parrot/library/SDL/Button.pir
==============================================================================
--- trunk/runtime/parrot/library/SDL/Button.pir (original)
+++ trunk/runtime/parrot/library/SDL/Button.pir Wed Mar 26 21:59:27 2008
@@ -66,39 +66,26 @@
 .sub init_pmc :vtable :method
     .param pmc name
 
-    $I0 = classoffset self, 'SDL::Button'
-
-    # image
     $P0 = new 'SDL::Image', name
-    setattribute self, $I0, $P0
+    setattribute self, 'image', $P0
 
-    # status
-    inc $I0
     $P0 = new 'Integer'
     $P0 = 0
-    setattribute self, $I0, $P0
+    setattribute self, 'status', $P0
 
-    # states
-    inc $I0
     $P0 = new 'Integer'
     $P0 = 1
-    setattribute self, $I0, $P0
+    setattribute self, 'states', $P0
 
-    # rect
-    inc $I0
     $P0 = new 'SDL::Rect'
-    setattribute self, $I0, $P0
+    setattribute self, 'rect', $P0
 
-    # clicked
-    inc $I0
     $P0 = new 'Integer'
     $P0 = 0
-    setattribute self, $I0, $P0
+    setattribute self, 'clicked', $P0
 
-    # actions
-    inc $I0
     $P0 = new 'ResizablePMCArray'
-    setattribute self, $I0, $P0
+    setattribute self, 'actions', $P0
 .end
 
 =item set_integer_native
@@ -108,9 +95,7 @@
 .sub set_integer_native :vtable :method
     .param int val
 
-    $I0 = classoffset self, 'SDL::Button'
-    inc $I0
-    $P0 = getattribute self, $I0
+    $P0 = getattribute self, 'status'
     $P0 = val
 .end
 
@@ -119,9 +104,7 @@
 =cut
 
 .sub get_integer :vtable :method
-    $I0 = classoffset self, 'SDL::Button'
-    inc $I0
-    $P0 = getattribute self, $I0
+    $P0 = getattribute self, 'status'
     $I0 = $P0
 
     .return( $I0 )
@@ -134,9 +117,7 @@
 .sub states :method
     .param int count
 
-    $I0 = classoffset self, 'SDL::Button'
-    add $I0, 2
-    $P0 = getattribute self, $I0
+    $P0 = getattribute self, 'states'
     $P0 = count
 .end
 
@@ -148,9 +129,7 @@
     .param int x
     .param int y
 
-    $I0 = classoffset self, 'SDL::Button'
-    add $I0, 3
-    $P0 = getattribute self, $I0
+    $P0 = getattribute self, 'rect'
 
     $P0.'x'( x )
     $P0.'y'( y )
@@ -164,9 +143,7 @@
     .param int w
     .param int h
 
-    $I0 = classoffset self, 'SDL::Button'
-    add $I0, 3
-    $P0 = getattribute self, $I0
+    $P0 = getattribute self, 'rect'
 
     $P0.'width'( w )
     $P0.'height'( h )
@@ -185,25 +162,18 @@
     .local pmc srect
     .local pmc clicked
 
-    $I0 = classoffset self, 'SDL::Button'
-
-    image = getattribute self, $I0
-
-    inc $I0
-    $P0 = getattribute self, $I0
-    status = $P0
+    image   = getattribute self, 'image'
 
-    inc $I0
-    $P0 = getattribute self, $I0
-    states = $P0
+    $P0     = getattribute self, 'status'
+    status  = $P0
 
-    inc $I0
-    drect = getattribute self, $I0
+    $P0     = getattribute self, 'states'
+    states  = $P0
 
-    inc $I0
-    clicked = getattribute self, $I0
+    drect   = getattribute self, 'rect'
+    clicked = getattribute self, 'clicked'
 
-    srect = new 'SDL::Rect'
+    srect   = new 'SDL::Rect'
 
     $I1 = drect.'height'()
     srect.'height'( $I1 )
@@ -235,11 +205,8 @@
     .local pmc rect
     .local pmc clicked
 
-    $I0 = classoffset self, 'SDL::Button'
-    add $I0, 3
-    rect = getattribute self, $I0
-    inc $I0
-    clicked = getattribute self, $I0
+    rect    = getattribute self, 'rect'
+    clicked = getattribute self, 'clicked'
 
     $I0 = rect.'x'()
     if x < $I0 goto OUT
@@ -285,16 +252,12 @@
     .local int status
     .local pmc action
 
-    $I0 = classoffset self, 'SDL::Button'
-
-    inc $I0
-    $P0 = getattribute self, $I0
+    $P0    = getattribute self, 'status'
     status = $P0
 
-    add $I0, 4
-    action = getattribute self, $I0
+    action = getattribute self, 'actions'
 
-    $P0 = action[status]
+    $P0    = action[status]
 
     $P0( arg )
 .end
@@ -308,10 +271,7 @@
     .param pmc cb
     .local pmc action
 
-    $I0 = classoffset self, 'SDL::Button'
-    add $I0, 5
-    action = getattribute self, $I0
-
+    action         = getattribute self, 'actions'
     action[status] = cb
 .end
 

Modified: trunk/runtime/parrot/library/SDL/LCD.pir
==============================================================================
--- trunk/runtime/parrot/library/SDL/LCD.pir    (original)
+++ trunk/runtime/parrot/library/SDL/LCD.pir    Wed Mar 26 21:59:27 2008
@@ -257,8 +257,7 @@
     .param int val
 
     $I0 = classoffset self, "SDL::LCD"
-    add $I0, 2
-    $P0 = getattribute self, $I0
+    $P0 = getattribute self, 'xpos'
     $P0 = val
 .end
 
@@ -271,9 +270,7 @@
 .sub ypos :method
     .param int val
 
-    $I0 = classoffset self, "SDL::LCD"
-    add $I0, 3
-    $P0 = getattribute self, $I0
+    $P0 = getattribute self, 'ypos'
     $P0 = val
 .end
 

Modified: trunk/runtime/parrot/library/SDL/StopWatch.pir
==============================================================================
--- trunk/runtime/parrot/library/SDL/StopWatch.pir      (original)
+++ trunk/runtime/parrot/library/SDL/StopWatch.pir      Wed Mar 26 21:59:27 2008
@@ -63,16 +63,13 @@
 .sub init :vtable :method
     .param pmc screen
 
-    $I0 = classoffset self, 'SDL::StopWatch'
-
     $P0 = new 'Float'
     $P0 = 0
-    setattribute self, $I0, $P0
+    setattribute self, 'time', $P0
 
-    inc $I0
     $P0 = new 'Float'
     $P0 = 0.1
-    setattribute self, $I0, $P0
+    setattribute self, 'precision', $P0
 
     inc $I0
     $P0 = new 'Float'
@@ -98,15 +95,12 @@
     .local pmc start
 
     # read the attributes
-    $I0 = classoffset self, 'SDL::StopWatch'
-    total = getattribute self, $I0
-    inc $I0
-    precision = getattribute self, $I0
-    inc $I0
-    start = getattribute self, $I0
+    total     = getattribute self, 'time'
+    precision = getattribute self, 'precision'
+    start     = getattribute self, 'start'
 
-    total = 0
-    start = 0
+    total     = 0
+    start     = 0
 .end
 
 =item start()
@@ -121,12 +115,9 @@
     .local pmc start
 
     # read the attributes
-    $I0 = classoffset self, 'SDL::StopWatch'
-    total = getattribute self, $I0
-    inc $I0
-    precision = getattribute self, $I0
-    inc $I0
-    start = getattribute self, $I0
+    total     = getattribute self, 'time'
+    precision = getattribute self, 'precision'
+    start     = getattribute self, 'start'
 
     if start != 0 goto END
 
@@ -151,29 +142,26 @@
     .local pmc start
 
     # read the attributes
-    $I0 = classoffset self, 'SDL::StopWatch'
-    total = getattribute self, $I0
-    inc $I0
-    precision = getattribute self, $I0
-    inc $I0
-    start = getattribute self, $I0
+    total     = getattribute self, 'time'
+    precision = getattribute self, 'precision'
+    start     = getattribute self, 'start'
 
     if start == 0 goto END
 
     time $N0
-    $N1 = start
-    $N0 = $N0 - $N1
+    $N1   = start
+    $N0   = $N0 - $N1
 
-    $N1 = total
-    $N0 += $N1
+    $N1   = total
+    $N0 + = $N1
 
-    $N1 = precision
-    $N0 /= $N1
+    $N1   = precision
+    $N0 / = $N1
 
     total = $N0
     start = 0
 
-    $P0 = find_global "SDL::StopWatch::Timer", "removeWatch"
+    $P0   = find_global "SDL::StopWatch::Timer", "removeWatch"
     $P0( self )
 END:
 .end
@@ -192,26 +180,23 @@
     .local int ret
 
     # read the attributes
-    $I0 = classoffset self, 'SDL::StopWatch'
-    total = getattribute self, $I0
-    inc $I0
-    precision = getattribute self, $I0
-    inc $I0
-    start = getattribute self, $I0
+    total     = getattribute self, 'time'
+    precision = getattribute self, 'precision'
+    start     = getattribute self, 'start'
 
     ret = total
     if start == 0 goto END
 
     time $N0
-    $N1 = start
-    $N0 = $N0 - $N1
+    $N1   = start
+    $N0   = $N0 - $N1
 
-    $N1 = total
-    $N0 += $N1
+    $N1   = total
+    $N0 + = $N1
 
-    $N1 = precision
-    $N0 /= $N1
-    ret = $N0
+    $N1   = precision
+    $N0 / = $N1
+    ret   = $N0
 
 END:
     .return( ret )
@@ -258,11 +243,9 @@
     self = $S0
 
     .local pmc screen
+    screen = getattribute self, 'screen'
+    $P0    = find_global "SDL::LCD", "draw"
 
-    $I0 = classoffset self, "SDL::StopWatch"
-    add $I0, 3
-    screen = getattribute self, $I0
-    $P0 = find_global "SDL::LCD", "draw"
     $P0( screen )
 .end
 

Reply via email to