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:48 UTC

[3/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/transport/TFramedTransport.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TFramedTransport.hx b/lib/haxe/src/org/apache/thrift/transport/TFramedTransport.hx
index 77335e7..5f0168a 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TFramedTransport.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TFramedTransport.hx
@@ -56,86 +56,86 @@ class TFramedTransport extends TTransport
      * Constructor wraps around another transport
      */
     public function new( transport : TTransport, maxLength : Int = DEFAULT_MAX_LENGTH) {
-    	transport_ = transport;
-    	maxLength_ = maxLength;
+        transport_ = transport;
+        maxLength_ = maxLength;
     }
 
     public override function open() : Void {
-    	transport_.open();
+        transport_.open();
     }
 
     public override function isOpen() : Bool {
-    	return transport_.isOpen();
+        return transport_.isOpen();
     }
 
     public override function close() : Void {
-    	transport_.close();
+        transport_.close();
     }
 
     public override function read(buf : BytesBuffer, off : Int, len : Int) : Int {
-		var data = Bytes.alloc(len);
-		
-    	if (readBuffer_ != null) {
-    		var got : Int = readBuffer_.readBytes(data, off, len);
-    		if (got > 0) {
-				buf.addBytes(data,0,got);
-    			return got;
-    		};
-    	};
-		
-    	// Read another frame of data
-    	readFrame();
-
-    	var got = readBuffer_.readBytes(data, off, len);
-		buf.addBytes(data,0,got);
-		return got;
+        var data = Bytes.alloc(len);
+
+        if (readBuffer_ != null) {
+            var got : Int = readBuffer_.readBytes(data, off, len);
+            if (got > 0) {
+                buf.addBytes(data,0,got);
+                return got;
+            };
+        };
+
+        // Read another frame of data
+        readFrame();
+
+        var got = readBuffer_.readBytes(data, off, len);
+        buf.addBytes(data,0,got);
+        return got;
     }
 
 
     function readFrameSize() : Int {
-    	var buffer = new BytesBuffer();
-    	var len = transport_.readAll( buffer, 0, 4);
-    	var inp = new BytesInput( buffer.getBytes(), 0, 4);
-    	inp.bigEndian = true;
-    	return inp.readInt32();
+        var buffer = new BytesBuffer();
+        var len = transport_.readAll( buffer, 0, 4);
+        var inp = new BytesInput( buffer.getBytes(), 0, 4);
+        inp.bigEndian = true;
+        return inp.readInt32();
     }
 
 
     function readFrame() : Void {
-    	var size : Int = readFrameSize();
-		
-    	if (size < 0) {
-    		throw new TTransportException(TTransportException.UNKNOWN, 'Read a negative frame size ($size)!');
-    	};
-    	if (size > maxLength_) {
-    		throw new TTransportException(TTransportException.UNKNOWN, 'Frame size ($size) larger than max length ($maxLength_)!');
-    	};
-
-    	var buffer = new BytesBuffer();
-    	size = transport_.readAll( buffer, 0, size);
-    	readBuffer_ = new BytesInput( buffer.getBytes(), 0, size);
-    	readBuffer_.bigEndian = true;
+        var size : Int = readFrameSize();
+
+        if (size < 0) {
+            throw new TTransportException(TTransportException.UNKNOWN, 'Read a negative frame size ($size)!');
+        };
+        if (size > maxLength_) {
+            throw new TTransportException(TTransportException.UNKNOWN, 'Frame size ($size) larger than max length ($maxLength_)!');
+        };
+
+        var buffer = new BytesBuffer();
+        size = transport_.readAll( buffer, 0, size);
+        readBuffer_ = new BytesInput( buffer.getBytes(), 0, size);
+        readBuffer_.bigEndian = true;
     }
 
     public override function write(buf : Bytes, off : Int, len : Int) : Void {
-    	writeBuffer_.writeBytes(buf, off, len);
+        writeBuffer_.writeBytes(buf, off, len);
     }
 
     function writeFrameSize(len : Int) : Void {
-		var out = new BytesOutput();
-		out.bigEndian = true;
-		out.writeInt32(len);
-		transport_.write(out.getBytes(), 0, 4);
+        var out = new BytesOutput();
+        out.bigEndian = true;
+        out.writeInt32(len);
+        transport_.write(out.getBytes(), 0, 4);
     }
 
     public override function flush( callback : Dynamic->Void =null) : Void {
-    	var buf : Bytes = writeBuffer_.getBytes();
-    	var len : Int = buf.length;
-    	writeBuffer_ = new BytesOutput();
+        var buf : Bytes = writeBuffer_.getBytes();
+        var len : Int = buf.length;
+        writeBuffer_ = new BytesOutput();
 
-		writeFrameSize(len);
-    	transport_.write(buf, 0, len);
-    	transport_.flush();
+        writeFrameSize(len);
+        transport_.write(buf, 0, len);
+        transport_.flush();
     }
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TFramedTransportFactory.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TFramedTransportFactory.hx b/lib/haxe/src/org/apache/thrift/transport/TFramedTransportFactory.hx
index 3cca1f8..8d45a64 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TFramedTransportFactory.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TFramedTransportFactory.hx
@@ -27,11 +27,11 @@ class TFramedTransportFactory extends TTransportFactory {
     var maxLength_ : Int;
 
     public function new(maxLength : Int = TFramedTransport.DEFAULT_MAX_LENGTH) {
-		super();
-    	maxLength_ = maxLength;
+        super();
+        maxLength_ = maxLength;
     }
 
     public override function getTransport(base : TTransport) : TTransport {
-    	return new TFramedTransport(base, maxLength_);
+        return new TFramedTransport(base, maxLength_);
     }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx b/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx
index 4e898f8..3cd2e51 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TFullDuplexHttpClient.hx
@@ -73,15 +73,15 @@ import flash.events.EventDispatcher;
             socket.close()
         }
 
-    	public override function peek()  :  Bool
-    	{
-			if(socket.connected)
-			{
-				trace("Bytes remained:" + socket.bytesAvailable);
-				return socket.bytesAvailable>0;
-			}
-			return false;
-		}
+        public override function peek()  :  Bool
+        {
+            if(socket.connected)
+            {
+                trace("Bytes remained:" + socket.bytesAvailable);
+                return socket.bytesAvailable>0;
+            }
+            return false;
+        }
 
         public override function read(buf : Bytes, off  :  Int, len  :  Int)  :  Int
         {
@@ -137,11 +137,11 @@ import flash.events.EventDispatcher;
                 trace(e);
                 throw new TTransportException(TTransportException.UNKNOWN, "No more data available.");
             }
-			catch (e : TException)
-			{
-				trace('TException $e');
-				throw e;
-			}
+            catch (e : TException)
+            {
+                trace('TException $e');
+                throw e;
+            }
             catch (e : Error)
             {
                 trace(e);
@@ -217,7 +217,7 @@ import flash.events.EventDispatcher;
 
         public function socketDataHandler(event : ProgressEvent)  :  Void
         {
-        	trace("Got Data call:" +ioCallback);
+            trace("Got Data call:" +ioCallback);
             if (ioCallback != null)
             {
                 ioCallback(null);

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/THttpClient.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/THttpClient.hx b/lib/haxe/src/org/apache/thrift/transport/THttpClient.hx
index 52a9d26..79f8661 100644
--- a/lib/haxe/src/org/apache/thrift/transport/THttpClient.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/THttpClient.hx
@@ -19,7 +19,7 @@
 
 package org.apache.thrift.transport;
 
-	
+
 import haxe.io.Bytes;
 import haxe.io.BytesBuffer;
 import haxe.io.BytesOutput;
@@ -28,76 +28,76 @@ import haxe.io.BytesInput;
 import haxe.Http;
 
 
-	
+
 /**
 * HTTP implementation of the TTransport interface. Used for working with a
 * Thrift web services implementation.
 */
-	
+
 class THttpClient extends TTransport {
 
     private var requestBuffer_  : BytesOutput = new BytesOutput();
     private var responseBuffer_ : BytesInput = null;
 
-	private var request_        : Http = null;
+    private var request_        : Http = null;
+
 
-    
-	public function new( requestUrl : String) : Void {
-	  	request_ = new Http(requestUrl);
-		request_.addHeader( "contentType", "application/x-thrift");
+    public function new( requestUrl : String) : Void {
+          request_ = new Http(requestUrl);
+        request_.addHeader( "contentType", "application/x-thrift");
     }
-    
-   
+
+
     public override function open() : Void {
     }
 
     public override function close() : Void {
     }
- 
+
     public override function isOpen() : Bool {
       return true;
     }
-    
+
     public override function read(buf:BytesBuffer, off : Int, len : Int) : Int {
-		if (responseBuffer_ == null) {
-        	throw new TTransportException(TTransportException.UNKNOWN, "Response buffer is empty, no request.");
-		}
-		
+        if (responseBuffer_ == null) {
+            throw new TTransportException(TTransportException.UNKNOWN, "Response buffer is empty, no request.");
+        }
+
         var data =Bytes.alloc(len);
-		len = responseBuffer_.readBytes(data, off, len);
-		buf.addBytes(data,0,len);
-		return len;
+        len = responseBuffer_.readBytes(data, off, len);
+        buf.addBytes(data,0,len);
+        return len;
     }
 
     public override function write(buf:Bytes, off : Int, len : Int) : Void {
       requestBuffer_.writeBytes(buf, off, len);
     }
 
-	
+
     public override function flush(callback:Dynamic->Void = null) : Void {
-		var buffer = requestBuffer_;
-		requestBuffer_ = new BytesOutput();
-		responseBuffer_ = null;
-			
-		request_.onData = function(data : String) { 
-			var tmp = new BytesBuffer();
-			tmp.addString(data);
-			responseBuffer_ = new BytesInput(tmp.getBytes());
-			if( callback != null) {
-				callback(null);
-			}
-		};
-		
-		request_.onError = function(msg : String) {
-			if( callback != null) {
-				callback(new TTransportException(TTransportException.UNKNOWN, "IOError: " + msg));
-			}
-		};
-		
-		request_.setPostData(buffer.getBytes().toString());
-		request_.request(true/*POST*/);
+        var buffer = requestBuffer_;
+        requestBuffer_ = new BytesOutput();
+        responseBuffer_ = null;
+
+        request_.onData = function(data : String) {
+            var tmp = new BytesBuffer();
+            tmp.addString(data);
+            responseBuffer_ = new BytesInput(tmp.getBytes());
+            if( callback != null) {
+                callback(null);
+            }
+        };
+
+        request_.onError = function(msg : String) {
+            if( callback != null) {
+                callback(new TTransportException(TTransportException.UNKNOWN, "IOError: " + msg));
+            }
+        };
+
+        request_.setPostData(buffer.getBytes().toString());
+        request_.request(true/*POST*/);
     }
-		
+
 }
 
-	
\ 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/transport/TServerSocket.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TServerSocket.hx b/lib/haxe/src/org/apache/thrift/transport/TServerSocket.hx
index 0eae931..f38b584 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TServerSocket.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TServerSocket.hx
@@ -19,7 +19,7 @@
 
 package org.apache.thrift.transport;
 
-import haxe.remoting.SocketProtocol;	
+import haxe.remoting.SocketProtocol;
 import haxe.io.Bytes;
 import haxe.io.BytesBuffer;
 import haxe.io.BytesInput;
@@ -29,104 +29,104 @@ import haxe.io.Output;
 import haxe.io.Eof;
 
 //import flash.net.ServerSocket; - not yet available on Haxe 3.1.3
-#if ! (flash || html5) 
-	
+#if ! (flash || html5)
+
 import sys.net.Host;
 
 
 class TServerSocket extends TServerTransport {
 
-	// Underlying server with socket
-	private var _socket : Socket= null;
-
-	// Port to listen on
-	private var _port : Int = 0;
-
-	// Timeout for client sockets from accept
-	private var _clientTimeout : Int = 0;
-
-	// Whether or not to wrap new TSocket connections in buffers
-	private var _useBufferedSockets : Bool = false;
-
-	
-	public function new( port : Int, clientTimeout : Int = 0, useBufferedSockets : Bool = false)
-	{
-		_port = port;
-		_clientTimeout = clientTimeout;
-		_useBufferedSockets = useBufferedSockets;
-
-		try
-		{
-			_socket = new Socket();
-			_socket.bind( new Host('localhost'), port);
-		}
-		catch (e : Dynamic)
-		{
-			_socket = null;
-			throw new TTransportException( TTransportException.UNKNOWN, 'Could not create ServerSocket on port $port: $e');
-		}
-	}
-
-
-	public override function Listen() : Void
-	{
-		// Make sure not to block on accept
-		if (_socket != null)	{
-			try
-			{
-				_socket.listen(1);
-			}
-			catch (e : Dynamic)
-			{
-				trace('Error $e');
-				throw new TTransportException( TTransportException.UNKNOWN, 'Could not accept on listening socket: $e');
-			}
-		}
-	}
-
-	private override function AcceptImpl() : TTransport
-	{
-		if (_socket == null) {
-			throw new TTransportException( TTransportException.NOT_OPEN, "No underlying server socket.");
-		}
-		
-		try
-		{
-			var accepted = _socket.accept();
-			var result = TSocket.fromSocket(accepted);
-			accepted.setTimeout( _clientTimeout);
-
-			if( _useBufferedSockets)
-			{
-				throw "buffered transport not yet supported";  // TODO
-				//result = new TBufferedTransport(result);
-			}
-
-			return result;
-		}
-		catch (e : Dynamic)
-		{
-			trace('Error $e');
-			throw new TTransportException( TTransportException.UNKNOWN, '$e');
-		}
-	}
-
-	public override function Close() : Void
-	{
-		if (_socket != null)
-		{
-			try
-			{
-				_socket.close();
-			}
-			catch (e : Dynamic)
-			{
-				trace('Error $e');
-				throw new TTransportException( TTransportException.UNKNOWN, 'WARNING: Could not close server socket: $e');
-			}
-			_socket = null;
-		}
-	}
+    // Underlying server with socket
+    private var _socket : Socket= null;
+
+    // Port to listen on
+    private var _port : Int = 0;
+
+    // Timeout for client sockets from accept
+    private var _clientTimeout : Int = 0;
+
+    // Whether or not to wrap new TSocket connections in buffers
+    private var _useBufferedSockets : Bool = false;
+
+
+    public function new( port : Int, clientTimeout : Int = 0, useBufferedSockets : Bool = false)
+    {
+        _port = port;
+        _clientTimeout = clientTimeout;
+        _useBufferedSockets = useBufferedSockets;
+
+        try
+        {
+            _socket = new Socket();
+            _socket.bind( new Host('localhost'), port);
+        }
+        catch (e : Dynamic)
+        {
+            _socket = null;
+            throw new TTransportException( TTransportException.UNKNOWN, 'Could not create ServerSocket on port $port: $e');
+        }
+    }
+
+
+    public override function Listen() : Void
+    {
+        // Make sure not to block on accept
+        if (_socket != null)    {
+            try
+            {
+                _socket.listen(1);
+            }
+            catch (e : Dynamic)
+            {
+                trace('Error $e');
+                throw new TTransportException( TTransportException.UNKNOWN, 'Could not accept on listening socket: $e');
+            }
+        }
+    }
+
+    private override function AcceptImpl() : TTransport
+    {
+        if (_socket == null) {
+            throw new TTransportException( TTransportException.NOT_OPEN, "No underlying server socket.");
+        }
+
+        try
+        {
+            var accepted = _socket.accept();
+            var result = TSocket.fromSocket(accepted);
+            accepted.setTimeout( _clientTimeout);
+
+            if( _useBufferedSockets)
+            {
+                throw "buffered transport not yet supported";  // TODO
+                //result = new TBufferedTransport(result);
+            }
+
+            return result;
+        }
+        catch (e : Dynamic)
+        {
+            trace('Error $e');
+            throw new TTransportException( TTransportException.UNKNOWN, '$e');
+        }
+    }
+
+    public override function Close() : Void
+    {
+        if (_socket != null)
+        {
+            try
+            {
+                _socket.close();
+            }
+            catch (e : Dynamic)
+            {
+                trace('Error $e');
+                throw new TTransportException( TTransportException.UNKNOWN, 'WARNING: Could not close server socket: $e');
+            }
+            _socket = null;
+        }
+    }
 }
 
 #end

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TServerTransport.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TServerTransport.hx b/lib/haxe/src/org/apache/thrift/transport/TServerTransport.hx
index 5819803..2189981 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TServerTransport.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TServerTransport.hx
@@ -21,23 +21,23 @@ package org.apache.thrift.transport;
 
 class TServerTransport {
 
-	public function Accept() : TTransport {
-		var transport = AcceptImpl();
-		if (transport == null) {
-		  throw new TTransportException( TTransportException.UNKNOWN, "accept() may not return NULL");
-		}
-		return transport;
-	}
-	
-	public function Listen() : Void {
-		throw new AbstractMethodError();
-	}
-	
-	public function Close() : Void {
-		throw new AbstractMethodError();
-	}
-	
-	private function AcceptImpl() : TTransport {
-		throw new AbstractMethodError();
-	}
+    public function Accept() : TTransport {
+        var transport = AcceptImpl();
+        if (transport == null) {
+          throw new TTransportException( TTransportException.UNKNOWN, "accept() may not return NULL");
+        }
+        return transport;
+    }
+
+    public function Listen() : Void {
+        throw new AbstractMethodError();
+    }
+
+    public function Close() : Void {
+        throw new AbstractMethodError();
+    }
+
+    private function AcceptImpl() : TTransport {
+        throw new AbstractMethodError();
+    }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TSocket.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TSocket.hx b/lib/haxe/src/org/apache/thrift/transport/TSocket.hx
index 306730d..9d5e2dc 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TSocket.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TSocket.hx
@@ -24,7 +24,7 @@ import flash.net.Socket;
 #elseif js
 import js.html.WebSocket;
 #else
-import haxe.remoting.SocketProtocol;	
+import haxe.remoting.SocketProtocol;
 #end
 
 import haxe.io.Bytes;
@@ -47,250 +47,250 @@ import sys.net.Host;
    */
 
 class TSocket extends TTransport  {
-	
+
     #if (flash || js)
-	private var host  :  String;
-	#else
-	private var host  :  Host;
-	#end
-	
+    private var host  :  String;
+    #else
+    private var host  :  Host;
+    #end
+
     private var port  :  Int;
 
-	#if js
+    #if js
     private var socket : WebSocket = null;
-	#else
+    #else
     private var socket : Socket = null;
-	#end
+    #end
 
-	#if js
+    #if js
     private var input : Dynamic = null;
     private var output : WebSocket = null;
-	#elseif flash
+    #elseif flash
     private var input : Socket = null;
     private var output : Socket = null;
-	#else 
-	private var input : Input = null;
+    #else
+    private var input : Input = null;
     private var output : Output = null;
-	#end
+    #end
 
-	private var obuffer : BytesOutput = new BytesOutput();
+    private var obuffer : BytesOutput = new BytesOutput();
     private var ioCallback : TException->Void = null;
-	private var readCount : Int = 0;
-	
+    private var readCount : Int = 0;
+
     public function new(host : String, port  :  Int)  :  Void  {
-		#if (flash || js)
-		this.host = host;
-		#else
-		this.host = new Host(host);
-		#end
-		this.port = port;
+        #if (flash || js)
+        this.host = host;
+        #else
+        this.host = new Host(host);
+        #end
+        this.port = port;
     }
 
-	#if ! (flash || js)
-	// used by TSocketServer
+    #if ! (flash || js)
+    // used by TSocketServer
     public static function fromSocket( socket : Socket) : TSocket  {
-		var result = new TSocket("",0);
-		result.assignSocket(socket);
-		return result;
+        var result = new TSocket("",0);
+        result.assignSocket(socket);
+        return result;
     }
-	#end
+    #end
 
     public override function close()  :  Void  {
-		input = null;
-		output = null;
-		socket.close();
+        input = null;
+        output = null;
+        socket.close();
     }
 
     public override function peek()  :  Bool  {
-		if( (input == null) || (socket == null)) {
-			return false;
-		} else {
-			#if flash 
-			return (input.bytesAvailable > 0);
-			#elseif js
-			return true;
-			#else
-			var ready = Socket.select( [socket], null, null, 0);
-			return (ready.read.length > 0);
-			#end
-		}
+        if( (input == null) || (socket == null)) {
+            return false;
+        } else {
+            #if flash
+            return (input.bytesAvailable > 0);
+            #elseif js
+            return true;
+            #else
+            var ready = Socket.select( [socket], null, null, 0);
+            return (ready.read.length > 0);
+            #end
+        }
     }
 
-	
-	public override function read( buf : BytesBuffer, off : Int, len : Int) : Int   {
-		try
-		{
-			#if flash
-
-			var remaining = len;	
-			while( remaining > 0) {
-				buf.addByte( input.readByte());
-				--remaining;
-			}
-			return len;
-			
-			#elseif js
-			
-			if( input == null) {
-				throw new TTransportException(TTransportException.UNKNOWN, "Still no data ");  // don't block
-			}
-			var nr = len;	
-			while( nr < len) {
-				buf.addByte( input.get(off+nr));
-				++nr;
-			}
-			return len;
-			
-			#else
-			
-			socket.waitForRead();
-			if(readCount < off) {
-				input.read(off-readCount);	
-				readCount = off;
-			}
-			var data = input.read(len);
-			readCount += data.length;
-			buf.add(data);
-			return data.length;
-			
-			#end
-		}
-		catch (e : Eof)
-		{
-			trace('Eof $e');
-			throw new TTransportException(TTransportException.END_OF_FILE, "No more data available.");
-		}
-		catch (e : TException)
-		{
-			trace('TException $e');
-			throw e;
-		}
-		catch (e : Dynamic)
-		{
-			trace('Error $e');
-			throw new TTransportException(TTransportException.UNKNOWN, 'Bad IO error : $e');
-		}
+
+    public override function read( buf : BytesBuffer, off : Int, len : Int) : Int   {
+        try
+        {
+            #if flash
+
+            var remaining = len;
+            while( remaining > 0) {
+                buf.addByte( input.readByte());
+                --remaining;
+            }
+            return len;
+
+            #elseif js
+
+            if( input == null) {
+                throw new TTransportException(TTransportException.UNKNOWN, "Still no data ");  // don't block
+            }
+            var nr = len;
+            while( nr < len) {
+                buf.addByte( input.get(off+nr));
+                ++nr;
+            }
+            return len;
+
+            #else
+
+            socket.waitForRead();
+            if(readCount < off) {
+                input.read(off-readCount);
+                readCount = off;
+            }
+            var data = input.read(len);
+            readCount += data.length;
+            buf.add(data);
+            return data.length;
+
+            #end
+        }
+        catch (e : Eof)
+        {
+            trace('Eof $e');
+            throw new TTransportException(TTransportException.END_OF_FILE, "No more data available.");
+        }
+        catch (e : TException)
+        {
+            trace('TException $e');
+            throw e;
+        }
+        catch (e : Dynamic)
+        {
+            trace('Error $e');
+            throw new TTransportException(TTransportException.UNKNOWN, 'Bad IO error : $e');
+        }
     }
-		
-	
+
+
     public override function write(buf : Bytes, off  :  Int, len  :  Int)  :  Void
     {
-		obuffer.writeBytes(buf, off, len);
+        obuffer.writeBytes(buf, off, len);
     }
 
 
-		
+
     public override function flush(callback : Dynamic->Void = null)  :  Void
     {
-		if( ! isOpen())
-		{
-			throw new TTransportException(TTransportException.NOT_OPEN, "Transport not open");
-		}
-
-		#if flash
-			
-		var bytes = new flash.utils.ByteArray();
-		var data = obuffer.getBytes();
-		var len = 0;
-		while( len < data.length) {
-			bytes.writeByte(data.get(len));
-			++len;
-		}
-
-		#elseif js
-		
-		var data = obuffer.getBytes();
-		var outbuf = new js.html.Int8Array(data.length);
-		var len = 0;
-		while( len < data.length) {
-			outbuf.set( [data.get(len)], len);
-			++len;
-		}
-		var bytes = outbuf.buffer;
-		
-
-		#else
-		
-		var bytes = obuffer.getBytes();
-		var len = bytes.length;
-		
-		#end
-			
-		obuffer = new BytesOutput();
-
-		
-		ioCallback = callback;
-		try {
-			readCount = 0;
-			#if js
-			output.send( bytes);
-			#else
-			output.writeBytes( bytes, 0, bytes.length);
-			#end
-			if(ioCallback != null) {
-				ioCallback(null);  // success call 
-			}
-		}
-		catch (e : TException)
-		{
-			trace('TException $e');
-			if(ioCallback != null) {
-				ioCallback(e);
-			}
-		}
-		catch (e : Dynamic) {
-			trace(e);
-			if(ioCallback != null) {
-				ioCallback(new TTransportException(TTransportException.UNKNOWN, 'Bad IO error : $e'));
-			}
-		}
+        if( ! isOpen())
+        {
+            throw new TTransportException(TTransportException.NOT_OPEN, "Transport not open");
+        }
+
+        #if flash
+
+        var bytes = new flash.utils.ByteArray();
+        var data = obuffer.getBytes();
+        var len = 0;
+        while( len < data.length) {
+            bytes.writeByte(data.get(len));
+            ++len;
+        }
+
+        #elseif js
+
+        var data = obuffer.getBytes();
+        var outbuf = new js.html.Int8Array(data.length);
+        var len = 0;
+        while( len < data.length) {
+            outbuf.set( [data.get(len)], len);
+            ++len;
+        }
+        var bytes = outbuf.buffer;
+
+
+        #else
+
+        var bytes = obuffer.getBytes();
+        var len = bytes.length;
+
+        #end
+
+        obuffer = new BytesOutput();
+
+
+        ioCallback = callback;
+        try {
+            readCount = 0;
+            #if js
+            output.send( bytes);
+            #else
+            output.writeBytes( bytes, 0, bytes.length);
+            #end
+            if(ioCallback != null) {
+                ioCallback(null);  // success call
+            }
+        }
+        catch (e : TException)
+        {
+            trace('TException $e');
+            if(ioCallback != null) {
+                ioCallback(e);
+            }
+        }
+        catch (e : Dynamic) {
+            trace(e);
+            if(ioCallback != null) {
+                ioCallback(new TTransportException(TTransportException.UNKNOWN, 'Bad IO error : $e'));
+            }
+        }
     }
 
     public override function isOpen()  :  Bool
     {
-		return (socket != null);
+        return (socket != null);
     }
 
     public override function open()  :  Void
     {
-		#if js
-		var socket = new WebSocket();
-		socket.onmessage = function( event : js.html.MessageEvent) {
-			this.input = event.data;
-		}
-		
-		#elseif flash
-			
-		var socket = new Socket();
-		socket.connect(host, port);
-
-		#else
-			
-		var socket = new Socket();
-		socket.setBlocking(true);
-		socket.setFastSend(true);
-		socket.connect(host, port);
-
-		#end
-			
-		assignSocket( socket);
+        #if js
+        var socket = new WebSocket();
+        socket.onmessage = function( event : js.html.MessageEvent) {
+            this.input = event.data;
+        }
+
+        #elseif flash
+
+        var socket = new Socket();
+        socket.connect(host, port);
+
+        #else
+
+        var socket = new Socket();
+        socket.setBlocking(true);
+        socket.setFastSend(true);
+        socket.connect(host, port);
+
+        #end
+
+        assignSocket( socket);
     }
 
-	#if js
-	private function assignSocket( socket : WebSocket)  :  Void
-	#else
-	private function assignSocket( socket : Socket)  :  Void
-	#end
+    #if js
+    private function assignSocket( socket : WebSocket)  :  Void
+    #else
+    private function assignSocket( socket : Socket)  :  Void
+    #end
     {
-		this.socket = socket;
-		
-		#if (flash || js)
-		output = socket;
-      	input = socket;
-		#else
-      	output = socket.output;
-      	input = socket.input;
-		#end
+        this.socket = socket;
+
+        #if (flash || js)
+        output = socket;
+          input = socket;
+        #else
+          output = socket.output;
+          input = socket.input;
+        #end
     }
 
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TStream.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TStream.hx b/lib/haxe/src/org/apache/thrift/transport/TStream.hx
index 0e1b52d..50b3ed3 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TStream.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TStream.hx
@@ -24,9 +24,9 @@ import haxe.io.BytesBuffer;
 
 
 interface TStream {
-	function Close() : Void;
-	function Peek() : Bool;
-	function Read( buf : Bytes, offset : Int, count : Int) : Int;
-	function Write( buf : Bytes, offset : Int, count : Int) : Void;
-	function Flush() : Void;
+    function Close() : Void;
+    function Peek() : Bool;
+    function Read( buf : Bytes, offset : Int, count : Int) : Int;
+    function Write( buf : Bytes, offset : Int, count : Int) : Void;
+    function Flush() : Void;
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TStreamTransport.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TStreamTransport.hx b/lib/haxe/src/org/apache/thrift/transport/TStreamTransport.hx
index 99203b4..31a7c14 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TStreamTransport.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TStreamTransport.hx
@@ -29,75 +29,75 @@ import haxe.io.BytesInput;
 
 
 class TStreamTransport extends TTransport {
-	
-	public var InputStream(default,null) : TStream;
-	public var OutputStream(default,null) : TStream;
-
-
-	public function new( input : TStream, output : TStream) {
-		this.InputStream = input;
-		this.OutputStream = output;
-	}
-	
-	public override function isOpen() : Bool {
-		return true;
-	}
-	
+
+    public var InputStream(default,null) : TStream;
+    public var OutputStream(default,null) : TStream;
+
+
+    public function new( input : TStream, output : TStream) {
+        this.InputStream = input;
+        this.OutputStream = output;
+    }
+
+    public override function isOpen() : Bool {
+        return true;
+    }
+
     public override function peek() : Bool {
-		return (InputStream != null);
-	}
+        return (InputStream != null);
+    }
 
     public override function open() : Void {
-	}
-
-	public override function close() : Void {
-		if (InputStream != null)
-		{
-			InputStream.Close();
-			InputStream = null;
-		}
-		if (OutputStream != null)
-		{
-			OutputStream.Close();
-			OutputStream = null;
-		}
-	}
-
-	public override function read( buf : BytesBuffer, off : Int, len : Int) : Int {
-		if (InputStream == null)
-		{
-			throw new TTransportException( TTransportException.NOT_OPEN, 
-								  		   "Cannot read from null InputStream");
-		}
-
-		var data : Bytes =  Bytes.alloc(len);
-		var size = InputStream.Read( data, off, len);
-		buf.addBytes( data, 0, size);
-		return size;
-	}
+    }
+
+    public override function close() : Void {
+        if (InputStream != null)
+        {
+            InputStream.Close();
+            InputStream = null;
+        }
+        if (OutputStream != null)
+        {
+            OutputStream.Close();
+            OutputStream = null;
+        }
+    }
+
+    public override function read( buf : BytesBuffer, off : Int, len : Int) : Int {
+        if (InputStream == null)
+        {
+            throw new TTransportException( TTransportException.NOT_OPEN,
+                                             "Cannot read from null InputStream");
+        }
+
+        var data : Bytes =  Bytes.alloc(len);
+        var size = InputStream.Read( data, off, len);
+        buf.addBytes( data, 0, size);
+        return size;
+    }
 
     public override function write(buf:Bytes, off : Int, len : Int) : Void {
-		if (OutputStream == null)
-		{
-			throw new TTransportException( TTransportException.NOT_OPEN, 
-										   "Cannot write to null OutputStream");
-		}
+        if (OutputStream == null)
+        {
+            throw new TTransportException( TTransportException.NOT_OPEN,
+                                           "Cannot write to null OutputStream");
+        }
 
-		OutputStream.Write(buf, off, len);
-	}
+        OutputStream.Write(buf, off, len);
+    }
 
     public override function flush(callback:Dynamic->Void =null) : Void {
-		if (OutputStream == null)
-		{
-			var err = new TTransportException( TTransportException.NOT_OPEN,
-											   "Cannot flush null OutputStream");
-	    	if(callback != null)
-				callback(err);
-			else
-				throw err;
-		}
-
-		OutputStream.Flush();
-	}
+        if (OutputStream == null)
+        {
+            var err = new TTransportException( TTransportException.NOT_OPEN,
+                                               "Cannot flush null OutputStream");
+            if(callback != null)
+                callback(err);
+            else
+                throw err;
+        }
+
+        OutputStream.Flush();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TTransport.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TTransport.hx b/lib/haxe/src/org/apache/thrift/transport/TTransport.hx
index 35303d5..4a3bd90 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TTransport.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TTransport.hx
@@ -22,7 +22,7 @@ package org.apache.thrift.transport;
 import haxe.io.Bytes;
 import haxe.io.BytesBuffer;
 import org.apache.thrift.AbstractMethodError;
-  
+
 class TTransport {
 
     /**
@@ -31,16 +31,16 @@ class TTransport {
      * @return True if the transport is open.
      */
     public function isOpen() : Bool {
-      	throw new AbstractMethodError();
+          throw new AbstractMethodError();
     }
-    
+
     /**
      * Is there more data to be read?
      *
      * @return True if the remote side is still alive and feeding us
      */
     public function peek() : Bool {
-      	return isOpen();
+          return isOpen();
     }
 
     /**
@@ -49,14 +49,14 @@ class TTransport {
      * @throws TTransportException if the transport could not be opened
      */
     public function open() : Void {
-      	throw new AbstractMethodError();
+          throw new AbstractMethodError();
     }
 
     /**
      * Closes the transport.
      */
     public function close() : Void {
-      	throw new AbstractMethodError();
+          throw new AbstractMethodError();
     };
 
     /**
@@ -69,7 +69,7 @@ class TTransport {
      * @throws TTransportException if there was an error reading data
      */
      public function read( buf : BytesBuffer, off : Int, len : Int) : Int {
-      	throw new AbstractMethodError();
+          throw new AbstractMethodError();
      }
 
     /**
@@ -82,14 +82,14 @@ class TTransport {
      * @throws TTransportException if there was an error reading data
      */
     public function readAll(buf : BytesBuffer, off : Int, len : Int) : Int {
-		var got : Int = 0;
-		var ret : Int = 0;
+        var got : Int = 0;
+        var ret : Int = 0;
         while (got < len) {
             ret = read(buf, off+got, len-got);
             if (ret <= 0) {
-              throw new TTransportException(TTransportException.UNKNOWN, 
-										"Cannot read. Remote side has closed. Tried to read " 
-										+ len + " bytes, but only got " + got + " bytes.");
+              throw new TTransportException(TTransportException.UNKNOWN,
+                                        "Cannot read. Remote side has closed. Tried to read "
+                                        + len + " bytes, but only got " + got + " bytes.");
             }
             got += ret;
         }
@@ -103,7 +103,7 @@ class TTransport {
      * @throws TTransportException if an error occurs writing data
      */
     public function writeAll(buf:Bytes) : Void {
-		write(buf, 0, buf.length);
+        write(buf, 0, buf.length);
     }
 
     /**
@@ -115,7 +115,7 @@ class TTransport {
      * @throws TTransportException if there was an error writing data
      */
     public function write(buf:Bytes, off : Int, len : Int) : Void {
-    	throw new AbstractMethodError();
+        throw new AbstractMethodError();
     }
 
     /**
@@ -124,10 +124,10 @@ class TTransport {
      * @throws TTransportException if there was an error writing out data.
      */
     public function flush(callback:Dynamic->Void =null) : Void {
-    	if(callback != null)
-			callback(new AbstractMethodError());
-		else
-			throw new AbstractMethodError();
+        if(callback != null)
+            callback(new AbstractMethodError());
+        else
+            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/transport/TTransportException.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx
index 3db6456..f930c52 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TTransportException.hx
@@ -16,21 +16,22 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- 
+
 package org.apache.thrift.transport;
-  
+
 import org.apache.thrift.TException;
 
 class TTransportException extends TException {
-    
+
     public static inline var UNKNOWN : Int = 0;
     public static inline var NOT_OPEN : Int = 1;
     public static inline var ALREADY_OPEN : Int = 2;
     public static inline var TIMED_OUT : Int = 3;
     public static inline var END_OF_FILE : Int = 4;
-  
+
     public function new(error : Int = UNKNOWN, message : String = "") {
-		super(message, error);
+        super(message, error);
     }
-    
+
 }
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/src/org/apache/thrift/transport/TTransportFactory.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/src/org/apache/thrift/transport/TTransportFactory.hx b/lib/haxe/src/org/apache/thrift/transport/TTransportFactory.hx
index f20321f..361f35f 100644
--- a/lib/haxe/src/org/apache/thrift/transport/TTransportFactory.hx
+++ b/lib/haxe/src/org/apache/thrift/transport/TTransportFactory.hx
@@ -28,17 +28,17 @@ package org.apache.thrift.transport;
  */
 class TTransportFactory {
 
-	public function new() {
-	}
+    public function new() {
+    }
 
-	/**
-	* Return a wrapped instance of the base Transport.
-	*
-	* @param trans The base transport
-	* @return Wrapped Transport
-	*/
-	public function getTransport( trans : TTransport) : TTransport {
-		return trans;
-	}
+    /**
+    * Return a wrapped instance of the base Transport.
+    *
+    * @param trans The base transport
+    * @return Wrapped Transport
+    */
+    public function getTransport( trans : TTransport) : TTransport {
+        return trans;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/test/src/Main.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/test/src/Main.hx b/lib/haxe/test/src/Main.hx
index fff8be5..da0a7f5 100644
--- a/lib/haxe/test/src/Main.hx
+++ b/lib/haxe/test/src/Main.hx
@@ -31,15 +31,15 @@ class Main
 {
     static public function main()
     {
-		try
-		{
-        	StreamTest.Run();
-			
-			trace("All tests completed.");
-		}
-		catch( e: Dynamic)
-		{
-			trace('$e');
-		}
-	}
+        try
+        {
+            StreamTest.Run();
+
+            trace("All tests completed.");
+        }
+        catch( e: Dynamic)
+        {
+            trace('$e');
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/test/src/StreamTest.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/test/src/StreamTest.hx b/lib/haxe/test/src/StreamTest.hx
index b28c8e9..7500eee 100644
--- a/lib/haxe/test/src/StreamTest.hx
+++ b/lib/haxe/test/src/StreamTest.hx
@@ -31,62 +31,62 @@ import thrift.test.*;  // generated code
 
 
 class StreamTest extends TestBase {
-	
-
-	private inline static var tmpfile : String = "bin/data.tmp";
-	
-
-	private static function Expect( expr : Bool, info : String, ?pos : haxe.PosInfos) : Void {
-		if( ! expr) {
-			throw ('Test "$info" failed at '+pos.methodName+' in '+pos.fileName+':'+pos.lineNumber);
-		}			
-	}
-	
-	private static function MakeTestData() : Xtruct {
-		var data : Xtruct = new Xtruct();
-		data.string_thing = "Streamtest";
-		data.byte_thing = -128;
-		data.i32_thing = 4711;
-		data.i64_thing = Int64.make(0x12345678,0x9ABCDEF0);
-		return data;
-	}
-	
-	public static function WriteData() : Xtruct
-	{
-		var stream : TStream = new TFileStream( tmpfile, CreateNew);
-		var trans : TTransport = new TStreamTransport( null, stream);
-		var prot = new TJSONProtocol( trans);
-
-		var data = MakeTestData();	
-		data.write(prot);
-		trans.close();
-		
-		return data;
-	}
-	
-	public static function ReadData() : Xtruct
-	{
-		var stream : TStream = new TFileStream( tmpfile, Read);
-		var trans : TTransport = new TStreamTransport( stream, null);
-		var prot = new TJSONProtocol( trans);
-
-		var data : Xtruct = new Xtruct();
-		data.read(prot);
-		trans.close();
-		
-		return data;
-	}
-	
-	public static override function Run() : Void
-	{
-		var written = WriteData();
-		var read = ReadData();
-
-		Expect( read.string_thing == written.string_thing, "string data");
-		Expect( read.byte_thing == written.byte_thing, "byte data");
-		Expect( read.i32_thing == written.i32_thing, "i32 data");
-		Expect( Int64.compare( read.i64_thing, written.i64_thing) == 0, "i64 data");
-	}
+
+
+    private inline static var tmpfile : String = "bin/data.tmp";
+
+
+    private static function Expect( expr : Bool, info : String, ?pos : haxe.PosInfos) : Void {
+        if( ! expr) {
+            throw ('Test "$info" failed at '+pos.methodName+' in '+pos.fileName+':'+pos.lineNumber);
+        }
+    }
+
+    private static function MakeTestData() : Xtruct {
+        var data : Xtruct = new Xtruct();
+        data.string_thing = "Streamtest";
+        data.byte_thing = -128;
+        data.i32_thing = 4711;
+        data.i64_thing = Int64.make(0x12345678,0x9ABCDEF0);
+        return data;
+    }
+
+    public static function WriteData() : Xtruct
+    {
+        var stream : TStream = new TFileStream( tmpfile, CreateNew);
+        var trans : TTransport = new TStreamTransport( null, stream);
+        var prot = new TJSONProtocol( trans);
+
+        var data = MakeTestData();
+        data.write(prot);
+        trans.close();
+
+        return data;
+    }
+
+    public static function ReadData() : Xtruct
+    {
+        var stream : TStream = new TFileStream( tmpfile, Read);
+        var trans : TTransport = new TStreamTransport( stream, null);
+        var prot = new TJSONProtocol( trans);
+
+        var data : Xtruct = new Xtruct();
+        data.read(prot);
+        trans.close();
+
+        return data;
+    }
+
+    public static override function Run() : Void
+    {
+        var written = WriteData();
+        var read = ReadData();
+
+        Expect( read.string_thing == written.string_thing, "string data");
+        Expect( read.byte_thing == written.byte_thing, "byte data");
+        Expect( read.i32_thing == written.i32_thing, "i32 data");
+        Expect( Int64.compare( read.i64_thing, written.i64_thing) == 0, "i64 data");
+    }
 
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/lib/haxe/test/src/TestBase.hx
----------------------------------------------------------------------
diff --git a/lib/haxe/test/src/TestBase.hx b/lib/haxe/test/src/TestBase.hx
index 03b66dd..2a344d6 100644
--- a/lib/haxe/test/src/TestBase.hx
+++ b/lib/haxe/test/src/TestBase.hx
@@ -28,12 +28,13 @@ import org.apache.thrift.meta_data.*;
 import thrift.test.*;  // generated code
 
 class TestBase {
-	
-	private function new() {
-		// override, if necessary
-	}
-	
-	public static function Run() : Void {
-      	throw new AbstractMethodError();
-	}	
+
+    private function new() {
+        // override, if necessary
+    }
+
+    public static function Run() : Void {
+          throw new AbstractMethodError();
+    }
 }
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/test/haxe/src/Arguments.hx
----------------------------------------------------------------------
diff --git a/test/haxe/src/Arguments.hx b/test/haxe/src/Arguments.hx
index ae23fa1..132f208 100644
--- a/test/haxe/src/Arguments.hx
+++ b/test/haxe/src/Arguments.hx
@@ -30,299 +30,299 @@ using StringTools;
 
 
 enum ProtocolType {
-	binary;
-	json;
+    binary;
+    json;
 }
 
 enum EndpointTransport {
-	socket;
-	http;	
+    socket;
+    http;
 }
 
 enum ServerType {
-	simple;
-	/*
-	threadpool;	
-	threaded;
-	nonblocking;
-	*/
+    simple;
+    /*
+    threadpool;
+    threaded;
+    nonblocking;
+    */
 }
 
 
 class Arguments
 {
-	public var printHelpOnly(default,null) : Bool = false;
-
-	public var server(default,null) : Bool = false;
-	public var servertype(default,null) : ServerType = simple;
-
-	public var host(default,null) : String = "localhost";
-	public var port(default,null) : Int = 9090;
-	
-	public var protocol(default,null) : ProtocolType = binary;
-	public var transport(default,null) : EndpointTransport = socket;
-	public var framed(default,null) : Bool = false;
-	public var buffered(default,null) : Bool = false;
-
-	public var numIterations(default,null) : Int = 1;
-	public var numThreads(default,null) : Int = 1;
-	public var skipSpeedTest(default,null) : Bool = false;
-	
-	
-	public function new() {
-		#if sys
-		try {
-  			ParseArgs();
-		} catch (e : String) {
-			trace(GetHelp());
-			throw e;
-		}
-		#else
-		trace("WN: Platform does not support program arguments, using defaults.");
-		#end
-	}
-	
-	#if sys
-		
-	private static function GetHelp() : String {
-		var sProg = Path.withoutDirectory( Sys.executablePath());
-		return "\n"
-			+sProg+"  [client|server]  [options]\n"
-			+"\n"
-			+"Modus: Either client or server, the default is client.\n"
-			+"\n"
-			+"Common options:\n"
-			+"  -h [ --help ]               produce help message\n"
-			+"  --port arg (=9090)          Port number to listen / connect to\n"
-			/* not supported yet
-			+"  --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)\n"
+    public var printHelpOnly(default,null) : Bool = false;
+
+    public var server(default,null) : Bool = false;
+    public var servertype(default,null) : ServerType = simple;
+
+    public var host(default,null) : String = "localhost";
+    public var port(default,null) : Int = 9090;
+
+    public var protocol(default,null) : ProtocolType = binary;
+    public var transport(default,null) : EndpointTransport = socket;
+    public var framed(default,null) : Bool = false;
+    public var buffered(default,null) : Bool = false;
+
+    public var numIterations(default,null) : Int = 1;
+    public var numThreads(default,null) : Int = 1;
+    public var skipSpeedTest(default,null) : Bool = false;
+
+
+    public function new() {
+        #if sys
+        try {
+              ParseArgs();
+        } catch (e : String) {
+            trace(GetHelp());
+            throw e;
+        }
+        #else
+        trace("WN: Platform does not support program arguments, using defaults.");
+        #end
+    }
+
+    #if sys
+
+    private static function GetHelp() : String {
+        var sProg = Path.withoutDirectory( Sys.executablePath());
+        return "\n"
+            +sProg+"  [client|server]  [options]\n"
+            +"\n"
+            +"Modus: Either client or server, the default is client.\n"
+            +"\n"
+            +"Common options:\n"
+            +"  -h [ --help ]               produce help message\n"
+            +"  --port arg (=9090)          Port number to listen / connect to\n"
+            /* not supported yet
+            +"  --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)\n"
             +"  --named-pipe arg            Windows Named Pipe (e.g. MyThriftPipe)\n"
-			*/
-			+"  --protocol arg (=binary)    protocol: binary, compact, json\n"
-			/* not supported yet
-			+"  --ssl                       Encrypted Transport using SSL\n"
-			*/
-			+"\n"
-			+"Server only options:\n"
+            */
+            +"  --protocol arg (=binary)    protocol: binary, compact, json\n"
+            /* not supported yet
+            +"  --ssl                       Encrypted Transport using SSL\n"
+            */
+            +"\n"
+            +"Server only options:\n"
             +"  --transport arg (=sockets)  Transport: buffered, framed, http, anonpipe\n"
-			/* not supported yet
-			+"  --processor-events          processor-events\n"
-			+"  --server-type arg (=simple) type of server, \"simple\", \"thread-pool\", \n"
-			+"                              \"threaded\", or \"nonblocking\"\n"
-			+"  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for \n"
-			+"                              thread-pool server type\n"
-			*/
-			+"\n"
-			+"Client only options:\n"
+            /* not supported yet
+            +"  --processor-events          processor-events\n"
+            +"  --server-type arg (=simple) type of server, \"simple\", \"thread-pool\", \n"
+            +"                              \"threaded\", or \"nonblocking\"\n"
+            +"  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for \n"
+            +"                              thread-pool server type\n"
+            */
+            +"\n"
+            +"Client only options:\n"
             +"  --host arg (=localhost)     Host to connect\n"
             +"  --transport arg (=sockets)  Transport: buffered, framed, http, evhttp\n"
-			/* not supported yet
+            /* not supported yet
             +"  --anon-pipes hRead hWrite   Windows Anonymous Pipes pair (handles)\n"
-			*/
+            */
             +"  -n [ --testloops ] arg (=1) Number of Tests\n"
             +"  -t [ --threads ] arg (=1)   Number of Test threads\n"
             +"  --skip-speed-test           Skip the speed test\n"
-			+"\n"
-			+"All arguments are optional.\n"
-			;
-	}
-	
-
-	private function ParseArgs() : Void {
-		
-		var args = Sys.args().copy();
-		if( (args == null) || (args.length <= 0)) {
-			server = false;
-			numThreads = 1;
-			return;
-		}
-		
-		var arg = args.shift();
-		if ( arg == "client") {
-			server = false;
-			numThreads = 1;
-		} 
-		else if ( arg == "server") {
-			server = true;
-			numThreads = 4;
-		} 
-		else if ( (arg == "-h") || (arg == "--help")) {
-			// -h [ --help ]               produce help message
-			Sys.println( GetHelp());
-			printHelpOnly = true;
-			return;
-		} 
-		else {
-			throw "First argument must be 'server' or 'client'";
-		}
-
-			
-		while( args.length > 0) {
-			arg = args.shift();
-			
-			if ( (arg == "-h") || (arg == "--help")) {
-				// -h [ --help ]               produce help message
-			    Sys.println( GetHelp());
-				printHelpOnly = true;
-				return;
-			} 
-			else if (arg == "--port") {		
-				// --port arg (=9090)          Port number to listen
-				arg = args.shift();
-				var tmp = Std.parseInt(arg);
-				if( tmp != null) {
-					port = tmp;
-				} else {
-					throw "Invalid port number "+arg;
-				}  
-			} 
-			else if (arg == "--domain-socket") {		
-				//   --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)
-				throw "domain sockets not supported yet";
-			} 
-			else if (arg == "--named-pipe") {		
-				//   --named-pipe arg            Windows Named Pipe (e.g. MyThriftPipe)
-				throw "named pipes not supported yet";
-			} 
-			else if (arg == "--protocol") {		
-				// --protocol arg (=binary)    protocol: binary, compact, json
-				arg = args.shift();
-				if( arg == "binary") {
-					protocol = binary;
-				} else if( arg == "compact") {
-					throw "Compact protocol not supported yet";
-				} else if( arg == "json") {
-					protocol = json;
-				} else {
-					InvalidArg(arg);
-				}
-			}  
-			else if (arg == "--ssl") {		
-				// --ssl                       Encrypted Transport using SSL
-				throw "SSL not supported yet";
-			} 
-			else {
+            +"\n"
+            +"All arguments are optional.\n"
+            ;
+    }
+
+
+    private function ParseArgs() : Void {
+
+        var args = Sys.args().copy();
+        if( (args == null) || (args.length <= 0)) {
+            server = false;
+            numThreads = 1;
+            return;
+        }
+
+        var arg = args.shift();
+        if ( arg == "client") {
+            server = false;
+            numThreads = 1;
+        }
+        else if ( arg == "server") {
+            server = true;
+            numThreads = 4;
+        }
+        else if ( (arg == "-h") || (arg == "--help")) {
+            // -h [ --help ]               produce help message
+            Sys.println( GetHelp());
+            printHelpOnly = true;
+            return;
+        }
+        else {
+            throw "First argument must be 'server' or 'client'";
+        }
+
+
+        while( args.length > 0) {
+            arg = args.shift();
+
+            if ( (arg == "-h") || (arg == "--help")) {
+                // -h [ --help ]               produce help message
+                Sys.println( GetHelp());
+                printHelpOnly = true;
+                return;
+            }
+            else if (arg == "--port") {
+                // --port arg (=9090)          Port number to listen
+                arg = args.shift();
+                var tmp = Std.parseInt(arg);
+                if( tmp != null) {
+                    port = tmp;
+                } else {
+                    throw "Invalid port number "+arg;
+                }
+            }
+            else if (arg == "--domain-socket") {
+                //   --domain-socket arg         Unix Domain Socket (e.g. /tmp/ThriftTest.thrift)
+                throw "domain sockets not supported yet";
+            }
+            else if (arg == "--named-pipe") {
+                //   --named-pipe arg            Windows Named Pipe (e.g. MyThriftPipe)
+                throw "named pipes not supported yet";
+            }
+            else if (arg == "--protocol") {
+                // --protocol arg (=binary)    protocol: binary, compact, json
+                arg = args.shift();
+                if( arg == "binary") {
+                    protocol = binary;
+                } else if( arg == "compact") {
+                    throw "Compact protocol not supported yet";
+                } else if( arg == "json") {
+                    protocol = json;
+                } else {
+                    InvalidArg(arg);
+                }
+            }
+            else if (arg == "--ssl") {
+                // --ssl                       Encrypted Transport using SSL
+                throw "SSL not supported yet";
+            }
+            else {
                 //Server only options:
-				if( server) {
-					ParseServerArgument( arg, args);
-				} else {
-					ParseClientArgument( arg, args);
-				}
-			}
-		}
-	}
-	
-
-	private function ParseServerArgument( arg : String, args : Array<String>) : Void {
-		if (arg == "--transport") {
-			//  --transport arg (=sockets)  Transport: buffered, framed, http, anonpipe
-			arg = args.shift();
-			if( arg == "buffered") {
-				buffered = true;
-			} else if( arg == "framed") {
-				framed = true;
-			} else if( arg == "http") {
-				transport = http;
-			} else if( arg == "anonpipe") {
-				throw "Anon pipes transport not supported yet";
-			} else {
-				InvalidArg(arg);
-			}  
-		}
-		else if (arg == "--processor-events") {
-			throw "Processor events not supported yet";
-		}
-		else if (arg == "--server-type") {
-			//  --server-type arg (=simple) type of server, 
-			// one of "simple", "thread-pool", "threaded", "nonblocking"
-			arg = args.shift();
-			if( arg == "simple") {
-				servertype = simple;
-			} else if( arg == "thread-pool") {
-				throw arg+" server not supported yet";
-			} else if( arg == "threaded") {
-				throw arg+" server not supported yet";
-			} else if( arg == "nonblocking") {
-				throw arg+" server not supported yet";
-			} else {
-				InvalidArg(arg);
-			}  
-		}
-		else if ((arg == "-n") || (arg == "--workers")) {
-			//  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for 
-			//                              thread-pool server type
-			arg = args.shift();
-			var tmp = Std.parseInt(arg);
-			if( tmp != null) {
-				numThreads = tmp;
-			} else{
-				throw "Invalid number "+arg;
-			} 
-		}
-		else {
-			InvalidArg(arg);
-		}
-	}
-	
-
-	private function ParseClientArgument( arg : String, args : Array<String>) : Void {
-		if (arg == "--host") {
+                if( server) {
+                    ParseServerArgument( arg, args);
+                } else {
+                    ParseClientArgument( arg, args);
+                }
+            }
+        }
+    }
+
+
+    private function ParseServerArgument( arg : String, args : Array<String>) : Void {
+        if (arg == "--transport") {
+            //  --transport arg (=sockets)  Transport: buffered, framed, http, anonpipe
+            arg = args.shift();
+            if( arg == "buffered") {
+                buffered = true;
+            } else if( arg == "framed") {
+                framed = true;
+            } else if( arg == "http") {
+                transport = http;
+            } else if( arg == "anonpipe") {
+                throw "Anon pipes transport not supported yet";
+            } else {
+                InvalidArg(arg);
+            }
+        }
+        else if (arg == "--processor-events") {
+            throw "Processor events not supported yet";
+        }
+        else if (arg == "--server-type") {
+            //  --server-type arg (=simple) type of server,
+            // one of "simple", "thread-pool", "threaded", "nonblocking"
+            arg = args.shift();
+            if( arg == "simple") {
+                servertype = simple;
+            } else if( arg == "thread-pool") {
+                throw arg+" server not supported yet";
+            } else if( arg == "threaded") {
+                throw arg+" server not supported yet";
+            } else if( arg == "nonblocking") {
+                throw arg+" server not supported yet";
+            } else {
+                InvalidArg(arg);
+            }
+        }
+        else if ((arg == "-n") || (arg == "--workers")) {
+            //  -n [ --workers ] arg (=4)   Number of thread pools workers. Only valid for
+            //                              thread-pool server type
+            arg = args.shift();
+            var tmp = Std.parseInt(arg);
+            if( tmp != null) {
+                numThreads = tmp;
+            } else{
+                throw "Invalid number "+arg;
+            }
+        }
+        else {
+            InvalidArg(arg);
+        }
+    }
+
+
+    private function ParseClientArgument( arg : String, args : Array<String>) : Void {
+        if (arg == "--host") {
             //  --host arg (=localhost)     Host to connect
-			host = args.shift();
-		}
-		else if (arg == "--transport") {
+            host = args.shift();
+        }
+        else if (arg == "--transport") {
             //  --transport arg (=sockets)  Transport: buffered, framed, http, evhttp
-			arg = args.shift();
-			if( arg == "buffered") {
-				buffered = true;
-			} else if( arg == "framed") {
-				framed = true;
-			} else if( arg == "http") {
-				transport = http;
-			} else if( arg == "evhttp") {
-				throw "evhttp transport not supported yet";
-			} else {
-				InvalidArg(arg);
-			}  
-		}
-		else if (arg == "--anon-pipes") {
-			//  --anon-pipes hRead hWrite   Windows Anonymous Pipes pair (handles)
-			throw "Anon pipes transport not supported yet";
-		}
-		else if ((arg == "-n") || (arg == "--testloops")) {
-			//  -n [ --testloops ] arg (=1) Number of Tests
-			arg = args.shift();
-			var tmp = Std.parseInt(arg);
-			if( tmp != null) {
-				numIterations = tmp;
-			} else {
-				throw "Invalid number "+arg;
-			}  
-		}
-		else if ((arg == "-t") || (arg == "--threads")) {
-			//  -t [ --threads ] arg (=1)   Number of Test threads
-			arg = args.shift();
-			var tmp = Std.parseInt(arg);
-			if( tmp != null) {
-				numThreads = tmp;
-			} else {
-				throw "Invalid number "+arg;
-			}  
-		}
-		else if (arg == "--skip-speed-test") {
-			//  --skip-speed-test  			Skip the speed test
-			skipSpeedTest = true;
-		}			
-		else {
-			InvalidArg(arg);
-		}
-	}
-
-	
-	#end
-		
-		
-	private function InvalidArg( arg : String) : Void {
-		throw 'Invalid argument $arg';
-	}
+            arg = args.shift();
+            if( arg == "buffered") {
+                buffered = true;
+            } else if( arg == "framed") {
+                framed = true;
+            } else if( arg == "http") {
+                transport = http;
+            } else if( arg == "evhttp") {
+                throw "evhttp transport not supported yet";
+            } else {
+                InvalidArg(arg);
+            }
+        }
+        else if (arg == "--anon-pipes") {
+            //  --anon-pipes hRead hWrite   Windows Anonymous Pipes pair (handles)
+            throw "Anon pipes transport not supported yet";
+        }
+        else if ((arg == "-n") || (arg == "--testloops")) {
+            //  -n [ --testloops ] arg (=1) Number of Tests
+            arg = args.shift();
+            var tmp = Std.parseInt(arg);
+            if( tmp != null) {
+                numIterations = tmp;
+            } else {
+                throw "Invalid number "+arg;
+            }
+        }
+        else if ((arg == "-t") || (arg == "--threads")) {
+            //  -t [ --threads ] arg (=1)   Number of Test threads
+            arg = args.shift();
+            var tmp = Std.parseInt(arg);
+            if( tmp != null) {
+                numThreads = tmp;
+            } else {
+                throw "Invalid number "+arg;
+            }
+        }
+        else if (arg == "--skip-speed-test") {
+            //  --skip-speed-test              Skip the speed test
+            skipSpeedTest = true;
+        }
+        else {
+            InvalidArg(arg);
+        }
+    }
+
+
+    #end
+
+
+    private function InvalidArg( arg : String) : Void {
+        throw 'Invalid argument $arg';
+    }
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/b502832c/test/haxe/src/Main.hx
----------------------------------------------------------------------
diff --git a/test/haxe/src/Main.hx b/test/haxe/src/Main.hx
index 6d80c21..30c04a6 100644
--- a/test/haxe/src/Main.hx
+++ b/test/haxe/src/Main.hx
@@ -17,7 +17,7 @@
  * under the License.
  */
 
- 
+
 package;
 
 import org.apache.thrift.*;
@@ -30,22 +30,22 @@ import thrift.test.*;  // generated code
 
 class Main
 {
-	static function main() {
-		try {
-			var args = new Arguments();
-			
-			if( args.printHelpOnly) 
-				return;
-			
-			if (args.server)
-				TestServer.Execute(args);
-			else 
-				TestClient.Execute(args);
-			
-			trace("Completed.");
-		} catch (e : String) {
-			trace(e);
-		}
-	}
+    static function main() {
+        try {
+            var args = new Arguments();
+
+            if( args.printHelpOnly)
+                return;
+
+            if (args.server)
+                TestServer.Execute(args);
+            else
+                TestClient.Execute(args);
+
+            trace("Completed.");
+        } catch (e : String) {
+            trace(e);
+        }
+    }
 
 }