artichoke / ferrocarril

🚆 Experiments to embed Ruby on Rails in Rust with mruby
https://artichoke.github.io/ferrocarril/mruby/
MIT License
62 stars 2 forks source link

Implement Rust wrappers around Value #17

Open lopopolo opened 5 years ago

lopopolo commented 5 years ago

This is a tracking ticket for implementing structs that wrap a Value with a single Ruby type, e.g. a struct that wraps mrb_vtype::MRB_TT_HASH, mrb_vtype::MRB_TT_ARRAY, or mrb_vtype::MRB_TT_DATA.

In order to implement Clone safely (see GH-3), Values with Ruby::Data Ruby type need to know their underlying T, but Value can't be generic on T. Wrapping Value and calling those wrappers from consumers of the mruby crate enables application code to check their invariants about the types of objects they are getting back from the mruby VM.

At a minimum, each wrapper should implement:

These wrappers are also a convenient place to implement the methods exposed by the mruby VM on Rust types, e.g. String#sub.

This might be a means to implement a Proc wrapper in terms of Rust closures, but that is out of scope for this tracking ticket.

Child tickets:

lopopolo commented 5 years ago

blocked on GH-46

lopopolo commented 5 years ago

This ticket has been repurposed from being about implementing wrappers around mrb_funcall_argv to encompass wrapping all mrb_vtypes with one Rust struct per Ruby type to accommodate implementing Clone, see GH-3.