Open timotheecour opened 4 years ago
js target should use jstring everywhere instead of cstring; but we can introduce an alias type cstring = jstring
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
nim js
should preserve style eg:
when defined case5:
proc fooBar() =
var barBaz = 1
echo barBaz
fooBar()
generates:
function foo_bar_13797801() {
var bar_baz_13797804 = 1;
rawEcho(cstrToNimstr((bar_baz_13797804)+""));
} 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
enhance openDefaultBrowser: option to open in new window (not new tab) see D20200408T185200
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
$nimb js -r --excessivestacktrace $nim_prs_D/tests/system/tostring.nim
("bee", 3)
("bee", 3)
047FC620
0x10488fd08
(x1: 1, x2: 0x0, x3: @[nil, 0x10488fd08, 0x104892208], x4: 0x10488fd08)
Hint: 44960 LOC; 0.324 sec; 49.844MiB peakmem; Debug build; proj: tostring; out: tostring.js [SuccessX]
("bee", 3)
("bee\x00", 4)
/Users/timothee/git_clone/nim/Nim_prs/tests/system/tostring.js:581
throw new Error(cbuf_3715201);
^
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
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.
test all importjs automatically to make sure they're correct (avoiding errors like https://github.com/timotheecour/Nim/issues/87#issuecomment-617395092)
introduce jstring and remap cstring to Uint8Array see cstring implicit conversion to pointer broken on JS · Issue #14097 · nim-lang/Nim
===
to jsffirefs: https://github.com/nim-lang/Nim/pull/16409#discussion_r554502475
proc `===`[T1, T2](a: T1, b: T2): bool {.importjs: "# === #.}`
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