You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 02:59:38 UTC

svn commit: r668921 - in /incubator/thrift/trunk/lib/rb/lib/thrift: protocol.rb protocol/binaryprotocol.rb server/thttpserver.rb server/tserver.rb struct.rb transport/thttpclient.rb transport/tsocket.rb transport/ttransport.rb

Author: kclark
Date: Tue Jun 17 17:59:37 2008
New Revision: 668921

URL: http://svn.apache.org/viewvc?rev=668921&view=rev
Log:
Finish up the CamelCase -> ruby_style changes

Modified:
    incubator/thrift/trunk/lib/rb/lib/thrift/protocol.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/protocol/binaryprotocol.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/server/thttpserver.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/server/tserver.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/transport/thttpclient.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/transport/tsocket.rb
    incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/protocol.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/protocol.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/protocol.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/protocol.rb Tue Jun 17 17:59:37 2008
@@ -258,5 +258,6 @@
 end
 
 class TProtocolFactory
-  def getProtocol(trans); nil; end
+  def get_protocol(trans); nil; end
+  deprecate! :getProtocol => :get_protocol
 end

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/protocol/binaryprotocol.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/protocol/binaryprotocol.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/protocol/binaryprotocol.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/protocol/binaryprotocol.rb Tue Jun 17 17:59:37 2008
@@ -19,41 +19,41 @@
     end
 
     def write_message_begin(name, type, seqid)
-      writeI32(VERSION_1 | type)
-      writeString(name)
-      writeI32(seqid)
+      write_i32(VERSION_1 | type)
+      write_string(name)
+      write_i32(seqid)
     end
 
     def write_field_begin(name, type, id)
-      writeByte(type)
-      writeI16(id)
+      write_byte(type)
+      write_i16(id)
     end
 
     def write_field_stop()
-      writeByte(Thrift::Types::STOP)
+      write_byte(Thrift::Types::STOP)
     end
 
     def write_map_begin(ktype, vtype, size)
-      writeByte(ktype)
-      writeByte(vtype)
-      writeI32(size)
+      write_byte(ktype)
+      write_byte(vtype)
+      write_i32(size)
     end
 
     def write_list_begin(etype, size)
-      writeByte(etype)
-      writeI32(size)
+      write_byte(etype)
+      write_i32(size)
     end
 
     def write_set_begin(etype, size)
-      writeByte(etype)
-      writeI32(size)
+      write_byte(etype)
+      write_i32(size)
     end
 
     def write_bool(bool)
       if (bool)
-        writeByte(1)
+        write_byte(1)
       else
-        writeByte(0)
+        write_byte(0)
       end
     end
 
@@ -80,56 +80,56 @@
     end
 
     def write_string(str)
-      writeI32(str.length)
+      write_i32(str.length)
       trans.write(str)
     end
 
     def read_message_begin()
-      version = readI32()
+      version = read_i32()
       if (version & VERSION_MASK != VERSION_1)
         raise ProtocolException.new(ProtocolException::BAD_VERSION, 'Missing version identifier')
       end
       type = version & 0x000000ff
-      name = readString()
-      seqid = readI32()
+      name = read_string()
+      seqid = read_i32()
       return name, type, seqid
     end
 
     def read_field_begin()
-      type = readByte()
+      type = read_byte()
       if (type === Types::STOP)
         return nil, type, 0
       end
-      id = readI16()
+      id = read_i16()
       return nil, type, id
     end
 
     def read_map_begin()
-      ktype = readByte()
-      vtype = readByte()
-      size = readI32()
+      ktype = read_byte()
+      vtype = read_byte()
+      size = read_i32()
       return ktype, vtype, size
     end
 
     def read_list_begin()
-      etype = readByte()
-      size = readI32()
+      etype = read_byte()
+      size = read_i32()
       return etype, size
     end
 
     def read_set_begin()
-      etype = readByte()
-      size = readI32()
+      etype = read_byte()
+      size = read_i32()
       return etype, size
     end
 
     def read_bool()
-      byte = readByte()
+      byte = read_byte()
       return byte != 0
     end
 
     def read_byte()
-      dat = trans.readAll(1)
+      dat = trans.read_all(1)
       val = dat[0]
       if (val > 0x7f)
         val = 0 - ((val - 1) ^ 0xff)
@@ -138,7 +138,7 @@
     end
 
     def read_i16()
-      dat = trans.readAll(2)
+      dat = trans.read_all(2)
       val, = dat.unpack('n')
       if (val > 0x7fff)
         val = 0 - ((val - 1) ^ 0xffff)
@@ -147,7 +147,7 @@
     end
 
     def read_i32()
-      dat = trans.readAll(4)
+      dat = trans.read_all(4)
       val, = dat.unpack('N')
       if (val > 0x7fffffff)
         val = 0 - ((val - 1) ^ 0xffffffff)
@@ -156,7 +156,7 @@
     end
 
     def read_i64()
-      dat = trans.readAll(8)
+      dat = trans.read_all(8)
       hi, lo = dat.unpack('N2')
       if (hi > 0x7fffffff)
         hi = hi ^ 0xffffffff
@@ -168,14 +168,14 @@
     end
 
     def read_double()
-      dat = trans.readAll(8)
+      dat = trans.read_all(8)
       val, = dat.unpack('G')
       return val
     end
 
     def read_string()
-      sz = readI32()
-      dat = trans.readAll(sz)
+      sz = read_i32()
+      dat = trans.read_all(sz)
       return dat
     end
 
@@ -184,7 +184,7 @@
 end
 
 class TBinaryProtocolFactory < TProtocolFactory
-  def getProtocol(trans)
+  def get_protocol(trans)
     return TBinaryProtocol.new(trans)
   end
 end

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/server/thttpserver.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/server/thttpserver.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/server/thttpserver.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/server/thttpserver.rb Tue Jun 17 17:59:37 2008
@@ -22,7 +22,7 @@
       response.start(200) do |head, out|
         head["Content-Type"] = "application/x-thrift"
         transport = TIOStreamTransport.new request.body, out
-        protocol = @protocol_factory.getProtocol transport
+        protocol = @protocol_factory.get_protocol transport
         @processor.process protocol, protocol
       end
     end

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/server/tserver.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/server/tserver.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/server/tserver.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/server/tserver.rb Tue Jun 17 17:59:37 2008
@@ -36,8 +36,8 @@
       @serverTransport.listen()
       while (true)
         client = @serverTransport.accept()
-        trans = @transportFactory.getTransport(client)
-        prot = @protocolFactory.getProtocol(trans)
+        trans = @transportFactory.get_transport(client)
+        prot = @protocolFactory.get_protocol(trans)
         begin
           while (true)
             @processor.process(prot, prot)
@@ -66,8 +66,8 @@
       @serverTransport.listen()
       while (true)
         client = @serverTransport.accept()
-        trans = @transportFactory.getTransport(client)
-        prot = @protocolFactory.getProtocol(trans)
+        trans = @transportFactory.get_transport(client)
+        prot = @protocolFactory.get_protocol(trans)
         Thread.new(prot, trans) do |p, t|
           begin
             while (true)
@@ -113,8 +113,8 @@
           begin
             while (true)
               client = @serverTransport.accept()
-              trans = @transportFactory.getTransport(client)
-              prot = @protocolFactory.getProtocol(trans)
+              trans = @transportFactory.get_transport(client)
+              prot = @protocolFactory.get_protocol(trans)
               begin
                 while (true)
                   @processor.process(prot, prot)

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb Tue Jun 17 17:59:37 2008
@@ -61,28 +61,28 @@
         value = field[:class].new
         value.read(iprot)
       elsif field[:type] == Types::MAP
-        key_type, val_type, size = iprot.readMapBegin
+        key_type, val_type, size = iprot.read_map_begin
         value = {}
         size.times do
           k = read_field(iprot, field_info(field[:key]))
           v = read_field(iprot, field_info(field[:value]))
           value[k] = v
         end
-        iprot.readMapEnd
+        iprot.read_map_end
       elsif field[:type] == Types::LIST
-        e_type, size = iprot.readListBegin
+        e_type, size = iprot.read_list_begin
         value = Array.new(size) do |n|
           read_field(iprot, field_info(field[:element]))
         end
-        iprot.readListEnd
+        iprot.read_list_end
       elsif field[:type] == Types::SET
-        e_type, size = iprot.readSetBegin
+        e_type, size = iprot.read_set_begin
         value = {}
         size.times do
           element = read_field(iprot, field_info(field[:element]))
           value[element] = true
         end
-        iprot.readSetEnd
+        iprot.read_set_end
       else
         value = iprot.read_type(field[:type])
       end

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/transport/thttpclient.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/transport/thttpclient.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/transport/thttpclient.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/transport/thttpclient.rb Tue Jun 17 17:59:37 2008
@@ -13,7 +13,7 @@
     @outbuf = ""
   end
 
-  def isOpen; true end
+  def open?; true end
   def read(sz); @inbuf.read sz end
   def write(buf); @outbuf << buf end
   def flush

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/transport/tsocket.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/transport/tsocket.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/transport/tsocket.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/transport/tsocket.rb Tue Jun 17 17:59:37 2008
@@ -18,7 +18,7 @@
     @handle = nil
   end
 
-  def setHandle(handle)
+  def set_handle(handle)
     @handle = handle
   end
 
@@ -30,7 +30,7 @@
     end
   end
 
-  def isOpen()
+  def open?()
     return !@handle.nil?
   end
 
@@ -75,7 +75,7 @@
     if (@handle != nil)
       sock = @handle.accept()
       trans = TSocket.new()
-      trans.setHandle(sock)
+      trans.set_handle(sock)
       return trans
     end
     return nil

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb?rev=668921&r1=668920&r2=668921&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/transport/ttransport.rb Tue Jun 17 17:59:37 2008
@@ -68,9 +68,10 @@
 end
 
 class TTransportFactory
-  def getTransport(trans)
+  def get_transport(trans)
     return trans
   end
+  deprecate! :getTransport => :get_transport
 end
 
 class TBufferedTransport < TTransport
@@ -79,8 +80,8 @@
     @wbuf = ''
   end
 
-  def isOpen()
-    return @transport.isOpen()
+  def open?()
+    return @transport.open?()
   end
 
   def open()
@@ -107,7 +108,7 @@
 end
 
 class TBufferedTransportFactory < TTransportFactory
-  def getTransport(transport)
+  def get_transport(transport)
     return TBufferedTransport.new(transport)
   end
 end
@@ -194,18 +195,18 @@
   private
 
   def read_frame
-    buf  = @transport.readAll(4)
+    buf  = @transport.read_all(4)
     val  = buf.unpack('N')
     sz   = val[0]
 
-    @rbuf = @transport.readAll(sz)
+    @rbuf = @transport.read_all(sz)
   end
 
 end
 
 
 class TFramedTransportFactory < TTransportFactory
-  def getTransport(transport)
+  def get_transport(transport)
     return TFramedTransport.new(transport)
   end
 end
@@ -282,7 +283,7 @@
     @output = output
   end
 
-  def isOpen; true end
+  def open?; true end
   def read(sz); @input.read(sz) end
   def write(buf); @output.write(buf) end
 end