#
# Autogenerated by Thrift Compiler (0.9.2)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

require 'thrift'
require 'small_test_types'

module TestNamespace
  module SmallService
    class Client
      include ::Thrift::Client

      def testThinger(bootz)
        send_testThinger(bootz)
        return recv_testThinger()
      end

      def send_testThinger(bootz)
        send_message('testThinger', TestThinger_args, :bootz => bootz)
      end

      def recv_testThinger()
        result = receive_message(TestThinger_result)
        return result.success unless result.success.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'testThinger failed: unknown result')
      end

      def testMe(hello, wonk)
        send_testMe(hello, wonk)
        return recv_testMe()
      end

      def send_testMe(hello, wonk)
        send_message('testMe', TestMe_args, :hello => hello, :wonk => wonk)
      end

      def recv_testMe()
        result = receive_message(TestMe_result)
        return result.success unless result.success.nil?
        raise result.g unless result.g.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'testMe failed: unknown result')
      end

      def testVoid()
        send_testVoid()
        recv_testVoid()
      end

      def send_testVoid()
        send_message('testVoid', TestVoid_args)
      end

      def recv_testVoid()
        result = receive_message(TestVoid_result)
        raise result.g unless result.g.nil?
        return
      end

      def testI32(boo)
        send_testI32(boo)
        return recv_testI32()
      end

      def send_testI32(boo)
        send_message('testI32', TestI32_args, :boo => boo)
      end

      def recv_testI32()
        result = receive_message(TestI32_result)
        return result.success unless result.success.nil?
        raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'testI32 failed: unknown result')
      end

    end

    class Processor
      include ::Thrift::Processor

      def process_testThinger(seqid, iprot, oprot)
        args = read_args(iprot, TestThinger_args)
        result = TestThinger_result.new()
        result.success = @handler.testThinger(args.bootz)
        write_result(result, oprot, 'testThinger', seqid)
      end

      def process_testMe(seqid, iprot, oprot)
        args = read_args(iprot, TestMe_args)
        result = TestMe_result.new()
        begin
          result.success = @handler.testMe(args.hello, args.wonk)
        rescue ::TestNamespace::Goodbye => g
          result.g = g
        end
        write_result(result, oprot, 'testMe', seqid)
      end

      def process_testVoid(seqid, iprot, oprot)
        args = read_args(iprot, TestVoid_args)
        result = TestVoid_result.new()
        begin
          @handler.testVoid()
        rescue ::TestNamespace::Goodbye => g
          result.g = g
        end
        write_result(result, oprot, 'testVoid', seqid)
      end

      def process_testI32(seqid, iprot, oprot)
        args = read_args(iprot, TestI32_args)
        result = TestI32_result.new()
        result.success = @handler.testI32(args.boo)
        write_result(result, oprot, 'testI32', seqid)
      end

    end

    # HELPER FUNCTIONS AND STRUCTURES

    class TestThinger_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      BOOTZ = 1

      FIELDS = {
        BOOTZ => {:type => ::Thrift::Types::STRING, :name => 'bootz'}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class TestThinger_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class TestMe_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      HELLO = 1
      WONK = 2

      FIELDS = {
        HELLO => {:type => ::Thrift::Types::I32, :name => 'hello', :default => 64},
        WONK => {:type => ::Thrift::Types::STRUCT, :name => 'wonk', :class => ::TestNamespace::Hello}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class TestMe_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0
      G = 1

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::TestNamespace::Hello},
        G => {:type => ::Thrift::Types::STRUCT, :name => 'g', :class => ::TestNamespace::Goodbye}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class TestVoid_args
      include ::Thrift::Struct, ::Thrift::Struct_Union

      FIELDS = {

      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class TestVoid_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      G = 1

      FIELDS = {
        G => {:type => ::Thrift::Types::STRUCT, :name => 'g', :class => ::TestNamespace::Goodbye}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class TestI32_args
      include ::Thrift::Struct, ::Thrift::Struct_Union
      BOO = 1

      FIELDS = {
        BOO => {:type => ::Thrift::Types::I32, :name => 'boo'}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

    class TestI32_result
      include ::Thrift::Struct, ::Thrift::Struct_Union
      SUCCESS = 0

      FIELDS = {
        SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
      }

      def struct_fields; FIELDS; end

      def validate
      end

      ::Thrift::Struct.generate_accessors self
    end

  end

end
