timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

misc nim js #95

Open timotheecour opened 4 years ago

timotheecour commented 4 years ago

links

https://developers.google.com/web/updates/2017/06/headless-karma-mocha-chai https://developers.google.com/web/updates/2017/04/headless-chrome cheerp: Cheerp | C/C++ to WebAssembly compiler

timotheecour commented 4 years ago

js target should use jstring everywhere instead of cstring; but we can introduce an alias type cstring = jstring

timotheecour commented 4 years ago

nim js -r -d:nimbrowser main should open simple html template that includes generated js in a browser (analog to karun) D20200405T220907

EDIT: could be via: nim js -r --port:1234 -d:nimbrowser main

timotheecour commented 4 years ago
timotheecour commented 4 years ago

} foo_bar_13797801();


=> should be `fooBar_13797801` not `foo_bar_13797801` etc (makes things easier to search, more consistent etc; plus we already have things like `function cstrToNimstr(` anyways
timotheecour commented 4 years ago

enhance openDefaultBrowser: option to open in new window (not new tab) see D20200408T185200

timotheecour commented 4 years ago

https://github.com/nim-lang/Nim/issues/13974#issuecomment-613105355

but for nim doc -r main it should be as simple as opening the browser

timotheecour commented 4 years ago

Add Optional JavaScript 'let' variables by juancarlospaco · Pull Request #13851 · nim-lang/Nim : Add Optional JavaScript 'let' variables by juancarlospaco · Pull Request #13851 · nim-lang/Nim => closed

timotheecour commented 4 years ago

Error: Error: unhandled exception: /Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.nim(102, 12) g == "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" [AssertionError] Traceback (most recent call last) tostring.stringCompare, line: 102 assertions.failedAssertImpl, line: 29 assertions.raiseAssert, line: 22 sysFatal.sysFatal, line: 49

at unhandledException (/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:581:11)
at raiseException (/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:319:5)
at sys_fatal_3627618 (/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:594:5)
at raise_assert_3627614 (/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:603:5)
at failed_assert_impl_3627680 (/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:612:5)
at string_compare_13475214 (/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:1743:5)
at Object.<anonymous> (/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:2148:1)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)

Error: execution of an external program failed: '/usr/local/Cellar/node/13.12.0/bin/node /Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js ' No stack traceback available To create a stacktrace, rerun compilation with ./koch temp js

timotheecour commented 4 years ago

testament/testament --targets:js --nim:$nimb r tests/js/trefbyvar.nim doesn't work (eg when file doesn't specify a target entry)

also, why is c appended to targets:

testament/testament --nim:$nimb r tests/js/trefbyvar.nim
gtk+3 3.24.14
PASS: tests/js/trefbyvar.nim C                                     ( 0.48 sec)
PASS: tests/js/trefbyvar.nim JS                                    ( 0.74 sec)
Used bin/nim.pr_dollar_ptr to run the tests. Use --nim to override.

=> https://github.com/nim-lang/Nim/issues/14242

timotheecour commented 4 years ago

test all importjs automatically to make sure they're correct (avoiding errors like https://github.com/timotheecour/Nim/issues/87#issuecomment-617395092)

timotheecour commented 4 years ago

introduce jstring and remap cstring to Uint8Array see cstring implicit conversion to pointer broken on JS · Issue #14097 · nim-lang/Nim

timotheecour commented 3 years ago

refs: https://github.com/nim-lang/Nim/pull/16409#discussion_r554502475

proc `===`[T1, T2](a: T1, b: T2): bool {.importjs: "# === #.}`