-
Notifications
You must be signed in to change notification settings - Fork 824
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
fix(runtime-c-api) Change mutability of memory
toconst
in wasmer_memory_data_length
#1335
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
MarkMcCaskey
approved these changes
Mar 26, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
bors r+ |
bors bot
added a commit
that referenced
this pull request
Mar 27, 2020
1335: fix(runtime-c-api) Change mutability of `memory` for `const` in `wasmer_memory_data_length` r=Hywan a=Hywan This PR changes mutability of `memory` for `const` in `wasmer_memory_data_length` to be more consistent regarding the returned value of `wasmer_instance_context_memory`. Fixes #1314. Fixes wasmerio/docs.wasmer.io#43. Co-authored-by: Ivan Enderlin <[email protected]> Co-authored-by: Ivan Enderlin <[email protected]>
Hywan
changed the title
fix(runtime-c-api) Change mutability of
fix(runtime-c-api) Change mutability of Mar 27, 2020
memory
for const
in wasmer_memory_data_length
memory
toconst
in wasmer_memory_data_length
Timed out |
bors r+ |
bors bot
added a commit
that referenced
this pull request
Mar 28, 2020
1335: fix(runtime-c-api) Change mutability of `memory` to`const` in `wasmer_memory_data_length` r=Hywan a=Hywan This PR changes mutability of `memory` for `const` in `wasmer_memory_data_length` to be more consistent regarding the returned value of `wasmer_instance_context_memory`. Fixes #1314. Fixes wasmerio/docs.wasmer.io#43. 1337: feat(interface-types) Better handling of i32 to usize casts r=Hywan a=Hywan Fix #1334 This PR introduces a new `NegativeValue` error. This PR fixes some `usize` and `u32` types for indexes (small changes). Finally, this PR casts `i32` to `usize` by using the `TryFrom` implementation. That way: ```rust let pointer = to_native::<i32>(&inputs[0], instruction)? as usize; ``` becomes: ```rust let pointer: usize = to_native::<i32>(&inputs[0], instruction)?.try_into().map_err(|_| { InstructionError::new( instruction, InstructionErrorKind::NegativeValue { subject: "pointer" }, ) })?; ``` It's more verbose, but it handles the casting correctly. Note: Maybe we should implement `From<TryFromIntError>` for `InstructionErrorKind`? What do you think? Edit: With `From<TryFromIntError>`, it looks like this: ```rust let pointer: usize = to_native::<i32>(&inputs[0], instruction)? // convert from WIT to native `i32` .try_into() // convert to `usize` .map_err(|e| (e, "pointer").into()) // convert the `TryFromIntError` to `InstructionErrorKind::NegativeValue` .map_err(|k| InstructionError::new(instruction, k))?; // convert to an `InstructionError` ``` It is indeed simpler. Keeping things like this. Co-authored-by: Ivan Enderlin <[email protected]> Co-authored-by: Ivan Enderlin <[email protected]>
This PR was included in a batch that timed out, it will be automatically retried |
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 changes mutability of
memory
forconst
inwasmer_memory_data_length
to be more consistent regarding the returned value ofwasmer_instance_context_memory
.Fixes #1314.
Fixes wasmerio/docs.wasmer.io#43.