Skip to content

Commit

Permalink
Cleanup, allow wasm memory growth
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Nov 8, 2024
1 parent a9fc03d commit 4f8abbf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 7 additions & 11 deletions config/comp_test.nim
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import std/[macros, options, unicode]
import results

import wit_guest

when defined(witRebuild):
static: hint("Rebuilding plugin_api.wit")
static: echo "Rebuilding plugin_api.wit"
importWit "../scripting/plugin_api.wit", "plugin_api_guest.nim"
else:
static: hint("Using cached plugin_api.wit (plugin_api_guest.nim)")
static: echo "Using cached plugin_api.wit (plugin_api_guest.nim)"
include plugin_api_guest

proc emscripten_notify_memory_growth*(a: int32) {.exportc.} =
discard
echo "emscripten_notify_memory_growth"

echo "global stuff"
proc emscripten_stack_init() {.importc.}

proc NimMain() {.importc.}
proc emscripten_stack_init() {.importc.}

proc plugin_main*() =
echo "global stuff"

proc initPlugin() =
emscripten_stack_init()
NimMain()

proc initPlugin() =
plugin_main()
echo "[guest] initPlugin"
echo getSelection()
4 changes: 3 additions & 1 deletion config/config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ switch("path", "../src")
switch("d", "release")
switch("d", "wasm")
switch("nimcache", "./nimcache")
# switch("d", "useMalloc")

switch("stackTrace", "on")
switch("lineTrace", "on")

let outputName = projectName() & ".wasm"
# Pass this to Emscripten linker to generate html file scaffold for us.
# No need for main, it's standalone wasm, and we dont need to error on undefined as we're probably importing
switch("passL", "--no-entry -sSTANDALONE_WASM=1 -sERROR_ON_UNDEFINED_SYMBOLS=0 -g")
# switch("passL", "--no-entry -sSTANDALONE_WASM=1 -sERROR_ON_UNDEFINED_SYMBOLS=0 -g")
switch("passL", "--no-entry -sSTANDALONE_WASM=1 -sERROR_ON_UNDEFINED_SYMBOLS=0 -sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=4294967296 -g")
# switch("passL", "-o wasm/" & outputName)
2 changes: 1 addition & 1 deletion src/scripting/scripting_wasm_components.nim
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ method init*(self: ScriptContextWasmComp, path: string, vfs: VFS): Future[void]

block:
proc cb(ctx: pointer, params: openArray[ComponentValT], results: var openArray[ComponentValT]) =
results[0] = Selection().toVal
results[0] = Selection(first: Cursor(line: 1, column: 2), last: Cursor(line: 6, column: 9)).toVal
echo &"[host][get-selection]:\n {params}\n -> {results}"

echo "func new"
Expand Down

0 comments on commit 4f8abbf

Please sign in to comment.