-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: Reb00t #48
Merged
Merged
feat: Reb00t #48
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
This was referenced May 11, 2021
Hywan
added
🎉 enhancement
New feature or request
📚 documentation
Do you like to read?
📦 component-extension
About the Ruby extension written in Rust
📦 component-runtime
About the Wasm runtime
🧪 tests
I love tests
labels
May 11, 2021
This was referenced May 11, 2021
This was referenced May 11, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
📦 component-extension
About the Ruby extension written in Rust
📦 component-runtime
About the Wasm runtime
📚 documentation
Do you like to read?
🎉 enhancement
New feature or request
🧪 tests
I love tests
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 massive rewrite the
wasmer-ruby
language embedding. Here are some highlights.rutie-derive
andrutie-derive-macros
We are using
rutie
as the layer to integrate Rust inside Ruby. It's nice, but the “DSL” is verbose and limited. We have decided to write 2 new crates:rutie-derive-macros
, which provides the#[rubyclass]
, the#[rubymethods]
and the#[rubyfunction]
procedural macros,rutie-derive
, which provides some extra logic needed byrutie-derive-macros
to upcast some types from Ruby to Rust seemlessly.This is not really super documented for the moment, as it's all experimental. The crates don't aim to be reused by other projects for the moment. There is still sharp edge corners, but it fulfills our initial objective: Making the Rust code more readable and easier to maintain.
Here is a before/after example, illustrating how the
rutie-derive*
crates improve the code. The before:And the after:
#[rubymethods]
can have a receiver of type&self
or&mut self
,RubyResult
type,::ruby_new
method is declared to create a Ruby object of a Rust type,It's not perfect as I said, but it's a good start!
The
wasmer
crateBefore, we were only able to create an instance from the raw Wasm bytes, and fetch an exported function or an exported global, with a poor API.
Now, we have a complete new API based on the Wasmer “standard API” (the one we use in Rust, but also in Go, in Python etc.), which includes:
Store
, which holds the engine, the compiler etc.Module
, which represents a Wasm module, withvalidate
,new
,name=
,name
,exports
,imports
,custom_sections
,serialize
anddeserialize
,Instance
, which represents a Wasm instance, withnew
andexports
,Exports
, which represents a collection of exported entities, withrespond_to_missing?
,method_missing
, andlength
,ImportObject
, which represents a collection of imports that will be passed toInstance
, withnew
,contains_namespace
, andregister
,Function
, which represents an imported or exported function, withnew
,call
andtype
,Memory
, which represents an imported or exported memory, withnew
,type
,size
,data_size
,grow
, + memory views that extendsEnumerable
,Global
, which represents an imported or exported global, withnew
,mutable?
,value
,value=
, andtype
,Table
, which represents an imported or exported table, withnew
(small API for the moment),Type
,FunctionType
,MemoryType
,GlobalType
andTableType
,ExportType
andImportType
,Value
which represents a Wasm value,Wasi
module, which provides theVersion
,StateBuilder
andEnvironment
classes.This new API is much richer and complete than the previous one!
Left to do