You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/11/09 03:33:49 UTC

[4/5] thrift git commit: THRIFT-2806 more whitespace fixups Client: Haxe Patch: Jens Geyer

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocol.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocol.hx b/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocol.hx
index 1a93332..aeed8f4 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocol.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocol.hx
@@ -47,747 +47,747 @@ import org.apache.thrift.transport.TTransport;
 */
 class TJSONProtocol implements TProtocol {
 
-	public var trans(default,null) : TTransport;
-
-	// Stack of nested contexts that we may be in
-	private var contextStack : GenericStack<JSONBaseContext> = new GenericStack<JSONBaseContext>();
-
-	// Current context that we are in
-	private var context : JSONBaseContext;
-
-	// Reader that manages a 1-byte buffer
-	private var reader : LookaheadReader;
-
-	// whether the underlying system holds Strings as UTF-8
-	// http://old.haxe.org/manual/encoding
-	private static var utf8Strings = haxe.Utf8.validate("Ç-ß-Æ-Ю-Ш");
-
-	// TJSONProtocol Constructor
-	public function new( trans : TTransport)
-	{
-		this.trans = trans;
-		this.context = new JSONBaseContext(this);
-		this.reader = new LookaheadReader(this);
-	}
-
-	public function getTransport() : TTransport {
-	  return trans;
-	}
-
-	public function writeMessageBegin(message:TMessage) : Void {
-		WriteJSONArrayStart();
-		WriteJSONInteger( JSONConstants.VERSION);
-		WriteJSONString( BytesFromString(message.name));
-		WriteJSONInteger( message.type);
-		WriteJSONInteger( message.seqid);
-	}
-
-	public function writeMessageEnd() : Void {
-		WriteJSONArrayEnd();
-	}
-
-	public function writeStructBegin(struct:TStruct) : Void {
-		WriteJSONObjectStart();
-	}
-
-	public function writeStructEnd() : Void {
-		WriteJSONObjectEnd();
-	}
-
-	public function writeFieldBegin(field:TField) : Void {
-		WriteJSONInteger( field.id );
-		WriteJSONObjectStart();
-		WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( field.type)));
-	}
-
-	public function writeFieldEnd() : Void {
-		WriteJSONObjectEnd();
-	}
-
-	public function writeFieldStop() : Void { }
-
-	public function writeMapBegin(map:TMap) : Void {
-		WriteJSONArrayStart();
-		WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( map.keyType)));
-		WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( map.valueType)));
-		WriteJSONInteger( map.size);
-		WriteJSONObjectStart();
-	}
-
-	public function writeMapEnd() : Void {
-		WriteJSONObjectEnd();
-		WriteJSONArrayEnd();
-	}
-
-	public function writeListBegin(list:TList) : Void {
-		WriteJSONArrayStart();
-		WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( list.elemType )));
-		WriteJSONInteger( list.size);
-	}
-
-	public function writeListEnd() : Void {
-		WriteJSONArrayEnd();
-	}
-
-	public function writeSetBegin(set:TSet) : Void {
-		WriteJSONArrayStart();
-		WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( set.elemType)));
-		WriteJSONInteger( set.size);
-	}
-
-	public function writeSetEnd() : Void {
-		WriteJSONArrayEnd();
-	}
-
-	public function writeBool(b : Bool) : Void {
-		if( b)
-			WriteJSONInteger( 1);
-		else
-			WriteJSONInteger( 0);
-	}
-
-	public function writeByte(b : Int) : Void {
-		WriteJSONInteger( b);
-	}
-
-	public function writeI16(i16 : Int) : Void {
-		WriteJSONInteger( i16);
-	}
-
-	public function writeI32(i32 : Int) : Void {
-		WriteJSONInteger( i32);
-	}
-
-	public function writeI64(i64 : haxe.Int64) : Void {
-		WriteJSONInt64( i64);
-	}
-
-	public function writeDouble(dub:Float) : Void {
-		WriteJSONDouble(dub);
-	}
-
-	public function writeString(str : String) : Void {
-		WriteJSONString( BytesFromString(str));
-	}
-
-	public function writeBinary(bin:Bytes) : Void {
-		WriteJSONBase64(bin);
-	}
-
-	public function readMessageBegin():TMessage {
-		var message : TMessage = new TMessage();
-		ReadJSONArrayStart();
-		if (ReadJSONInteger() != JSONConstants.VERSION)
-		{
-			throw new TProtocolException(TProtocolException.BAD_VERSION,
-										 "Message contained bad version.");
-		}
-
-		message.name = ReadJSONString(false);
-		message.type = ReadJSONInteger();
-		message.seqid = ReadJSONInteger();
-		return message;
-	}
-
-	public function readMessageEnd() : Void {
-		ReadJSONArrayEnd();
-	}
-
-	public function readStructBegin():TStruct {
-		ReadJSONObjectStart();
-		return new TStruct();
-	}
-
-	public function readStructEnd() : Void {
-		ReadJSONObjectEnd();
-	}
-
-	public function readFieldBegin() : TField {
-		var field : TField = new TField();
-		var ch = reader.Peek();
-		if (StringFromBytes(ch) == JSONConstants.RBRACE)
-		{
-			field.type = TType.STOP;
-		}
-		else
-		{
-			field.id = ReadJSONInteger();
-			ReadJSONObjectStart();
-			field.type = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
-		}
-		return field;
-	}
-
-	public function readFieldEnd() : Void {
-		ReadJSONObjectEnd();
-	}
-
-	public function readMapBegin() : TMap {
-		ReadJSONArrayStart();
-		var KeyType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
-		var ValueType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
-		var Count : Int = ReadJSONInteger();
-		ReadJSONObjectStart();
-
-		var map = new TMap( KeyType, ValueType, Count);
-		return map;
-	}
-
-	public function readMapEnd() : Void {
-		ReadJSONObjectEnd();
-		ReadJSONArrayEnd();
-	}
-
-	public function readListBegin():TList {
-		ReadJSONArrayStart();
-		var ElementType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
-		var Count : Int = ReadJSONInteger();
-
-		var list = new TList( ElementType, Count);
-		return list;
-	}
-
-	public function readListEnd() : Void {
-		ReadJSONArrayEnd();
-	}
-
-	public function readSetBegin() : TSet {
-		ReadJSONArrayStart();
-		var ElementType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
-		var Count : Int = ReadJSONInteger();
-
-		var set = new TSet( ElementType, Count);
-		return set;
-	}
-
-	public function readSetEnd() : Void {
-		ReadJSONArrayEnd();
-	}
-
-	public function readBool() : Bool {
-		return (ReadJSONInteger() != 0);
-	}
-
-	public function readByte() : Int {
-		return ReadJSONInteger();
-	}
-
-	public function readI16() : Int {
-		return ReadJSONInteger();
-	}
-
-	public function readI32() : Int {
-		return ReadJSONInteger();
-	}
-
-	public function readI64() : haxe.Int64 {
-		return ReadJSONInt64();
-	}
-
-	public function readDouble():Float {
-		return ReadJSONDouble();
-	}
-
-	public function readString() : String {
+    public var trans(default,null) : TTransport;
+
+    // Stack of nested contexts that we may be in
+    private var contextStack : GenericStack<JSONBaseContext> = new GenericStack<JSONBaseContext>();
+
+    // Current context that we are in
+    private var context : JSONBaseContext;
+
+    // Reader that manages a 1-byte buffer
+    private var reader : LookaheadReader;
+
+    // whether the underlying system holds Strings as UTF-8
+    // http://old.haxe.org/manual/encoding
+    private static var utf8Strings = haxe.Utf8.validate("Ç-ß-Æ-Ю-Ш");
+
+    // TJSONProtocol Constructor
+    public function new( trans : TTransport)
+    {
+        this.trans = trans;
+        this.context = new JSONBaseContext(this);
+        this.reader = new LookaheadReader(this);
+    }
+
+    public function getTransport() : TTransport {
+      return trans;
+    }
+
+    public function writeMessageBegin(message:TMessage) : Void {
+        WriteJSONArrayStart();
+        WriteJSONInteger( JSONConstants.VERSION);
+        WriteJSONString( BytesFromString(message.name));
+        WriteJSONInteger( message.type);
+        WriteJSONInteger( message.seqid);
+    }
+
+    public function writeMessageEnd() : Void {
+        WriteJSONArrayEnd();
+    }
+
+    public function writeStructBegin(struct:TStruct) : Void {
+        WriteJSONObjectStart();
+    }
+
+    public function writeStructEnd() : Void {
+        WriteJSONObjectEnd();
+    }
+
+    public function writeFieldBegin(field:TField) : Void {
+        WriteJSONInteger( field.id );
+        WriteJSONObjectStart();
+        WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( field.type)));
+    }
+
+    public function writeFieldEnd() : Void {
+        WriteJSONObjectEnd();
+    }
+
+    public function writeFieldStop() : Void { }
+
+    public function writeMapBegin(map:TMap) : Void {
+        WriteJSONArrayStart();
+        WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( map.keyType)));
+        WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( map.valueType)));
+        WriteJSONInteger( map.size);
+        WriteJSONObjectStart();
+    }
+
+    public function writeMapEnd() : Void {
+        WriteJSONObjectEnd();
+        WriteJSONArrayEnd();
+    }
+
+    public function writeListBegin(list:TList) : Void {
+        WriteJSONArrayStart();
+        WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( list.elemType )));
+        WriteJSONInteger( list.size);
+    }
+
+    public function writeListEnd() : Void {
+        WriteJSONArrayEnd();
+    }
+
+    public function writeSetBegin(set:TSet) : Void {
+        WriteJSONArrayStart();
+        WriteJSONString( BytesFromString( JSONConstants.GetTypeNameForTypeID( set.elemType)));
+        WriteJSONInteger( set.size);
+    }
+
+    public function writeSetEnd() : Void {
+        WriteJSONArrayEnd();
+    }
+
+    public function writeBool(b : Bool) : Void {
+        if( b)
+            WriteJSONInteger( 1);
+        else
+            WriteJSONInteger( 0);
+    }
+
+    public function writeByte(b : Int) : Void {
+        WriteJSONInteger( b);
+    }
+
+    public function writeI16(i16 : Int) : Void {
+        WriteJSONInteger( i16);
+    }
+
+    public function writeI32(i32 : Int) : Void {
+        WriteJSONInteger( i32);
+    }
+
+    public function writeI64(i64 : haxe.Int64) : Void {
+        WriteJSONInt64( i64);
+    }
+
+    public function writeDouble(dub:Float) : Void {
+        WriteJSONDouble(dub);
+    }
+
+    public function writeString(str : String) : Void {
+        WriteJSONString( BytesFromString(str));
+    }
+
+    public function writeBinary(bin:Bytes) : Void {
+        WriteJSONBase64(bin);
+    }
+
+    public function readMessageBegin():TMessage {
+        var message : TMessage = new TMessage();
+        ReadJSONArrayStart();
+        if (ReadJSONInteger() != JSONConstants.VERSION)
+        {
+            throw new TProtocolException(TProtocolException.BAD_VERSION,
+                                         "Message contained bad version.");
+        }
+
+        message.name = ReadJSONString(false);
+        message.type = ReadJSONInteger();
+        message.seqid = ReadJSONInteger();
+        return message;
+    }
+
+    public function readMessageEnd() : Void {
+        ReadJSONArrayEnd();
+    }
+
+    public function readStructBegin():TStruct {
+        ReadJSONObjectStart();
+        return new TStruct();
+    }
+
+    public function readStructEnd() : Void {
+        ReadJSONObjectEnd();
+    }
+
+    public function readFieldBegin() : TField {
+        var field : TField = new TField();
+        var ch = reader.Peek();
+        if (StringFromBytes(ch) == JSONConstants.RBRACE)
+        {
+            field.type = TType.STOP;
+        }
+        else
+        {
+            field.id = ReadJSONInteger();
+            ReadJSONObjectStart();
+            field.type = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
+        }
+        return field;
+    }
+
+    public function readFieldEnd() : Void {
+        ReadJSONObjectEnd();
+    }
+
+    public function readMapBegin() : TMap {
+        ReadJSONArrayStart();
+        var KeyType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
+        var ValueType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
+        var Count : Int = ReadJSONInteger();
+        ReadJSONObjectStart();
+
+        var map = new TMap( KeyType, ValueType, Count);
+        return map;
+    }
+
+    public function readMapEnd() : Void {
+        ReadJSONObjectEnd();
+        ReadJSONArrayEnd();
+    }
+
+    public function readListBegin():TList {
+        ReadJSONArrayStart();
+        var ElementType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
+        var Count : Int = ReadJSONInteger();
+
+        var list = new TList( ElementType, Count);
+        return list;
+    }
+
+    public function readListEnd() : Void {
+        ReadJSONArrayEnd();
+    }
+
+    public function readSetBegin() : TSet {
+        ReadJSONArrayStart();
+        var ElementType = JSONConstants.GetTypeIDForTypeName( ReadJSONString(false));
+        var Count : Int = ReadJSONInteger();
+
+        var set = new TSet( ElementType, Count);
+        return set;
+    }
+
+    public function readSetEnd() : Void {
+        ReadJSONArrayEnd();
+    }
+
+    public function readBool() : Bool {
+        return (ReadJSONInteger() != 0);
+    }
+
+    public function readByte() : Int {
+        return ReadJSONInteger();
+    }
+
+    public function readI16() : Int {
+        return ReadJSONInteger();
+    }
+
+    public function readI32() : Int {
+        return ReadJSONInteger();
+    }
+
+    public function readI64() : haxe.Int64 {
+        return ReadJSONInt64();
+    }
+
+    public function readDouble():Float {
+        return ReadJSONDouble();
+    }
+
+    public function readString() : String {
         return ReadJSONString(false);
-	}
-
-	public function readBinary() : Bytes {
-		return ReadJSONBase64();
-	}
-
-	// Push a new JSON context onto the stack.
-	private function  PushContext(c : JSONBaseContext) : Void {
-		contextStack.add(context);
-		context = c;
-	}
-
-	// Pop the last JSON context off the stack
-	private function  PopContext() : Void {
-		context = contextStack.pop();
-	}
-
-
-	// Write the bytes in array buf as a JSON characters, escaping as needed
-	private function WriteJSONString( b : Bytes) : Void {
-		context.Write();
-
-		var tmp = BytesFromString( JSONConstants.QUOTE);
-		trans.write( tmp, 0, tmp.length);
-
-		for (i in 0 ... b.length) {
-			var value = b.get(i);
-
-			if ((value & 0x00FF) >= 0x30)
-			{
-				if (String.fromCharCode(value) == JSONConstants.BACKSLASH.charAt(0))
-				{
-					tmp = BytesFromString( JSONConstants.BACKSLASH + JSONConstants.BACKSLASH);
-					trans.write( tmp, 0, tmp.length);
-				}
-				else
-				{
-					trans.write( b, i, 1);
-				}
-			}
-			else
-			{
-				var num = JSONConstants.JSON_CHAR_TABLE[value];
-				if (num == 1)
-				{
-					trans.write( b, i, 1);
-				}
-				else if (num > 1)
-				{
-					var buf = new BytesBuffer();
-					buf.addString( JSONConstants.BACKSLASH);
-					buf.addByte( num);
-					tmp = buf.getBytes();
-					trans.write( tmp, 0, tmp.length);
-				}
-				else
-				{
-					var buf = new BytesBuffer();
-					buf.addString( JSONConstants.ESCSEQ);
-					buf.addString( HexChar( (value & 0xFF000000) >> 12));
-					buf.addString( HexChar( (value & 0x00FF0000) >> 8));
-					buf.addString( HexChar( (value & 0x0000FF00) >> 4));
-					buf.addString( HexChar( value & 0x000000FF));
-					tmp = buf.getBytes();
-					trans.write( tmp, 0, tmp.length);
-				}
-			}
-		}
-
-		tmp = BytesFromString( JSONConstants.QUOTE);
-		trans.write( tmp, 0, tmp.length);
-	}
-
-	// Write out number as a JSON value. If the context dictates so,
-	// it will be wrapped in quotes to output as a JSON string.
-	private function WriteJSONInteger( num : Int) : Void {
-		context.Write();
-
-		var str : String = "";
-		var escapeNum : Bool = context.EscapeNumbers();
-
-		if (escapeNum) {
-			str += JSONConstants.QUOTE;
-		}
-
-		str += Std.string(num);
-
-		if (escapeNum) {
-			str += JSONConstants.QUOTE;
-		}
-
-		var tmp = BytesFromString( str);
-		trans.write( tmp, 0, tmp.length);
-	}
-
-	// Write out number as a JSON value. If the context dictates so,
-	// it will be wrapped in quotes to output as a JSON string.
-	private function WriteJSONInt64( num : Int64) : Void {
-		context.Write();
-
-		var str : String = "";
-		var escapeNum : Bool = context.EscapeNumbers();
-
-		if (escapeNum) {
-			str += JSONConstants.QUOTE;
-		}
-
-		str += Std.string(num);
-
-		if (escapeNum) {
-			str += JSONConstants.QUOTE;
-		}
-
-		var tmp = BytesFromString( str);
-		trans.write( tmp, 0, tmp.length);
-	}
-
-	// Write out a double as a JSON value. If it is NaN or infinity or if the
-	// context dictates escaping, Write out as JSON string.
-	private function WriteJSONDouble(num : Float) : Void {
-		context.Write();
-
-
-		var special : Bool = false;
-		var rendered : String = "";
-		if( Math.isNaN(num)) {
-			special = true;
-			rendered = JSONConstants.FLOAT_IS_NAN;
-		} else if (! Math.isFinite(num)) {
-			special = true;
-			if( num > 0) {
-				rendered = JSONConstants.FLOAT_IS_POS_INF;
-			} else {
-				rendered = JSONConstants.FLOAT_IS_NEG_INF;
-			}
-		} else {
-			rendered = Std.string(num);  // plain and simple float number
-		}
-
-		// compose output
-		var escapeNum : Bool = special || context.EscapeNumbers();
-		var str : String = "";
-		if (escapeNum) {
-			str += JSONConstants.QUOTE;
-		}
-		str += rendered;
-		if (escapeNum) {
-			str += JSONConstants.QUOTE;
-		}
-
-		var tmp = BytesFromString( str);
-		trans.write( tmp, 0, tmp.length);
-	}
-
-	// Write out contents of byte array b as a JSON string with base-64 encoded data
-	private function WriteJSONBase64( b : Bytes) : Void {
-		context.Write();
-
-		var buf = new BytesBuffer();
-		buf.addString( JSONConstants.QUOTE);
-		buf.addString( Base64.encode(b));
-		buf.addString( JSONConstants.QUOTE);
-
-		var tmp = buf.getBytes();
-		trans.write( tmp, 0, tmp.length);
-	}
-
-	private function WriteJSONObjectStart() : Void {
-		context.Write();
-		var tmp = BytesFromString( JSONConstants.LBRACE);
-		trans.write( tmp, 0, tmp.length);
-		PushContext( new JSONPairContext(this));
-	}
-
-	private function WriteJSONObjectEnd() : Void {
-		PopContext();
-		var tmp = BytesFromString( JSONConstants.RBRACE);
-		trans.write( tmp, 0, tmp.length);
-	}
-
-	private function WriteJSONArrayStart() : Void {
-		context.Write();
-		var tmp = BytesFromString( JSONConstants.LBRACKET);
-		trans.write( tmp, 0, tmp.length);
-		PushContext( new JSONListContext(this));
-	}
-
-	private function WriteJSONArrayEnd() : Void {
-		PopContext();
-		var tmp = BytesFromString( JSONConstants.RBRACKET);
-		trans.write( tmp, 0, tmp.length);
-	}
-
-
-	/**
-	 * Reading methods.
-	 */
-
-	// Read a byte that must match char, otherwise an exception is thrown.
-	public function ReadJSONSyntaxChar( char : String) : Void {
-		var b = BytesFromString( char);
-		
-		var ch = reader.Read();
-		if (ch.get(0) != b.get(0))
-		{
-			throw new TProtocolException(TProtocolException.INVALID_DATA,
-										 'Unexpected character: $ch');
-		}
-	}
-
-	// Read in a JSON string, unescaping as appropriate.
+    }
+
+    public function readBinary() : Bytes {
+        return ReadJSONBase64();
+    }
+
+    // Push a new JSON context onto the stack.
+    private function  PushContext(c : JSONBaseContext) : Void {
+        contextStack.add(context);
+        context = c;
+    }
+
+    // Pop the last JSON context off the stack
+    private function  PopContext() : Void {
+        context = contextStack.pop();
+    }
+
+
+    // Write the bytes in array buf as a JSON characters, escaping as needed
+    private function WriteJSONString( b : Bytes) : Void {
+        context.Write();
+
+        var tmp = BytesFromString( JSONConstants.QUOTE);
+        trans.write( tmp, 0, tmp.length);
+
+        for (i in 0 ... b.length) {
+            var value = b.get(i);
+
+            if ((value & 0x00FF) >= 0x30)
+            {
+                if (String.fromCharCode(value) == JSONConstants.BACKSLASH.charAt(0))
+                {
+                    tmp = BytesFromString( JSONConstants.BACKSLASH + JSONConstants.BACKSLASH);
+                    trans.write( tmp, 0, tmp.length);
+                }
+                else
+                {
+                    trans.write( b, i, 1);
+                }
+            }
+            else
+            {
+                var num = JSONConstants.JSON_CHAR_TABLE[value];
+                if (num == 1)
+                {
+                    trans.write( b, i, 1);
+                }
+                else if (num > 1)
+                {
+                    var buf = new BytesBuffer();
+                    buf.addString( JSONConstants.BACKSLASH);
+                    buf.addByte( num);
+                    tmp = buf.getBytes();
+                    trans.write( tmp, 0, tmp.length);
+                }
+                else
+                {
+                    var buf = new BytesBuffer();
+                    buf.addString( JSONConstants.ESCSEQ);
+                    buf.addString( HexChar( (value & 0xFF000000) >> 12));
+                    buf.addString( HexChar( (value & 0x00FF0000) >> 8));
+                    buf.addString( HexChar( (value & 0x0000FF00) >> 4));
+                    buf.addString( HexChar( value & 0x000000FF));
+                    tmp = buf.getBytes();
+                    trans.write( tmp, 0, tmp.length);
+                }
+            }
+        }
+
+        tmp = BytesFromString( JSONConstants.QUOTE);
+        trans.write( tmp, 0, tmp.length);
+    }
+
+    // Write out number as a JSON value. If the context dictates so,
+    // it will be wrapped in quotes to output as a JSON string.
+    private function WriteJSONInteger( num : Int) : Void {
+        context.Write();
+
+        var str : String = "";
+        var escapeNum : Bool = context.EscapeNumbers();
+
+        if (escapeNum) {
+            str += JSONConstants.QUOTE;
+        }
+
+        str += Std.string(num);
+
+        if (escapeNum) {
+            str += JSONConstants.QUOTE;
+        }
+
+        var tmp = BytesFromString( str);
+        trans.write( tmp, 0, tmp.length);
+    }
+
+    // Write out number as a JSON value. If the context dictates so,
+    // it will be wrapped in quotes to output as a JSON string.
+    private function WriteJSONInt64( num : Int64) : Void {
+        context.Write();
+
+        var str : String = "";
+        var escapeNum : Bool = context.EscapeNumbers();
+
+        if (escapeNum) {
+            str += JSONConstants.QUOTE;
+        }
+
+        str += Std.string(num);
+
+        if (escapeNum) {
+            str += JSONConstants.QUOTE;
+        }
+
+        var tmp = BytesFromString( str);
+        trans.write( tmp, 0, tmp.length);
+    }
+
+    // Write out a double as a JSON value. If it is NaN or infinity or if the
+    // context dictates escaping, Write out as JSON string.
+    private function WriteJSONDouble(num : Float) : Void {
+        context.Write();
+
+
+        var special : Bool = false;
+        var rendered : String = "";
+        if( Math.isNaN(num)) {
+            special = true;
+            rendered = JSONConstants.FLOAT_IS_NAN;
+        } else if (! Math.isFinite(num)) {
+            special = true;
+            if( num > 0) {
+                rendered = JSONConstants.FLOAT_IS_POS_INF;
+            } else {
+                rendered = JSONConstants.FLOAT_IS_NEG_INF;
+            }
+        } else {
+            rendered = Std.string(num);  // plain and simple float number
+        }
+
+        // compose output
+        var escapeNum : Bool = special || context.EscapeNumbers();
+        var str : String = "";
+        if (escapeNum) {
+            str += JSONConstants.QUOTE;
+        }
+        str += rendered;
+        if (escapeNum) {
+            str += JSONConstants.QUOTE;
+        }
+
+        var tmp = BytesFromString( str);
+        trans.write( tmp, 0, tmp.length);
+    }
+
+    // Write out contents of byte array b as a JSON string with base-64 encoded data
+    private function WriteJSONBase64( b : Bytes) : Void {
+        context.Write();
+
+        var buf = new BytesBuffer();
+        buf.addString( JSONConstants.QUOTE);
+        buf.addString( Base64.encode(b));
+        buf.addString( JSONConstants.QUOTE);
+
+        var tmp = buf.getBytes();
+        trans.write( tmp, 0, tmp.length);
+    }
+
+    private function WriteJSONObjectStart() : Void {
+        context.Write();
+        var tmp = BytesFromString( JSONConstants.LBRACE);
+        trans.write( tmp, 0, tmp.length);
+        PushContext( new JSONPairContext(this));
+    }
+
+    private function WriteJSONObjectEnd() : Void {
+        PopContext();
+        var tmp = BytesFromString( JSONConstants.RBRACE);
+        trans.write( tmp, 0, tmp.length);
+    }
+
+    private function WriteJSONArrayStart() : Void {
+        context.Write();
+        var tmp = BytesFromString( JSONConstants.LBRACKET);
+        trans.write( tmp, 0, tmp.length);
+        PushContext( new JSONListContext(this));
+    }
+
+    private function WriteJSONArrayEnd() : Void {
+        PopContext();
+        var tmp = BytesFromString( JSONConstants.RBRACKET);
+        trans.write( tmp, 0, tmp.length);
+    }
+
+
+    /**
+     * Reading methods.
+     */
+
+    // Read a byte that must match char, otherwise an exception is thrown.
+    public function ReadJSONSyntaxChar( char : String) : Void {
+        var b = BytesFromString( char);
+
+        var ch = reader.Read();
+        if (ch.get(0) != b.get(0))
+        {
+            throw new TProtocolException(TProtocolException.INVALID_DATA,
+                                         'Unexpected character: $ch');
+        }
+    }
+
+    // Read in a JSON string, unescaping as appropriate.
     // Skip Reading from the context if skipContext is true.
-	private function ReadJSONString(skipContext : Bool) : String
-	{
-		if (!skipContext)
-		{
-			context.Read();
-		}
-
-		var buffer : BytesBuffer = new BytesBuffer();
-
-		ReadJSONSyntaxChar( JSONConstants.QUOTE);
-		while (true)
-		{
-			var ch = reader.Read();
-
-			// end of string?
-			if (StringFromBytes(ch) == JSONConstants.QUOTE)
-			{
-				break;
-			}
-
-			// escaped?
-			if (StringFromBytes(ch) != JSONConstants.ESCSEQ.charAt(0))
-			{
-				buffer.addByte( ch.get(0));
-				continue;
-			}
-
-			// distinguish between \uXXXX (hex unicode) and \X (control chars)
-			ch = reader.Read();
-			if (StringFromBytes(ch) != JSONConstants.ESCSEQ.charAt(1))
-			{
-				var value = JSONConstants.ESCAPE_CHARS_TO_VALUES[ch.get(0)];
-				if( value == null)
-				{
-					throw new TProtocolException( TProtocolException.INVALID_DATA, "Expected control char");
-				}
-				buffer.addByte( value);
-				continue;
-			}
-
-
-			// it's \uXXXX
-			var hexbuf = new BytesBuffer();
-			var hexlen = trans.readAll( hexbuf, 0, 4);
-			if( hexlen != 4)
-			{
-				throw new TProtocolException( TProtocolException.INVALID_DATA, "Not enough data for \\uNNNN sequence");
-			}
-
-			var hexdigits = hexbuf.getBytes();
-			var charcode = 0;
-			charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(0)));
-			charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(1)));
-			charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(2)));
-			charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(3)));
-			buffer.addString( String.fromCharCode(charcode));
-		}
-
-		return StringFromBytes( buffer.getBytes());
-	}
-
-	// Return true if the given byte could be a valid part of a JSON number.
-	private function IsJSONNumeric(b : Int) : Bool {
-		switch (b)
-		{
-			case "+".code:  return true;
-			case "-".code:  return true;
-			case ".".code:  return true;
-			case "0".code:  return true;
-			case "1".code:  return true;
-			case "2".code:  return true;
-			case "3".code:  return true;
-			case "4".code:  return true;
-			case "5".code:  return true;
-			case "6".code:  return true;
-			case "7".code:  return true;
-			case "8".code:  return true;
-			case "9".code:  return true;
-			case "E".code:  return true;
-			case "e".code:  return true;
-		}
-		return false;
-	}
-
-	// Read in a sequence of characters that are all valid in JSON numbers. Does
-	// not do a complete regex check to validate that this is actually a number.
-	private function ReadJSONNumericChars() : String
-	{
-		var buffer : BytesBuffer = new BytesBuffer();
-		while (true)
-		{
-			var ch = reader.Peek();
-			if( ! IsJSONNumeric( ch.get(0)))
-			{
-				break;
-			}
-			buffer.addByte( reader.Read().get(0));
-		}
-		return StringFromBytes( buffer.getBytes());
-	}
-
-	// Read in a JSON number. If the context dictates, Read in enclosing quotes.
-	private function ReadJSONInteger() : Int {
-		context.Read();
-
-		if (context.EscapeNumbers()) {
-			ReadJSONSyntaxChar( JSONConstants.QUOTE);
-		}
-
-		var str : String = ReadJSONNumericChars();
-
-		if (context.EscapeNumbers()) {
-			ReadJSONSyntaxChar( JSONConstants.QUOTE);
-		}
-
-		var value = Std.parseInt(str);
-		if( value == null) {
-			throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
-		}
-
-		return value;
-	}
-
-	// Read in a JSON number. If the context dictates, Read in enclosing quotes.
-	private function ReadJSONInt64() : haxe.Int64 {
-		context.Read();
-
-		if (context.EscapeNumbers()) {
-			ReadJSONSyntaxChar( JSONConstants.QUOTE);
-		}
-
-		var str : String = ReadJSONNumericChars();
-		if( str.length == 0) {
-			throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
-		}
-
-		if (context.EscapeNumbers()) {
-			ReadJSONSyntaxChar( JSONConstants.QUOTE);
-		}
-
-	    // process sign
-		var bMinus = false;
-		var startAt = 0;
-		if( (str.charAt(0) == "+") || (str.charAt(0) == "-")) {
-			bMinus = (str.charAt(0) == "-");
-			startAt++;
-		}
-
-		// process digits
-		var value : Int64 = Int64.make(0,0);
-		var bGotDigits = false;
-		for( i in startAt ... str.length) {
-			var ch = str.charAt(i);
-			var digit = JSONConstants.DECIMAL_DIGITS[ch];
-			if( digit == null) {
-				throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
-			}
-			bGotDigits = true;
-
-			// these are decimal digits
-			value = Int64.mul( value, Int64.make(0,10));
-			value = Int64.add( value, Int64.make(0,digit));
-		}
-
-		// process pending minus sign, if applicable
-		// this should also handle the edge case MIN_INT64 correctly
-		if( bMinus && (Int64.compare(value,Int64.make(0,0)) > 0)) {
-			value = Int64.neg( value);
-			bMinus = false;
-		}
-
-		if( ! bGotDigits) {
-			throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
-		}
-			
-		return value;
-	}
-
-	// Read in a JSON double value. Throw if the value is not wrapped in quotes
-	// when expected or if wrapped in quotes when not expected.
-	private function ReadJSONDouble() : Float {
-		context.Read();
-		
-		var str : String = "";
-		if (StringFromBytes(reader.Peek()) == JSONConstants.QUOTE) {
-			str = ReadJSONString(true);
-			
-			// special cases
-			if( str == JSONConstants.FLOAT_IS_NAN) {
-				return Math.NaN;
-			}
-			if( str == JSONConstants.FLOAT_IS_POS_INF) {
-				return Math.POSITIVE_INFINITY;
-			}
-			if( str == JSONConstants.FLOAT_IS_NEG_INF) {
-				return Math.NEGATIVE_INFINITY;
-			}
-			
-			if( ! context.EscapeNumbers())	{
-				// throw - we should not be in a string in this case
-				throw new TProtocolException(TProtocolException.INVALID_DATA, "Numeric data unexpectedly quoted");
-			}
-		}
-		else
-		{
-			if( context.EscapeNumbers())	{
-				// This will throw - we should have had a quote if EscapeNumbers() == true
-				ReadJSONSyntaxChar( JSONConstants.QUOTE);
-			}
-
-			str = ReadJSONNumericChars();
-		}
-
-		// parse and check - we should have at least one valid digit
-		var dub = Std.parseFloat( str);
-		if( (str.length == 0) || Math.isNaN(dub)) {
-			throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
-		}
-
-		return dub;
-	}
-
-	// Read in a JSON string containing base-64 encoded data and decode it.
-	private function ReadJSONBase64() : Bytes
-	{
-		var str = ReadJSONString(false);
-		return Base64.decode( str);
-	}
-
-	private function ReadJSONObjectStart() : Void {
-		context.Read();
-		ReadJSONSyntaxChar( JSONConstants.LBRACE);
-		PushContext(new JSONPairContext(this));
-	}
-
-	private function ReadJSONObjectEnd() : Void {
-		ReadJSONSyntaxChar( JSONConstants.RBRACE);
-		PopContext();
-	}
-
-	private function ReadJSONArrayStart() : Void {
-		context.Read();
-		ReadJSONSyntaxChar( JSONConstants.LBRACKET);
-		PushContext(new JSONListContext(this));
-	}
-
-	private function ReadJSONArrayEnd() : Void {
-		ReadJSONSyntaxChar( JSONConstants.RBRACKET);
-		PopContext();
-	}
-
-
-	public static function BytesFromString( str : String) : Bytes {
-		var buf = new BytesBuffer();
-		if( utf8Strings)
-			buf.addString( str);  // no need to encode on UTF8 targets, the string is just fine
-		else
-			buf.addString( Utf8.encode( str));
-		return buf.getBytes();
-	}
-
-	public static function StringFromBytes( buf : Bytes) : String {
-		var inp = new BytesInput( buf);
-		if( buf.length == 0)
-			return "";  // readString() would return null in that case, which is wrong
-		var str = inp.readString( buf.length);
-		if( utf8Strings)
-			return str;  // no need to decode on UTF8 targets, the string is just fine
-		else
-			return Utf8.decode( str);
-	}
-
-	// Convert a byte containing a hex char ('0'-'9' or 'a'-'f') into its corresponding hex value
-	private static function HexVal(char : String) : Int {
-		var value = JSONConstants.HEX_DIGITS[char];
-		if( value == null) {
-			throw new TProtocolException(TProtocolException.INVALID_DATA, 'Expected hex character: $char');
-		}
-		return value;
-	}
-
-	// Convert a byte containing a hex nibble to its corresponding hex character
-	private static function HexChar(nibble : Int) : String
-	{
-		return "0123456789abcdef".charAt(nibble & 0x0F);
-	}
+    private function ReadJSONString(skipContext : Bool) : String
+    {
+        if (!skipContext)
+        {
+            context.Read();
+        }
+
+        var buffer : BytesBuffer = new BytesBuffer();
+
+        ReadJSONSyntaxChar( JSONConstants.QUOTE);
+        while (true)
+        {
+            var ch = reader.Read();
+
+            // end of string?
+            if (StringFromBytes(ch) == JSONConstants.QUOTE)
+            {
+                break;
+            }
+
+            // escaped?
+            if (StringFromBytes(ch) != JSONConstants.ESCSEQ.charAt(0))
+            {
+                buffer.addByte( ch.get(0));
+                continue;
+            }
+
+            // distinguish between \uXXXX (hex unicode) and \X (control chars)
+            ch = reader.Read();
+            if (StringFromBytes(ch) != JSONConstants.ESCSEQ.charAt(1))
+            {
+                var value = JSONConstants.ESCAPE_CHARS_TO_VALUES[ch.get(0)];
+                if( value == null)
+                {
+                    throw new TProtocolException( TProtocolException.INVALID_DATA, "Expected control char");
+                }
+                buffer.addByte( value);
+                continue;
+            }
+
+
+            // it's \uXXXX
+            var hexbuf = new BytesBuffer();
+            var hexlen = trans.readAll( hexbuf, 0, 4);
+            if( hexlen != 4)
+            {
+                throw new TProtocolException( TProtocolException.INVALID_DATA, "Not enough data for \\uNNNN sequence");
+            }
+
+            var hexdigits = hexbuf.getBytes();
+            var charcode = 0;
+            charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(0)));
+            charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(1)));
+            charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(2)));
+            charcode = (charcode << 4) + HexVal( String.fromCharCode(hexdigits.get(3)));
+            buffer.addString( String.fromCharCode(charcode));
+        }
+
+        return StringFromBytes( buffer.getBytes());
+    }
+
+    // Return true if the given byte could be a valid part of a JSON number.
+    private function IsJSONNumeric(b : Int) : Bool {
+        switch (b)
+        {
+            case "+".code:  return true;
+            case "-".code:  return true;
+            case ".".code:  return true;
+            case "0".code:  return true;
+            case "1".code:  return true;
+            case "2".code:  return true;
+            case "3".code:  return true;
+            case "4".code:  return true;
+            case "5".code:  return true;
+            case "6".code:  return true;
+            case "7".code:  return true;
+            case "8".code:  return true;
+            case "9".code:  return true;
+            case "E".code:  return true;
+            case "e".code:  return true;
+        }
+        return false;
+    }
+
+    // Read in a sequence of characters that are all valid in JSON numbers. Does
+    // not do a complete regex check to validate that this is actually a number.
+    private function ReadJSONNumericChars() : String
+    {
+        var buffer : BytesBuffer = new BytesBuffer();
+        while (true)
+        {
+            var ch = reader.Peek();
+            if( ! IsJSONNumeric( ch.get(0)))
+            {
+                break;
+            }
+            buffer.addByte( reader.Read().get(0));
+        }
+        return StringFromBytes( buffer.getBytes());
+    }
+
+    // Read in a JSON number. If the context dictates, Read in enclosing quotes.
+    private function ReadJSONInteger() : Int {
+        context.Read();
+
+        if (context.EscapeNumbers()) {
+            ReadJSONSyntaxChar( JSONConstants.QUOTE);
+        }
+
+        var str : String = ReadJSONNumericChars();
+
+        if (context.EscapeNumbers()) {
+            ReadJSONSyntaxChar( JSONConstants.QUOTE);
+        }
+
+        var value = Std.parseInt(str);
+        if( value == null) {
+            throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
+        }
+
+        return value;
+    }
+
+    // Read in a JSON number. If the context dictates, Read in enclosing quotes.
+    private function ReadJSONInt64() : haxe.Int64 {
+        context.Read();
+
+        if (context.EscapeNumbers()) {
+            ReadJSONSyntaxChar( JSONConstants.QUOTE);
+        }
+
+        var str : String = ReadJSONNumericChars();
+        if( str.length == 0) {
+            throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
+        }
+
+        if (context.EscapeNumbers()) {
+            ReadJSONSyntaxChar( JSONConstants.QUOTE);
+        }
+
+        // process sign
+        var bMinus = false;
+        var startAt = 0;
+        if( (str.charAt(0) == "+") || (str.charAt(0) == "-")) {
+            bMinus = (str.charAt(0) == "-");
+            startAt++;
+        }
+
+        // process digits
+        var value : Int64 = Int64.make(0,0);
+        var bGotDigits = false;
+        for( i in startAt ... str.length) {
+            var ch = str.charAt(i);
+            var digit = JSONConstants.DECIMAL_DIGITS[ch];
+            if( digit == null) {
+                throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
+            }
+            bGotDigits = true;
+
+            // these are decimal digits
+            value = Int64.mul( value, Int64.make(0,10));
+            value = Int64.add( value, Int64.make(0,digit));
+        }
+
+        // process pending minus sign, if applicable
+        // this should also handle the edge case MIN_INT64 correctly
+        if( bMinus && (Int64.compare(value,Int64.make(0,0)) > 0)) {
+            value = Int64.neg( value);
+            bMinus = false;
+        }
+
+        if( ! bGotDigits) {
+            throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
+        }
+
+        return value;
+    }
+
+    // Read in a JSON double value. Throw if the value is not wrapped in quotes
+    // when expected or if wrapped in quotes when not expected.
+    private function ReadJSONDouble() : Float {
+        context.Read();
+
+        var str : String = "";
+        if (StringFromBytes(reader.Peek()) == JSONConstants.QUOTE) {
+            str = ReadJSONString(true);
+
+            // special cases
+            if( str == JSONConstants.FLOAT_IS_NAN) {
+                return Math.NaN;
+            }
+            if( str == JSONConstants.FLOAT_IS_POS_INF) {
+                return Math.POSITIVE_INFINITY;
+            }
+            if( str == JSONConstants.FLOAT_IS_NEG_INF) {
+                return Math.NEGATIVE_INFINITY;
+            }
+
+            if( ! context.EscapeNumbers())    {
+                // throw - we should not be in a string in this case
+                throw new TProtocolException(TProtocolException.INVALID_DATA, "Numeric data unexpectedly quoted");
+            }
+        }
+        else
+        {
+            if( context.EscapeNumbers())    {
+                // This will throw - we should have had a quote if EscapeNumbers() == true
+                ReadJSONSyntaxChar( JSONConstants.QUOTE);
+            }
+
+            str = ReadJSONNumericChars();
+        }
+
+        // parse and check - we should have at least one valid digit
+        var dub = Std.parseFloat( str);
+        if( (str.length == 0) || Math.isNaN(dub)) {
+            throw new TProtocolException(TProtocolException.INVALID_DATA, 'Bad numeric data: $str');
+        }
+
+        return dub;
+    }
+
+    // Read in a JSON string containing base-64 encoded data and decode it.
+    private function ReadJSONBase64() : Bytes
+    {
+        var str = ReadJSONString(false);
+        return Base64.decode( str);
+    }
+
+    private function ReadJSONObjectStart() : Void {
+        context.Read();
+        ReadJSONSyntaxChar( JSONConstants.LBRACE);
+        PushContext(new JSONPairContext(this));
+    }
+
+    private function ReadJSONObjectEnd() : Void {
+        ReadJSONSyntaxChar( JSONConstants.RBRACE);
+        PopContext();
+    }
+
+    private function ReadJSONArrayStart() : Void {
+        context.Read();
+        ReadJSONSyntaxChar( JSONConstants.LBRACKET);
+        PushContext(new JSONListContext(this));
+    }
+
+    private function ReadJSONArrayEnd() : Void {
+        ReadJSONSyntaxChar( JSONConstants.RBRACKET);
+        PopContext();
+    }
+
+
+    public static function BytesFromString( str : String) : Bytes {
+        var buf = new BytesBuffer();
+        if( utf8Strings)
+            buf.addString( str);  // no need to encode on UTF8 targets, the string is just fine
+        else
+            buf.addString( Utf8.encode( str));
+        return buf.getBytes();
+    }
+
+    public static function StringFromBytes( buf : Bytes) : String {
+        var inp = new BytesInput( buf);
+        if( buf.length == 0)
+            return "";  // readString() would return null in that case, which is wrong
+        var str = inp.readString( buf.length);
+        if( utf8Strings)
+            return str;  // no need to decode on UTF8 targets, the string is just fine
+        else
+            return Utf8.decode( str);
+    }
+
+    // Convert a byte containing a hex char ('0'-'9' or 'a'-'f') into its corresponding hex value
+    private static function HexVal(char : String) : Int {
+        var value = JSONConstants.HEX_DIGITS[char];
+        if( value == null) {
+            throw new TProtocolException(TProtocolException.INVALID_DATA, 'Expected hex character: $char');
+        }
+        return value;
+    }
+
+    // Convert a byte containing a hex nibble to its corresponding hex character
+    private static function HexChar(nibble : Int) : String
+    {
+        return "0123456789abcdef".charAt(nibble & 0x0F);
+    }
 
 
 }
@@ -795,136 +795,136 @@ class TJSONProtocol implements TProtocol {
 
 @:allow(TJSONProtocol)
 class JSONConstants {
-	public static var COMMA = ",";
-	public static var COLON = ":";
-	public static var LBRACE = "{";
-	public static var RBRACE = "}";
-	public static var LBRACKET = "[";
-	public static var RBRACKET = "]";
-	public static var QUOTE = "\"";
-	public static var BACKSLASH = "\\";
-
-	public static var ESCSEQ = "\\u";
-
-	public static var FLOAT_IS_NAN = "NaN";
-	public static var FLOAT_IS_POS_INF = "Infinity";
-	public static var FLOAT_IS_NEG_INF = "-Infinity";
-	
-	public static var VERSION = 1;
-	public static var JSON_CHAR_TABLE = [
-		0,  0,  0,  0,  0,  0,  0,  0,
-		"b".code, "t".code, "n".code,  0, "f".code, "r".code,  0,  0,
-		0,  0,  0,  0,  0,  0,  0,  0,
-		0,  0,  0,  0,  0,  0,  0,  0,
-		1,  1, "\"".code,  1,  1,  1,  1,  1,
-		1,  1,  1,  1,  1,  1,  1,  1,
-	];
-
-	public static var ESCAPE_CHARS     = ['"','\\','/','b','f','n','r','t'];
-	public static var ESCAPE_CHARS_TO_VALUES = [
-		"\"".code => 0x22,
-		"\\".code => 0x5C,
-		"/".code  => 0x2F,
-		"b".code  => 0x08,
-		"f".code  => 0x0C,
-		"n".code  => 0x0A,
-		"r".code  => 0x0D,
-		"t".code  => 0x09
-	];
-
-	public static var DECIMAL_DIGITS = [
-		"0" => 0,
-		"1" => 1,
-		"2" => 2,
-		"3" => 3,
-		"4" => 4,
-		"5" => 5,
-		"6" => 6,
-		"7" => 7,
-		"8" => 8,
-		"9" => 9
-	];
-
-	public static var HEX_DIGITS = [
-		"0" => 0,
-		"1" => 1,
-		"2" => 2,
-		"3" => 3,
-		"4" => 4,
-		"5" => 5,
-		"6" => 6,
-		"7" => 7,
-		"8" => 8,
-		"9" => 9,
-		"A" => 10,
-		"a" => 10,
-		"B" => 11,
-		"b" => 11,
-		"C" => 12,
-		"c" => 12,
-		"D" => 13,
-		"d" => 13,
-		"E" => 14,
-		"e" => 14,
-		"F" => 15,
-		"f" => 15
-	];
-
-
-	public static var DEF_STRING_SIZE = 16;
-
-	public static var NAME_BOOL   = 'tf';
-	public static var NAME_BYTE   = 'i8';
-	public static var NAME_I16    = 'i16';
-	public static var NAME_I32    = 'i32';
-	public static var NAME_I64    = 'i64';
-	public static var NAME_DOUBLE = 'dbl';
-	public static var NAME_STRUCT = 'rec';
-	public static var NAME_STRING = 'str';
-	public static var NAME_MAP    = 'map';
-	public static var NAME_LIST   = 'lst';
-	public static var NAME_SET    = 'set';
-
-	public static function GetTypeNameForTypeID(typeID : Int) : String {
-		switch (typeID)
-		{
-			case TType.BOOL:     return NAME_BOOL;
-			case TType.BYTE:     return NAME_BYTE;
-			case TType.I16:		 return NAME_I16;
-			case TType.I32:		 return NAME_I32;
-			case TType.I64:		 return NAME_I64;
-			case TType.DOUBLE:	 return NAME_DOUBLE;
-			case TType.STRING:	 return NAME_STRING;
-			case TType.STRUCT:	 return NAME_STRUCT;
-			case TType.MAP:		 return NAME_MAP;
-			case TType.SET:		 return NAME_SET;
-			case TType.LIST:	 return NAME_LIST;
-		}
-		throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED, "Unrecognized type");
-	}
-
-	private static var NAMES_TO_TYPES = [
-		NAME_BOOL   => TType.BOOL,
-		NAME_BYTE   => TType.BYTE,
-		NAME_I16    => TType.I16,
-		NAME_I32    => TType.I32,
-		NAME_I64    => TType.I64,
-		NAME_DOUBLE => TType.DOUBLE,
-		NAME_STRING => TType.STRING,
-		NAME_STRUCT => TType.STRUCT,
-		NAME_MAP    => TType.MAP,
-		NAME_SET    => TType.SET,
-		NAME_LIST   => TType.LIST
-	];
-
-	public static function GetTypeIDForTypeName(name : String) : Int
-	{
-		var type = NAMES_TO_TYPES[name];
-		if( null != type) {
-			return type;
-		}
-		throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED, "Unrecognized type");
-	}
+    public static var COMMA = ",";
+    public static var COLON = ":";
+    public static var LBRACE = "{";
+    public static var RBRACE = "}";
+    public static var LBRACKET = "[";
+    public static var RBRACKET = "]";
+    public static var QUOTE = "\"";
+    public static var BACKSLASH = "\\";
+
+    public static var ESCSEQ = "\\u";
+
+    public static var FLOAT_IS_NAN = "NaN";
+    public static var FLOAT_IS_POS_INF = "Infinity";
+    public static var FLOAT_IS_NEG_INF = "-Infinity";
+
+    public static var VERSION = 1;
+    public static var JSON_CHAR_TABLE = [
+        0,  0,  0,  0,  0,  0,  0,  0,
+        "b".code, "t".code, "n".code,  0, "f".code, "r".code,  0,  0,
+        0,  0,  0,  0,  0,  0,  0,  0,
+        0,  0,  0,  0,  0,  0,  0,  0,
+        1,  1, "\"".code,  1,  1,  1,  1,  1,
+        1,  1,  1,  1,  1,  1,  1,  1,
+    ];
+
+    public static var ESCAPE_CHARS     = ['"','\\','/','b','f','n','r','t'];
+    public static var ESCAPE_CHARS_TO_VALUES = [
+        "\"".code => 0x22,
+        "\\".code => 0x5C,
+        "/".code  => 0x2F,
+        "b".code  => 0x08,
+        "f".code  => 0x0C,
+        "n".code  => 0x0A,
+        "r".code  => 0x0D,
+        "t".code  => 0x09
+    ];
+
+    public static var DECIMAL_DIGITS = [
+        "0" => 0,
+        "1" => 1,
+        "2" => 2,
+        "3" => 3,
+        "4" => 4,
+        "5" => 5,
+        "6" => 6,
+        "7" => 7,
+        "8" => 8,
+        "9" => 9
+    ];
+
+    public static var HEX_DIGITS = [
+        "0" => 0,
+        "1" => 1,
+        "2" => 2,
+        "3" => 3,
+        "4" => 4,
+        "5" => 5,
+        "6" => 6,
+        "7" => 7,
+        "8" => 8,
+        "9" => 9,
+        "A" => 10,
+        "a" => 10,
+        "B" => 11,
+        "b" => 11,
+        "C" => 12,
+        "c" => 12,
+        "D" => 13,
+        "d" => 13,
+        "E" => 14,
+        "e" => 14,
+        "F" => 15,
+        "f" => 15
+    ];
+
+
+    public static var DEF_STRING_SIZE = 16;
+
+    public static var NAME_BOOL   = 'tf';
+    public static var NAME_BYTE   = 'i8';
+    public static var NAME_I16    = 'i16';
+    public static var NAME_I32    = 'i32';
+    public static var NAME_I64    = 'i64';
+    public static var NAME_DOUBLE = 'dbl';
+    public static var NAME_STRUCT = 'rec';
+    public static var NAME_STRING = 'str';
+    public static var NAME_MAP    = 'map';
+    public static var NAME_LIST   = 'lst';
+    public static var NAME_SET    = 'set';
+
+    public static function GetTypeNameForTypeID(typeID : Int) : String {
+        switch (typeID)
+        {
+            case TType.BOOL:     return NAME_BOOL;
+            case TType.BYTE:     return NAME_BYTE;
+            case TType.I16:         return NAME_I16;
+            case TType.I32:         return NAME_I32;
+            case TType.I64:         return NAME_I64;
+            case TType.DOUBLE:     return NAME_DOUBLE;
+            case TType.STRING:     return NAME_STRING;
+            case TType.STRUCT:     return NAME_STRUCT;
+            case TType.MAP:         return NAME_MAP;
+            case TType.SET:         return NAME_SET;
+            case TType.LIST:     return NAME_LIST;
+        }
+        throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED, "Unrecognized type");
+    }
+
+    private static var NAMES_TO_TYPES = [
+        NAME_BOOL   => TType.BOOL,
+        NAME_BYTE   => TType.BYTE,
+        NAME_I16    => TType.I16,
+        NAME_I32    => TType.I32,
+        NAME_I64    => TType.I64,
+        NAME_DOUBLE => TType.DOUBLE,
+        NAME_STRING => TType.STRING,
+        NAME_STRUCT => TType.STRUCT,
+        NAME_MAP    => TType.MAP,
+        NAME_SET    => TType.SET,
+        NAME_LIST   => TType.LIST
+    ];
+
+    public static function GetTypeIDForTypeName(name : String) : Int
+    {
+        var type = NAMES_TO_TYPES[name];
+        if( null != type) {
+            return type;
+        }
+        throw new TProtocolException(TProtocolException.NOT_IMPLEMENTED, "Unrecognized type");
+    }
 
 }
 
@@ -934,19 +934,19 @@ class JSONConstants {
 @:allow(TJSONProtocol)
 class JSONBaseContext
 {
-	private var proto : TJSONProtocol;
+    private var proto : TJSONProtocol;
 
-	public function new(proto : TJSONProtocol )
-	{
-		this.proto = proto;
-	}
+    public function new(proto : TJSONProtocol )
+    {
+        this.proto = proto;
+    }
 
-	public function Write() : Void { }
-	public function Read() : Void { }
+    public function Write() : Void { }
+    public function Read() : Void { }
 
-	public function EscapeNumbers() : Bool {
-		return false;
-	}
+    public function EscapeNumbers() : Bool {
+        return false;
+    }
 }
 
 
@@ -955,36 +955,36 @@ class JSONBaseContext
 @:allow(TJSONProtocol)
 class JSONListContext extends JSONBaseContext
 {
-	public function new( proto : TJSONProtocol) {
-		super(proto);
-	}
-
-	private var first : Bool = true;
-
-	public override function Write() : Void {
-		if (first)
-		{
-			first = false;
-		}
-		else
-		{
-			var buf = new BytesBuffer();
-			buf.addString( JSONConstants.COMMA);
-			var tmp = buf.getBytes();
-			proto.trans.write( tmp, 0, tmp.length);
-		}
-	}
-
-	public override function Read() : Void {
-		if (first)
-		{
-			first = false;
-		}
-		else
-		{
-			proto.ReadJSONSyntaxChar( JSONConstants.COMMA);
-		}
-	}
+    public function new( proto : TJSONProtocol) {
+        super(proto);
+    }
+
+    private var first : Bool = true;
+
+    public override function Write() : Void {
+        if (first)
+        {
+            first = false;
+        }
+        else
+        {
+            var buf = new BytesBuffer();
+            buf.addString( JSONConstants.COMMA);
+            var tmp = buf.getBytes();
+            proto.trans.write( tmp, 0, tmp.length);
+        }
+    }
+
+    public override function Read() : Void {
+        if (first)
+        {
+            first = false;
+        }
+        else
+        {
+            proto.ReadJSONSyntaxChar( JSONConstants.COMMA);
+        }
+    }
 }
 
 
@@ -996,78 +996,78 @@ class JSONListContext extends JSONBaseContext
 @:allow(TJSONProtocol)
 class JSONPairContext extends JSONBaseContext
 {
-	public function new( proto : TJSONProtocol ) {
-		super( proto);
-	}
-
-	private var first : Bool = true;
-	private var colon : Bool  = true;
-
-	public override function Write() : Void {
-		if (first)
-		{
-			first = false;
-			colon = true;
-		}
-		else
-		{
-			var buf = new BytesBuffer();
-			buf.addString( colon ? JSONConstants.COLON : JSONConstants.COMMA);
-			var tmp = buf.getBytes();
-			proto.trans.write( tmp, 0, tmp.length);
-			colon = !colon;
-		}
-	}
-
-	public override function Read() : Void {
-		if (first)
-		{
-			first = false;
-			colon = true;
-		}
-		else
-		{
-			proto.ReadJSONSyntaxChar( colon ? JSONConstants.COLON : JSONConstants.COMMA);
-			colon = !colon;
-		}
-	}
-
-	public override function EscapeNumbers() : Bool
-	{
-		return colon;
-	}
+    public function new( proto : TJSONProtocol ) {
+        super( proto);
+    }
+
+    private var first : Bool = true;
+    private var colon : Bool  = true;
+
+    public override function Write() : Void {
+        if (first)
+        {
+            first = false;
+            colon = true;
+        }
+        else
+        {
+            var buf = new BytesBuffer();
+            buf.addString( colon ? JSONConstants.COLON : JSONConstants.COMMA);
+            var tmp = buf.getBytes();
+            proto.trans.write( tmp, 0, tmp.length);
+            colon = !colon;
+        }
+    }
+
+    public override function Read() : Void {
+        if (first)
+        {
+            first = false;
+            colon = true;
+        }
+        else
+        {
+            proto.ReadJSONSyntaxChar( colon ? JSONConstants.COLON : JSONConstants.COMMA);
+            colon = !colon;
+        }
+    }
+
+    public override function EscapeNumbers() : Bool
+    {
+        return colon;
+    }
 }
 
 // Holds up to one byte from the transport
 @:allow(TJSONProtocol)
 class LookaheadReader {
 
-	private var proto : TJSONProtocol;
-	private var data : Bytes;
-
-	public function new( proto : TJSONProtocol ) {
-		this.proto = proto;
-		data = null;
-	}
-
-	
-	// Return and consume the next byte to be Read, either taking it from the
-	// data buffer if present or getting it from the transport otherwise.
-	public function Read() : Bytes {
-		var retval = Peek();
-		data = null;
-		return retval;
-	}
-
-	// Return the next byte to be Read without consuming, filling the data
-	// buffer if it has not been filled alReady.
-	public function Peek() : Bytes {
-		if (data == null) {
-			var buf = new BytesBuffer();
-			proto.trans.readAll(buf, 0, 1);
-			data = buf.getBytes();
-		}
-		return data;
-	}
+    private var proto : TJSONProtocol;
+    private var data : Bytes;
+
+    public function new( proto : TJSONProtocol ) {
+        this.proto = proto;
+        data = null;
+    }
+
+
+    // Return and consume the next byte to be Read, either taking it from the
+    // data buffer if present or getting it from the transport otherwise.
+    public function Read() : Bytes {
+        var retval = Peek();
+        data = null;
+        return retval;
+    }
+
+    // Return the next byte to be Read without consuming, filling the data
+    // buffer if it has not been filled alReady.
+    public function Peek() : Bytes {
+        if (data == null) {
+            var buf = new BytesBuffer();
+            proto.trans.readAll(buf, 0, 1);
+            data = buf.getBytes();
+        }
+        return data;
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocolFactory.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocolFactory.hx b/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocolFactory.hx
index 169629a..363558a 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocolFactory.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TJSONProtocolFactory.hx
@@ -26,15 +26,15 @@ import org.apache.thrift.transport.TTransport;
 * JSON Protocol Factory
 */
 class TJSONProtocolFactory implements TProtocolFactory {
-	
-	public function new() {
-	}
 
-	public function getProtocol( trans : TTransport) : TProtocol  {
-		return new TJSONProtocol( trans);
-	}
+    public function new() {
+    }
+
+    public function getProtocol( trans : TTransport) : TProtocol  {
+        return new TJSONProtocol( trans);
+    }
 }
 
 
 
-	
\ No newline at end of file
+    
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TList.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TList.hx b/lib/haxe/src/org/apache/thrift/protocol/TList.hx
index d6c15c1..5a1fb55 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TList.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TList.hx
@@ -16,14 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
+
 package org.apache.thrift.protocol;
-  
+
 class TList {
 
     public var elemType : Int;
     public var size : Int;
-  
+
       public function new(t : Int = 0, s : Int = 0) {
         elemType = t;
         size = s;

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TMap.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMap.hx b/lib/haxe/src/org/apache/thrift/protocol/TMap.hx
index 5af8c4e..f4e6288 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TMap.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TMap.hx
@@ -16,19 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
+
 package org.apache.thrift.protocol;
 
 class TMap {
-    
+
     public var keyType : Int;
     public var valueType : Int;
     public var size : Int;
-  
+
     public function new(k : Int = 0, v : Int = 0, s : Int = 0) {
       keyType = k;
       valueType = v;
       size = s;
     }
- 
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx b/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx
index 98c883b..58d71a9 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TMessage.hx
@@ -16,25 +16,25 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
+
 package org.apache.thrift.protocol;
-  
+
 class TMessage {
-    
+
     public var name : String;
     public var type : Int;
     public var seqid : Int;
-  
+
     public function new(n : String = "", t : Int = 0, s : Int = 0) {
       name = n;
       type = t;
       seqid = s;
     }
-    
+
     public function toString() : String {
       return "<TMessage name:'" + name + "' type: " + type + " seqid:" + seqid + ">";
     }
-    
+
     public function equals(other:TMessage) : Bool {
       return name == other.name && type == other.type && seqid == other.seqid;
     }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx b/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx
index b141940..7cb38b3 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TMessageType.hx
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
+
 package org.apache.thrift.protocol;
-  
+
 class TMessageType {
     public static inline var CALL      : Int = 1;
-    public static inline var REPLY 	   : Int = 2;
+    public static inline var REPLY        : Int = 2;
     public static inline var EXCEPTION : Int = 3;
     public static inline var ONEWAY    : Int = 4;
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TProtocol.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocol.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocol.hx
index 58873da..0998e92 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TProtocol.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TProtocol.hx
@@ -27,7 +27,7 @@ import org.apache.thrift.transport.TTransport;
 * Protocol interface definition
 */
 interface TProtocol {
-  
+
     function getTransport() : TTransport;
 
     /**
@@ -39,44 +39,44 @@ interface TProtocol {
     function writeStructEnd() : Void;
     function writeFieldBegin(field:TField) : Void;
     function writeFieldEnd() : Void;
-    function writeFieldStop() : Void;    
-    function writeMapBegin(map:TMap) : Void;    
-    function writeMapEnd() : Void;    
-    function writeListBegin(list:TList) : Void;    
-    function writeListEnd() : Void;    
-    function writeSetBegin(set:TSet) : Void;    
-    function writeSetEnd() : Void;    
-    function writeBool(b : Bool) : Void;    
-    function writeByte(b : Int) : Void;    
-    function writeI16(i16 : Int) : Void;    
-    function writeI32(i32 : Int) : Void;    
-    function writeI64(i64 : haxe.Int64) : Void;    
-    function writeDouble(dub : Float) : Void;    
-    function writeString(str : String) : Void;    
-    function writeBinary(bin : Bytes) : Void;    
-	
+    function writeFieldStop() : Void;
+    function writeMapBegin(map:TMap) : Void;
+    function writeMapEnd() : Void;
+    function writeListBegin(list:TList) : Void;
+    function writeListEnd() : Void;
+    function writeSetBegin(set:TSet) : Void;
+    function writeSetEnd() : Void;
+    function writeBool(b : Bool) : Void;
+    function writeByte(b : Int) : Void;
+    function writeI16(i16 : Int) : Void;
+    function writeI32(i32 : Int) : Void;
+    function writeI64(i64 : haxe.Int64) : Void;
+    function writeDouble(dub : Float) : Void;
+    function writeString(str : String) : Void;
+    function writeBinary(bin : Bytes) : Void;
+
     /**
      * Reading methods.
      */
-    function readMessageBegin():TMessage;   
-    function readMessageEnd() : Void;    
-    function readStructBegin():TStruct;    
-    function readStructEnd() : Void;    
-    function readFieldBegin():TField;    
-    function readFieldEnd() : Void;    
-    function readMapBegin():TMap;    
-    function readMapEnd() : Void;    
-    function readListBegin():TList;    
-    function readListEnd() : Void;    
-    function readSetBegin():TSet;    
-    function readSetEnd() : Void;    
-    function readBool() : Bool;    
-    function readByte() : Int;    
-    function readI16() : Int;    
-    function readI32() : Int;    
-    function readI64() : haxe.Int64;     
-    function readDouble() : Float;    
-    function readString() : String;    
+    function readMessageBegin():TMessage;
+    function readMessageEnd() : Void;
+    function readStructBegin():TStruct;
+    function readStructEnd() : Void;
+    function readFieldBegin():TField;
+    function readFieldEnd() : Void;
+    function readMapBegin():TMap;
+    function readMapEnd() : Void;
+    function readListBegin():TList;
+    function readListEnd() : Void;
+    function readSetBegin():TSet;
+    function readSetEnd() : Void;
+    function readBool() : Bool;
+    function readByte() : Int;
+    function readI16() : Int;
+    function readI32() : Int;
+    function readI64() : haxe.Int64;
+    function readDouble() : Float;
+    function readString() : String;
     function readBinary() : Bytes;
 
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx
index dbbcb8c..6e528cb 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TProtocolException.hx
@@ -18,11 +18,11 @@
  */
 
 package org.apache.thrift.protocol;
-  
+
 import org.apache.thrift.TException;
 
 class TProtocolException extends TException {
-    
+
     public static inline var UNKNOWN : Int = 0;
     public static inline var INVALID_DATA : Int = 1;
     public static inline var NEGATIVE_SIZE : Int = 2;
@@ -30,10 +30,10 @@ class TProtocolException extends TException {
     public static inline var BAD_VERSION : Int = 4;
     public static inline var NOT_IMPLEMENTED : Int = 5;
     public static inline var DEPTH_LIMIT : Int = 6;
-  
+
     public function new(error : Int = UNKNOWN, message : String = "") {
       super(message, error);
     }
-    
-  
-}
\ No newline at end of file
+
+
+} 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TProtocolFactory.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TProtocolFactory.hx b/lib/haxe/src/org/apache/thrift/protocol/TProtocolFactory.hx
index d231dbe..1c2d62e 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TProtocolFactory.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TProtocolFactory.hx
@@ -20,7 +20,7 @@
 package org.apache.thrift.protocol;
 
 import org.apache.thrift.transport.TTransport;
-  
+
 interface TProtocolFactory {
      function getProtocol(trans:TTransport):TProtocol;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TSet.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TSet.hx b/lib/haxe/src/org/apache/thrift/protocol/TSet.hx
index 77806e6..44eab36 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TSet.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TSet.hx
@@ -18,15 +18,15 @@
  */
 
 package org.apache.thrift.protocol;
-  
+
 class TSet {
 
     public var elemType : Int;
     public var size : Int;
-  
+
       public function new(t : Int = 0, s : Int = 0) {
         elemType = t;
         size = s;
       }
-      
-}
\ No newline at end of file
+
+}    
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TStruct.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TStruct.hx b/lib/haxe/src/org/apache/thrift/protocol/TStruct.hx
index faeef40..9e0b7dd 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TStruct.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TStruct.hx
@@ -18,13 +18,13 @@
  */
 
 package org.apache.thrift.protocol;
-  
+
 class TStruct {
-    
+
     public var name : String;
-    
+
     public function new(n : String = "") {
       name = n;
     }
-    
-}
\ No newline at end of file
+
+}  
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/protocol/TType.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/protocol/TType.hx b/lib/haxe/src/org/apache/thrift/protocol/TType.hx
index 0534399..1e093c2 100644
--- a/lib/haxe/src/org/apache/thrift/protocol/TType.hx
+++ b/lib/haxe/src/org/apache/thrift/protocol/TType.hx
@@ -18,9 +18,9 @@
  */
 
 package org.apache.thrift.protocol;
-  
+
 class TType {
-    
+
     public static inline var STOP : Int   = 0;
     public static inline var VOID : Int   = 1;
     public static inline var BOOL : Int   = 2;

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/server/TServer.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/server/TServer.hx b/lib/haxe/src/org/apache/thrift/server/TServer.hx
index 37105bd..e689b32 100644
--- a/lib/haxe/src/org/apache/thrift/server/TServer.hx
+++ b/lib/haxe/src/org/apache/thrift/server/TServer.hx
@@ -33,73 +33,74 @@ class TServer
     private var inputProtocolFactory : TProtocolFactory = null;
     private var outputProtocolFactory : TProtocolFactory = null;
 
-	// server events
-	public var serverEventHandler : TServerEventHandler = null;
+    // server events
+    public var serverEventHandler : TServerEventHandler = null;
 
     // Log delegation
     private var _logDelegate : Dynamic->Void  = null;
     public var logDelegate(default,set) : Dynamic->Void;
-	
+
     public function new( processor : TProcessor,
-						 serverTransport : TServerTransport,
-						 inputTransportFactory : TTransportFactory = null,
-						 outputTransportFactory : TTransportFactory = null,
-						 inputProtocolFactory : TProtocolFactory = null,
-						 outputProtocolFactory : TProtocolFactory = null,
-						 logDelegate : Dynamic->Void = null)
+                         serverTransport : TServerTransport,
+                         inputTransportFactory : TTransportFactory = null,
+                         outputTransportFactory : TTransportFactory = null,
+                         inputProtocolFactory : TProtocolFactory = null,
+                         outputProtocolFactory : TProtocolFactory = null,
+                         logDelegate : Dynamic->Void = null)
     {
       this.processor = processor;
       this.serverTransport = serverTransport;
-      this.inputTransportFactory = inputTransportFactory;	
+      this.inputTransportFactory = inputTransportFactory;
       this.outputTransportFactory = outputTransportFactory;
       this.inputProtocolFactory = inputProtocolFactory;
       this.outputProtocolFactory = outputProtocolFactory;
       this.logDelegate = logDelegate;
 
-	  ApplyMissingDefaults();
-	}
-	
-	private function ApplyMissingDefaults() {
-		if( processor == null) 
-			throw "Invalid server configuration: processor missing";
-		if( serverTransport == null)
-			throw "Invalid server configuration: serverTransport missing";
-		if( inputTransportFactory == null)
-			inputTransportFactory = new TTransportFactory();
-		if( outputTransportFactory  == null)
-			outputTransportFactory = new TTransportFactory();
-		if( inputProtocolFactory  == null)
-			inputProtocolFactory = new TBinaryProtocolFactory();
-		if( outputProtocolFactory == null)
-			outputProtocolFactory= new TBinaryProtocolFactory();
-		if( logDelegate == null)
-			logDelegate = DefaultLogDelegate;
+      ApplyMissingDefaults();
+    }
+
+    private function ApplyMissingDefaults() {
+        if( processor == null)
+            throw "Invalid server configuration: processor missing";
+        if( serverTransport == null)
+            throw "Invalid server configuration: serverTransport missing";
+        if( inputTransportFactory == null)
+            inputTransportFactory = new TTransportFactory();
+        if( outputTransportFactory  == null)
+            outputTransportFactory = new TTransportFactory();
+        if( inputProtocolFactory  == null)
+            inputProtocolFactory = new TBinaryProtocolFactory();
+        if( outputProtocolFactory == null)
+            outputProtocolFactory= new TBinaryProtocolFactory();
+        if( logDelegate == null)
+            logDelegate = DefaultLogDelegate;
     }
 
 
-	private function set_logDelegate(value : Dynamic->Void) : Dynamic->Void {
-		if(value != null) {
-			_logDelegate = value;
-		} else {
-			_logDelegate = DefaultLogDelegate; 
-		}
-		return _logDelegate;
+    private function set_logDelegate(value : Dynamic->Void) : Dynamic->Void {
+        if(value != null) {
+            _logDelegate = value;
+        } else {
+            _logDelegate = DefaultLogDelegate;
+        }
+        return _logDelegate;
     }
-    
-		
-	private function DefaultLogDelegate(value : Dynamic) : Void  {
-		trace( value);
+
+
+    private function DefaultLogDelegate(value : Dynamic) : Void  {
+        trace( value);
     }
 
-    
-		
+
+
     public function Serve() : Void {
-		throw new AbstractMethodError();
-	}
-		
-	
+        throw new AbstractMethodError();
+    }
+
+
     public function Stop() : Void {
-		throw new AbstractMethodError();
-	}
-	
+        throw new AbstractMethodError();
+    }
+
 }
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/server/TServerEventHandler.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/server/TServerEventHandler.hx b/lib/haxe/src/org/apache/thrift/server/TServerEventHandler.hx
index 83bff95..9bc9927 100644
--- a/lib/haxe/src/org/apache/thrift/server/TServerEventHandler.hx
+++ b/lib/haxe/src/org/apache/thrift/server/TServerEventHandler.hx
@@ -27,15 +27,15 @@ import org.apache.thrift.protocol.*;
 // Interface implemented by server users to handle events from the server
 interface TServerEventHandler {
 
-	// Called before the server begins 
+    // Called before the server begins
     function preServe() : Void;
-	
-    // Called when a new client has connected and is about to being processing 
+
+    // Called when a new client has connected and is about to being processing
     function createContext( input : TProtocol, output : TProtocol) : Dynamic;
-    
-	// Called when a client has finished request-handling to delete server context 
+
+    // Called when a client has finished request-handling to delete server context
     function deleteContext( serverContext : Dynamic, input : TProtocol, output : TProtocol) : Void;
-    
-	// Called when a client is about to call the processor 
+
+    // Called when a client is about to call the processor
     function processContext( serverContext : Dynamic, transport : TTransport) : Void;
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/server/TSimpleServer.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/server/TSimpleServer.hx b/lib/haxe/src/org/apache/thrift/server/TSimpleServer.hx
index c516b78..cb7cbd6 100644
--- a/lib/haxe/src/org/apache/thrift/server/TSimpleServer.hx
+++ b/lib/haxe/src/org/apache/thrift/server/TSimpleServer.hx
@@ -30,92 +30,92 @@ class TSimpleServer extends TServer  {
     private var stop : Bool = false;
 
     public function new( processor : TProcessor,
-						 serverTransport : TServerTransport,
-						 transportFactory : TTransportFactory = null,
-						 protocolFactory : TProtocolFactory = null,
-						 logDelegate : Dynamic->Void = null) {
+                         serverTransport : TServerTransport,
+                         transportFactory : TTransportFactory = null,
+                         protocolFactory : TProtocolFactory = null,
+                         logDelegate : Dynamic->Void = null) {
       super( processor, serverTransport,
-			 transportFactory, transportFactory,
-			 protocolFactory, protocolFactory,
-			 logDelegate);
+             transportFactory, transportFactory,
+             protocolFactory, protocolFactory,
+             logDelegate);
     }
 
 
-	
-    public override function Serve() : Void 
-	{
-		try
-		{
-			serverTransport.Listen();
-		}
-		catch (ttx : TTransportException)
-		{
-			logDelegate(ttx);
-			return;
-		}
 
-		// Fire the preServe server event when server is up, 
-		// but before any client connections
-		if (serverEventHandler != null) {
-			serverEventHandler.preServe();
-		}
+    public override function Serve() : Void
+    {
+        try
+        {
+            serverTransport.Listen();
+        }
+        catch (ttx : TTransportException)
+        {
+            logDelegate(ttx);
+            return;
+        }
+
+        // Fire the preServe server event when server is up,
+        // but before any client connections
+        if (serverEventHandler != null) {
+            serverEventHandler.preServe();
+        }
 
-		while( ! stop)
-		{
-			var client : TTransport = null;
-			var inputTransport : TTransport = null;
-			var outputTransport : TTransport = null;
-			var inputProtocol : TProtocol = null;
-			var outputProtocol : TProtocol = null;
-			var connectionContext : Dynamic = null;
-			try
-			{
-				client = serverTransport.Accept();
-				if (client != null) {
-					inputTransport = inputTransportFactory.getTransport( client);
-					outputTransport = outputTransportFactory.getTransport( client);
-					inputProtocol = inputProtocolFactory.getProtocol( inputTransport);
-					outputProtocol = outputProtocolFactory.getProtocol( outputTransport);
+        while( ! stop)
+        {
+            var client : TTransport = null;
+            var inputTransport : TTransport = null;
+            var outputTransport : TTransport = null;
+            var inputProtocol : TProtocol = null;
+            var outputProtocol : TProtocol = null;
+            var connectionContext : Dynamic = null;
+            try
+            {
+                client = serverTransport.Accept();
+                if (client != null) {
+                    inputTransport = inputTransportFactory.getTransport( client);
+                    outputTransport = outputTransportFactory.getTransport( client);
+                    inputProtocol = inputProtocolFactory.getProtocol( inputTransport);
+                    outputProtocol = outputProtocolFactory.getProtocol( outputTransport);
 
-					// Recover event handler (if any) and fire createContext 
-					// server event when a client connects
-					if (serverEventHandler != null) {
-						connectionContext = serverEventHandler.createContext(inputProtocol, outputProtocol);
-					}
+                    // Recover event handler (if any) and fire createContext
+                    // server event when a client connects
+                    if (serverEventHandler != null) {
+                        connectionContext = serverEventHandler.createContext(inputProtocol, outputProtocol);
+                    }
 
-					// Process client requests until client disconnects
-					while( true) {
-						// Fire processContext server event
-						// N.B. This is the pattern implemented in C++ and the event fires provisionally.
-						// That is to say it may be many minutes between the event firing and the client request
-						// actually arriving or the client may hang up without ever makeing a request.
-						if (serverEventHandler != null) {
-							serverEventHandler.processContext(connectionContext, inputTransport);
-						}
-							
-						//Process client request (blocks until transport is readable)
-						if( ! processor.process( inputProtocol, outputProtocol)) {
-							break;
-						}
-					}
-				}
-			}
-			catch( ttx : TTransportException)
-			{
-			  	// Usually a client disconnect, expected
-			}
-			catch( e : Dynamic)
-			{
-				// Unexpected
-			  	logDelegate(e); 
-			}
+                    // Process client requests until client disconnects
+                    while( true) {
+                        // Fire processContext server event
+                        // N.B. This is the pattern implemented in C++ and the event fires provisionally.
+                        // That is to say it may be many minutes between the event firing and the client request
+                        // actually arriving or the client may hang up without ever makeing a request.
+                        if (serverEventHandler != null) {
+                            serverEventHandler.processContext(connectionContext, inputTransport);
+                        }
 
-			// Fire deleteContext server event after client disconnects
-			if (serverEventHandler != null) {
-				serverEventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
-			}
-		}
-	}
+                        //Process client request (blocks until transport is readable)
+                        if( ! processor.process( inputProtocol, outputProtocol)) {
+                            break;
+                        }
+                    }
+                }
+            }
+            catch( ttx : TTransportException)
+            {
+                  // Usually a client disconnect, expected
+            }
+            catch( e : Dynamic)
+            {
+                // Unexpected
+                  logDelegate(e);
+            }
+
+            // Fire deleteContext server event after client disconnects
+            if (serverEventHandler != null) {
+                serverEventHandler.deleteContext(connectionContext, inputProtocol, outputProtocol);
+            }
+        }
+    }
 
     public override function Stop() : Void
     {

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx b/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx
index 03e031f..cd8ad17 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TFileStream.hx
@@ -26,75 +26,76 @@ import haxe.io.Output;
 
 
 enum TFileMode {
-	CreateNew;
-	Append;
-	Read;
+    CreateNew;
+    Append;
+    Read;
 }
-	
+
 
 class TFileStream implements TStream {
 
-	public var FileName(default,null) : String;
-	
-	private var Input  : sys.io.FileInput;
-	private var Output : sys.io.FileOutput;
-	
-	
-	public function new( fname : String, mode : TFileMode) {
-		FileName = fname;	
-		switch ( mode)
-		{
-			case TFileMode.CreateNew:
-				Output = sys.io.File.write( fname, true);
-
-			case TFileMode.Append:
-				Output = sys.io.File.append( fname, true);
-
-			case TFileMode.Read:
-				Input = sys.io.File.read( fname, true);
-
-			default:
-				throw new TTransportException( TTransportException.UNKNOWN,
-											   "Unsupported mode");
-		}
-
-	}
-	
-	public function Close() : Void {
-		if( Input != null) {
-			Input.close();
-			Input = null;
-		}
-		if( Output != null) { 
-			Output.close();
-			Output = null;
-		}
-	}
-	
-	public function Peek() : Bool {
-		if( Input == null)
-			throw new TTransportException( TTransportException.NOT_OPEN, "File not open for input");
-
-		return (! Input.eof());
-	}
-	
-	public function Read( buf : Bytes, offset : Int, count : Int) : Int {
-		if( Input == null)
-			throw new TTransportException( TTransportException.NOT_OPEN, "File not open for input");
-
-		return Input.readBytes( buf, offset, count);
-	}
-	
-	public function Write( buf : Bytes, offset : Int, count : Int) : Void {
-		if( Output == null)
-			throw new TTransportException( TTransportException.NOT_OPEN, "File not open for output");
-		
-		Output.writeBytes( buf, offset, count);			
-	}
-
-	public function Flush() : Void {
-		if( Output != null) 
-			Output.flush();
-	}
-	
+    public var FileName(default,null) : String;
+
+    private var Input  : sys.io.FileInput;
+    private var Output : sys.io.FileOutput;
+
+
+    public function new( fname : String, mode : TFileMode) {
+        FileName = fname;
+        switch ( mode)
+        {
+            case TFileMode.CreateNew:
+                Output = sys.io.File.write( fname, true);
+
+            case TFileMode.Append:
+                Output = sys.io.File.append( fname, true);
+
+            case TFileMode.Read:
+                Input = sys.io.File.read( fname, true);
+
+            default:
+                throw new TTransportException( TTransportException.UNKNOWN,
+                                               "Unsupported mode");
+        }
+
+    }
+
+    public function Close() : Void {
+        if( Input != null) {
+            Input.close();
+            Input = null;
+        }
+        if( Output != null) {
+            Output.close();
+            Output = null;
+        }
+    }
+
+    public function Peek() : Bool {
+        if( Input == null)
+            throw new TTransportException( TTransportException.NOT_OPEN, "File not open for input");
+
+        return (! Input.eof());
+    }
+
+    public function Read( buf : Bytes, offset : Int, count : Int) : Int {
+        if( Input == null)
+            throw new TTransportException( TTransportException.NOT_OPEN, "File not open for input");
+
+        return Input.readBytes( buf, offset, count);
+    }
+
+    public function Write( buf : Bytes, offset : Int, count : Int) : Void {
+        if( Output == null)
+            throw new TTransportException( TTransportException.NOT_OPEN, "File not open for output");
+
+        Output.writeBytes( buf, offset, count);
+    }
+
+    public function Flush() : Void {
+        if( Output != null)
+            Output.flush();
+    }
+
 }
+ 
\ No newline at end of file