-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inspect and iterate handles #200
Merged
Merged
Conversation
This file contains 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
justjake
force-pushed
the
jake--iterate-props
branch
from
August 31, 2024 17:55
d1a95c6
to
d0d5840
Compare
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.
This PR is a large change aimed to make it easier to work values in the guest, primarily focused on reading guest objects and collections. There are also a major but hopefully non-breaking change to the
SuccessOrFail
result type returned by many operationsCollection & Iteration
Fixes #185
context.getOwnPropertyNames(handle, options)
to iterate the key or array index handles.context.getLength(handle)
which readshandle.length
and returns it as a number or undefined to make writingfor (i=0;i<length;i++)
loops easier.context.getIterator(handle)
callshandle[Symbol.iterator]()
and then exposes the result as anIterableIterator
to host javascript.Usability improvements
SuccessOrFail<T, QuickJSHandle>
return type is largely replaced with a new return typeDisposableSuccess<T> | DisposableFail<QuickJSHandle>
. The new type implementsresult.unwrap()
as a replacement forcontext.unwrapResult(result)
. It also implementsdispose()
directly, so you no longer need to distinguish between success and failure to clean up.context.callMethod(handle, 'methodName')
, this makes it easier to call methods likecontext.callMethod(handle, 'keys')
orcontext.callMethod('values')
which can be used with the new iterator.Equality
context.eq(a, b)
,context.sameValue(a, b)
,context.sameValueZero(a, b)
Debug logging changes
Debug logging is now disabled by default, even when using a DEBUG variant. It can be enabled on a runtime-by-runtime basis with
runtime.setDebugMode(boolean)
orcontext.runtime.setDebugMode(boolean)
, or globally usingsetDebugMode(boolean)
. As with before, you should use a DEBUG variant to see logs from the WebAssembly C code.