take-cheeze / mruby-marshal

mruby implementation of cruby marshaling.
12 stars 9 forks source link

Marshaling of arrays #6

Closed catsidhe closed 9 years ago

catsidhe commented 9 years ago

Since major/minor versions match, I believe this is supposed to be interoperable with Ruby?

puts Marshal.dump(['test']).bytes.inspect

Ruby 2.2.1

[4, 8, 91, 6, 73, 34, 9, 116, 101, 115, 116, 6, 58, 6, 69, 84]

Mruby

[4, 8, 91, 6, 34, 9, 116, 101, 115, 116]

Consequentially, trying to load an array serialized with Ruby in Mruby fails.

take-cheeze commented 9 years ago

This issue is related to https://github.com/take-cheeze/rgss_script_editor/issues/6 . The problem is due to Encoding unsupported in mruby and the lacks of instance variables in some mruby type. After Encoding support in CRuby, Encoding field was added to marshaled data as instance variable :E. Though in mruby Array doesn't support instance variables so it's treated as error in mruby-marshal.

The exception should be raised from mrb_iv_set so needs a workaround in 'I' tag to ignore Encoding data.