Repository navigation
feat(runtime): ns:interop builtin modules, interop globals as compat - #2074
Draft
edusperoni wants to merge 1 commit into
Draft
edusperoni wants to merge 1 commit into
edusperoni wants to merge 1 commit into
Conversation
Add the ns:interop and ns:interop/android builtin modules and move
escapeException onto ns:runtime, per rfcs#58 ("interop and runtime
helpers", adoption step 0).
- ns:interop: frozen and empty on Android (none of the cross-platform
native-memory members exist here).
- ns:interop/android: long, byte, short, char, float, double and
newArray (the function Array.create has always been).
- ns:runtime: gains escapeException.
The natives move from being set on the global (template casts,
Interop::Init, ArrayHelper::Init) to binding factories in
NsBuiltinModules.cpp. The legacy globals are now assembled by
interop-globals.js, an internal-tier builtin run eagerly at the point
the interop global was installed: it requires ns:runtime and
ns:interop/android and assigns their functions, so interop.escapeException,
the cast globals and Array.create are the module exports themselves,
with the same writable/enumerable/configurable attributes as before.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adoption step 0 of rfcs#58 ("
interopand runtime helpers"). The interop helpers move into builtin modules, and today's globals become a compat layer built from them.ns:interopinitializerwill land here.ns:interop/androidlong,byte,short,char,float,double,newArray(the functionArray.createhas always been)ns:runtime(new member)escapeExceptionCompat.
js/interop-globals.jsis an internal builtin that requiresns:runtimeandns:interop/androidand installs:globalThis.interop = { escapeException };Array.create.Each global holds the module's own function object, with the same writable, enumerable and configurable attributes as before. It runs eagerly, at the point where
interopused to be installed, for both the main isolate and workers, because@nativescript/corereads these at module top level. Thens:files never refer to it.Native changes:
Array.createandescapeExceptionare now built by binding factories inNsBuiltinModules.cpp, rather than set on the global template or the global itself.ArrayHelper's JNI class/method lookup runs once per process (std::call_once). It used to be redone per isolate, with unsynchronized writes to static fields.Typings. This repo doesn't ship
.d.tsfor itsns:modules yet, so none are added here. The iOS runtime ships them intypes/, and Android doing the same is a follow-up.Does your commit message include the wording below to reference a specific issue in this repo?
No issue; this implements part of rfcs#58.
Related Pull Requests
Does your pull request have unit tests?
Yes.
tests/testNsInterop.js(16 specs) andtests/nsInteropWorker.jscover:newArrayby type name and by class;testNsRuntime.jsnow expectsescapeException.Full suite: 1281 passed, 0 failed (baseline 1265 plus the 16 new specs), on an API 35 arm64 emulator.