// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java
// public abstract class DService<T extends NexusService> implements DAttribute
// {
//     /** Used to create service attributes. */
//     public interface Factory<T extends NexusService>
//     {
//         /** Creates a service attribute with the supplied owner. */
//         DService<T> createService (NexusObject owner);
//     }
// 
//     /** An implementation detail used by service dispatchers. */
//     public static abstract class Dispatcher<T extends NexusService> extends DService<T> {
//         /** Dispatches a service call that came in over the network. */
//         public RFuture<?> dispatchCall (short methodId, Object[] args) {
//             throw new IllegalArgumentException("Unknown service method [id=" + methodId +
//                                                ", obj=" + _owner.getClass().getName() +
//                                                ", attrIdx=" + _index + "]");
//         }
// 
//         protected Dispatcher (NexusObject owner) {
//             super(owner);
//         }
// 
//         /** Used to concisely, and without warning, cast arguments of generic type. */
//         @SuppressWarnings("unchecked")
//         protected final <C> C cast (Object obj) {
//             return (C)obj;
//         }
//     }
// 
//     /** Returns the service encapsulated by this attribute. */
//     public abstract T get ();
// 
//     /** Returns the class for the service encapsulated by this attribute. */
//     public abstract Class<T> getServiceClass ();
// 
//     @Override public void readContents (Streamable.Input in) {
//         // NOOP
//     }
// 
//     @Override public void writeContents (Streamable.Output out) {
//         // NOOP
//     }
// 
//     protected DService (NexusObject owner) {
//         _owner = owner;
//         _index = owner.registerAttr(this);
//     }
// 
//     /** Used by marshallers to dispatch calls over the network. */
//     protected <R> RFuture<R> postCall (short methodId, Object... args) {
//         RPromise<R> result = RPromise.create();
//         _owner.postCall(_index, methodId, args, result);
//         return result;
//     }
// 
//     /** Used by marshallers to dispatch calls over the network. */
//     protected void postVoidCall (short methodId, Object... args) {
//         _owner.postCall(_index, methodId, args, null);
//     }
// 
//     /** The object that owns this attribute. */
//     protected final NexusObject _owner;
// 
//     /** The index of this attribute in its containing object. */
//     protected final short _index;
// }
// 
// Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java
// public interface NexusService
// {
// }


import java.util.Iterator;
import java.util.NoSuchElementException;
import com.google.gwt.user.server.Base64Utils;
import com.threerings.nexus.distrib.DService;
import com.threerings.nexus.distrib.NexusService;

    @Override public char readChar () {
        return (char)readInt();
    }

    @Override public int readInt () {
        return Integer.parseInt(_valiter.next());
    }

    @Override public long readLong () {
        return Base64Utils.longFromBase64(_valiter.next());
    }

    @Override public float readFloat () {
        return (float)readDouble();
    }

    @Override public double readDouble () {
        return Double.parseDouble(_valiter.next());
    }

    @Override public String readString () {
        return readBoolean() ? _valiter.next() : null; // TODO: is wrong?
    }

    @Override public <T extends Streamable> Class<T> readClass () {
        @SuppressWarnings("unchecked") Class<T> c = (Class<T>)_szer.getClass(readShort());
        return c;
    }

// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java
// public abstract class DService<T extends NexusService> implements DAttribute
// {
//     /** Used to create service attributes. */
//     public interface Factory<T extends NexusService>
//     {
//         /** Creates a service attribute with the supplied owner. */
//         DService<T> createService (NexusObject owner);
//     }
// 
//     /** An implementation detail used by service dispatchers. */
//     public static abstract class Dispatcher<T extends NexusService> extends DService<T> {
//         /** Dispatches a service call that came in over the network. */
//         public RFuture<?> dispatchCall (short methodId, Object[] args) {
//             throw new IllegalArgumentException("Unknown service method [id=" + methodId +
//                                                ", obj=" + _owner.getClass().getName() +
//                                                ", attrIdx=" + _index + "]");
//         }
// 
//         protected Dispatcher (NexusObject owner) {
//             super(owner);
//         }
// 
//         /** Used to concisely, and without warning, cast arguments of generic type. */
//         @SuppressWarnings("unchecked")
//         protected final <C> C cast (Object obj) {
//             return (C)obj;
//         }
//     }
// 
//     /** Returns the service encapsulated by this attribute. */
//     public abstract T get ();
// 
//     /** Returns the class for the service encapsulated by this attribute. */
//     public abstract Class<T> getServiceClass ();
// 
//     @Override public void readContents (Streamable.Input in) {
//         // NOOP
//     }
// 
//     @Override public void writeContents (Streamable.Output out) {
//         // NOOP
//     }
// 
//     protected DService (NexusObject owner) {
//         _owner = owner;
//         _index = owner.registerAttr(this);
//     }
// 
//     /** Used by marshallers to dispatch calls over the network. */
//     protected <R> RFuture<R> postCall (short methodId, Object... args) {
//         RPromise<R> result = RPromise.create();
//         _owner.postCall(_index, methodId, args, result);
//         return result;
//     }
// 
//     /** Used by marshallers to dispatch calls over the network. */
//     protected void postVoidCall (short methodId, Object... args) {
//         _owner.postCall(_index, methodId, args, null);
//     }
// 
//     /** The object that owns this attribute. */
//     protected final NexusObject _owner;
// 
//     /** The index of this attribute in its containing object. */
//     protected final short _index;
// }
// 
// Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java
// public interface NexusService
// {
// }


// Path: gwt-server/src/main/java/com/threerings/nexus/io/ServerInput.java
import java.util.Iterator;
import java.util.NoSuchElementException;
import com.google.gwt.user.server.Base64Utils;
import com.threerings.nexus.distrib.DService;
import com.threerings.nexus.distrib.NexusService;


    @Override public char readChar () {
        return (char)readInt();
    }

    @Override public int readInt () {
        return Integer.parseInt(_valiter.next());
    }

    @Override public long readLong () {
        return Base64Utils.longFromBase64(_valiter.next());
    }

    @Override public float readFloat () {
        return (float)readDouble();
    }

    @Override public double readDouble () {
        return Double.parseDouble(_valiter.next());
    }

    @Override public String readString () {
        return readBoolean() ? _valiter.next() : null; // TODO: is wrong?
    }

    @Override public <T extends Streamable> Class<T> readClass () {
        @SuppressWarnings("unchecked") Class<T> c = (Class<T>)_szer.getClass(readShort());
        return c;
    }

    @Override public <T extends NexusService> DService.Factory<T> readService () {