Open lopopolo opened 5 years ago
blocked on GH-46
This ticket has been repurposed from being about implementing wrappers around mrb_funcall_argv
to encompass wrapping all mrb_vtype
s with one Rust struct per Ruby
type to accommodate implementing Clone
, see GH-3.
This is a tracking ticket for implementing structs that wrap a
Value
with a singleRuby
type, e.g. a struct that wrapsmrb_vtype::MRB_TT_HASH
,mrb_vtype::MRB_TT_ARRAY
, ormrb_vtype::MRB_TT_DATA
.In order to implement
Clone
safely (see GH-3),Value
s withRuby::Data
Ruby type need to know their underlyingT
, butValue
can't be generic onT
. WrappingValue
and calling those wrappers from consumers of themruby
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:
new(Value) -> Result<Self,MrbError>
Clone::clone
funcall(self, method: String, args: &[Value]) -> Result<Value, MrbError>
(we might be able to move this to aValueLike
trait and provide a default impl).funcall_with_block(self, method: String, args: &[Value], blk: Proc) -> Result<Value, MrbError>
(out of scope).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:
Ruby::Data
: GH-64Ruby::Array
: GH-65