about summary refs log tree commit diff stats
path: root/src/js/fromjs.nim
Commit message (Collapse)AuthorAgeFilesLines
* Move JS wrapper into Monouchabptato2024-06-031-445/+0
| | | | Operation "modularize Chawan somewhat" part 3
* js: allow var instead of ptrbptato2024-05-121-0/+3
|
* fromjs: remove broken uint64 converterbptato2024-05-091-5/+0
| | | | It would silently truncate the upper 32 bits... not a very bright idea.
* js: refactorbptato2024-05-081-37/+2
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* js: fix various leaks etc.bptato2024-05-031-49/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we didn't actually free the main JS runtime, probably because you can't do this without first waiting for JS to unwind the stack. (This has the unfortunate effect that code now *can* run after quit(). TODO: find a fix for this.) This isn't a huge problem per se, we only have one of these and the OS can clean it up. However, it also disabled the JS_FreeRuntime leak check, which resulted in sieve-like behavior (manual refcounting is a pain). So now we choose the other tradeoff: quit no longer runs exitnow, but it waits for the event loop to run to the end and only then exits the browser. Then, before exit we free the JS context & runtime, and also all JS values allocated by config. Fixes: * fix `ad' flag not being set for just one siteconf/omnirule * fix various leaks (since leak check is enabled now) * use ptr UncheckedArray[JSValue] for QJS bindings that take an array * allow JSAtom in jsgetprop etc., also disallow int types other than uint32 * do not set a destructor for globals
* Remove unnecessary unsigned castsbptato2024-04-261-1/+1
| | | | | Unsigned operations and conversions to unsigned types always wrap/narrow without checks, so no need to manually mask/cast/etc. them.
* Update code stylebptato2024-04-171-31/+34
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* js: remove automatic function -> closure conversionbptato2024-04-151-58/+0
| | | | | | | | | | | | | | | It's a bad idea for several reasons: * it's inefficient; must allocate an environment for a closure in Nim, even though we already have one in JS * writing macros for automatically creating functions with variadic arguments is suprisingly difficult (see the entire `js/javascript' module) * it never really worked properly, because we never freed the associated function pointer. We hardly used it anyway, so the easiest fix is to get rid of it completely.
* js: proper distinction between Opt/Optionbptato2024-03-241-32/+13
| | | | | | | | | | | | | | | | until now, this had very strange (and inconsistent) semantics: * err() was used for exception propagation, but also as a null value * Option accepted undefined as a none value, but not null * Opt and Option were used interchangeably (and mostly randomly) Now, Result is always used for error reporting, and err(nil) means JS_EXCEPTION. (Opt is a special case of Result where we don't care about the error type, and is not used in JS.) Option on the other hand means "nullable variation of normally non-nullable type", and translates to JS_NULL. In JS we mainly use it for turning strings nullable.
* config: clean up/simplifybptato2024-03-171-4/+6
| | | | | | | | | * Parse the default config at runtime. There's no significant performance difference, but this makes it much less painful to write config code. * Add better error reporting * Make fromJS2 easier to use * Unquote ChaPaths while parsing config
* quickjs: reduce diff with upstreambptato2024-03-021-5/+0
| | | | | | * the uint8array thing is probably from txiki.js, but we never used it * upstream now has JS_GetClassID, importing that instead... (so this commit won't build :/)
* regex: re-work compileSearchRegexbptato2024-02-171-16/+7
| | | | | | | I've gotten tired of not being able to search for forward slashes. Now it works like in vim, and you can also set default ignore case in the config.
* js: fix fromJSEnumbptato2024-02-081-6/+14
| | | | std enum parsing uses Nim ident matching rules, which is incorrect here.
* js: small improvementsbptato2024-01-171-1/+3
| | | | | * turn JSFuncGenerator into a ref object (it's faster this way) * remove strformat dependency
* js: merge some type modules into jstypesbptato2024-01-111-7/+5
| | | | They only had type definitions, no need to put them in separate modules.
* Use std/* imports everywherebptato2024-01-071-5/+5
|
* Compile with styleCheck:usagesbptato2023-12-281-1/+1
| | | | much better
* pager, container: add text selection/copyingbptato2023-12-031-0/+25
| | | | | | | | | | * Add select & copy selection functionality to container * Fix bug in generateSwapOutput where output could be misplaced because of zero-width cells * Add fromJSPromise, call runJSJobs in every iteration of the headed event loop * "await" pager actions that output a promise * Change default view source keybinding to `\'
* fromjs: fix fromJSOption with nilbptato2023-11-211-1/+1
| | | | Use option() instead of some()
* js: refine isInstanceOf check in functionsbptato2023-10-251-4/+25
| | | | Special case the global object, check for inheritance, etc.
* fromjs: update FromJSAllowedTbptato2023-10-211-1/+2
|
* fromjs: remove IsNumber check from float, remove unused functionsbptato2023-10-211-21/+0
|
* fromJSInt: do not fail if not IsNumberbptato2023-10-211-2/+0
| | | | to match standard behavior (e.g. accept null as int, etc)
* base64: reduce pointless re-coding using JSStringbptato2023-10-211-0/+5
| | | | | We now expose some functions from QuickJS to interact with JavaScript strings without re-encoding them into UTF-8.
* javascript: add TextEncoder, TextDecoderbptato2023-10-211-0/+32
|
* move around more modulesbptato2023-09-141-1/+1
| | | | | | | | | | * ips -> io/ * loader related stuff -> loader/ * tempfile -> extern/ * buffer, forkserver -> server/ * lineedit, window -> display/ * cell -> types/ * opt -> types/
* javascript: add JSDict typebptato2023-09-091-1/+16
| | | | And use that in extern().
* buffer: basic click event supportbptato2023-08-311-3/+14
| | | | | | | Mostly a proof of concept. Just bubble it unconditionally for now and never prevent default. Also, fix fromJSFunction by Dup'ing its closure JSValue.
* javascript: fix fromJSFunction, simplify setOpaquebptato2023-08-301-1/+3
| | | | | | * fromJSFunction: dup the value, so that it cannot go out of context. * setOpaque no longer calls GC_ref, so no need for it to be generic instead of just taking a pointer.
* javascript: factor out fromJSbptato2023-08-291-0/+457