Class: RString
Instance Attribute Summary
Attributes inherited from String
Instance Method Summary collapse
-
#initialize(wasm_instance, rlang_obj_addr) ⇒ RString
constructor
Turn a Rlang String object into a Ruby String mirror object.
Methods inherited from String
#!=, #*, #+, #==, #[], #[]=, #empty?, #ord, #reverse!, #size, #to_s, #to_wasm
Constructor Details
#initialize(wasm_instance, rlang_obj_addr) ⇒ RString
Turn a Rlang String object into a Ruby String mirror object
9 10 11 12 13 14 15 |
# File 'lib/ruby/mirror/rstring.rb', line 9 def initialize(wasm_instance, rlang_obj_addr) stg_ptr = wasm_instance.exports.string_i_ptr.call(rlang_obj_addr) stg_length = wasm_instance.exports.string_i_length.call(rlang_obj_addr) mem8 = wasm_instance.exports.memory.uint8_view stg_ptr ruby_stg = 0.upto(stg_length-1).collect {|i| mem8[i].chr}.join('') super(ruby_stg) end |