Started work on the 'crowd' package.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3935 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -7,10 +7,13 @@ import flash.util.ByteArray;
|
||||
import com.threerings.util.SimpleMap;
|
||||
|
||||
import com.threerings.io.streamers.ArrayStreamer;
|
||||
import com.threerings.io.streamers.ByteyStreamer;
|
||||
import com.threerings.io.streamers.ByteArrayStreamer;
|
||||
import com.threerings.io.streamers.IntStreamer;
|
||||
import com.threerings.io.streamers.FloatStreamer;
|
||||
import com.threerings.io.streamers.IntegerStreamer;
|
||||
import com.threerings.io.streamers.NumberStreamer;
|
||||
import com.threerings.io.streamers.ObjectArrayStreamer;
|
||||
import com.threerings.io.streamers.ShortStreamer;
|
||||
import com.threerings.io.streamers.StringStreamer;
|
||||
|
||||
public class Streamer
|
||||
@@ -125,10 +128,13 @@ public class Streamer
|
||||
if (_streamers == null) {
|
||||
_streamers = [
|
||||
new StringStreamer(),
|
||||
new IntStreamer(),
|
||||
new NumberStreamer(),
|
||||
new ObjectArrayStreamer(),
|
||||
new ByteArrayStreamer()
|
||||
new ByteArrayStreamer(),
|
||||
new ByteStreamer(),
|
||||
new ShortStreamer(),
|
||||
new IntegerStreamer(),
|
||||
new FloatStreamer()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+10
-8
@@ -1,35 +1,37 @@
|
||||
package com.threerings.io.streamers {
|
||||
|
||||
import com.threerings.util.Byte;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamer;
|
||||
|
||||
/**
|
||||
* A Streamer for int objects.
|
||||
* A Streamer for Byte objects.
|
||||
*/
|
||||
public class IntStreamer extends Streamer
|
||||
public class ByteStreamer extends Streamer
|
||||
{
|
||||
public function IntStreamer ()
|
||||
public function ByteStreamer ()
|
||||
{
|
||||
super(int, "java.lang.Integer");
|
||||
super(Byte, "java.lang.Byte");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return ins.readInt();
|
||||
return new Byte(ins.readByte());
|
||||
}
|
||||
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var i :int = (obj as int);
|
||||
out.writeInt(i);
|
||||
var byte :Byte = (obj as Byte);
|
||||
out.writeByte(byte.value);
|
||||
}
|
||||
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
// nothing here, the int is fully read in createObject()
|
||||
// unneeded, done in createObject
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.threerings.io.streamers {
|
||||
|
||||
import com.threerings.util.Float;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamer;
|
||||
|
||||
/**
|
||||
* A Streamer for Float objects.
|
||||
*/
|
||||
public class FloatStreamer extends Streamer
|
||||
{
|
||||
public function FloatStreamer ()
|
||||
{
|
||||
super(Float, "java.lang.Float");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return new Float(ins.readFloat());
|
||||
}
|
||||
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var float :Float = (obj as Float);
|
||||
out.writeFloat(float.value);
|
||||
}
|
||||
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
// unneeded, done in createObject
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.threerings.io.streamers {
|
||||
|
||||
import com.threerings.util.Integer;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamer;
|
||||
|
||||
/**
|
||||
* A Streamer for Integer objects.
|
||||
*/
|
||||
public class IntegerStreamer extends Streamer
|
||||
{
|
||||
public function IntegerStreamer ()
|
||||
{
|
||||
super(Integer, "java.lang.Integer");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return new Integer(ins.readInt());
|
||||
}
|
||||
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var inty :Integer = (obj as Integer);
|
||||
out.writeInt(inty.value);
|
||||
}
|
||||
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
// unneeded, done in createObject
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.threerings.io.streamers {
|
||||
|
||||
import com.threerings.util.Short;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamer;
|
||||
|
||||
/**
|
||||
* A Streamer for Short objects.
|
||||
*/
|
||||
public class ShortStreamer extends Streamer
|
||||
{
|
||||
public function ShortStreamer ()
|
||||
{
|
||||
super(Short, "java.lang.Short");
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :Object
|
||||
{
|
||||
return new Short(ins.readShort());
|
||||
}
|
||||
|
||||
public override function writeObject (obj :Object, out :ObjectOutputStream)
|
||||
:void
|
||||
{
|
||||
var short :Short = (obj as Short);
|
||||
out.writeShort(short.value);
|
||||
}
|
||||
|
||||
public override function readObject (obj :Object, ins :ObjectInputStream)
|
||||
:void
|
||||
{
|
||||
// unneeded, done in createObject
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user