public MarshalStream(Ruby runtime, OutputStream out, int depthLimit) throws IOException { super(out); this.runtime = runtime; this.depthLimit = depthLimit >= 0 ? depthLimit : Integer.MAX_VALUE; this.cache = new MarshalCache(); out.write(Constants.MARSHAL_MAJOR); out.write(Constants.MARSHAL_MINOR); }
private void writeAndRegister(IRubyObject value) throws IOException { ByteList sym; if (value instanceof RubySymbol && cache.isSymbolRegistered(sym = ((RubySymbol) value).getBytes())) { cache.writeSymbolLink(this, sym); } else if (!(value instanceof RubySymbol) && cache.isRegistered(value)) { cache.writeLink(this, value); } else { value.getMetaClass().smartDump(this, value); } }
public void registerSymbol(ByteList sym) { cache.registerSymbol(sym); }
private void writeAndRegisterSymbol(ByteList sym) throws IOException { if (cache.isSymbolRegistered(sym)) { cache.writeSymbolLink(this, sym); } else { registerSymbol(sym); dumpSymbol(sym); } }
public void writeLink(MarshalStream output, IRubyObject value) throws IOException { if (value instanceof RubySymbol) { writeSymbolLink(output, ((RubySymbol)value).asJavaString()); } else { output.write('@'); output.writeInt(registeredIndex(value)); } }
private void writeAndRegister(IRubyObject value) throws IOException { if (cache.isRegistered(value)) { cache.writeLink(this, value); } else { value.getMetaClass().smartDump(this, value); } }
private int registeredIndex(IRubyObject value) { if (value instanceof RubySymbol) { return registeredSymbolIndex(value.asJavaString()); } else { return linkCache.get(value).intValue(); } }
public void registerLinkTarget(IRubyObject newObject) { if (shouldBeRegistered(newObject)) { cache.register(newObject); } }
public void writeLink(MarshalStream output, IRubyObject value) throws IOException { assert !(value instanceof RubySymbol) : "Use writeSymbolLink for symbols"; output.write('@'); output.writeInt(registeredIndex(value)); }
public boolean isRegistered(IRubyObject value) { if (value instanceof RubySymbol) { return isSymbolRegistered(((RubySymbol)value).asJavaString()); } return linkCache.containsKey(value); }
private void writeAndRegisterSymbol(String sym) throws IOException { if (cache.isSymbolRegistered(sym)) { cache.writeSymbolLink(this, sym); } else { registerSymbol(sym); dumpSymbol(sym); } }
public void writeLink(MarshalStream output, IRubyObject value) throws IOException { if (value instanceof RubySymbol) { writeSymbolLink(output, ((RubySymbol)value).asJavaString()); } else { output.write('@'); output.writeInt(registeredIndex(value)); } }
private void writeAndRegister(IRubyObject value) throws IOException { if (cache.isRegistered(value)) { cache.writeLink(this, value); } else { value.getMetaClass().smartDump(this, value); } }
private int registeredIndex(IRubyObject value) { if (value instanceof RubySymbol) { return registeredSymbolIndex(value.asJavaString()); } else { return linkCache.get(value).intValue(); } }
public void registerLinkTarget(IRubyObject newObject) { if (shouldBeRegistered(newObject)) { cache.register(newObject); } }
public void writeLink(MarshalStream output, IRubyObject value) throws IOException { assert !(value instanceof RubySymbol) : "Use writeSymbolLink for symbols"; output.write('@'); output.writeInt(registeredIndex(value)); }
public boolean isRegistered(IRubyObject value) { if (value instanceof RubySymbol) { return isSymbolRegistered(((RubySymbol)value).asJavaString()); } return linkCache.containsKey(value); }
private void writeAndRegister(IRubyObject value) throws IOException { ByteList sym; if (value instanceof RubySymbol && cache.isSymbolRegistered(sym = ((RubySymbol) value).getBytes())) { cache.writeSymbolLink(this, sym); } else if (!(value instanceof RubySymbol) && cache.isRegistered(value)) { cache.writeLink(this, value); } else { value.getMetaClass().smartDump(this, value); } }
private void writeAndRegisterSymbol(ByteList sym) throws IOException { if (cache.isSymbolRegistered(sym)) { cache.writeSymbolLink(this, sym); } else { registerSymbol(sym); dumpSymbol(sym); } }
public void registerSymbol(String sym) { cache.registerSymbol(sym); }