From 477a580aa40c871e5b211a9a53108852969f2895 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Sat, 30 Jun 2007 01:18:12 +0000 Subject: [PATCH] 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 --- test/rb/TestClient.rb | 4 +++ test/rb/TestServer.rb | 10 ++++++ thrift.bnf | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 thrift.bnf diff --git a/test/rb/TestClient.rb b/test/rb/TestClient.rb index a4aecb8d..fedb818e 100755 --- a/test/rb/TestClient.rb +++ b/test/rb/TestClient.rb @@ -26,6 +26,10 @@ puts c.testMap({1 => 1, 2 => 2, 3 => 3}) 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 6e083135..c0d7b59f 100755 --- a/test/rb/TestServer.rb +++ b/test/rb/TestServer.rb @@ -60,6 +60,16 @@ class TestHandler 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 00000000..60e757d7 --- /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 +. Depending upon the message type, the can be +interpreted as the argument list to a function, the return value +of a function, or an exception. + +-------------------------------------------------------------------- + + ::= + + ::= + + ::= STRING + + ::= T_CALL | T_REPLY | T_EXCEPTION + + ::= I32 + + ::= * + + ::= + + ::= STRING + + ::= T_STOP + + ::= + + ::= + + ::= STRING + + ::= T_BOOL | T_BYTE | T_I8 | T_I16 | T_I32 | T_I64 | T_DOUBLE + | T_STRING | T_STRUCT | T_MAP | T_SET | T_LIST + + ::= I16 + + ::= I8 | I16 | I32 | I64 | DOUBLE | STRING | + | | | + + ::= * + + ::= + + ::= + + ::= + + ::= I32 + + ::= * + + ::= + + ::= + + ::= I32 + + ::= * + + ::= + + ::= + + ::= I32 -- 2.17.1