diff modules/bytearray.tp @ 318:4c669942c30d

Add bindings for SDL_CreateTexture, SDL_LockTexture, SDL_SetBlendMode and SDL_GetBlendMode in SDL module
author Michael Pavone <pavone@retrodev.com>
date Thu, 19 Mar 2015 22:40:43 -0700
parents 2a0a88799737
children ff7ea11b4b60
line wrap: on
line diff
--- a/modules/bytearray.tp	Thu Mar 19 22:39:42 2015 -0700
+++ b/modules/bytearray.tp	Thu Mar 19 22:40:43 2015 -0700
@@ -1,16 +1,17 @@
 #{
 	includeSystemHeader: "unistd.h"
 	includeSystemHeader: "sys/mman.h"
-
-	normal <- :size {
+	
+	fromOpaque:withSize <- :opaque :size{
 		#{
 			llProperty: bytes withType: uint32_t
 			llProperty: buffer withType: (void ptr)
 			llMessage: _init_buf withVars: {
 				sz <- obj_int32 ptr
-			} andCode: :sz {
+				opaque <- cpointer ptr
+			} andCode: :opaque sz {
 				bytes <- sz num
-				buffer <- GC_MALLOC_ATOMIC: bytes
+				buffer <- (opaque val)
 				self
 			}
 
@@ -89,7 +90,21 @@
 					found: i
 				}
 			}
-		} _init_buf: size
+		} _init_buf: opaque size
+	}
+
+	normal <- :size {
+		helper <- #{
+			llMessage: alloc withVars: {
+				size <- obj_int32 ptr
+				opaqueret <- cpointer ptr
+			} andCode: :size {
+				opaqueret <- make_object: (addr_of: cpointer_meta) NULL 0
+				opaqueret val!: (GC_MALLOC_ATOMIC: (size num))
+				opaqueret
+			}
+		}
+		fromOpaque: (helper alloc: size) withSize: size
 	}
 
 	executable <- :size {