From 39137294a37b769eec7b610520bf67cb47e437e8 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 20 Jun 2012 00:21:53 +0200 Subject: [PATCH] made some tests green again --- lib/impure/graphics.nim | 23 ++++++++++++----------- tests/run/tclosure2.nim | 1 + todo.txt | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/impure/graphics.nim b/lib/impure/graphics.nim index 9ddb697683..348907f9a4 100755 --- a/lib/impure/graphics.nim +++ b/lib/impure/graphics.nim @@ -48,8 +48,8 @@ proc toSdlRect*(r: TRect): sdl.TRect = ## Convert ``graphics.TRect`` to ``sdl.TRect``. result.x = int16(r.x) result.y = int16(r.y) - result.w = int16(r.width) - result.h = int16(r.height) + result.w = uint16(r.width) + result.h = uint16(r.height) proc raiseEGraphics = raise newException(EGraphics, $SDL.GetError()) @@ -106,10 +106,10 @@ type PPixels = ptr TPixels template setPix(video, pitch, x, y, col: expr): stmt = - video[y * pitch + x] = int32(col) + video[y * pitch.int + x] = int32(col) template getPix(video, pitch, x, y: expr): expr = - colors.TColor(video[y * pitch + x]) + colors.TColor(video[y * pitch.int + x]) const ColSize = 4 @@ -117,14 +117,15 @@ const proc getPixel(sur: PSurface, x, y: Natural): colors.TColor {.inline.} = assert x <% sur.w assert y <% sur.h - result = getPix(cast[PPixels](sur.s.pixels), sur.s.pitch div ColSize, x, y) + result = getPix(cast[PPixels](sur.s.pixels), sur.s.pitch div ColSize.uint16, + x, y) proc setPixel(sur: PSurface, x, y: Natural, col: colors.TColor) {.inline.} = assert x <% sur.w assert y <% sur.h var pixs = cast[PPixels](sur.s.pixels) #pixs[y * (sur.s.pitch div colSize) + x] = int(col) - setPix(pixs, sur.s.pitch div ColSize, x, y, col) + setPix(pixs, sur.s.pitch div ColSize.uint16, x, y, col) proc `[]`*(sur: PSurface, p: TPoint): TColor = ## get pixel at position `p`. No range checking is done! @@ -149,13 +150,13 @@ proc blit*(destSurf: PSurface, destRect: TRect, srcSurf: PSurface, destTRect.x = int16(destRect.x) destTRect.y = int16(destRect.y) - destTRect.w = int16(destRect.width) - destTRect.h = int16(destRect.height) + destTRect.w = uint16(destRect.width) + destTRect.h = uint16(destRect.height) srcTRect.x = int16(srcRect.x) srcTRect.y = int16(srcRect.y) - srcTRect.w = int16(srcRect.width) - srcTRect.h = int16(srcRect.height) + srcTRect.w = uint16(srcRect.width) + srcTRect.h = uint16(srcRect.height) if SDL.blitSurface(srcSurf.s, addr(srcTRect), destSurf.s, addr(destTRect)) != 0: raiseEGraphics() @@ -191,7 +192,7 @@ proc drawCircle*(sur: PSurface, p: TPoint, r: Natural, color: TColor) = ## draws a circle with center `p` and radius `r` with the given color ## onto the surface `sur`. var video = cast[PPixels](sur.s.pixels) - var pitch = sur.s.pitch div ColSize + var pitch = sur.s.pitch.int div ColSize var a = 1 - r var py = r var px = 0 diff --git a/tests/run/tclosure2.nim b/tests/run/tclosure2.nim index 113c982507..d2c16eac96 100644 --- a/tests/run/tclosure2.nim +++ b/tests/run/tclosure2.nim @@ -19,6 +19,7 @@ discard """ 11 9 11 +11 py py py diff --git a/todo.txt b/todo.txt index 6bbfe02897..24f3267c61 100755 --- a/todo.txt +++ b/todo.txt @@ -11,6 +11,8 @@ version 0.9.0 - make toplevel but in a scope vars local; make procs there inner procs - fix evals.nim with closures - test sequence of closures; especially that the GC does not leak for those! + - proc types shall have closure calling convention per default + - implement ``byCopy`` pragma - implement proper coroutines - document 'do' notation