public void marshalTo(Ruby runtime, Object obj, RubyClass type, MarshalStream marshalStream) throws IOException { RubySystemCallError exc = (RubySystemCallError) obj; marshalStream.registerLinkTarget(exc); List<Variable<Object>> attrs = exc.getVariableList(); attrs.add( new VariableEntry<Object>( "mesg", exc.message == null ? runtime.getNil() : exc.message)); attrs.add(new VariableEntry<Object>("errno", exc.errno)); attrs.add(new VariableEntry<Object>("bt", exc.getBacktrace())); marshalStream.dumpVariables(attrs); }
public Object unmarshalFrom(Ruby runtime, RubyClass type, UnmarshalStream unmarshalStream) throws IOException { RubySystemCallError exc = (RubySystemCallError) type.allocate(); unmarshalStream.registerLinkTarget(exc); unmarshalStream.defaultVariablesUnmarshal(exc); exc.message = (IRubyObject) exc.removeInternalVariable("mesg"); exc.errno = (IRubyObject) exc.removeInternalVariable("errno"); exc.set_backtrace((IRubyObject) exc.removeInternalVariable("bt")); return exc; }