Ruby test code fix, and BNF file for protocol
Reviewed By: aditya
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665148 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/rb/TestClient.rb b/test/rb/TestClient.rb
index a4aecb8..fedb818 100755
--- a/test/rb/TestClient.rb
+++ b/test/rb/TestClient.rb
@@ -26,6 +26,10 @@
puts c.testList([1,2,3,4,5])
puts c.testSet({1 => true, 2 => true, 3 => true})
+struct = Xtruct.new({'string_thing' => 'hi!', 'i32_thing' => 4 })
+puts c.testStruct(struct)
+puts c.testNest(Xtruct2.new({'struct_thing' => struct, 'i32_thing' => 10}))
+
s.close()
diff --git a/test/rb/TestServer.rb b/test/rb/TestServer.rb
index 6e08313..c0d7b59 100755
--- a/test/rb/TestServer.rb
+++ b/test/rb/TestServer.rb
@@ -60,6 +60,16 @@
return thing
end
+ def testNest(thing)
+ print "testNest(#{thing})\n"
+ puts " i32_thing: #{thing.i32_thing}"
+ puts " with struct: "
+ %w{ string_thing byte_thing i32_thing }.each do |t|
+ puts " #{t}: #{thing.struct_thing.send(t)}"
+ end
+ return thing
+ end
+
end
handler = TestHandler.new()
diff --git a/thrift.bnf b/thrift.bnf
new file mode 100644
index 0000000..60e757d
--- /dev/null
+++ b/thrift.bnf
@@ -0,0 +1,82 @@
+Thrift Protocol Structure
+
+Mark Slee (mcslee@facebook.com)
+
+Last Modified: 2007-Jun-29
+
+Thrift is distributed under the Thrift open source software license.
+Please see the included LICENSE file.
+
+--------------------------------------------------------------------
+
+This document describes the structure of the Thrift protocol
+without specifying the encoding. Thus, the order of elements
+could in some cases be rearranged depending upon the TProtocol
+implementation, but this document specifies the minimum required
+structure. There are some "dumb" terminals like STRING and INT
+that take the place of an actual encoding specification.
+
+They key point to notice is that ALL messages are just one wrapped
+<struct>. Depending upon the message type, the <struct> can be
+interpreted as the argument list to a function, the return value
+of a function, or an exception.
+
+--------------------------------------------------------------------
+
+ <message> ::= <message-begin> <struct> <message-end>
+
+ <message-begin> ::= <method-name> <message-type> <message-seqid>
+
+ <method-name> ::= STRING
+
+ <message-type> ::= T_CALL | T_REPLY | T_EXCEPTION
+
+ <message-seqid> ::= I32
+
+ <struct> ::= <struct-begin> <field>* <field-stop> <struct-end>
+
+ <struct-begin> ::= <struct-name>
+
+ <struct-name> ::= STRING
+
+ <field-stop> ::= T_STOP
+
+ <field> ::= <field-begin> <field-data> <field-end>
+
+ <field-begin> ::= <field-name> <field-type> <field-id>
+
+ <field-name> ::= STRING
+
+ <field-type> ::= T_BOOL | T_BYTE | T_I8 | T_I16 | T_I32 | T_I64 | T_DOUBLE
+ | T_STRING | T_STRUCT | T_MAP | T_SET | T_LIST
+
+ <field-id> ::= I16
+
+ <field-data> ::= I8 | I16 | I32 | I64 | DOUBLE | STRING |
+ <struct> | <map> | <list> | <set>
+
+ <map> ::= <map-begin> <field-datum>* <map-end>
+
+ <map-begin> ::= <map-key-type> <map-value-type> <map-size>
+
+ <map-key-type> ::= <field-type>
+
+<map-value-type> ::= <field-type>
+
+ <map-size> ::= I32
+
+ <list> ::= <list-begin> <field-data>* <list-end>
+
+ <list-begin> ::= <list-elem-type> <list-size>
+
+<list-elem-type> ::= <field-type>
+
+ <list-size> ::= I32
+
+ <set> ::= <set-begin> <field-data>* <set-end>
+
+ <set-begin> ::= <set-elem-type> <set-size>
+
+ <set-elem-type> ::= <field-type>
+
+ <set-size> ::= I32