27 May 2023 |
konsumer | * I do similar stuff on the js host (even for strings, but also structs), so it's not a big deal, just a bit confused by how it all fit together. Makes perfect sense, now | 22:11:32 |
Elegantbeef | It's weird that emscripten does it the way it does | 22:13:59 |
Elegantbeef | You could always use a type WasmPtr[T] = distinct uint32 might result in proper semantics | 22:14:38 |
konsumer | yeh, it gets really weird too, when you are making wasm in other ecosystems too (like assemblyscript) | 22:14:46 |
Elegantbeef | Wait do they all pass in a ptr T ? | 22:15:00 |
konsumer | where would I put that? | 22:15:02 |
Elegantbeef | Inside the module | 22:15:15 |
konsumer | I think yes, but assemblyscript returns it | 22:15:19 |
Elegantbeef | You want wasm to treat it as a module | 22:15:25 |
Elegantbeef | primitive* | 22:15:34 |
Elegantbeef | Brainfart and a half there | 22:15:40 |
konsumer | * I think yes, but assemblyscript returns the pointer (not mangle the function) | 22:16:06 |
konsumer | After I get all the functions demo'd in nim on both sides of the wasm-barrier, I will start making other wasm-side languages do similar. For example, I made an assemblyscript-side adapter for strings, so they look the same in both hosts. Aseemblyscript has automatic struct stuff, but it returns the pointer (instead of adding it as the second parm) so I will probly have to do something else there, but that is a problem for another day. | 22:19:16 |
konsumer | * After I get all the functions demo'd in nim on both sides of the wasm-barrier, I will start making other wasm-side languages do similar. For example, I made an assemblyscript-side adapter for strings, so they look the same in both hosts (js and nim.) Aseemblyscript has automatic struct stuff, but it returns the pointer (instead of adding it as the second parm) so I will probly have to do something else there, but that is a problem for another day. | 22:19:43 |
Elegantbeef | There might be a flag to disable this behaviour, do not remember | 22:19:46 |
konsumer | maybe if I setup (wasm-side) the function to return a pointer, it wouldd do it more how I expect. That could be a good solution (so it all works the same) | 22:22:17 |
konsumer | * maybe if I setup (wasm-side) the function to return a pointer, it would do it more how I expect. That could be a good solution (so it all works the same) | 22:22:25 |
konsumer | I don;t really mind this, though, like if all just put the return var on the end, I can make other labguages do that too | 22:23:34 |
konsumer | * I don;t really mind this, though, like if all just put the return var on the end, I can make other languages do that too. they all will have little wrapper-headers to make it feel normal in whatever the wasm language is, so it's not a huge deal. | 22:24:20 |
konsumer | in nim, I do similar, like # Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}
proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
draw_image(targetID, sourceID, int32 x, int32 y)
proc draw_image*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
proc draw*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
# so I can do this:
logo.draw(offset.x, offset.y) | 22:25:40 |
konsumer | * in wasm-side nim, I do similar, like # Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}
proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
draw_image(targetID, sourceID, int32 x, int32 y)
proc draw_image*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
proc draw*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
# so I can do this:
logo.draw(offset.x, offset.y) | 22:25:55 |
konsumer | The goal is that it's helpful for people learning a language, or if they are just new to programming, so they can work with whatever language they chose in a friendly way. | 22:26:39 |
konsumer | * in wasm-side nim, I do similar, like # Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}
proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
draw_image(targetID, sourceID, int32 x, int32 y)
proc draw_image*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
proc draw*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
proc draw*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
# so I can do this:
logo.draw(offset.x, offset.y) | 22:27:19 |
konsumer | * in wasm-side nim, I do similar, like # Draw an image on another image
proc draw_image*(targetID: Image, sourceID:Image, x: int32, y: int32) {.importc, cdecl.}
proc draw_image*(targetID: Image, sourceID:Image, x: int, y: int) =
draw_image(targetID, sourceID, int32 x, int32 y)
proc draw_image*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
proc draw*(sourceID: Image, x: int, y: int) =
draw_image(screen, sourceID, x, y)
# so I can do this:
logo.draw(offset.x, offset.y) | 22:27:28 |
konsumer | * The goal is that it's helpful for people learning a language, or if they are just new to programming, so they can work with whatever language they chose in a friendly way. I originally made stuff in C, JS, Rust & Assemblyscript, but I am learning nim, and rewriting everything in that, since I am already loving the language. It's been really nice, and I have added a lot more features than the original stuff. Nim makes it a lot more fun. | 22:31:08 |
konsumer | Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimension(returnPtr, image) | 22:51:32 |
konsumer | * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimension(returnPtr, imageID) | 22:51:41 |
konsumer | * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimension(returnPtr, imageID) for this wasm-side:proc dimensions*(sourceID: Image): Vector2 {.importc, cdecl.} | 22:52:19 |
konsumer | * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimensions(returnPtr, imageID) for this wasm-side:proc dimensions*(sourceID: Image): Vector2 {.importc, cdecl.} | 22:52:36 |
konsumer | * Another note on struct-return: it appears it puts the ret-pointer in the 1st param: dimensions(returnPtr, imageID) for this wasm-side:proc dimensions*(imageID: Image): Vector2 {.importc, cdecl.} | 22:52:47 |