auser-poolparty 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/bin/cloud-compile +6 -1
- data/config/jeweler.rb +1 -3
- data/lib/cloud_providers/cloud_provider_instance.rb +11 -1
- data/lib/dependency_resolvers/chef/resources/chef_recipe.rb +51 -0
- data/lib/dependency_resolvers/chef.rb +12 -3
- data/lib/mixins/callbacks.rb +6 -2
- data/lib/poolparty/plugins/apache2/passenger_site.rb +2 -2
- data/test/fixtures/chef/recipes/sudo/attributes/sudoers.rb +30 -0
- data/test/fixtures/chef/recipes/sudo/recipes/default.rb +33 -0
- data/test/fixtures/chef/recipes/sudo/templates/default/sudoers.erb +22 -0
- data/test/lib/dependency_resolvers/chef/resources/chef_recipe_test.rb +21 -0
- data/test/lib/dependency_resolvers/chef_test.rb +8 -1
- data/vendor/gems/thrift/CHANGELOG +1 -0
- data/vendor/gems/thrift/Makefile.am +25 -6
- data/vendor/gems/thrift/Manifest +81 -0
- data/vendor/gems/thrift/README +17 -111
- data/vendor/gems/thrift/Rakefile +104 -0
- data/vendor/gems/thrift/{lib/hs/Setup.lhs → benchmark/Benchmark.thrift} +5 -4
- data/vendor/gems/thrift/benchmark/benchmark.rb +271 -0
- data/vendor/gems/thrift/benchmark/client.rb +74 -0
- data/vendor/gems/thrift/benchmark/server.rb +82 -0
- data/vendor/gems/thrift/benchmark/thin_server.rb +44 -0
- data/vendor/gems/thrift/ext/binary_protocol_accelerated.c +474 -0
- data/vendor/gems/thrift/{lib/cocoa/src/protocol/TProtocolException.m → ext/binary_protocol_accelerated.h} +1 -4
- data/vendor/gems/thrift/ext/compact_protocol.c +665 -0
- data/vendor/gems/thrift/{lib/cocoa/src/protocol/TProtocolException.h → ext/compact_protocol.h} +1 -6
- data/vendor/gems/thrift/ext/constants.h +95 -0
- data/vendor/gems/thrift/{contrib/fb303/Makefile.am → ext/extconf.rb} +8 -13
- data/vendor/gems/thrift/{compiler/cpp/src/platform.h → ext/macros.h} +18 -13
- data/vendor/gems/thrift/ext/memory_buffer.c +76 -0
- data/vendor/gems/thrift/{lib/csharp/src/Protocol/TMessageType.cs → ext/memory_buffer.h} +2 -13
- data/vendor/gems/thrift/ext/protocol.c +185 -0
- data/vendor/gems/thrift/{lib/csharp/src/TProcessor.cs → ext/protocol.h} +2 -11
- data/vendor/gems/thrift/ext/struct.c +606 -0
- data/vendor/gems/thrift/ext/struct.h +67 -0
- data/vendor/gems/thrift/ext/thrift_native.c +194 -0
- data/vendor/gems/thrift/lib/thrift/client.rb +62 -0
- data/vendor/gems/thrift/{contrib/fb303/py/fb303_scripts/__init__.py → lib/thrift/core_ext/fixnum.rb} +13 -4
- data/vendor/gems/thrift/{contrib/fb303/global_footer.mk → lib/thrift/core_ext.rb} +4 -2
- data/vendor/gems/thrift/lib/thrift/exceptions.rb +82 -0
- data/vendor/gems/thrift/lib/thrift/processor.rb +57 -0
- data/vendor/gems/thrift/lib/thrift/protocol/base_protocol.rb +290 -0
- data/vendor/gems/thrift/lib/thrift/protocol/binary_protocol.rb +225 -0
- data/vendor/gems/thrift/{cleanup.sh → lib/thrift/protocol/binary_protocol_accelerated.rb} +19 -42
- data/vendor/gems/thrift/lib/thrift/protocol/compact_protocol.rb +422 -0
- data/vendor/gems/thrift/lib/thrift/serializer/deserializer.rb +33 -0
- data/vendor/gems/thrift/{bootstrap.sh → lib/thrift/serializer/serializer.rb} +17 -18
- data/vendor/gems/thrift/lib/thrift/server/base_server.rb +31 -0
- data/vendor/gems/thrift/lib/thrift/server/mongrel_http_server.rb +58 -0
- data/vendor/gems/thrift/lib/thrift/server/nonblocking_server.rb +296 -0
- data/vendor/gems/thrift/lib/thrift/server/simple_server.rb +43 -0
- data/vendor/gems/thrift/lib/thrift/server/thread_pool_server.rb +75 -0
- data/vendor/gems/thrift/lib/thrift/server/threaded_server.rb +47 -0
- data/vendor/gems/thrift/lib/thrift/struct.rb +298 -0
- data/vendor/gems/thrift/{contrib/fb303/bootstrap.sh → lib/thrift/thrift_native.rb} +5 -7
- data/vendor/gems/thrift/lib/{erl/Makefile → thrift/transport/base_server_transport.rb} +20 -20
- data/vendor/gems/thrift/lib/thrift/transport/base_transport.rb +70 -0
- data/vendor/gems/thrift/lib/thrift/transport/buffered_transport.rb +77 -0
- data/vendor/gems/thrift/lib/thrift/transport/framed_transport.rb +90 -0
- data/vendor/gems/thrift/lib/thrift/transport/http_client_transport.rb +45 -0
- data/vendor/gems/thrift/lib/thrift/transport/io_stream_transport.rb +39 -0
- data/vendor/gems/thrift/lib/thrift/transport/memory_buffer_transport.rb +96 -0
- data/vendor/gems/thrift/lib/thrift/transport/server_socket.rb +63 -0
- data/vendor/gems/thrift/lib/thrift/transport/socket.rb +136 -0
- data/vendor/gems/thrift/lib/{java/Makefile.am → thrift/transport/unix_server_socket.rb} +39 -17
- data/vendor/gems/thrift/{contrib/fb303/global_header.mk → lib/thrift/transport/unix_socket.rb} +23 -21
- data/vendor/gems/thrift/lib/thrift/types.rb +101 -0
- data/vendor/gems/thrift/lib/thrift.rb +59 -0
- data/vendor/gems/thrift/script/proto_benchmark.rb +121 -0
- data/vendor/gems/thrift/{lib/Makefile.am → script/read_struct.rb} +24 -36
- data/vendor/gems/thrift/{contrib/fb303/py/setup.py → script/write_struct.rb} +8 -5
- data/vendor/gems/thrift/setup.rb +1585 -0
- data/vendor/gems/thrift/spec/ThriftSpec.thrift +84 -0
- data/vendor/gems/thrift/spec/base_protocol_spec.rb +160 -0
- data/vendor/gems/thrift/spec/base_transport_spec.rb +351 -0
- data/vendor/gems/thrift/{contrib/fb303/py/Makefile.am → spec/binary_protocol_accelerated_spec.rb} +22 -25
- data/vendor/gems/thrift/spec/binary_protocol_spec.rb +63 -0
- data/vendor/gems/thrift/spec/binary_protocol_spec_shared.rb +375 -0
- data/vendor/gems/thrift/spec/client_spec.rb +100 -0
- data/vendor/gems/thrift/spec/compact_protocol_spec.rb +117 -0
- data/vendor/gems/thrift/spec/exception_spec.rb +142 -0
- data/vendor/gems/thrift/spec/http_client_spec.rb +49 -0
- data/vendor/gems/thrift/spec/mongrel_http_server_spec.rb +117 -0
- data/vendor/gems/thrift/spec/nonblocking_server_spec.rb +265 -0
- data/vendor/gems/thrift/spec/processor_spec.rb +83 -0
- data/vendor/gems/thrift/spec/serializer_spec.rb +69 -0
- data/vendor/gems/thrift/spec/server_socket_spec.rb +80 -0
- data/vendor/gems/thrift/spec/server_spec.rb +160 -0
- data/vendor/gems/thrift/spec/socket_spec.rb +61 -0
- data/vendor/gems/thrift/spec/socket_spec_shared.rb +104 -0
- data/vendor/gems/thrift/spec/spec_helper.rb +60 -0
- data/vendor/gems/thrift/spec/struct_spec.rb +252 -0
- data/vendor/gems/thrift/spec/types_spec.rb +116 -0
- data/vendor/gems/thrift/spec/unix_socket_spec.rb +108 -0
- data/vendor/gems/trollop/FAQ.txt +84 -0
- data/vendor/gems/trollop/History.txt +101 -0
- data/vendor/gems/trollop/Manifest.txt +7 -0
- data/vendor/gems/trollop/README.txt +40 -0
- data/vendor/gems/trollop/Rakefile +36 -0
- data/vendor/gems/trollop/lib/trollop.rb +739 -0
- data/vendor/gems/trollop/release-script.txt +13 -0
- data/vendor/gems/trollop/test/test_trollop.rb +1048 -0
- data/vendor/gems/trollop/www/index.html +172 -0
- metadata +123 -347
- data/vendor/gems/thrift/CHANGES +0 -35
- data/vendor/gems/thrift/CONTRIBUTORS +0 -77
- data/vendor/gems/thrift/DISCLAIMER +0 -6
- data/vendor/gems/thrift/LICENSE +0 -202
- data/vendor/gems/thrift/NEWS +0 -79
- data/vendor/gems/thrift/NOTICE +0 -26
- data/vendor/gems/thrift/aclocal/ax_boost_base.m4 +0 -198
- data/vendor/gems/thrift/aclocal/ax_javac_and_java.m4 +0 -107
- data/vendor/gems/thrift/aclocal/ax_lib_event.m4 +0 -194
- data/vendor/gems/thrift/aclocal/ax_lib_zlib.m4 +0 -173
- data/vendor/gems/thrift/aclocal/ax_signed_right_shift.m4 +0 -127
- data/vendor/gems/thrift/aclocal/ax_thrift_internal.m4 +0 -39
- data/vendor/gems/thrift/compiler/cpp/Makefile.am +0 -136
- data/vendor/gems/thrift/compiler/cpp/README +0 -39
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_cocoa_generator.cc +0 -2331
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_cpp_generator.cc +0 -3003
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_csharp_generator.cc +0 -1700
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_erl_generator.cc +0 -932
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.cc +0 -173
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_generator.h +0 -321
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_hs_generator.cc +0 -1445
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_html_generator.cc +0 -637
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_java_generator.cc +0 -3069
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_ocaml_generator.cc +0 -1673
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_oop_generator.h +0 -77
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_perl_generator.cc +0 -1812
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_php_generator.cc +0 -2281
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_py_generator.cc +0 -2310
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_rb_generator.cc +0 -1114
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_st_generator.cc +0 -1071
- data/vendor/gems/thrift/compiler/cpp/src/generate/t_xsd_generator.cc +0 -354
- data/vendor/gems/thrift/compiler/cpp/src/globals.h +0 -117
- data/vendor/gems/thrift/compiler/cpp/src/main.cc +0 -1207
- data/vendor/gems/thrift/compiler/cpp/src/main.h +0 -103
- data/vendor/gems/thrift/compiler/cpp/src/md5.c +0 -381
- data/vendor/gems/thrift/compiler/cpp/src/md5.h +0 -91
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_base_type.h +0 -137
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_const.h +0 -59
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_const_value.h +0 -121
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_container.h +0 -56
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_doc.h +0 -51
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum.h +0 -59
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_enum_value.h +0 -64
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_field.h +0 -150
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_function.h +0 -93
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_list.h +0 -56
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_map.h +0 -64
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_program.h +0 -223
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_scope.h +0 -86
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_service.h +0 -68
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_set.h +0 -55
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_struct.h +0 -127
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_type.h +0 -176
- data/vendor/gems/thrift/compiler/cpp/src/parse/t_typedef.h +0 -70
- data/vendor/gems/thrift/compiler/cpp/src/thriftl.ll +0 -303
- data/vendor/gems/thrift/compiler/cpp/src/thrifty.yy +0 -1140
- data/vendor/gems/thrift/configure.ac +0 -255
- data/vendor/gems/thrift/contrib/fb303/LICENSE +0 -16
- data/vendor/gems/thrift/contrib/fb303/README +0 -37
- data/vendor/gems/thrift/contrib/fb303/acinclude.m4 +0 -258
- data/vendor/gems/thrift/contrib/fb303/aclocal/ax_boost_base.m4 +0 -198
- data/vendor/gems/thrift/contrib/fb303/configure.ac +0 -115
- data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.cpp +0 -124
- data/vendor/gems/thrift/contrib/fb303/cpp/FacebookBase.h +0 -103
- data/vendor/gems/thrift/contrib/fb303/cpp/Makefile.am +0 -84
- data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.cpp +0 -481
- data/vendor/gems/thrift/contrib/fb303/cpp/ServiceTracker.h +0 -215
- data/vendor/gems/thrift/contrib/fb303/if/fb303.thrift +0 -112
- data/vendor/gems/thrift/contrib/fb303/java/FacebookBase.java +0 -103
- data/vendor/gems/thrift/contrib/fb303/java/build.xml +0 -84
- data/vendor/gems/thrift/contrib/fb303/php/FacebookBase.php +0 -89
- data/vendor/gems/thrift/contrib/fb303/py/fb303/FacebookBase.py +0 -82
- data/vendor/gems/thrift/contrib/fb303/py/fb303_scripts/fb303_simple_mgmt.py +0 -195
- data/vendor/gems/thrift/contrib/thrift.el +0 -126
- data/vendor/gems/thrift/contrib/thrift.spec +0 -206
- data/vendor/gems/thrift/contrib/thrift.vim +0 -91
- data/vendor/gems/thrift/contrib/thrift_dump.cpp +0 -91
- data/vendor/gems/thrift/doc/lgpl-2.1.txt +0 -504
- data/vendor/gems/thrift/doc/otp-base-license.txt +0 -20
- data/vendor/gems/thrift/doc/thrift.bnf +0 -96
- data/vendor/gems/thrift/doc/thrift.tex +0 -1057
- data/vendor/gems/thrift/lib/cocoa/README +0 -21
- data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.h +0 -44
- data/vendor/gems/thrift/lib/cocoa/src/TApplicationException.m +0 -130
- data/vendor/gems/thrift/lib/cocoa/src/TException.h +0 -34
- data/vendor/gems/thrift/lib/cocoa/src/TException.m +0 -64
- data/vendor/gems/thrift/lib/cocoa/src/TProcessor.h +0 -29
- data/vendor/gems/thrift/lib/cocoa/src/TProcessorFactory.h +0 -27
- data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.h +0 -27
- data/vendor/gems/thrift/lib/cocoa/src/TSharedProcessorFactory.m +0 -51
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.h +0 -51
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TBinaryProtocol.m +0 -477
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocol.h +0 -148
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolFactory.h +0 -29
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.h +0 -29
- data/vendor/gems/thrift/lib/cocoa/src/protocol/TProtocolUtil.m +0 -104
- data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.h +0 -50
- data/vendor/gems/thrift/lib/cocoa/src/server/TSocketServer.m +0 -153
- data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.h +0 -42
- data/vendor/gems/thrift/lib/cocoa/src/transport/THTTPClient.m +0 -159
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.h +0 -35
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSFileHandleTransport.m +0 -91
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.h +0 -38
- data/vendor/gems/thrift/lib/cocoa/src/transport/TNSStreamTransport.m +0 -89
- data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.h +0 -32
- data/vendor/gems/thrift/lib/cocoa/src/transport/TSocketClient.m +0 -58
- data/vendor/gems/thrift/lib/cocoa/src/transport/TTransport.h +0 -36
- data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.h +0 -30
- data/vendor/gems/thrift/lib/cocoa/src/transport/TTransportException.m +0 -43
- data/vendor/gems/thrift/lib/cpp/Makefile.am +0 -158
- data/vendor/gems/thrift/lib/cpp/README +0 -67
- data/vendor/gems/thrift/lib/cpp/src/TLogging.h +0 -163
- data/vendor/gems/thrift/lib/cpp/src/TProcessor.h +0 -53
- data/vendor/gems/thrift/lib/cpp/src/TReflectionLocal.h +0 -96
- data/vendor/gems/thrift/lib/cpp/src/Thrift.cpp +0 -148
- data/vendor/gems/thrift/lib/cpp/src/Thrift.h +0 -191
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Exception.h +0 -60
- data/vendor/gems/thrift/lib/cpp/src/concurrency/FunctionRunner.h +0 -77
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.cpp +0 -137
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Monitor.h +0 -84
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.cpp +0 -160
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Mutex.h +0 -114
- data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.cpp +0 -314
- data/vendor/gems/thrift/lib/cpp/src/concurrency/PosixThreadFactory.h +0 -130
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Thread.h +0 -125
- data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.cpp +0 -493
- data/vendor/gems/thrift/lib/cpp/src/concurrency/ThreadManager.h +0 -169
- data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.cpp +0 -284
- data/vendor/gems/thrift/lib/cpp/src/concurrency/TimerManager.h +0 -122
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.cpp +0 -55
- data/vendor/gems/thrift/lib/cpp/src/concurrency/Util.h +0 -100
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/Tests.cpp +0 -155
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadFactoryTests.h +0 -354
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/ThreadManagerTests.h +0 -379
- data/vendor/gems/thrift/lib/cpp/src/concurrency/test/TimerManagerTests.h +0 -155
- data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.cpp +0 -122
- data/vendor/gems/thrift/lib/cpp/src/processor/PeekProcessor.h +0 -77
- data/vendor/gems/thrift/lib/cpp/src/processor/StatsProcessor.h +0 -264
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.cpp +0 -79
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBase64Utils.h +0 -42
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.cpp +0 -394
- data/vendor/gems/thrift/lib/cpp/src/protocol/TBinaryProtocol.h +0 -254
- data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.cpp +0 -736
- data/vendor/gems/thrift/lib/cpp/src/protocol/TCompactProtocol.h +0 -279
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.cpp +0 -346
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDebugProtocol.h +0 -225
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.cpp +0 -762
- data/vendor/gems/thrift/lib/cpp/src/protocol/TDenseProtocol.h +0 -253
- data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.cpp +0 -998
- data/vendor/gems/thrift/lib/cpp/src/protocol/TJSONProtocol.h +0 -340
- data/vendor/gems/thrift/lib/cpp/src/protocol/TOneWayProtocol.h +0 -304
- data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocol.h +0 -438
- data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolException.h +0 -104
- data/vendor/gems/thrift/lib/cpp/src/protocol/TProtocolTap.h +0 -187
- data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.cpp +0 -750
- data/vendor/gems/thrift/lib/cpp/src/server/TNonblockingServer.h +0 -435
- data/vendor/gems/thrift/lib/cpp/src/server/TServer.cpp +0 -38
- data/vendor/gems/thrift/lib/cpp/src/server/TServer.h +0 -213
- data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.cpp +0 -118
- data/vendor/gems/thrift/lib/cpp/src/server/TSimpleServer.h +0 -70
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.cpp +0 -217
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadPoolServer.h +0 -79
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.cpp +0 -243
- data/vendor/gems/thrift/lib/cpp/src/server/TThreadedServer.h +0 -74
- data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.cpp +0 -370
- data/vendor/gems/thrift/lib/cpp/src/transport/TBufferTransports.h +0 -667
- data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.cpp +0 -77
- data/vendor/gems/thrift/lib/cpp/src/transport/TFDTransport.h +0 -73
- data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.cpp +0 -953
- data/vendor/gems/thrift/lib/cpp/src/transport/TFileTransport.h +0 -442
- data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.cpp +0 -348
- data/vendor/gems/thrift/lib/cpp/src/transport/THttpClient.h +0 -111
- data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.cpp +0 -368
- data/vendor/gems/thrift/lib/cpp/src/transport/TServerSocket.h +0 -76
- data/vendor/gems/thrift/lib/cpp/src/transport/TServerTransport.h +0 -92
- data/vendor/gems/thrift/lib/cpp/src/transport/TShortReadTransport.h +0 -96
- data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.cpp +0 -54
- data/vendor/gems/thrift/lib/cpp/src/transport/TSimpleFileTransport.h +0 -41
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.cpp +0 -591
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocket.h +0 -242
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.cpp +0 -235
- data/vendor/gems/thrift/lib/cpp/src/transport/TSocketPool.h +0 -191
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransport.h +0 -224
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.cpp +0 -31
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportException.h +0 -117
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.cpp +0 -178
- data/vendor/gems/thrift/lib/cpp/src/transport/TTransportUtils.h +0 -287
- data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.cpp +0 -299
- data/vendor/gems/thrift/lib/cpp/src/transport/TZlibTransport.h +0 -219
- data/vendor/gems/thrift/lib/cpp/thrift-nb.pc.in +0 -30
- data/vendor/gems/thrift/lib/cpp/thrift-z.pc.in +0 -30
- data/vendor/gems/thrift/lib/cpp/thrift.pc.in +0 -29
- data/vendor/gems/thrift/lib/csharp/Makefile.am +0 -70
- data/vendor/gems/thrift/lib/csharp/README +0 -26
- data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/Properties/AssemblyInfo.cs +0 -55
- data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftBuild.cs +0 -242
- data/vendor/gems/thrift/lib/csharp/ThriftMSBuildTask/ThriftMSBuildTask.csproj +0 -62
- data/vendor/gems/thrift/lib/csharp/src/Collections/THashSet.cs +0 -142
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TBase.cs +0 -34
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TBinaryProtocol.cs +0 -392
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TField.cs +0 -58
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TList.cs +0 -50
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TMap.cs +0 -58
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TMessage.cs +0 -58
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocol.cs +0 -87
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolException.cs +0 -61
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolFactory.cs +0 -29
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TProtocolUtil.cs +0 -94
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TSet.cs +0 -50
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TStruct.cs +0 -42
- data/vendor/gems/thrift/lib/csharp/src/Protocol/TType.cs +0 -40
- data/vendor/gems/thrift/lib/csharp/src/Server/TServer.cs +0 -135
- data/vendor/gems/thrift/lib/csharp/src/Server/TSimpleServer.cs +0 -148
- data/vendor/gems/thrift/lib/csharp/src/Server/TThreadPoolServer.cs +0 -186
- data/vendor/gems/thrift/lib/csharp/src/Server/TThreadedServer.cs +0 -234
- data/vendor/gems/thrift/lib/csharp/src/TApplicationException.cs +0 -131
- data/vendor/gems/thrift/lib/csharp/src/Thrift.csproj +0 -73
- data/vendor/gems/thrift/lib/csharp/src/Thrift.sln +0 -35
- data/vendor/gems/thrift/lib/csharp/src/Transport/TBufferedTransport.cs +0 -100
- data/vendor/gems/thrift/lib/csharp/src/Transport/TServerSocket.cs +0 -157
- data/vendor/gems/thrift/lib/csharp/src/Transport/TServerTransport.cs +0 -39
- data/vendor/gems/thrift/lib/csharp/src/Transport/TSocket.cs +0 -144
- data/vendor/gems/thrift/lib/csharp/src/Transport/TStreamTransport.cs +0 -103
- data/vendor/gems/thrift/lib/csharp/src/Transport/TTransport.cs +0 -66
- data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportException.cs +0 -64
- data/vendor/gems/thrift/lib/csharp/src/Transport/TTransportFactory.cs +0 -38
- data/vendor/gems/thrift/lib/erl/README +0 -56
- data/vendor/gems/thrift/lib/erl/build/beamver +0 -59
- data/vendor/gems/thrift/lib/erl/build/buildtargets.mk +0 -15
- data/vendor/gems/thrift/lib/erl/build/colors.mk +0 -24
- data/vendor/gems/thrift/lib/erl/build/docs.mk +0 -12
- data/vendor/gems/thrift/lib/erl/build/mime.types +0 -98
- data/vendor/gems/thrift/lib/erl/build/otp.mk +0 -146
- data/vendor/gems/thrift/lib/erl/build/otp_subdir.mk +0 -85
- data/vendor/gems/thrift/lib/erl/build/raw_test.mk +0 -29
- data/vendor/gems/thrift/lib/erl/include/thrift_constants.hrl +0 -54
- data/vendor/gems/thrift/lib/erl/include/thrift_protocol.hrl +0 -31
- data/vendor/gems/thrift/lib/erl/src/Makefile +0 -116
- data/vendor/gems/thrift/lib/erl/src/test_handler.erl +0 -26
- data/vendor/gems/thrift/lib/erl/src/test_service.erl +0 -29
- data/vendor/gems/thrift/lib/erl/src/thrift.app.src +0 -44
- data/vendor/gems/thrift/lib/erl/src/thrift.appup.src +0 -1
- data/vendor/gems/thrift/lib/erl/src/thrift_base64_transport.erl +0 -64
- data/vendor/gems/thrift/lib/erl/src/thrift_binary_protocol.erl +0 -325
- data/vendor/gems/thrift/lib/erl/src/thrift_buffered_transport.erl +0 -180
- data/vendor/gems/thrift/lib/erl/src/thrift_client.erl +0 -384
- data/vendor/gems/thrift/lib/erl/src/thrift_disk_log_transport.erl +0 -118
- data/vendor/gems/thrift/lib/erl/src/thrift_file_transport.erl +0 -87
- data/vendor/gems/thrift/lib/erl/src/thrift_framed_transport.erl +0 -208
- data/vendor/gems/thrift/lib/erl/src/thrift_http_transport.erl +0 -199
- data/vendor/gems/thrift/lib/erl/src/thrift_memory_buffer.erl +0 -164
- data/vendor/gems/thrift/lib/erl/src/thrift_processor.erl +0 -188
- data/vendor/gems/thrift/lib/erl/src/thrift_protocol.erl +0 -356
- data/vendor/gems/thrift/lib/erl/src/thrift_server.erl +0 -183
- data/vendor/gems/thrift/lib/erl/src/thrift_service.erl +0 -25
- data/vendor/gems/thrift/lib/erl/src/thrift_socket_server.erl +0 -249
- data/vendor/gems/thrift/lib/erl/src/thrift_socket_transport.erl +0 -119
- data/vendor/gems/thrift/lib/erl/src/thrift_transport.erl +0 -57
- data/vendor/gems/thrift/lib/erl/vsn.mk +0 -1
- data/vendor/gems/thrift/lib/hs/README +0 -82
- data/vendor/gems/thrift/lib/hs/TODO +0 -2
- data/vendor/gems/thrift/lib/hs/Thrift.cabal +0 -20
- data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol/Binary.hs +0 -147
- data/vendor/gems/thrift/lib/hs/src/Thrift/Protocol.hs +0 -191
- data/vendor/gems/thrift/lib/hs/src/Thrift/Server.hs +0 -65
- data/vendor/gems/thrift/lib/hs/src/Thrift/Transport/Handle.hs +0 -58
- data/vendor/gems/thrift/lib/hs/src/Thrift/Transport.hs +0 -60
- data/vendor/gems/thrift/lib/hs/src/Thrift.hs +0 -111
- data/vendor/gems/thrift/lib/java/README +0 -43
- data/vendor/gems/thrift/lib/java/build.xml +0 -195
- data/vendor/gems/thrift/lib/java/ivy.xml +0 -8
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/IntRangeSet.java +0 -171
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TApplicationException.java +0 -123
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBase.java +0 -66
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TBaseHelper.java +0 -102
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java +0 -46
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TDeserializer.java +0 -94
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TException.java +0 -45
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TFieldRequirementType.java +0 -30
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessor.java +0 -32
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TProcessorFactory.java +0 -39
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/TSerializer.java +0 -110
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldMetaData.java +0 -69
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/FieldValueMetaData.java +0 -42
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/ListMetaData.java +0 -29
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/MapMetaData.java +0 -31
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/SetMetaData.java +0 -29
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/meta_data/StructMetaData.java +0 -31
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBase64Utils.java +0 -128
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java +0 -331
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TCompactProtocol.java +0 -741
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TField.java +0 -48
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TJSONProtocol.java +0 -927
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TList.java +0 -38
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMap.java +0 -40
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessage.java +0 -48
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TMessageType.java +0 -31
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocol.java +0 -146
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolException.java +0 -81
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolFactory.java +0 -30
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TProtocolUtil.java +0 -158
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSet.java +0 -42
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TSimpleJSONProtocol.java +0 -384
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TStruct.java +0 -36
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/protocol/TType.java +0 -40
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/THsHaServer.java +0 -304
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TNonblockingServer.java +0 -772
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TServer.java +0 -126
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TSimpleServer.java +0 -145
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java +0 -271
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TFramedTransport.java +0 -126
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/THttpClient.java +0 -157
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TIOStreamTransport.java +0 -159
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TMemoryBuffer.java +0 -98
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerSocket.java +0 -160
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingServerTransport.java +0 -31
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingSocket.java +0 -213
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TNonblockingTransport.java +0 -31
- data/vendor/gems/thrift/lib/java/src/org/apache/thrift/transport/TServerSocket.java +0 -145
@@ -1,3069 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
3
|
-
* or more contributor license agreements. See the NOTICE file
|
4
|
-
* distributed with this work for additional information
|
5
|
-
* regarding copyright ownership. The ASF licenses this file
|
6
|
-
* to you under the Apache License, Version 2.0 (the
|
7
|
-
* "License"); you may not use this file except in compliance
|
8
|
-
* with the License. You may obtain a copy of the License at
|
9
|
-
*
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
*
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
13
|
-
* software distributed under the License is distributed on an
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
-
* KIND, either express or implied. See the License for the
|
16
|
-
* specific language governing permissions and limitations
|
17
|
-
* under the License.
|
18
|
-
*/
|
19
|
-
|
20
|
-
#include <sstream>
|
21
|
-
#include <string>
|
22
|
-
#include <fstream>
|
23
|
-
#include <iostream>
|
24
|
-
#include <vector>
|
25
|
-
#include <cctype>
|
26
|
-
|
27
|
-
#include <sys/stat.h>
|
28
|
-
#include <stdexcept>
|
29
|
-
|
30
|
-
#include "platform.h"
|
31
|
-
#include "t_oop_generator.h"
|
32
|
-
using namespace std;
|
33
|
-
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Java code generator.
|
37
|
-
*
|
38
|
-
*/
|
39
|
-
class t_java_generator : public t_oop_generator {
|
40
|
-
public:
|
41
|
-
t_java_generator(
|
42
|
-
t_program* program,
|
43
|
-
const std::map<std::string, std::string>& parsed_options,
|
44
|
-
const std::string& option_string)
|
45
|
-
: t_oop_generator(program)
|
46
|
-
{
|
47
|
-
std::map<std::string, std::string>::const_iterator iter;
|
48
|
-
|
49
|
-
iter = parsed_options.find("beans");
|
50
|
-
bean_style_ = (iter != parsed_options.end());
|
51
|
-
|
52
|
-
iter = parsed_options.find("nocamel");
|
53
|
-
nocamel_style_ = (iter != parsed_options.end());
|
54
|
-
|
55
|
-
iter = parsed_options.find("hashcode");
|
56
|
-
gen_hash_code_ = (iter != parsed_options.end());
|
57
|
-
|
58
|
-
out_dir_base_ = (bean_style_ ? "gen-javabean" : "gen-java");
|
59
|
-
}
|
60
|
-
|
61
|
-
/**
|
62
|
-
* Init and close methods
|
63
|
-
*/
|
64
|
-
|
65
|
-
void init_generator();
|
66
|
-
void close_generator();
|
67
|
-
|
68
|
-
void generate_consts(std::vector<t_const*> consts);
|
69
|
-
|
70
|
-
/**
|
71
|
-
* Program-level generation functions
|
72
|
-
*/
|
73
|
-
|
74
|
-
void generate_typedef (t_typedef* ttypedef);
|
75
|
-
void generate_enum (t_enum* tenum);
|
76
|
-
void generate_struct (t_struct* tstruct);
|
77
|
-
void generate_xception(t_struct* txception);
|
78
|
-
void generate_service (t_service* tservice);
|
79
|
-
|
80
|
-
void print_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value, bool in_static, bool defval=false);
|
81
|
-
std::string render_const_value(std::ofstream& out, std::string name, t_type* type, t_const_value* value);
|
82
|
-
|
83
|
-
/**
|
84
|
-
* Service-level generation functions
|
85
|
-
*/
|
86
|
-
|
87
|
-
void generate_java_struct(t_struct* tstruct, bool is_exception);
|
88
|
-
|
89
|
-
void generate_java_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false, bool in_class=false, bool is_result=false);
|
90
|
-
void generate_java_struct_equality(std::ofstream& out, t_struct* tstruct);
|
91
|
-
void generate_java_struct_compare_to(std::ofstream& out, t_struct* tstruct);
|
92
|
-
void generate_java_struct_reader(std::ofstream& out, t_struct* tstruct);
|
93
|
-
void generate_java_validator(std::ofstream& out, t_struct* tstruct);
|
94
|
-
void generate_java_struct_result_writer(std::ofstream& out, t_struct* tstruct);
|
95
|
-
void generate_java_struct_writer(std::ofstream& out, t_struct* tstruct);
|
96
|
-
void generate_java_struct_tostring(std::ofstream& out, t_struct* tstruct);
|
97
|
-
void generate_java_meta_data_map(std::ofstream& out, t_struct* tstruct);
|
98
|
-
void generate_field_value_meta_data(std::ofstream& out, t_type* type);
|
99
|
-
std::string get_java_type_string(t_type* type);
|
100
|
-
void generate_reflection_setters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
|
101
|
-
void generate_reflection_getters(std::ostringstream& out, t_type* type, std::string field_name, std::string cap_name);
|
102
|
-
void generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct);
|
103
|
-
void generate_generic_isset_method(std::ofstream& out, t_struct* tstruct);
|
104
|
-
void generate_java_bean_boilerplate(std::ofstream& out, t_struct* tstruct);
|
105
|
-
|
106
|
-
void generate_function_helpers(t_function* tfunction);
|
107
|
-
std::string get_cap_name(std::string name);
|
108
|
-
std::string generate_isset_check(t_field* field);
|
109
|
-
std::string generate_isset_check(std::string field);
|
110
|
-
void generate_isset_set(ofstream& out, t_field* field);
|
111
|
-
std::string isset_field_id(t_field* field);
|
112
|
-
|
113
|
-
void generate_service_interface (t_service* tservice);
|
114
|
-
void generate_service_helpers (t_service* tservice);
|
115
|
-
void generate_service_client (t_service* tservice);
|
116
|
-
void generate_service_server (t_service* tservice);
|
117
|
-
void generate_process_function (t_service* tservice, t_function* tfunction);
|
118
|
-
|
119
|
-
/**
|
120
|
-
* Serialization constructs
|
121
|
-
*/
|
122
|
-
|
123
|
-
void generate_deserialize_field (std::ofstream& out,
|
124
|
-
t_field* tfield,
|
125
|
-
std::string prefix="");
|
126
|
-
|
127
|
-
void generate_deserialize_struct (std::ofstream& out,
|
128
|
-
t_struct* tstruct,
|
129
|
-
std::string prefix="");
|
130
|
-
|
131
|
-
void generate_deserialize_container (std::ofstream& out,
|
132
|
-
t_type* ttype,
|
133
|
-
std::string prefix="");
|
134
|
-
|
135
|
-
void generate_deserialize_set_element (std::ofstream& out,
|
136
|
-
t_set* tset,
|
137
|
-
std::string prefix="");
|
138
|
-
|
139
|
-
void generate_deserialize_map_element (std::ofstream& out,
|
140
|
-
t_map* tmap,
|
141
|
-
std::string prefix="");
|
142
|
-
|
143
|
-
void generate_deserialize_list_element (std::ofstream& out,
|
144
|
-
t_list* tlist,
|
145
|
-
std::string prefix="");
|
146
|
-
|
147
|
-
void generate_serialize_field (std::ofstream& out,
|
148
|
-
t_field* tfield,
|
149
|
-
std::string prefix="");
|
150
|
-
|
151
|
-
void generate_serialize_struct (std::ofstream& out,
|
152
|
-
t_struct* tstruct,
|
153
|
-
std::string prefix="");
|
154
|
-
|
155
|
-
void generate_serialize_container (std::ofstream& out,
|
156
|
-
t_type* ttype,
|
157
|
-
std::string prefix="");
|
158
|
-
|
159
|
-
void generate_serialize_map_element (std::ofstream& out,
|
160
|
-
t_map* tmap,
|
161
|
-
std::string iter,
|
162
|
-
std::string map);
|
163
|
-
|
164
|
-
void generate_serialize_set_element (std::ofstream& out,
|
165
|
-
t_set* tmap,
|
166
|
-
std::string iter);
|
167
|
-
|
168
|
-
void generate_serialize_list_element (std::ofstream& out,
|
169
|
-
t_list* tlist,
|
170
|
-
std::string iter);
|
171
|
-
|
172
|
-
void generate_java_doc (std::ofstream& out,
|
173
|
-
t_field* field);
|
174
|
-
|
175
|
-
void generate_java_doc (std::ofstream& out,
|
176
|
-
t_doc* tdoc);
|
177
|
-
|
178
|
-
void generate_java_doc (std::ofstream& out,
|
179
|
-
t_function* tdoc);
|
180
|
-
|
181
|
-
void generate_java_docstring_comment (std::ofstream &out,
|
182
|
-
string contents);
|
183
|
-
|
184
|
-
void generate_deep_copy_container(std::ofstream& out, std::string source_name_p1, std::string source_name_p2, std::string result_name, t_type* type);
|
185
|
-
void generate_deep_copy_non_container(std::ofstream& out, std::string source_name, std::string dest_name, t_type* type);
|
186
|
-
|
187
|
-
bool is_comparable(t_struct* tstruct);
|
188
|
-
bool is_comparable(t_type* type);
|
189
|
-
|
190
|
-
bool has_bit_vector(t_struct* tstruct);
|
191
|
-
|
192
|
-
/**
|
193
|
-
* Helper rendering functions
|
194
|
-
*/
|
195
|
-
|
196
|
-
std::string java_package();
|
197
|
-
std::string java_type_imports();
|
198
|
-
std::string java_thrift_imports();
|
199
|
-
std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false);
|
200
|
-
std::string base_type_name(t_base_type* tbase, bool in_container=false);
|
201
|
-
std::string declare_field(t_field* tfield, bool init=false);
|
202
|
-
std::string function_signature(t_function* tfunction, std::string prefix="");
|
203
|
-
std::string argument_list(t_struct* tstruct);
|
204
|
-
std::string type_to_enum(t_type* ttype);
|
205
|
-
std::string get_enum_class_name(t_type* type);
|
206
|
-
|
207
|
-
bool type_can_be_null(t_type* ttype) {
|
208
|
-
ttype = get_true_type(ttype);
|
209
|
-
|
210
|
-
return
|
211
|
-
ttype->is_container() ||
|
212
|
-
ttype->is_struct() ||
|
213
|
-
ttype->is_xception() ||
|
214
|
-
ttype->is_string();
|
215
|
-
}
|
216
|
-
|
217
|
-
std::string constant_name(std::string name);
|
218
|
-
|
219
|
-
private:
|
220
|
-
|
221
|
-
/**
|
222
|
-
* File streams
|
223
|
-
*/
|
224
|
-
|
225
|
-
std::string package_name_;
|
226
|
-
std::ofstream f_service_;
|
227
|
-
std::string package_dir_;
|
228
|
-
|
229
|
-
bool bean_style_;
|
230
|
-
bool nocamel_style_;
|
231
|
-
bool gen_hash_code_;
|
232
|
-
|
233
|
-
};
|
234
|
-
|
235
|
-
|
236
|
-
/**
|
237
|
-
* Prepares for file generation by opening up the necessary file output
|
238
|
-
* streams.
|
239
|
-
*
|
240
|
-
* @param tprogram The program to generate
|
241
|
-
*/
|
242
|
-
void t_java_generator::init_generator() {
|
243
|
-
// Make output directory
|
244
|
-
MKDIR(get_out_dir().c_str());
|
245
|
-
package_name_ = program_->get_namespace("java");
|
246
|
-
|
247
|
-
string dir = package_name_;
|
248
|
-
string subdir = get_out_dir();
|
249
|
-
string::size_type loc;
|
250
|
-
while ((loc = dir.find(".")) != string::npos) {
|
251
|
-
subdir = subdir + "/" + dir.substr(0, loc);
|
252
|
-
MKDIR(subdir.c_str());
|
253
|
-
dir = dir.substr(loc+1);
|
254
|
-
}
|
255
|
-
if (dir.size() > 0) {
|
256
|
-
subdir = subdir + "/" + dir;
|
257
|
-
MKDIR(subdir.c_str());
|
258
|
-
}
|
259
|
-
|
260
|
-
package_dir_ = subdir;
|
261
|
-
}
|
262
|
-
|
263
|
-
/**
|
264
|
-
* Packages the generated file
|
265
|
-
*
|
266
|
-
* @return String of the package, i.e. "package org.apache.thriftdemo;"
|
267
|
-
*/
|
268
|
-
string t_java_generator::java_package() {
|
269
|
-
if (!package_name_.empty()) {
|
270
|
-
return string("package ") + package_name_ + ";\n\n";
|
271
|
-
}
|
272
|
-
return "";
|
273
|
-
}
|
274
|
-
|
275
|
-
/**
|
276
|
-
* Prints standard java imports
|
277
|
-
*
|
278
|
-
* @return List of imports for Java types that are used in here
|
279
|
-
*/
|
280
|
-
string t_java_generator::java_type_imports() {
|
281
|
-
string hash_builder;
|
282
|
-
if (gen_hash_code_) {
|
283
|
-
hash_builder = "import org.apache.commons.lang.builder.HashCodeBuilder;\n";
|
284
|
-
}
|
285
|
-
|
286
|
-
return
|
287
|
-
string() +
|
288
|
-
hash_builder +
|
289
|
-
"import java.util.List;\n" +
|
290
|
-
"import java.util.ArrayList;\n" +
|
291
|
-
"import java.util.Map;\n" +
|
292
|
-
"import java.util.HashMap;\n" +
|
293
|
-
"import java.util.Set;\n" +
|
294
|
-
"import java.util.HashSet;\n" +
|
295
|
-
"import java.util.Collections;\n" +
|
296
|
-
"import java.util.BitSet;\n" +
|
297
|
-
"import org.slf4j.Logger;\n" +
|
298
|
-
"import org.slf4j.LoggerFactory;\n\n";
|
299
|
-
}
|
300
|
-
|
301
|
-
/**
|
302
|
-
* Prints standard java imports
|
303
|
-
*
|
304
|
-
* @return List of imports necessary for thrift
|
305
|
-
*/
|
306
|
-
string t_java_generator::java_thrift_imports() {
|
307
|
-
return
|
308
|
-
string() +
|
309
|
-
"import org.apache.thrift.*;\n" +
|
310
|
-
"import org.apache.thrift.meta_data.*;\n" +
|
311
|
-
"import org.apache.thrift.protocol.*;\n\n";
|
312
|
-
}
|
313
|
-
|
314
|
-
/**
|
315
|
-
* Nothing in Java
|
316
|
-
*/
|
317
|
-
void t_java_generator::close_generator() {}
|
318
|
-
|
319
|
-
/**
|
320
|
-
* Generates a typedef. This is not done in Java, since it does
|
321
|
-
* not support arbitrary name replacements, and it'd be a wacky waste
|
322
|
-
* of overhead to make wrapper classes.
|
323
|
-
*
|
324
|
-
* @param ttypedef The type definition
|
325
|
-
*/
|
326
|
-
void t_java_generator::generate_typedef(t_typedef* ttypedef) {}
|
327
|
-
|
328
|
-
/**
|
329
|
-
* Enums are a class with a set of static constants.
|
330
|
-
*
|
331
|
-
* @param tenum The enumeration
|
332
|
-
*/
|
333
|
-
void t_java_generator::generate_enum(t_enum* tenum) {
|
334
|
-
// Make output file
|
335
|
-
string f_enum_name = package_dir_+"/"+(tenum->get_name())+".java";
|
336
|
-
ofstream f_enum;
|
337
|
-
f_enum.open(f_enum_name.c_str());
|
338
|
-
|
339
|
-
// Comment and package it
|
340
|
-
f_enum <<
|
341
|
-
autogen_comment() <<
|
342
|
-
java_package() << endl;
|
343
|
-
|
344
|
-
// Add java imports
|
345
|
-
f_enum << string() +
|
346
|
-
"import java.util.Set;\n" +
|
347
|
-
"import java.util.HashSet;\n" +
|
348
|
-
"import java.util.Collections;\n" +
|
349
|
-
"import org.apache.thrift.IntRangeSet;\n" +
|
350
|
-
"import java.util.Map;\n" +
|
351
|
-
"import java.util.HashMap;\n" << endl;
|
352
|
-
|
353
|
-
f_enum <<
|
354
|
-
"public class " << tenum->get_name() << " ";
|
355
|
-
scope_up(f_enum);
|
356
|
-
|
357
|
-
vector<t_enum_value*> constants = tenum->get_constants();
|
358
|
-
vector<t_enum_value*>::iterator c_iter;
|
359
|
-
int value = -1;
|
360
|
-
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
|
361
|
-
if ((*c_iter)->has_value()) {
|
362
|
-
value = (*c_iter)->get_value();
|
363
|
-
} else {
|
364
|
-
++value;
|
365
|
-
}
|
366
|
-
|
367
|
-
generate_java_doc(f_enum, *c_iter);
|
368
|
-
indent(f_enum) <<
|
369
|
-
"public static final int " << (*c_iter)->get_name() <<
|
370
|
-
" = " << value << ";" << endl;
|
371
|
-
}
|
372
|
-
|
373
|
-
// Create a static Set with all valid values for this enum
|
374
|
-
f_enum << endl;
|
375
|
-
indent(f_enum) << "public static final IntRangeSet VALID_VALUES = new IntRangeSet(";
|
376
|
-
indent_up();
|
377
|
-
bool first = true;
|
378
|
-
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
|
379
|
-
// populate set
|
380
|
-
f_enum << (first ? "" : ", ") << endl;
|
381
|
-
first = false;
|
382
|
-
indent(f_enum) << (*c_iter)->get_name();
|
383
|
-
}
|
384
|
-
f_enum << " );" << endl << endl;
|
385
|
-
indent_down();
|
386
|
-
|
387
|
-
indent(f_enum) << "public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{" << endl;
|
388
|
-
|
389
|
-
indent_up();
|
390
|
-
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
|
391
|
-
indent(f_enum) << "put(" << (*c_iter)->get_name() << ", \"" << (*c_iter)->get_name() <<"\");" << endl;
|
392
|
-
}
|
393
|
-
indent_down();
|
394
|
-
|
395
|
-
|
396
|
-
indent(f_enum) << "}};" << endl;
|
397
|
-
|
398
|
-
scope_down(f_enum);
|
399
|
-
|
400
|
-
f_enum.close();
|
401
|
-
}
|
402
|
-
|
403
|
-
/**
|
404
|
-
* Generates a class that holds all the constants.
|
405
|
-
*/
|
406
|
-
void t_java_generator::generate_consts(std::vector<t_const*> consts) {
|
407
|
-
if (consts.empty()) {
|
408
|
-
return;
|
409
|
-
}
|
410
|
-
|
411
|
-
string f_consts_name = package_dir_+"/Constants.java";
|
412
|
-
ofstream f_consts;
|
413
|
-
f_consts.open(f_consts_name.c_str());
|
414
|
-
|
415
|
-
// Print header
|
416
|
-
f_consts <<
|
417
|
-
autogen_comment() <<
|
418
|
-
java_package() <<
|
419
|
-
java_type_imports();
|
420
|
-
|
421
|
-
f_consts <<
|
422
|
-
"public class Constants {" << endl <<
|
423
|
-
endl;
|
424
|
-
indent_up();
|
425
|
-
vector<t_const*>::iterator c_iter;
|
426
|
-
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
|
427
|
-
print_const_value(f_consts,
|
428
|
-
(*c_iter)->get_name(),
|
429
|
-
(*c_iter)->get_type(),
|
430
|
-
(*c_iter)->get_value(),
|
431
|
-
false);
|
432
|
-
}
|
433
|
-
indent_down();
|
434
|
-
indent(f_consts) <<
|
435
|
-
"}" << endl;
|
436
|
-
f_consts.close();
|
437
|
-
}
|
438
|
-
|
439
|
-
|
440
|
-
/**
|
441
|
-
* Prints the value of a constant with the given type. Note that type checking
|
442
|
-
* is NOT performed in this function as it is always run beforehand using the
|
443
|
-
* validate_types method in main.cc
|
444
|
-
*/
|
445
|
-
void t_java_generator::print_const_value(std::ofstream& out, string name, t_type* type, t_const_value* value, bool in_static, bool defval) {
|
446
|
-
type = get_true_type(type);
|
447
|
-
|
448
|
-
indent(out);
|
449
|
-
if (!defval) {
|
450
|
-
out <<
|
451
|
-
(in_static ? "" : "public static final ") <<
|
452
|
-
type_name(type) << " ";
|
453
|
-
}
|
454
|
-
if (type->is_base_type()) {
|
455
|
-
string v2 = render_const_value(out, name, type, value);
|
456
|
-
out << name << " = " << v2 << ";" << endl << endl;
|
457
|
-
} else if (type->is_enum()) {
|
458
|
-
out << name << " = " << value->get_integer() << ";" << endl << endl;
|
459
|
-
} else if (type->is_struct() || type->is_xception()) {
|
460
|
-
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
|
461
|
-
vector<t_field*>::const_iterator f_iter;
|
462
|
-
const map<t_const_value*, t_const_value*>& val = value->get_map();
|
463
|
-
map<t_const_value*, t_const_value*>::const_iterator v_iter;
|
464
|
-
out << name << " = new " << type_name(type, false, true) << "();" << endl;
|
465
|
-
if (!in_static) {
|
466
|
-
indent(out) << "static {" << endl;
|
467
|
-
indent_up();
|
468
|
-
}
|
469
|
-
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
|
470
|
-
t_type* field_type = NULL;
|
471
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
472
|
-
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
|
473
|
-
field_type = (*f_iter)->get_type();
|
474
|
-
}
|
475
|
-
}
|
476
|
-
if (field_type == NULL) {
|
477
|
-
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
|
478
|
-
}
|
479
|
-
string val = render_const_value(out, name, field_type, v_iter->second);
|
480
|
-
indent(out) << name << ".";
|
481
|
-
std::string cap_name = get_cap_name(v_iter->first->get_string());
|
482
|
-
out << "set" << cap_name << "(" << val << ");" << endl;
|
483
|
-
}
|
484
|
-
if (!in_static) {
|
485
|
-
indent_down();
|
486
|
-
indent(out) << "}" << endl;
|
487
|
-
}
|
488
|
-
out << endl;
|
489
|
-
} else if (type->is_map()) {
|
490
|
-
out << name << " = new " << type_name(type, false, true) << "();" << endl;
|
491
|
-
if (!in_static) {
|
492
|
-
indent(out) << "static {" << endl;
|
493
|
-
indent_up();
|
494
|
-
}
|
495
|
-
t_type* ktype = ((t_map*)type)->get_key_type();
|
496
|
-
t_type* vtype = ((t_map*)type)->get_val_type();
|
497
|
-
const map<t_const_value*, t_const_value*>& val = value->get_map();
|
498
|
-
map<t_const_value*, t_const_value*>::const_iterator v_iter;
|
499
|
-
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
|
500
|
-
string key = render_const_value(out, name, ktype, v_iter->first);
|
501
|
-
string val = render_const_value(out, name, vtype, v_iter->second);
|
502
|
-
indent(out) << name << ".put(" << key << ", " << val << ");" << endl;
|
503
|
-
}
|
504
|
-
if (!in_static) {
|
505
|
-
indent_down();
|
506
|
-
indent(out) << "}" << endl;
|
507
|
-
}
|
508
|
-
out << endl;
|
509
|
-
} else if (type->is_list() || type->is_set()) {
|
510
|
-
out << name << " = new " << type_name(type, false, true) << "();" << endl;
|
511
|
-
if (!in_static) {
|
512
|
-
indent(out) << "static {" << endl;
|
513
|
-
indent_up();
|
514
|
-
}
|
515
|
-
t_type* etype;
|
516
|
-
if (type->is_list()) {
|
517
|
-
etype = ((t_list*)type)->get_elem_type();
|
518
|
-
} else {
|
519
|
-
etype = ((t_set*)type)->get_elem_type();
|
520
|
-
}
|
521
|
-
const vector<t_const_value*>& val = value->get_list();
|
522
|
-
vector<t_const_value*>::const_iterator v_iter;
|
523
|
-
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
|
524
|
-
string val = render_const_value(out, name, etype, *v_iter);
|
525
|
-
indent(out) << name << ".add(" << val << ");" << endl;
|
526
|
-
}
|
527
|
-
if (!in_static) {
|
528
|
-
indent_down();
|
529
|
-
indent(out) << "}" << endl;
|
530
|
-
}
|
531
|
-
out << endl;
|
532
|
-
} else {
|
533
|
-
throw "compiler error: no const of type " + type->get_name();
|
534
|
-
}
|
535
|
-
}
|
536
|
-
|
537
|
-
string t_java_generator::render_const_value(ofstream& out, string name, t_type* type, t_const_value* value) {
|
538
|
-
type = get_true_type(type);
|
539
|
-
std::ostringstream render;
|
540
|
-
|
541
|
-
if (type->is_base_type()) {
|
542
|
-
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
|
543
|
-
switch (tbase) {
|
544
|
-
case t_base_type::TYPE_STRING:
|
545
|
-
render << '"' << get_escaped_string(value) << '"';
|
546
|
-
break;
|
547
|
-
case t_base_type::TYPE_BOOL:
|
548
|
-
render << ((value->get_integer() > 0) ? "true" : "false");
|
549
|
-
break;
|
550
|
-
case t_base_type::TYPE_BYTE:
|
551
|
-
render << "(byte)" << value->get_integer();
|
552
|
-
break;
|
553
|
-
case t_base_type::TYPE_I16:
|
554
|
-
render << "(short)" << value->get_integer();
|
555
|
-
break;
|
556
|
-
case t_base_type::TYPE_I32:
|
557
|
-
render << value->get_integer();
|
558
|
-
break;
|
559
|
-
case t_base_type::TYPE_I64:
|
560
|
-
render << value->get_integer() << "L";
|
561
|
-
break;
|
562
|
-
case t_base_type::TYPE_DOUBLE:
|
563
|
-
if (value->get_type() == t_const_value::CV_INTEGER) {
|
564
|
-
render << "(double)" << value->get_integer();
|
565
|
-
} else {
|
566
|
-
render << value->get_double();
|
567
|
-
}
|
568
|
-
break;
|
569
|
-
default:
|
570
|
-
throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase);
|
571
|
-
}
|
572
|
-
} else if (type->is_enum()) {
|
573
|
-
render << value->get_integer();
|
574
|
-
} else {
|
575
|
-
string t = tmp("tmp");
|
576
|
-
print_const_value(out, t, type, value, true);
|
577
|
-
render << t;
|
578
|
-
}
|
579
|
-
|
580
|
-
return render.str();
|
581
|
-
}
|
582
|
-
|
583
|
-
/**
|
584
|
-
* Generates a struct definition for a thrift data type. This is a class
|
585
|
-
* with data members, read(), write(), and an inner Isset class.
|
586
|
-
*
|
587
|
-
* @param tstruct The struct definition
|
588
|
-
*/
|
589
|
-
void t_java_generator::generate_struct(t_struct* tstruct) {
|
590
|
-
generate_java_struct(tstruct, false);
|
591
|
-
}
|
592
|
-
|
593
|
-
/**
|
594
|
-
* Exceptions are structs, but they inherit from Exception
|
595
|
-
*
|
596
|
-
* @param tstruct The struct definition
|
597
|
-
*/
|
598
|
-
void t_java_generator::generate_xception(t_struct* txception) {
|
599
|
-
generate_java_struct(txception, true);
|
600
|
-
}
|
601
|
-
|
602
|
-
|
603
|
-
/**
|
604
|
-
* Java struct definition.
|
605
|
-
*
|
606
|
-
* @param tstruct The struct definition
|
607
|
-
*/
|
608
|
-
void t_java_generator::generate_java_struct(t_struct* tstruct,
|
609
|
-
bool is_exception) {
|
610
|
-
// Make output file
|
611
|
-
string f_struct_name = package_dir_+"/"+(tstruct->get_name())+".java";
|
612
|
-
ofstream f_struct;
|
613
|
-
f_struct.open(f_struct_name.c_str());
|
614
|
-
|
615
|
-
f_struct <<
|
616
|
-
autogen_comment() <<
|
617
|
-
java_package() <<
|
618
|
-
java_type_imports() <<
|
619
|
-
java_thrift_imports();
|
620
|
-
|
621
|
-
generate_java_struct_definition(f_struct,
|
622
|
-
tstruct,
|
623
|
-
is_exception);
|
624
|
-
f_struct.close();
|
625
|
-
}
|
626
|
-
|
627
|
-
/**
|
628
|
-
* Java struct definition. This has various parameters, as it could be
|
629
|
-
* generated standalone or inside another class as a helper. If it
|
630
|
-
* is a helper than it is a static class.
|
631
|
-
*
|
632
|
-
* @param tstruct The struct definition
|
633
|
-
* @param is_exception Is this an exception?
|
634
|
-
* @param in_class If inside a class, needs to be static class
|
635
|
-
* @param is_result If this is a result it needs a different writer
|
636
|
-
*/
|
637
|
-
void t_java_generator::generate_java_struct_definition(ofstream &out,
|
638
|
-
t_struct* tstruct,
|
639
|
-
bool is_exception,
|
640
|
-
bool in_class,
|
641
|
-
bool is_result) {
|
642
|
-
generate_java_doc(out, tstruct);
|
643
|
-
|
644
|
-
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
|
645
|
-
|
646
|
-
indent(out) <<
|
647
|
-
"public " << (is_final ? "final " : "") <<
|
648
|
-
(in_class ? "static " : "") << "class " << tstruct->get_name() << " ";
|
649
|
-
|
650
|
-
if (is_exception) {
|
651
|
-
out << "extends Exception ";
|
652
|
-
}
|
653
|
-
out << "implements TBase, java.io.Serializable, Cloneable";
|
654
|
-
|
655
|
-
if (is_comparable(tstruct)) {
|
656
|
-
out << ", Comparable<" << type_name(tstruct) << ">";
|
657
|
-
}
|
658
|
-
|
659
|
-
out << " ";
|
660
|
-
|
661
|
-
scope_up(out);
|
662
|
-
|
663
|
-
indent(out) <<
|
664
|
-
"private static final TStruct STRUCT_DESC = new TStruct(\"" << tstruct->get_name() << "\");" << endl;
|
665
|
-
|
666
|
-
// Members are public for -java, private for -javabean
|
667
|
-
const vector<t_field*>& members = tstruct->get_members();
|
668
|
-
vector<t_field*>::const_iterator m_iter;
|
669
|
-
|
670
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
671
|
-
indent(out) <<
|
672
|
-
"private static final TField " << constant_name((*m_iter)->get_name()) <<
|
673
|
-
"_FIELD_DESC = new TField(\"" << (*m_iter)->get_name() << "\", " <<
|
674
|
-
type_to_enum((*m_iter)->get_type()) << ", " <<
|
675
|
-
"(short)" << (*m_iter)->get_key() << ");" << endl;
|
676
|
-
}
|
677
|
-
|
678
|
-
out << endl;
|
679
|
-
|
680
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
681
|
-
if (bean_style_) {
|
682
|
-
indent(out) << "private ";
|
683
|
-
} else {
|
684
|
-
generate_java_doc(out, *m_iter);
|
685
|
-
indent(out) << "public ";
|
686
|
-
}
|
687
|
-
out << declare_field(*m_iter, false) << endl;
|
688
|
-
|
689
|
-
indent(out) << "public static final int " << upcase_string((*m_iter)->get_name()) << " = " << (*m_iter)->get_key() << ";" << endl;
|
690
|
-
}
|
691
|
-
|
692
|
-
// isset data
|
693
|
-
if (members.size() > 0) {
|
694
|
-
out << endl;
|
695
|
-
|
696
|
-
indent(out) << "// isset id assignments" << endl;
|
697
|
-
|
698
|
-
int i = 0;
|
699
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
700
|
-
if (!type_can_be_null((*m_iter)->get_type())) {
|
701
|
-
indent(out) << "private static final int " << isset_field_id(*m_iter)
|
702
|
-
<< " = " << i << ";" << endl;
|
703
|
-
i++;
|
704
|
-
}
|
705
|
-
}
|
706
|
-
|
707
|
-
if (i > 0) {
|
708
|
-
indent(out) << "private BitSet __isset_bit_vector = new BitSet(" << i << ");" << endl;
|
709
|
-
}
|
710
|
-
|
711
|
-
out << endl;
|
712
|
-
}
|
713
|
-
|
714
|
-
generate_java_meta_data_map(out, tstruct);
|
715
|
-
|
716
|
-
// Static initializer to populate global class to struct metadata map
|
717
|
-
indent(out) << "static {" << endl;
|
718
|
-
indent_up();
|
719
|
-
indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ".class, metaDataMap);" << endl;
|
720
|
-
indent_down();
|
721
|
-
indent(out) << "}" << endl << endl;
|
722
|
-
|
723
|
-
// Default constructor
|
724
|
-
indent(out) <<
|
725
|
-
"public " << tstruct->get_name() << "() {" << endl;
|
726
|
-
indent_up();
|
727
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
728
|
-
t_type* t = get_true_type((*m_iter)->get_type());
|
729
|
-
if ((*m_iter)->get_value() != NULL) {
|
730
|
-
print_const_value(out, "this." + (*m_iter)->get_name(), t, (*m_iter)->get_value(), true, true);
|
731
|
-
}
|
732
|
-
}
|
733
|
-
indent_down();
|
734
|
-
indent(out) << "}" << endl << endl;
|
735
|
-
|
736
|
-
|
737
|
-
if (!members.empty()) {
|
738
|
-
// Full constructor for all fields
|
739
|
-
indent(out) <<
|
740
|
-
"public " << tstruct->get_name() << "(" << endl;
|
741
|
-
indent_up();
|
742
|
-
for (m_iter = members.begin(); m_iter != members.end(); ) {
|
743
|
-
indent(out) << type_name((*m_iter)->get_type()) << " " <<
|
744
|
-
(*m_iter)->get_name();
|
745
|
-
++m_iter;
|
746
|
-
if (m_iter != members.end()) {
|
747
|
-
out << "," << endl;
|
748
|
-
}
|
749
|
-
}
|
750
|
-
out << ")" << endl;
|
751
|
-
indent_down();
|
752
|
-
indent(out) << "{" << endl;
|
753
|
-
indent_up();
|
754
|
-
indent(out) << "this();" << endl;
|
755
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
756
|
-
indent(out) << "this." << (*m_iter)->get_name() << " = " <<
|
757
|
-
(*m_iter)->get_name() << ";" << endl;
|
758
|
-
generate_isset_set(out, (*m_iter));
|
759
|
-
}
|
760
|
-
indent_down();
|
761
|
-
indent(out) << "}" << endl << endl;
|
762
|
-
}
|
763
|
-
|
764
|
-
// copy constructor
|
765
|
-
indent(out) << "/**" << endl;
|
766
|
-
indent(out) << " * Performs a deep copy on <i>other</i>." << endl;
|
767
|
-
indent(out) << " */" << endl;
|
768
|
-
indent(out) << "public " << tstruct->get_name() << "(" << tstruct->get_name() << " other) {" << endl;
|
769
|
-
indent_up();
|
770
|
-
|
771
|
-
if (has_bit_vector(tstruct)) {
|
772
|
-
indent(out) << "__isset_bit_vector.clear();" << endl;
|
773
|
-
indent(out) << "__isset_bit_vector.or(other.__isset_bit_vector);" << endl;
|
774
|
-
}
|
775
|
-
|
776
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
777
|
-
t_field* field = (*m_iter);
|
778
|
-
std::string field_name = field->get_name();
|
779
|
-
t_type* type = field->get_type();
|
780
|
-
bool can_be_null = type_can_be_null(type);
|
781
|
-
|
782
|
-
if (can_be_null) {
|
783
|
-
indent(out) << "if (other." << generate_isset_check(field) << ") {" << endl;
|
784
|
-
indent_up();
|
785
|
-
}
|
786
|
-
|
787
|
-
if (type->is_container()) {
|
788
|
-
generate_deep_copy_container(out, "other", field_name, "__this__" + field_name, type);
|
789
|
-
indent(out) << "this." << field_name << " = __this__" << field_name << ";" << endl;
|
790
|
-
} else {
|
791
|
-
indent(out) << "this." << field_name << " = ";
|
792
|
-
generate_deep_copy_non_container(out, "other." + field_name, field_name, type);
|
793
|
-
out << ";" << endl;
|
794
|
-
}
|
795
|
-
|
796
|
-
if (can_be_null) {
|
797
|
-
indent_down();
|
798
|
-
indent(out) << "}" << endl;
|
799
|
-
}
|
800
|
-
}
|
801
|
-
|
802
|
-
indent_down();
|
803
|
-
indent(out) << "}" << endl << endl;
|
804
|
-
|
805
|
-
// clone method, so that you can deep copy an object when you don't know its class.
|
806
|
-
indent(out) << "@Override" << endl;
|
807
|
-
indent(out) << "public " << tstruct->get_name() << " clone() {" << endl;
|
808
|
-
indent(out) << " return new " << tstruct->get_name() << "(this);" << endl;
|
809
|
-
indent(out) << "}" << endl << endl;
|
810
|
-
|
811
|
-
generate_java_bean_boilerplate(out, tstruct);
|
812
|
-
generate_generic_field_getters_setters(out, tstruct);
|
813
|
-
generate_generic_isset_method(out, tstruct);
|
814
|
-
|
815
|
-
generate_java_struct_equality(out, tstruct);
|
816
|
-
if (is_comparable(tstruct)) {
|
817
|
-
generate_java_struct_compare_to(out, tstruct);
|
818
|
-
}
|
819
|
-
|
820
|
-
generate_java_struct_reader(out, tstruct);
|
821
|
-
if (is_result) {
|
822
|
-
generate_java_struct_result_writer(out, tstruct);
|
823
|
-
} else {
|
824
|
-
generate_java_struct_writer(out, tstruct);
|
825
|
-
}
|
826
|
-
generate_java_struct_tostring(out, tstruct);
|
827
|
-
generate_java_validator(out, tstruct);
|
828
|
-
scope_down(out);
|
829
|
-
out << endl;
|
830
|
-
}
|
831
|
-
|
832
|
-
/**
|
833
|
-
* Generates equals methods and a hashCode method for a structure.
|
834
|
-
*
|
835
|
-
* @param tstruct The struct definition
|
836
|
-
*/
|
837
|
-
void t_java_generator::generate_java_struct_equality(ofstream& out,
|
838
|
-
t_struct* tstruct) {
|
839
|
-
out << indent() << "@Override" << endl <<
|
840
|
-
indent() << "public boolean equals(Object that) {" << endl;
|
841
|
-
indent_up();
|
842
|
-
out <<
|
843
|
-
indent() << "if (that == null)" << endl <<
|
844
|
-
indent() << " return false;" << endl <<
|
845
|
-
indent() << "if (that instanceof " << tstruct->get_name() << ")" << endl <<
|
846
|
-
indent() << " return this.equals((" << tstruct->get_name() << ")that);" << endl <<
|
847
|
-
indent() << "return false;" << endl;
|
848
|
-
scope_down(out);
|
849
|
-
out << endl;
|
850
|
-
|
851
|
-
out <<
|
852
|
-
indent() << "public boolean equals(" << tstruct->get_name() << " that) {" << endl;
|
853
|
-
indent_up();
|
854
|
-
out <<
|
855
|
-
indent() << "if (that == null)" << endl <<
|
856
|
-
indent() << " return false;" << endl;
|
857
|
-
|
858
|
-
const vector<t_field*>& members = tstruct->get_members();
|
859
|
-
vector<t_field*>::const_iterator m_iter;
|
860
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
861
|
-
out << endl;
|
862
|
-
|
863
|
-
t_type* t = get_true_type((*m_iter)->get_type());
|
864
|
-
// Most existing Thrift code does not use isset or optional/required,
|
865
|
-
// so we treat "default" fields as required.
|
866
|
-
bool is_optional = (*m_iter)->get_req() == t_field::T_OPTIONAL;
|
867
|
-
bool can_be_null = type_can_be_null(t);
|
868
|
-
string name = (*m_iter)->get_name();
|
869
|
-
|
870
|
-
string this_present = "true";
|
871
|
-
string that_present = "true";
|
872
|
-
string unequal;
|
873
|
-
|
874
|
-
if (is_optional || can_be_null) {
|
875
|
-
this_present += " && this." + generate_isset_check(*m_iter);
|
876
|
-
that_present += " && that." + generate_isset_check(*m_iter);
|
877
|
-
}
|
878
|
-
|
879
|
-
out <<
|
880
|
-
indent() << "boolean this_present_" << name << " = "
|
881
|
-
<< this_present << ";" << endl <<
|
882
|
-
indent() << "boolean that_present_" << name << " = "
|
883
|
-
<< that_present << ";" << endl <<
|
884
|
-
indent() << "if (" << "this_present_" << name
|
885
|
-
<< " || that_present_" << name << ") {" << endl;
|
886
|
-
indent_up();
|
887
|
-
out <<
|
888
|
-
indent() << "if (!(" << "this_present_" << name
|
889
|
-
<< " && that_present_" << name << "))" << endl <<
|
890
|
-
indent() << " return false;" << endl;
|
891
|
-
|
892
|
-
if (t->is_base_type() && ((t_base_type*)t)->is_binary()) {
|
893
|
-
unequal = "!java.util.Arrays.equals(this." + name + ", that." + name + ")";
|
894
|
-
} else if (can_be_null) {
|
895
|
-
unequal = "!this." + name + ".equals(that." + name + ")";
|
896
|
-
} else {
|
897
|
-
unequal = "this." + name + " != that." + name;
|
898
|
-
}
|
899
|
-
|
900
|
-
out <<
|
901
|
-
indent() << "if (" << unequal << ")" << endl <<
|
902
|
-
indent() << " return false;" << endl;
|
903
|
-
|
904
|
-
scope_down(out);
|
905
|
-
}
|
906
|
-
out << endl;
|
907
|
-
indent(out) << "return true;" << endl;
|
908
|
-
scope_down(out);
|
909
|
-
out << endl;
|
910
|
-
|
911
|
-
out << indent() << "@Override" << endl <<
|
912
|
-
indent() << "public int hashCode() {" << endl;
|
913
|
-
indent_up();
|
914
|
-
if (gen_hash_code_) {
|
915
|
-
indent(out) << "HashCodeBuilder builder = new HashCodeBuilder();" << endl;
|
916
|
-
|
917
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
918
|
-
out << endl;
|
919
|
-
|
920
|
-
t_type* t = get_true_type((*m_iter)->get_type());
|
921
|
-
bool is_optional = (*m_iter)->get_req() == t_field::T_OPTIONAL;
|
922
|
-
bool can_be_null = type_can_be_null(t);
|
923
|
-
string name = (*m_iter)->get_name();
|
924
|
-
|
925
|
-
string present = "true";
|
926
|
-
|
927
|
-
if (is_optional || can_be_null) {
|
928
|
-
present += " && (" + generate_isset_check(*m_iter) + ")";
|
929
|
-
}
|
930
|
-
|
931
|
-
out <<
|
932
|
-
indent() << "boolean present_" << name << " = "
|
933
|
-
<< present << ";" << endl <<
|
934
|
-
indent() << "builder.append(present_" << name << ");" << endl <<
|
935
|
-
indent() << "if (present_" << name << ")" << endl <<
|
936
|
-
indent() << " builder.append(" << name << ");" << endl;
|
937
|
-
}
|
938
|
-
|
939
|
-
out << endl;
|
940
|
-
indent(out) << "return builder.toHashCode();" << endl;
|
941
|
-
} else {
|
942
|
-
indent(out) << "return 0;" << endl;
|
943
|
-
}
|
944
|
-
indent_down();
|
945
|
-
indent(out) << "}" << endl << endl;
|
946
|
-
}
|
947
|
-
|
948
|
-
void t_java_generator::generate_java_struct_compare_to(ofstream& out, t_struct* tstruct) {
|
949
|
-
indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl;
|
950
|
-
indent_up();
|
951
|
-
|
952
|
-
indent(out) << "if (!getClass().equals(other.getClass())) {" << endl;
|
953
|
-
indent(out) << " return getClass().getName().compareTo(other.getClass().getName());" << endl;
|
954
|
-
indent(out) << "}" << endl;
|
955
|
-
out << endl;
|
956
|
-
|
957
|
-
indent(out) << "int lastComparison = 0;" << endl;
|
958
|
-
indent(out) << type_name(tstruct) << " typedOther = (" << type_name(tstruct) << ")other;" << endl;
|
959
|
-
out << endl;
|
960
|
-
|
961
|
-
const vector<t_field*>& members = tstruct->get_members();
|
962
|
-
vector<t_field*>::const_iterator m_iter;
|
963
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
964
|
-
t_field* field = *m_iter;
|
965
|
-
indent(out) << "lastComparison = Boolean.valueOf(" << generate_isset_check(field) << ").compareTo(" << generate_isset_check(field) << ");" << endl;
|
966
|
-
indent(out) << "if (lastComparison != 0) {" << endl;
|
967
|
-
indent(out) << " return lastComparison;" << endl;
|
968
|
-
indent(out) << "}" << endl;
|
969
|
-
|
970
|
-
indent(out) << "lastComparison = TBaseHelper.compareTo(" << field->get_name() << ", typedOther." << field->get_name() << ");" << endl;
|
971
|
-
indent(out) << "if (lastComparison != 0) {" << endl;
|
972
|
-
indent(out) << " return lastComparison;" << endl;
|
973
|
-
indent(out) << "}" << endl;
|
974
|
-
}
|
975
|
-
|
976
|
-
indent(out) << "return 0;" << endl;
|
977
|
-
|
978
|
-
indent_down();
|
979
|
-
indent(out) << "}" << endl << endl;
|
980
|
-
}
|
981
|
-
|
982
|
-
/**
|
983
|
-
* Generates a function to read all the fields of the struct.
|
984
|
-
*
|
985
|
-
* @param tstruct The struct definition
|
986
|
-
*/
|
987
|
-
void t_java_generator::generate_java_struct_reader(ofstream& out,
|
988
|
-
t_struct* tstruct) {
|
989
|
-
out <<
|
990
|
-
indent() << "public void read(TProtocol iprot) throws TException {" << endl;
|
991
|
-
indent_up();
|
992
|
-
|
993
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
994
|
-
vector<t_field*>::const_iterator f_iter;
|
995
|
-
|
996
|
-
// Declare stack tmp variables and read struct header
|
997
|
-
out <<
|
998
|
-
indent() << "TField field;" << endl <<
|
999
|
-
indent() << "iprot.readStructBegin();" << endl;
|
1000
|
-
|
1001
|
-
// Loop over reading in fields
|
1002
|
-
indent(out) <<
|
1003
|
-
"while (true)" << endl;
|
1004
|
-
scope_up(out);
|
1005
|
-
|
1006
|
-
// Read beginning field marker
|
1007
|
-
indent(out) <<
|
1008
|
-
"field = iprot.readFieldBegin();" << endl;
|
1009
|
-
|
1010
|
-
// Check for field STOP marker and break
|
1011
|
-
indent(out) <<
|
1012
|
-
"if (field.type == TType.STOP) { " << endl;
|
1013
|
-
indent_up();
|
1014
|
-
indent(out) <<
|
1015
|
-
"break;" << endl;
|
1016
|
-
indent_down();
|
1017
|
-
indent(out) <<
|
1018
|
-
"}" << endl;
|
1019
|
-
|
1020
|
-
// Switch statement on the field we are reading
|
1021
|
-
indent(out) <<
|
1022
|
-
"switch (field.id)" << endl;
|
1023
|
-
|
1024
|
-
scope_up(out);
|
1025
|
-
|
1026
|
-
// Generate deserialization code for known cases
|
1027
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1028
|
-
indent(out) <<
|
1029
|
-
"case " << upcase_string((*f_iter)->get_name()) << ":" << endl;
|
1030
|
-
indent_up();
|
1031
|
-
indent(out) <<
|
1032
|
-
"if (field.type == " << type_to_enum((*f_iter)->get_type()) << ") {" << endl;
|
1033
|
-
indent_up();
|
1034
|
-
|
1035
|
-
generate_deserialize_field(out, *f_iter, "this.");
|
1036
|
-
generate_isset_set(out, *f_iter);
|
1037
|
-
indent_down();
|
1038
|
-
out <<
|
1039
|
-
indent() << "} else { " << endl <<
|
1040
|
-
indent() << " TProtocolUtil.skip(iprot, field.type);" << endl <<
|
1041
|
-
indent() << "}" << endl <<
|
1042
|
-
indent() << "break;" << endl;
|
1043
|
-
indent_down();
|
1044
|
-
}
|
1045
|
-
|
1046
|
-
// In the default case we skip the field
|
1047
|
-
out <<
|
1048
|
-
indent() << "default:" << endl <<
|
1049
|
-
indent() << " TProtocolUtil.skip(iprot, field.type);" << endl <<
|
1050
|
-
indent() << " break;" << endl;
|
1051
|
-
|
1052
|
-
scope_down(out);
|
1053
|
-
|
1054
|
-
// Read field end marker
|
1055
|
-
indent(out) <<
|
1056
|
-
"iprot.readFieldEnd();" << endl;
|
1057
|
-
|
1058
|
-
scope_down(out);
|
1059
|
-
|
1060
|
-
out <<
|
1061
|
-
indent() << "iprot.readStructEnd();" << endl << endl;
|
1062
|
-
|
1063
|
-
// in non-beans style, check for required fields of primitive type
|
1064
|
-
// (which can be checked here but not in the general validate method)
|
1065
|
-
if (!bean_style_){
|
1066
|
-
out << endl << indent() << "// check for required fields of primitive type, which can't be checked in the validate method" << endl;
|
1067
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1068
|
-
if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) {
|
1069
|
-
out <<
|
1070
|
-
indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl <<
|
1071
|
-
indent() << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not found in serialized data! Struct: \" + toString());" << endl <<
|
1072
|
-
indent() << "}" << endl;
|
1073
|
-
}
|
1074
|
-
}
|
1075
|
-
}
|
1076
|
-
|
1077
|
-
// performs various checks (e.g. check that all required fields are set)
|
1078
|
-
indent(out) << "validate();" << endl;
|
1079
|
-
|
1080
|
-
indent_down();
|
1081
|
-
out <<
|
1082
|
-
indent() << "}" << endl <<
|
1083
|
-
endl;
|
1084
|
-
}
|
1085
|
-
|
1086
|
-
// generates java method to perform various checks
|
1087
|
-
// (e.g. check that all required fields are set)
|
1088
|
-
void t_java_generator::generate_java_validator(ofstream& out,
|
1089
|
-
t_struct* tstruct){
|
1090
|
-
indent(out) << "public void validate() throws TException {" << endl;
|
1091
|
-
indent_up();
|
1092
|
-
|
1093
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
1094
|
-
vector<t_field*>::const_iterator f_iter;
|
1095
|
-
|
1096
|
-
out << indent() << "// check for required fields" << endl;
|
1097
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1098
|
-
if ((*f_iter)->get_req() == t_field::T_REQUIRED) {
|
1099
|
-
if (bean_style_) {
|
1100
|
-
out <<
|
1101
|
-
indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl <<
|
1102
|
-
indent() << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl <<
|
1103
|
-
indent() << "}" << endl << endl;
|
1104
|
-
} else{
|
1105
|
-
if (type_can_be_null((*f_iter)->get_type())) {
|
1106
|
-
indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl;
|
1107
|
-
indent(out) << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl;
|
1108
|
-
indent(out) << "}" << endl;
|
1109
|
-
} else {
|
1110
|
-
indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() << "' because it's a primitive and you chose the non-beans generator." << endl;
|
1111
|
-
}
|
1112
|
-
}
|
1113
|
-
}
|
1114
|
-
}
|
1115
|
-
|
1116
|
-
// check that fields of type enum have valid values
|
1117
|
-
out << indent() << "// check that fields of type enum have valid values" << endl;
|
1118
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1119
|
-
t_field* field = (*f_iter);
|
1120
|
-
t_type* type = field->get_type();
|
1121
|
-
// if field is an enum, check that its value is valid
|
1122
|
-
if (type->is_enum()){
|
1123
|
-
indent(out) << "if (" << generate_isset_check(field) << " && !" << get_enum_class_name(type) << ".VALID_VALUES.contains(" << field->get_name() << ")){" << endl;
|
1124
|
-
indent_up();
|
1125
|
-
indent(out) << "throw new TProtocolException(\"The field '" << field->get_name() << "' has been assigned the invalid value \" + " << field->get_name() << ");" << endl;
|
1126
|
-
indent_down();
|
1127
|
-
indent(out) << "}" << endl;
|
1128
|
-
}
|
1129
|
-
}
|
1130
|
-
|
1131
|
-
indent_down();
|
1132
|
-
indent(out) << "}" << endl << endl;
|
1133
|
-
}
|
1134
|
-
|
1135
|
-
/**
|
1136
|
-
* Generates a function to write all the fields of the struct
|
1137
|
-
*
|
1138
|
-
* @param tstruct The struct definition
|
1139
|
-
*/
|
1140
|
-
void t_java_generator::generate_java_struct_writer(ofstream& out,
|
1141
|
-
t_struct* tstruct) {
|
1142
|
-
out <<
|
1143
|
-
indent() << "public void write(TProtocol oprot) throws TException {" << endl;
|
1144
|
-
indent_up();
|
1145
|
-
|
1146
|
-
string name = tstruct->get_name();
|
1147
|
-
const vector<t_field*>& fields = tstruct->get_sorted_members();
|
1148
|
-
vector<t_field*>::const_iterator f_iter;
|
1149
|
-
|
1150
|
-
// performs various checks (e.g. check that all required fields are set)
|
1151
|
-
indent(out) << "validate();" << endl << endl;
|
1152
|
-
|
1153
|
-
indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
|
1154
|
-
|
1155
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1156
|
-
bool null_allowed = type_can_be_null((*f_iter)->get_type());
|
1157
|
-
if (null_allowed) {
|
1158
|
-
out <<
|
1159
|
-
indent() << "if (this." << (*f_iter)->get_name() << " != null) {" << endl;
|
1160
|
-
indent_up();
|
1161
|
-
}
|
1162
|
-
bool optional = (*f_iter)->get_req() == t_field::T_OPTIONAL;
|
1163
|
-
if (optional) {
|
1164
|
-
indent(out) << "if (" << generate_isset_check((*f_iter)) << ") {" << endl;
|
1165
|
-
indent_up();
|
1166
|
-
}
|
1167
|
-
|
1168
|
-
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
|
1169
|
-
|
1170
|
-
// Write field contents
|
1171
|
-
generate_serialize_field(out, *f_iter, "this.");
|
1172
|
-
|
1173
|
-
// Write field closer
|
1174
|
-
indent(out) <<
|
1175
|
-
"oprot.writeFieldEnd();" << endl;
|
1176
|
-
|
1177
|
-
if (optional) {
|
1178
|
-
indent_down();
|
1179
|
-
indent(out) << "}" << endl;
|
1180
|
-
}
|
1181
|
-
if (null_allowed) {
|
1182
|
-
indent_down();
|
1183
|
-
indent(out) << "}" << endl;
|
1184
|
-
}
|
1185
|
-
}
|
1186
|
-
// Write the struct map
|
1187
|
-
out <<
|
1188
|
-
indent() << "oprot.writeFieldStop();" << endl <<
|
1189
|
-
indent() << "oprot.writeStructEnd();" << endl;
|
1190
|
-
|
1191
|
-
indent_down();
|
1192
|
-
out <<
|
1193
|
-
indent() << "}" << endl <<
|
1194
|
-
endl;
|
1195
|
-
}
|
1196
|
-
|
1197
|
-
/**
|
1198
|
-
* Generates a function to write all the fields of the struct,
|
1199
|
-
* which is a function result. These fields are only written
|
1200
|
-
* if they are set in the Isset array, and only one of them
|
1201
|
-
* can be set at a time.
|
1202
|
-
*
|
1203
|
-
* @param tstruct The struct definition
|
1204
|
-
*/
|
1205
|
-
void t_java_generator::generate_java_struct_result_writer(ofstream& out,
|
1206
|
-
t_struct* tstruct) {
|
1207
|
-
out <<
|
1208
|
-
indent() << "public void write(TProtocol oprot) throws TException {" << endl;
|
1209
|
-
indent_up();
|
1210
|
-
|
1211
|
-
string name = tstruct->get_name();
|
1212
|
-
const vector<t_field*>& fields = tstruct->get_sorted_members();
|
1213
|
-
vector<t_field*>::const_iterator f_iter;
|
1214
|
-
|
1215
|
-
indent(out) << "oprot.writeStructBegin(STRUCT_DESC);" << endl;
|
1216
|
-
|
1217
|
-
bool first = true;
|
1218
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1219
|
-
if (first) {
|
1220
|
-
first = false;
|
1221
|
-
out <<
|
1222
|
-
endl <<
|
1223
|
-
indent() << "if ";
|
1224
|
-
} else {
|
1225
|
-
out << " else if ";
|
1226
|
-
}
|
1227
|
-
|
1228
|
-
out << "(this." << generate_isset_check(*f_iter) << ") {" << endl;
|
1229
|
-
|
1230
|
-
indent_up();
|
1231
|
-
|
1232
|
-
indent(out) << "oprot.writeFieldBegin(" << constant_name((*f_iter)->get_name()) << "_FIELD_DESC);" << endl;
|
1233
|
-
|
1234
|
-
// Write field contents
|
1235
|
-
generate_serialize_field(out, *f_iter, "this.");
|
1236
|
-
|
1237
|
-
// Write field closer
|
1238
|
-
indent(out) <<
|
1239
|
-
"oprot.writeFieldEnd();" << endl;
|
1240
|
-
|
1241
|
-
indent_down();
|
1242
|
-
indent(out) << "}";
|
1243
|
-
}
|
1244
|
-
// Write the struct map
|
1245
|
-
out <<
|
1246
|
-
endl <<
|
1247
|
-
indent() << "oprot.writeFieldStop();" << endl <<
|
1248
|
-
indent() << "oprot.writeStructEnd();" << endl;
|
1249
|
-
|
1250
|
-
indent_down();
|
1251
|
-
out <<
|
1252
|
-
indent() << "}" << endl <<
|
1253
|
-
endl;
|
1254
|
-
}
|
1255
|
-
|
1256
|
-
void t_java_generator::generate_reflection_getters(ostringstream& out, t_type* type, string field_name, string cap_name) {
|
1257
|
-
indent(out) << "case " << upcase_string(field_name) << ":" << endl;
|
1258
|
-
indent_up();
|
1259
|
-
|
1260
|
-
if (type->is_base_type() && !type->is_string()) {
|
1261
|
-
t_base_type* base_type = (t_base_type*)type;
|
1262
|
-
|
1263
|
-
indent(out) << "return new " << type_name(type, true, false) << "(" << (base_type->is_bool() ? "is" : "get") << cap_name << "());" << endl << endl;
|
1264
|
-
} else {
|
1265
|
-
indent(out) << "return get" << cap_name << "();" << endl << endl;
|
1266
|
-
}
|
1267
|
-
|
1268
|
-
indent_down();
|
1269
|
-
}
|
1270
|
-
|
1271
|
-
void t_java_generator::generate_reflection_setters(ostringstream& out, t_type* type, string field_name, string cap_name) {
|
1272
|
-
indent(out) << "case " << upcase_string(field_name) << ":" << endl;
|
1273
|
-
indent_up();
|
1274
|
-
indent(out) << "if (value == null) {" << endl;
|
1275
|
-
indent(out) << " unset" << get_cap_name(field_name) << "();" << endl;
|
1276
|
-
indent(out) << "} else {" << endl;
|
1277
|
-
indent(out) << " set" << cap_name << "((" << type_name(type, true, false) << ")value);" << endl;
|
1278
|
-
indent(out) << "}" << endl;
|
1279
|
-
indent(out) << "break;" << endl << endl;
|
1280
|
-
|
1281
|
-
indent_down();
|
1282
|
-
}
|
1283
|
-
|
1284
|
-
void t_java_generator::generate_generic_field_getters_setters(std::ofstream& out, t_struct* tstruct) {
|
1285
|
-
|
1286
|
-
std::ostringstream getter_stream;
|
1287
|
-
std::ostringstream setter_stream;
|
1288
|
-
|
1289
|
-
// build up the bodies of both the getter and setter at once
|
1290
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
1291
|
-
vector<t_field*>::const_iterator f_iter;
|
1292
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1293
|
-
t_field* field = *f_iter;
|
1294
|
-
t_type* type = get_true_type(field->get_type());
|
1295
|
-
std::string field_name = field->get_name();
|
1296
|
-
std::string cap_name = get_cap_name(field_name);
|
1297
|
-
|
1298
|
-
indent_up();
|
1299
|
-
generate_reflection_setters(setter_stream, type, field_name, cap_name);
|
1300
|
-
generate_reflection_getters(getter_stream, type, field_name, cap_name);
|
1301
|
-
indent_down();
|
1302
|
-
}
|
1303
|
-
|
1304
|
-
|
1305
|
-
// create the setter
|
1306
|
-
indent(out) << "public void setFieldValue(int fieldID, Object value) {" << endl;
|
1307
|
-
indent_up();
|
1308
|
-
|
1309
|
-
indent(out) << "switch (fieldID) {" << endl;
|
1310
|
-
|
1311
|
-
out << setter_stream.str();
|
1312
|
-
|
1313
|
-
indent(out) << "default:" << endl;
|
1314
|
-
indent(out) << " throw new IllegalArgumentException(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
|
1315
|
-
|
1316
|
-
indent(out) << "}" << endl;
|
1317
|
-
|
1318
|
-
indent_down();
|
1319
|
-
indent(out) << "}" << endl << endl;
|
1320
|
-
|
1321
|
-
// create the getter
|
1322
|
-
indent(out) << "public Object getFieldValue(int fieldID) {" << endl;
|
1323
|
-
indent_up();
|
1324
|
-
|
1325
|
-
indent(out) << "switch (fieldID) {" << endl;
|
1326
|
-
|
1327
|
-
out << getter_stream.str();
|
1328
|
-
|
1329
|
-
indent(out) << "default:" << endl;
|
1330
|
-
indent(out) << " throw new IllegalArgumentException(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
|
1331
|
-
|
1332
|
-
indent(out) << "}" << endl;
|
1333
|
-
|
1334
|
-
indent_down();
|
1335
|
-
|
1336
|
-
indent(out) << "}" << endl << endl;
|
1337
|
-
}
|
1338
|
-
|
1339
|
-
// Creates a generic isSet method that takes the field number as argument
|
1340
|
-
void t_java_generator::generate_generic_isset_method(std::ofstream& out, t_struct* tstruct){
|
1341
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
1342
|
-
vector<t_field*>::const_iterator f_iter;
|
1343
|
-
|
1344
|
-
// create the isSet method
|
1345
|
-
indent(out) << "// Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise" << endl;
|
1346
|
-
indent(out) << "public boolean isSet(int fieldID) {" << endl;
|
1347
|
-
indent_up();
|
1348
|
-
indent(out) << "switch (fieldID) {" << endl;
|
1349
|
-
|
1350
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1351
|
-
t_field* field = *f_iter;
|
1352
|
-
indent(out) << "case " << upcase_string(field->get_name()) << ":" << endl;
|
1353
|
-
indent_up();
|
1354
|
-
indent(out) << "return " << generate_isset_check(field) << ";" << endl;
|
1355
|
-
indent_down();
|
1356
|
-
}
|
1357
|
-
|
1358
|
-
indent(out) << "default:" << endl;
|
1359
|
-
indent(out) << " throw new IllegalArgumentException(\"Field \" + fieldID + \" doesn't exist!\");" << endl;
|
1360
|
-
|
1361
|
-
indent(out) << "}" << endl;
|
1362
|
-
|
1363
|
-
indent_down();
|
1364
|
-
indent(out) << "}" << endl << endl;
|
1365
|
-
}
|
1366
|
-
|
1367
|
-
/**
|
1368
|
-
* Generates a set of Java Bean boilerplate functions (setters, getters, etc.)
|
1369
|
-
* for the given struct.
|
1370
|
-
*
|
1371
|
-
* @param tstruct The struct definition
|
1372
|
-
*/
|
1373
|
-
void t_java_generator::generate_java_bean_boilerplate(ofstream& out,
|
1374
|
-
t_struct* tstruct) {
|
1375
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
1376
|
-
vector<t_field*>::const_iterator f_iter;
|
1377
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1378
|
-
t_field* field = *f_iter;
|
1379
|
-
t_type* type = get_true_type(field->get_type());
|
1380
|
-
std::string field_name = field->get_name();
|
1381
|
-
std::string cap_name = get_cap_name(field_name);
|
1382
|
-
|
1383
|
-
// Simple getter
|
1384
|
-
generate_java_doc(out, field);
|
1385
|
-
indent(out) << "public " << type_name(type);
|
1386
|
-
if (type->is_base_type() &&
|
1387
|
-
((t_base_type*)type)->get_base() == t_base_type::TYPE_BOOL) {
|
1388
|
-
out << " is";
|
1389
|
-
} else {
|
1390
|
-
out << " get";
|
1391
|
-
}
|
1392
|
-
out << cap_name << "() {" << endl;
|
1393
|
-
indent_up();
|
1394
|
-
indent(out) << "return this." << field_name << ";" << endl;
|
1395
|
-
indent_down();
|
1396
|
-
indent(out) << "}" << endl << endl;
|
1397
|
-
|
1398
|
-
// Simple setter
|
1399
|
-
generate_java_doc(out, field);
|
1400
|
-
indent(out) << "public " << type_name(tstruct) << " set" << cap_name << "(" << type_name(type) <<
|
1401
|
-
" " << field_name << ") {" << endl;
|
1402
|
-
indent_up();
|
1403
|
-
indent(out) << "this." << field_name << " = " << field_name << ";" <<
|
1404
|
-
endl;
|
1405
|
-
generate_isset_set(out, field);
|
1406
|
-
indent(out) << "return this;" << endl;
|
1407
|
-
|
1408
|
-
indent_down();
|
1409
|
-
indent(out) << "}" << endl << endl;
|
1410
|
-
|
1411
|
-
// Unsetter
|
1412
|
-
indent(out) << "public void unset" << cap_name << "() {" << endl;
|
1413
|
-
indent_up();
|
1414
|
-
if (type_can_be_null(type)) {
|
1415
|
-
indent(out) << "this." << field_name << " = null;" << endl;
|
1416
|
-
} else {
|
1417
|
-
indent(out) << "__isset_bit_vector.clear(" << isset_field_id(field) << ");" << endl;
|
1418
|
-
}
|
1419
|
-
indent_down();
|
1420
|
-
indent(out) << "}" << endl << endl;
|
1421
|
-
|
1422
|
-
// isSet method
|
1423
|
-
indent(out) << "// Returns true if field " << field_name << " is set (has been asigned a value) and false otherwise" << endl;
|
1424
|
-
indent(out) << "public boolean is" << get_cap_name("set") << cap_name << "() {" << endl;
|
1425
|
-
indent_up();
|
1426
|
-
if (type_can_be_null(type)) {
|
1427
|
-
indent(out) << "return this." << field_name << " != null;" << endl;
|
1428
|
-
} else {
|
1429
|
-
indent(out) << "return __isset_bit_vector.get(" << isset_field_id(field) << ");" << endl;
|
1430
|
-
}
|
1431
|
-
indent_down();
|
1432
|
-
indent(out) << "}" << endl << endl;
|
1433
|
-
|
1434
|
-
indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {" << endl;
|
1435
|
-
indent_up();
|
1436
|
-
if (type_can_be_null(type)) {
|
1437
|
-
indent(out) << "if (!value) {" << endl;
|
1438
|
-
indent(out) << " this." << field_name << " = null;" << endl;
|
1439
|
-
indent(out) << "}" << endl;
|
1440
|
-
} else {
|
1441
|
-
indent(out) << "__isset_bit_vector.set(" << isset_field_id(field) << ", value);" << endl;
|
1442
|
-
}
|
1443
|
-
indent_down();
|
1444
|
-
indent(out) << "}" << endl << endl;
|
1445
|
-
}
|
1446
|
-
}
|
1447
|
-
|
1448
|
-
/**
|
1449
|
-
* Generates a toString() method for the given struct
|
1450
|
-
*
|
1451
|
-
* @param tstruct The struct definition
|
1452
|
-
*/
|
1453
|
-
void t_java_generator::generate_java_struct_tostring(ofstream& out,
|
1454
|
-
t_struct* tstruct) {
|
1455
|
-
out << indent() << "@Override" << endl <<
|
1456
|
-
indent() << "public String toString() {" << endl;
|
1457
|
-
indent_up();
|
1458
|
-
|
1459
|
-
out <<
|
1460
|
-
indent() << "StringBuilder sb = new StringBuilder(\"" << tstruct->get_name() << "(\");" << endl;
|
1461
|
-
out << indent() << "boolean first = true;" << endl << endl;
|
1462
|
-
|
1463
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
1464
|
-
vector<t_field*>::const_iterator f_iter;
|
1465
|
-
bool first = true;
|
1466
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1467
|
-
bool could_be_unset = (*f_iter)->get_req() == t_field::T_OPTIONAL;
|
1468
|
-
if(could_be_unset) {
|
1469
|
-
indent(out) << "if (" << generate_isset_check(*f_iter) << ") {" << endl;
|
1470
|
-
indent_up();
|
1471
|
-
}
|
1472
|
-
|
1473
|
-
t_field* field = (*f_iter);
|
1474
|
-
|
1475
|
-
if (!first) {
|
1476
|
-
indent(out) << "if (!first) sb.append(\", \");" << endl;
|
1477
|
-
}
|
1478
|
-
indent(out) << "sb.append(\"" << (*f_iter)->get_name() << ":\");" << endl;
|
1479
|
-
bool can_be_null = type_can_be_null(field->get_type());
|
1480
|
-
if (can_be_null) {
|
1481
|
-
indent(out) << "if (this." << (*f_iter)->get_name() << " == null) {" << endl;
|
1482
|
-
indent(out) << " sb.append(\"null\");" << endl;
|
1483
|
-
indent(out) << "} else {" << endl;
|
1484
|
-
indent_up();
|
1485
|
-
}
|
1486
|
-
|
1487
|
-
if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) {
|
1488
|
-
indent(out) << " int __" << field->get_name() << "_size = Math.min(this." << field->get_name() << ".length, 128);" << endl;
|
1489
|
-
indent(out) << " for (int i = 0; i < __" << field->get_name() << "_size; i++) {" << endl;
|
1490
|
-
indent(out) << " if (i != 0) sb.append(\" \");" << endl;
|
1491
|
-
indent(out) << " sb.append(Integer.toHexString(this." << field->get_name() << "[i]).length() > 1 ? Integer.toHexString(this." << field->get_name() << "[i]).substring(Integer.toHexString(this." << field->get_name() << "[i]).length() - 2).toUpperCase() : \"0\" + Integer.toHexString(this." << field->get_name() << "[i]).toUpperCase());" <<endl;
|
1492
|
-
indent(out) << " }" << endl;
|
1493
|
-
indent(out) << " if (this." << field->get_name() << ".length > 128) sb.append(\" ...\");" << endl;
|
1494
|
-
} else if(field->get_type()->is_enum()) {
|
1495
|
-
indent(out) << "String " << field->get_name() << "_name = " << get_enum_class_name(field->get_type()) << ".VALUES_TO_NAMES.get(this." << (*f_iter)->get_name() << ");"<< endl;
|
1496
|
-
indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
|
1497
|
-
indent(out) << " sb.append(" << field->get_name() << "_name);" << endl;
|
1498
|
-
indent(out) << " sb.append(\" (\");" << endl;
|
1499
|
-
indent(out) << "}" << endl;
|
1500
|
-
indent(out) << "sb.append(this." << field->get_name() << ");" << endl;
|
1501
|
-
indent(out) << "if (" << field->get_name() << "_name != null) {" << endl;
|
1502
|
-
indent(out) << " sb.append(\")\");" << endl;
|
1503
|
-
indent(out) << "}" << endl;
|
1504
|
-
} else {
|
1505
|
-
indent(out) << "sb.append(this." << (*f_iter)->get_name() << ");" << endl;
|
1506
|
-
}
|
1507
|
-
|
1508
|
-
if (can_be_null) {
|
1509
|
-
indent_down();
|
1510
|
-
indent(out) << "}" << endl;
|
1511
|
-
}
|
1512
|
-
indent(out) << "first = false;" << endl;
|
1513
|
-
|
1514
|
-
if(could_be_unset) {
|
1515
|
-
indent_down();
|
1516
|
-
indent(out) << "}" << endl;
|
1517
|
-
}
|
1518
|
-
first = false;
|
1519
|
-
}
|
1520
|
-
out <<
|
1521
|
-
indent() << "sb.append(\")\");" << endl <<
|
1522
|
-
indent() << "return sb.toString();" << endl;
|
1523
|
-
|
1524
|
-
indent_down();
|
1525
|
-
indent(out) << "}" << endl <<
|
1526
|
-
endl;
|
1527
|
-
}
|
1528
|
-
|
1529
|
-
/**
|
1530
|
-
* Generates a static map with meta data to store information such as fieldID to
|
1531
|
-
* fieldName mapping
|
1532
|
-
*
|
1533
|
-
* @param tstruct The struct definition
|
1534
|
-
*/
|
1535
|
-
void t_java_generator::generate_java_meta_data_map(ofstream& out,
|
1536
|
-
t_struct* tstruct) {
|
1537
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
1538
|
-
vector<t_field*>::const_iterator f_iter;
|
1539
|
-
|
1540
|
-
// Static Map with fieldID -> FieldMetaData mappings
|
1541
|
-
indent(out) << "public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{" << endl;
|
1542
|
-
|
1543
|
-
// Populate map
|
1544
|
-
indent_up();
|
1545
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
1546
|
-
t_field* field = *f_iter;
|
1547
|
-
std::string field_name = field->get_name();
|
1548
|
-
indent(out) << "put(" << upcase_string(field_name) << ", new FieldMetaData(\"" << field_name << "\", ";
|
1549
|
-
|
1550
|
-
// Set field requirement type (required, optional, etc.)
|
1551
|
-
if (field->get_req() == t_field::T_REQUIRED) {
|
1552
|
-
out << "TFieldRequirementType.REQUIRED, ";
|
1553
|
-
} else if (field->get_req() == t_field::T_OPTIONAL) {
|
1554
|
-
out << "TFieldRequirementType.OPTIONAL, ";
|
1555
|
-
} else {
|
1556
|
-
out << "TFieldRequirementType.DEFAULT, ";
|
1557
|
-
}
|
1558
|
-
|
1559
|
-
// Create value meta data
|
1560
|
-
generate_field_value_meta_data(out, field->get_type());
|
1561
|
-
out << "));" << endl;
|
1562
|
-
}
|
1563
|
-
indent_down();
|
1564
|
-
indent(out) << "}});" << endl << endl;
|
1565
|
-
}
|
1566
|
-
|
1567
|
-
/**
|
1568
|
-
* Returns a string with the java representation of the given thrift type
|
1569
|
-
* (e.g. for the type struct it returns "TType.STRUCT")
|
1570
|
-
*/
|
1571
|
-
std::string t_java_generator::get_java_type_string(t_type* type) {
|
1572
|
-
if (type->is_list()){
|
1573
|
-
return "TType.LIST";
|
1574
|
-
} else if (type->is_map()) {
|
1575
|
-
return "TType.MAP";
|
1576
|
-
} else if (type->is_set()) {
|
1577
|
-
return "TType.SET";
|
1578
|
-
} else if (type->is_struct() || type->is_xception()) {
|
1579
|
-
return "TType.STRUCT";
|
1580
|
-
} else if (type->is_enum()) {
|
1581
|
-
return "TType.I32";
|
1582
|
-
} else if (type->is_typedef()) {
|
1583
|
-
return get_java_type_string(((t_typedef*)type)->get_type());
|
1584
|
-
} else if (type->is_base_type()) {
|
1585
|
-
switch (((t_base_type*)type)->get_base()) {
|
1586
|
-
case t_base_type::TYPE_VOID : return "TType.VOID"; break;
|
1587
|
-
case t_base_type::TYPE_STRING : return "TType.STRING"; break;
|
1588
|
-
case t_base_type::TYPE_BOOL : return "TType.BOOL"; break;
|
1589
|
-
case t_base_type::TYPE_BYTE : return "TType.BYTE"; break;
|
1590
|
-
case t_base_type::TYPE_I16 : return "TType.I16"; break;
|
1591
|
-
case t_base_type::TYPE_I32 : return "TType.I32"; break;
|
1592
|
-
case t_base_type::TYPE_I64 : return "TType.I64"; break;
|
1593
|
-
case t_base_type::TYPE_DOUBLE : return "TType.DOUBLE"; break;
|
1594
|
-
default : throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_java_generator::get_java_type_string!"); break; // This should never happen!
|
1595
|
-
}
|
1596
|
-
} else {
|
1597
|
-
throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_java_generator::get_java_type_string!"); // This should never happen!
|
1598
|
-
}
|
1599
|
-
}
|
1600
|
-
|
1601
|
-
void t_java_generator::generate_field_value_meta_data(std::ofstream& out, t_type* type){
|
1602
|
-
out << endl;
|
1603
|
-
indent_up();
|
1604
|
-
indent_up();
|
1605
|
-
if (type->is_struct()){
|
1606
|
-
indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type) << ".class";
|
1607
|
-
} else if (type->is_container()){
|
1608
|
-
if (type->is_list()){
|
1609
|
-
indent(out) << "new ListMetaData(TType.LIST, ";
|
1610
|
-
t_type* elem_type = ((t_list*)type)->get_elem_type();
|
1611
|
-
generate_field_value_meta_data(out, elem_type);
|
1612
|
-
} else if (type->is_set()){
|
1613
|
-
indent(out) << "new SetMetaData(TType.SET, ";
|
1614
|
-
t_type* elem_type = ((t_list*)type)->get_elem_type();
|
1615
|
-
generate_field_value_meta_data(out, elem_type);
|
1616
|
-
} else{ // map
|
1617
|
-
indent(out) << "new MapMetaData(TType.MAP, ";
|
1618
|
-
t_type* key_type = ((t_map*)type)->get_key_type();
|
1619
|
-
t_type* val_type = ((t_map*)type)->get_val_type();
|
1620
|
-
generate_field_value_meta_data(out, key_type);
|
1621
|
-
out << ", ";
|
1622
|
-
generate_field_value_meta_data(out, val_type);
|
1623
|
-
}
|
1624
|
-
} else {
|
1625
|
-
indent(out) << "new FieldValueMetaData(" << get_java_type_string(type);
|
1626
|
-
}
|
1627
|
-
out << ")";
|
1628
|
-
indent_down();
|
1629
|
-
indent_down();
|
1630
|
-
}
|
1631
|
-
|
1632
|
-
|
1633
|
-
/**
|
1634
|
-
* Generates a thrift service. In C++, this comprises an entirely separate
|
1635
|
-
* header and source file. The header file defines the methods and includes
|
1636
|
-
* the data types defined in the main header file, and the implementation
|
1637
|
-
* file contains implementations of the basic printer and default interfaces.
|
1638
|
-
*
|
1639
|
-
* @param tservice The service definition
|
1640
|
-
*/
|
1641
|
-
void t_java_generator::generate_service(t_service* tservice) {
|
1642
|
-
// Make output file
|
1643
|
-
string f_service_name = package_dir_+"/"+service_name_+".java";
|
1644
|
-
f_service_.open(f_service_name.c_str());
|
1645
|
-
|
1646
|
-
f_service_ <<
|
1647
|
-
autogen_comment() <<
|
1648
|
-
java_package() <<
|
1649
|
-
java_type_imports() <<
|
1650
|
-
java_thrift_imports();
|
1651
|
-
|
1652
|
-
f_service_ <<
|
1653
|
-
"public class " << service_name_ << " {" << endl <<
|
1654
|
-
endl;
|
1655
|
-
indent_up();
|
1656
|
-
|
1657
|
-
// Generate the three main parts of the service
|
1658
|
-
generate_service_interface(tservice);
|
1659
|
-
generate_service_client(tservice);
|
1660
|
-
generate_service_server(tservice);
|
1661
|
-
generate_service_helpers(tservice);
|
1662
|
-
|
1663
|
-
indent_down();
|
1664
|
-
f_service_ <<
|
1665
|
-
"}" << endl;
|
1666
|
-
f_service_.close();
|
1667
|
-
}
|
1668
|
-
|
1669
|
-
/**
|
1670
|
-
* Generates a service interface definition.
|
1671
|
-
*
|
1672
|
-
* @param tservice The service to generate a header definition for
|
1673
|
-
*/
|
1674
|
-
void t_java_generator::generate_service_interface(t_service* tservice) {
|
1675
|
-
string extends = "";
|
1676
|
-
string extends_iface = "";
|
1677
|
-
if (tservice->get_extends() != NULL) {
|
1678
|
-
extends = type_name(tservice->get_extends());
|
1679
|
-
extends_iface = " extends " + extends + ".Iface";
|
1680
|
-
}
|
1681
|
-
|
1682
|
-
generate_java_doc(f_service_, tservice);
|
1683
|
-
f_service_ << indent() << "public interface Iface" << extends_iface <<
|
1684
|
-
" {" << endl << endl;
|
1685
|
-
indent_up();
|
1686
|
-
vector<t_function*> functions = tservice->get_functions();
|
1687
|
-
vector<t_function*>::iterator f_iter;
|
1688
|
-
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
|
1689
|
-
generate_java_doc(f_service_, *f_iter);
|
1690
|
-
indent(f_service_) << "public " << function_signature(*f_iter) << ";" <<
|
1691
|
-
endl << endl;
|
1692
|
-
}
|
1693
|
-
indent_down();
|
1694
|
-
f_service_ <<
|
1695
|
-
indent() << "}" << endl <<
|
1696
|
-
endl;
|
1697
|
-
}
|
1698
|
-
|
1699
|
-
/**
|
1700
|
-
* Generates structs for all the service args and return types
|
1701
|
-
*
|
1702
|
-
* @param tservice The service
|
1703
|
-
*/
|
1704
|
-
void t_java_generator::generate_service_helpers(t_service* tservice) {
|
1705
|
-
vector<t_function*> functions = tservice->get_functions();
|
1706
|
-
vector<t_function*>::iterator f_iter;
|
1707
|
-
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
|
1708
|
-
t_struct* ts = (*f_iter)->get_arglist();
|
1709
|
-
generate_java_struct_definition(f_service_, ts, false, true);
|
1710
|
-
generate_function_helpers(*f_iter);
|
1711
|
-
}
|
1712
|
-
}
|
1713
|
-
|
1714
|
-
/**
|
1715
|
-
* Generates a service client definition.
|
1716
|
-
*
|
1717
|
-
* @param tservice The service to generate a server for.
|
1718
|
-
*/
|
1719
|
-
void t_java_generator::generate_service_client(t_service* tservice) {
|
1720
|
-
string extends = "";
|
1721
|
-
string extends_client = "";
|
1722
|
-
if (tservice->get_extends() != NULL) {
|
1723
|
-
extends = type_name(tservice->get_extends());
|
1724
|
-
extends_client = " extends " + extends + ".Client";
|
1725
|
-
}
|
1726
|
-
|
1727
|
-
indent(f_service_) <<
|
1728
|
-
"public static class Client" << extends_client << " implements Iface {" << endl;
|
1729
|
-
indent_up();
|
1730
|
-
|
1731
|
-
indent(f_service_) <<
|
1732
|
-
"public Client(TProtocol prot)" << endl;
|
1733
|
-
scope_up(f_service_);
|
1734
|
-
indent(f_service_) <<
|
1735
|
-
"this(prot, prot);" << endl;
|
1736
|
-
scope_down(f_service_);
|
1737
|
-
f_service_ << endl;
|
1738
|
-
|
1739
|
-
indent(f_service_) <<
|
1740
|
-
"public Client(TProtocol iprot, TProtocol oprot)" << endl;
|
1741
|
-
scope_up(f_service_);
|
1742
|
-
if (extends.empty()) {
|
1743
|
-
f_service_ <<
|
1744
|
-
indent() << "iprot_ = iprot;" << endl <<
|
1745
|
-
indent() << "oprot_ = oprot;" << endl;
|
1746
|
-
} else {
|
1747
|
-
f_service_ <<
|
1748
|
-
indent() << "super(iprot, oprot);" << endl;
|
1749
|
-
}
|
1750
|
-
scope_down(f_service_);
|
1751
|
-
f_service_ << endl;
|
1752
|
-
|
1753
|
-
if (extends.empty()) {
|
1754
|
-
f_service_ <<
|
1755
|
-
indent() << "protected TProtocol iprot_;" << endl <<
|
1756
|
-
indent() << "protected TProtocol oprot_;" << endl <<
|
1757
|
-
endl <<
|
1758
|
-
indent() << "protected int seqid_;" << endl <<
|
1759
|
-
endl;
|
1760
|
-
|
1761
|
-
indent(f_service_) <<
|
1762
|
-
"public TProtocol getInputProtocol()" << endl;
|
1763
|
-
scope_up(f_service_);
|
1764
|
-
indent(f_service_) <<
|
1765
|
-
"return this.iprot_;" << endl;
|
1766
|
-
scope_down(f_service_);
|
1767
|
-
f_service_ << endl;
|
1768
|
-
|
1769
|
-
indent(f_service_) <<
|
1770
|
-
"public TProtocol getOutputProtocol()" << endl;
|
1771
|
-
scope_up(f_service_);
|
1772
|
-
indent(f_service_) <<
|
1773
|
-
"return this.oprot_;" << endl;
|
1774
|
-
scope_down(f_service_);
|
1775
|
-
f_service_ << endl;
|
1776
|
-
|
1777
|
-
}
|
1778
|
-
|
1779
|
-
// Generate client method implementations
|
1780
|
-
vector<t_function*> functions = tservice->get_functions();
|
1781
|
-
vector<t_function*>::const_iterator f_iter;
|
1782
|
-
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
|
1783
|
-
string funname = (*f_iter)->get_name();
|
1784
|
-
|
1785
|
-
// Open function
|
1786
|
-
indent(f_service_) <<
|
1787
|
-
"public " << function_signature(*f_iter) << endl;
|
1788
|
-
scope_up(f_service_);
|
1789
|
-
indent(f_service_) <<
|
1790
|
-
"send_" << funname << "(";
|
1791
|
-
|
1792
|
-
// Get the struct of function call params
|
1793
|
-
t_struct* arg_struct = (*f_iter)->get_arglist();
|
1794
|
-
|
1795
|
-
// Declare the function arguments
|
1796
|
-
const vector<t_field*>& fields = arg_struct->get_members();
|
1797
|
-
vector<t_field*>::const_iterator fld_iter;
|
1798
|
-
bool first = true;
|
1799
|
-
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
|
1800
|
-
if (first) {
|
1801
|
-
first = false;
|
1802
|
-
} else {
|
1803
|
-
f_service_ << ", ";
|
1804
|
-
}
|
1805
|
-
f_service_ << (*fld_iter)->get_name();
|
1806
|
-
}
|
1807
|
-
f_service_ << ");" << endl;
|
1808
|
-
|
1809
|
-
if (!(*f_iter)->is_oneway()) {
|
1810
|
-
f_service_ << indent();
|
1811
|
-
if (!(*f_iter)->get_returntype()->is_void()) {
|
1812
|
-
f_service_ << "return ";
|
1813
|
-
}
|
1814
|
-
f_service_ <<
|
1815
|
-
"recv_" << funname << "();" << endl;
|
1816
|
-
}
|
1817
|
-
scope_down(f_service_);
|
1818
|
-
f_service_ << endl;
|
1819
|
-
|
1820
|
-
t_function send_function(g_type_void,
|
1821
|
-
string("send_") + (*f_iter)->get_name(),
|
1822
|
-
(*f_iter)->get_arglist());
|
1823
|
-
|
1824
|
-
string argsname = (*f_iter)->get_name() + "_args";
|
1825
|
-
|
1826
|
-
// Open function
|
1827
|
-
indent(f_service_) <<
|
1828
|
-
"public " << function_signature(&send_function) << endl;
|
1829
|
-
scope_up(f_service_);
|
1830
|
-
|
1831
|
-
// Serialize the request
|
1832
|
-
f_service_ <<
|
1833
|
-
indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", TMessageType.CALL, seqid_));" << endl <<
|
1834
|
-
indent() << argsname << " args = new " << argsname << "();" << endl;
|
1835
|
-
|
1836
|
-
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
|
1837
|
-
f_service_ <<
|
1838
|
-
indent() << "args." << (*fld_iter)->get_name() << " = " << (*fld_iter)->get_name() << ";" << endl;
|
1839
|
-
}
|
1840
|
-
|
1841
|
-
f_service_ <<
|
1842
|
-
indent() << "args.write(oprot_);" << endl <<
|
1843
|
-
indent() << "oprot_.writeMessageEnd();" << endl <<
|
1844
|
-
indent() << "oprot_.getTransport().flush();" << endl;
|
1845
|
-
|
1846
|
-
scope_down(f_service_);
|
1847
|
-
f_service_ << endl;
|
1848
|
-
|
1849
|
-
if (!(*f_iter)->is_oneway()) {
|
1850
|
-
string resultname = (*f_iter)->get_name() + "_result";
|
1851
|
-
|
1852
|
-
t_struct noargs(program_);
|
1853
|
-
t_function recv_function((*f_iter)->get_returntype(),
|
1854
|
-
string("recv_") + (*f_iter)->get_name(),
|
1855
|
-
&noargs,
|
1856
|
-
(*f_iter)->get_xceptions());
|
1857
|
-
// Open function
|
1858
|
-
indent(f_service_) <<
|
1859
|
-
"public " << function_signature(&recv_function) << endl;
|
1860
|
-
scope_up(f_service_);
|
1861
|
-
|
1862
|
-
// TODO(mcslee): Message validation here, was the seqid etc ok?
|
1863
|
-
|
1864
|
-
f_service_ <<
|
1865
|
-
indent() << "TMessage msg = iprot_.readMessageBegin();" << endl <<
|
1866
|
-
indent() << "if (msg.type == TMessageType.EXCEPTION) {" << endl <<
|
1867
|
-
indent() << " TApplicationException x = TApplicationException.read(iprot_);" << endl <<
|
1868
|
-
indent() << " iprot_.readMessageEnd();" << endl <<
|
1869
|
-
indent() << " throw x;" << endl <<
|
1870
|
-
indent() << "}" << endl <<
|
1871
|
-
indent() << resultname << " result = new " << resultname << "();" << endl <<
|
1872
|
-
indent() << "result.read(iprot_);" << endl <<
|
1873
|
-
indent() << "iprot_.readMessageEnd();" << endl;
|
1874
|
-
|
1875
|
-
// Careful, only return _result if not a void function
|
1876
|
-
if (!(*f_iter)->get_returntype()->is_void()) {
|
1877
|
-
f_service_ <<
|
1878
|
-
indent() << "if (result." << generate_isset_check("success") << ") {" << endl <<
|
1879
|
-
indent() << " return result.success;" << endl <<
|
1880
|
-
indent() << "}" << endl;
|
1881
|
-
}
|
1882
|
-
|
1883
|
-
t_struct* xs = (*f_iter)->get_xceptions();
|
1884
|
-
const std::vector<t_field*>& xceptions = xs->get_members();
|
1885
|
-
vector<t_field*>::const_iterator x_iter;
|
1886
|
-
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
|
1887
|
-
f_service_ <<
|
1888
|
-
indent() << "if (result." << (*x_iter)->get_name() << " != null) {" << endl <<
|
1889
|
-
indent() << " throw result." << (*x_iter)->get_name() << ";" << endl <<
|
1890
|
-
indent() << "}" << endl;
|
1891
|
-
}
|
1892
|
-
|
1893
|
-
// If you get here it's an exception, unless a void function
|
1894
|
-
if ((*f_iter)->get_returntype()->is_void()) {
|
1895
|
-
indent(f_service_) <<
|
1896
|
-
"return;" << endl;
|
1897
|
-
} else {
|
1898
|
-
f_service_ <<
|
1899
|
-
indent() << "throw new TApplicationException(TApplicationException.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl;
|
1900
|
-
}
|
1901
|
-
|
1902
|
-
// Close function
|
1903
|
-
scope_down(f_service_);
|
1904
|
-
f_service_ << endl;
|
1905
|
-
}
|
1906
|
-
}
|
1907
|
-
|
1908
|
-
indent_down();
|
1909
|
-
indent(f_service_) <<
|
1910
|
-
"}" << endl;
|
1911
|
-
}
|
1912
|
-
|
1913
|
-
/**
|
1914
|
-
* Generates a service server definition.
|
1915
|
-
*
|
1916
|
-
* @param tservice The service to generate a server for.
|
1917
|
-
*/
|
1918
|
-
void t_java_generator::generate_service_server(t_service* tservice) {
|
1919
|
-
// Generate the dispatch methods
|
1920
|
-
vector<t_function*> functions = tservice->get_functions();
|
1921
|
-
vector<t_function*>::iterator f_iter;
|
1922
|
-
|
1923
|
-
// Extends stuff
|
1924
|
-
string extends = "";
|
1925
|
-
string extends_processor = "";
|
1926
|
-
if (tservice->get_extends() != NULL) {
|
1927
|
-
extends = type_name(tservice->get_extends());
|
1928
|
-
extends_processor = " extends " + extends + ".Processor";
|
1929
|
-
}
|
1930
|
-
|
1931
|
-
// Generate the header portion
|
1932
|
-
indent(f_service_) <<
|
1933
|
-
"public static class Processor" << extends_processor << " implements TProcessor {" << endl;
|
1934
|
-
indent_up();
|
1935
|
-
|
1936
|
-
indent(f_service_) << "private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());" << endl;
|
1937
|
-
|
1938
|
-
indent(f_service_) <<
|
1939
|
-
"public Processor(Iface iface)" << endl;
|
1940
|
-
scope_up(f_service_);
|
1941
|
-
if (!extends.empty()) {
|
1942
|
-
f_service_ <<
|
1943
|
-
indent() << "super(iface);" << endl;
|
1944
|
-
}
|
1945
|
-
f_service_ <<
|
1946
|
-
indent() << "iface_ = iface;" << endl;
|
1947
|
-
|
1948
|
-
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
|
1949
|
-
f_service_ <<
|
1950
|
-
indent() << "processMap_.put(\"" << (*f_iter)->get_name() << "\", new " << (*f_iter)->get_name() << "());" << endl;
|
1951
|
-
}
|
1952
|
-
|
1953
|
-
scope_down(f_service_);
|
1954
|
-
f_service_ << endl;
|
1955
|
-
|
1956
|
-
if (extends.empty()) {
|
1957
|
-
f_service_ <<
|
1958
|
-
indent() << "protected static interface ProcessFunction {" << endl <<
|
1959
|
-
indent() << " public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;" << endl <<
|
1960
|
-
indent() << "}" << endl <<
|
1961
|
-
endl;
|
1962
|
-
}
|
1963
|
-
|
1964
|
-
f_service_ <<
|
1965
|
-
indent() << "private Iface iface_;" << endl;
|
1966
|
-
|
1967
|
-
if (extends.empty()) {
|
1968
|
-
f_service_ <<
|
1969
|
-
indent() << "protected final HashMap<String,ProcessFunction> processMap_ = new HashMap<String,ProcessFunction>();" << endl;
|
1970
|
-
}
|
1971
|
-
|
1972
|
-
f_service_ << endl;
|
1973
|
-
|
1974
|
-
// Generate the server implementation
|
1975
|
-
indent(f_service_) <<
|
1976
|
-
"public boolean process(TProtocol iprot, TProtocol oprot) throws TException" << endl;
|
1977
|
-
scope_up(f_service_);
|
1978
|
-
|
1979
|
-
f_service_ <<
|
1980
|
-
indent() << "TMessage msg = iprot.readMessageBegin();" << endl;
|
1981
|
-
|
1982
|
-
// TODO(mcslee): validate message, was the seqid etc. legit?
|
1983
|
-
|
1984
|
-
f_service_ <<
|
1985
|
-
indent() << "ProcessFunction fn = processMap_.get(msg.name);" << endl <<
|
1986
|
-
indent() << "if (fn == null) {" << endl <<
|
1987
|
-
indent() << " TProtocolUtil.skip(iprot, TType.STRUCT);" << endl <<
|
1988
|
-
indent() << " iprot.readMessageEnd();" << endl <<
|
1989
|
-
indent() << " TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: '\"+msg.name+\"'\");" << endl <<
|
1990
|
-
indent() << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl <<
|
1991
|
-
indent() << " x.write(oprot);" << endl <<
|
1992
|
-
indent() << " oprot.writeMessageEnd();" << endl <<
|
1993
|
-
indent() << " oprot.getTransport().flush();" << endl <<
|
1994
|
-
indent() << " return true;" << endl <<
|
1995
|
-
indent() << "}" << endl <<
|
1996
|
-
indent() << "fn.process(msg.seqid, iprot, oprot);" << endl;
|
1997
|
-
|
1998
|
-
f_service_ <<
|
1999
|
-
indent() << "return true;" << endl;
|
2000
|
-
|
2001
|
-
scope_down(f_service_);
|
2002
|
-
f_service_ << endl;
|
2003
|
-
|
2004
|
-
// Generate the process subfunctions
|
2005
|
-
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
|
2006
|
-
generate_process_function(tservice, *f_iter);
|
2007
|
-
}
|
2008
|
-
|
2009
|
-
indent_down();
|
2010
|
-
indent(f_service_) <<
|
2011
|
-
"}" << endl <<
|
2012
|
-
endl;
|
2013
|
-
}
|
2014
|
-
|
2015
|
-
/**
|
2016
|
-
* Generates a struct and helpers for a function.
|
2017
|
-
*
|
2018
|
-
* @param tfunction The function
|
2019
|
-
*/
|
2020
|
-
void t_java_generator::generate_function_helpers(t_function* tfunction) {
|
2021
|
-
if (tfunction->is_oneway()) {
|
2022
|
-
return;
|
2023
|
-
}
|
2024
|
-
|
2025
|
-
t_struct result(program_, tfunction->get_name() + "_result");
|
2026
|
-
t_field success(tfunction->get_returntype(), "success", 0);
|
2027
|
-
if (!tfunction->get_returntype()->is_void()) {
|
2028
|
-
result.append(&success);
|
2029
|
-
}
|
2030
|
-
|
2031
|
-
t_struct* xs = tfunction->get_xceptions();
|
2032
|
-
const vector<t_field*>& fields = xs->get_members();
|
2033
|
-
vector<t_field*>::const_iterator f_iter;
|
2034
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
2035
|
-
result.append(*f_iter);
|
2036
|
-
}
|
2037
|
-
|
2038
|
-
generate_java_struct_definition(f_service_, &result, false, true, true);
|
2039
|
-
}
|
2040
|
-
|
2041
|
-
/**
|
2042
|
-
* Generates a process function definition.
|
2043
|
-
*
|
2044
|
-
* @param tfunction The function to write a dispatcher for
|
2045
|
-
*/
|
2046
|
-
void t_java_generator::generate_process_function(t_service* tservice,
|
2047
|
-
t_function* tfunction) {
|
2048
|
-
// Open class
|
2049
|
-
indent(f_service_) <<
|
2050
|
-
"private class " << tfunction->get_name() << " implements ProcessFunction {" << endl;
|
2051
|
-
indent_up();
|
2052
|
-
|
2053
|
-
// Open function
|
2054
|
-
indent(f_service_) <<
|
2055
|
-
"public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException" << endl;
|
2056
|
-
scope_up(f_service_);
|
2057
|
-
|
2058
|
-
string argsname = tfunction->get_name() + "_args";
|
2059
|
-
string resultname = tfunction->get_name() + "_result";
|
2060
|
-
|
2061
|
-
f_service_ <<
|
2062
|
-
indent() << argsname << " args = new " << argsname << "();" << endl <<
|
2063
|
-
indent() << "args.read(iprot);" << endl <<
|
2064
|
-
indent() << "iprot.readMessageEnd();" << endl;
|
2065
|
-
|
2066
|
-
t_struct* xs = tfunction->get_xceptions();
|
2067
|
-
const std::vector<t_field*>& xceptions = xs->get_members();
|
2068
|
-
vector<t_field*>::const_iterator x_iter;
|
2069
|
-
|
2070
|
-
// Declare result for non oneway function
|
2071
|
-
if (!tfunction->is_oneway()) {
|
2072
|
-
f_service_ <<
|
2073
|
-
indent() << resultname << " result = new " << resultname << "();" << endl;
|
2074
|
-
}
|
2075
|
-
|
2076
|
-
// Try block for a function with exceptions
|
2077
|
-
if (xceptions.size() > 0) {
|
2078
|
-
f_service_ <<
|
2079
|
-
indent() << "try {" << endl;
|
2080
|
-
indent_up();
|
2081
|
-
}
|
2082
|
-
|
2083
|
-
// Generate the function call
|
2084
|
-
t_struct* arg_struct = tfunction->get_arglist();
|
2085
|
-
const std::vector<t_field*>& fields = arg_struct->get_members();
|
2086
|
-
vector<t_field*>::const_iterator f_iter;
|
2087
|
-
|
2088
|
-
f_service_ << indent();
|
2089
|
-
if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void()) {
|
2090
|
-
f_service_ << "result.success = ";
|
2091
|
-
}
|
2092
|
-
f_service_ <<
|
2093
|
-
"iface_." << tfunction->get_name() << "(";
|
2094
|
-
bool first = true;
|
2095
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
2096
|
-
if (first) {
|
2097
|
-
first = false;
|
2098
|
-
} else {
|
2099
|
-
f_service_ << ", ";
|
2100
|
-
}
|
2101
|
-
f_service_ << "args." << (*f_iter)->get_name();
|
2102
|
-
}
|
2103
|
-
f_service_ << ");" << endl;
|
2104
|
-
|
2105
|
-
// Set isset on success field
|
2106
|
-
if (!tfunction->is_oneway() && !tfunction->get_returntype()->is_void() && !type_can_be_null(tfunction->get_returntype())) {
|
2107
|
-
f_service_ <<
|
2108
|
-
indent() << "result.set" << get_cap_name("success") << get_cap_name("isSet") << "(true);" << endl;
|
2109
|
-
}
|
2110
|
-
|
2111
|
-
if (!tfunction->is_oneway() && xceptions.size() > 0) {
|
2112
|
-
indent_down();
|
2113
|
-
f_service_ << indent() << "}";
|
2114
|
-
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
|
2115
|
-
f_service_ << " catch (" << type_name((*x_iter)->get_type(), false, false) << " " << (*x_iter)->get_name() << ") {" << endl;
|
2116
|
-
if (!tfunction->is_oneway()) {
|
2117
|
-
indent_up();
|
2118
|
-
f_service_ <<
|
2119
|
-
indent() << "result." << (*x_iter)->get_name() << " = " << (*x_iter)->get_name() << ";" << endl;
|
2120
|
-
indent_down();
|
2121
|
-
f_service_ << indent() << "}";
|
2122
|
-
} else {
|
2123
|
-
f_service_ << "}";
|
2124
|
-
}
|
2125
|
-
}
|
2126
|
-
f_service_ << " catch (Throwable th) {" << endl;
|
2127
|
-
indent_up();
|
2128
|
-
f_service_ <<
|
2129
|
-
indent() << "LOGGER.error(\"Internal error processing " << tfunction->get_name() << "\", th);" << endl <<
|
2130
|
-
indent() << "TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, \"Internal error processing " << tfunction->get_name() << "\");" << endl <<
|
2131
|
-
indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl <<
|
2132
|
-
indent() << "x.write(oprot);" << endl <<
|
2133
|
-
indent() << "oprot.writeMessageEnd();" << endl <<
|
2134
|
-
indent() << "oprot.getTransport().flush();" << endl <<
|
2135
|
-
indent() << "return;" << endl;
|
2136
|
-
indent_down();
|
2137
|
-
f_service_ << indent() << "}" << endl;
|
2138
|
-
}
|
2139
|
-
|
2140
|
-
// Shortcut out here for oneway functions
|
2141
|
-
if (tfunction->is_oneway()) {
|
2142
|
-
f_service_ <<
|
2143
|
-
indent() << "return;" << endl;
|
2144
|
-
scope_down(f_service_);
|
2145
|
-
|
2146
|
-
// Close class
|
2147
|
-
indent_down();
|
2148
|
-
f_service_ <<
|
2149
|
-
indent() << "}" << endl <<
|
2150
|
-
endl;
|
2151
|
-
return;
|
2152
|
-
}
|
2153
|
-
|
2154
|
-
f_service_ <<
|
2155
|
-
indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.REPLY, seqid));" << endl <<
|
2156
|
-
indent() << "result.write(oprot);" << endl <<
|
2157
|
-
indent() << "oprot.writeMessageEnd();" << endl <<
|
2158
|
-
indent() << "oprot.getTransport().flush();" << endl;
|
2159
|
-
|
2160
|
-
// Close function
|
2161
|
-
scope_down(f_service_);
|
2162
|
-
f_service_ << endl;
|
2163
|
-
|
2164
|
-
// Close class
|
2165
|
-
indent_down();
|
2166
|
-
f_service_ <<
|
2167
|
-
indent() << "}" << endl <<
|
2168
|
-
endl;
|
2169
|
-
}
|
2170
|
-
|
2171
|
-
/**
|
2172
|
-
* Deserializes a field of any type.
|
2173
|
-
*
|
2174
|
-
* @param tfield The field
|
2175
|
-
* @param prefix The variable name or container for this field
|
2176
|
-
*/
|
2177
|
-
void t_java_generator::generate_deserialize_field(ofstream& out,
|
2178
|
-
t_field* tfield,
|
2179
|
-
string prefix) {
|
2180
|
-
t_type* type = get_true_type(tfield->get_type());
|
2181
|
-
|
2182
|
-
if (type->is_void()) {
|
2183
|
-
throw "CANNOT GENERATE DESERIALIZE CODE FOR void TYPE: " +
|
2184
|
-
prefix + tfield->get_name();
|
2185
|
-
}
|
2186
|
-
|
2187
|
-
string name = prefix + tfield->get_name();
|
2188
|
-
|
2189
|
-
if (type->is_struct() || type->is_xception()) {
|
2190
|
-
generate_deserialize_struct(out,
|
2191
|
-
(t_struct*)type,
|
2192
|
-
name);
|
2193
|
-
} else if (type->is_container()) {
|
2194
|
-
generate_deserialize_container(out, type, name);
|
2195
|
-
} else if (type->is_base_type() || type->is_enum()) {
|
2196
|
-
|
2197
|
-
indent(out) <<
|
2198
|
-
name << " = iprot.";
|
2199
|
-
|
2200
|
-
if (type->is_base_type()) {
|
2201
|
-
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
|
2202
|
-
switch (tbase) {
|
2203
|
-
case t_base_type::TYPE_VOID:
|
2204
|
-
throw "compiler error: cannot serialize void field in a struct: " +
|
2205
|
-
name;
|
2206
|
-
break;
|
2207
|
-
case t_base_type::TYPE_STRING:
|
2208
|
-
if (((t_base_type*)type)->is_binary()) {
|
2209
|
-
out << "readBinary();";
|
2210
|
-
} else {
|
2211
|
-
out << "readString();";
|
2212
|
-
}
|
2213
|
-
break;
|
2214
|
-
case t_base_type::TYPE_BOOL:
|
2215
|
-
out << "readBool();";
|
2216
|
-
break;
|
2217
|
-
case t_base_type::TYPE_BYTE:
|
2218
|
-
out << "readByte();";
|
2219
|
-
break;
|
2220
|
-
case t_base_type::TYPE_I16:
|
2221
|
-
out << "readI16();";
|
2222
|
-
break;
|
2223
|
-
case t_base_type::TYPE_I32:
|
2224
|
-
out << "readI32();";
|
2225
|
-
break;
|
2226
|
-
case t_base_type::TYPE_I64:
|
2227
|
-
out << "readI64();";
|
2228
|
-
break;
|
2229
|
-
case t_base_type::TYPE_DOUBLE:
|
2230
|
-
out << "readDouble();";
|
2231
|
-
break;
|
2232
|
-
default:
|
2233
|
-
throw "compiler error: no Java name for base type " + t_base_type::t_base_name(tbase);
|
2234
|
-
}
|
2235
|
-
} else if (type->is_enum()) {
|
2236
|
-
out << "readI32();";
|
2237
|
-
}
|
2238
|
-
out <<
|
2239
|
-
endl;
|
2240
|
-
} else {
|
2241
|
-
printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
|
2242
|
-
tfield->get_name().c_str(), type_name(type).c_str());
|
2243
|
-
}
|
2244
|
-
}
|
2245
|
-
|
2246
|
-
/**
|
2247
|
-
* Generates an unserializer for a struct, invokes read()
|
2248
|
-
*/
|
2249
|
-
void t_java_generator::generate_deserialize_struct(ofstream& out,
|
2250
|
-
t_struct* tstruct,
|
2251
|
-
string prefix) {
|
2252
|
-
out <<
|
2253
|
-
indent() << prefix << " = new " << type_name(tstruct) << "();" << endl <<
|
2254
|
-
indent() << prefix << ".read(iprot);" << endl;
|
2255
|
-
}
|
2256
|
-
|
2257
|
-
/**
|
2258
|
-
* Deserializes a container by reading its size and then iterating
|
2259
|
-
*/
|
2260
|
-
void t_java_generator::generate_deserialize_container(ofstream& out,
|
2261
|
-
t_type* ttype,
|
2262
|
-
string prefix) {
|
2263
|
-
scope_up(out);
|
2264
|
-
|
2265
|
-
string obj;
|
2266
|
-
|
2267
|
-
if (ttype->is_map()) {
|
2268
|
-
obj = tmp("_map");
|
2269
|
-
} else if (ttype->is_set()) {
|
2270
|
-
obj = tmp("_set");
|
2271
|
-
} else if (ttype->is_list()) {
|
2272
|
-
obj = tmp("_list");
|
2273
|
-
}
|
2274
|
-
|
2275
|
-
// Declare variables, read header
|
2276
|
-
if (ttype->is_map()) {
|
2277
|
-
indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << endl;
|
2278
|
-
} else if (ttype->is_set()) {
|
2279
|
-
indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << endl;
|
2280
|
-
} else if (ttype->is_list()) {
|
2281
|
-
indent(out) << "TList " << obj << " = iprot.readListBegin();" << endl;
|
2282
|
-
}
|
2283
|
-
|
2284
|
-
indent(out)
|
2285
|
-
<< prefix << " = new " << type_name(ttype, false, true)
|
2286
|
-
// size the collection correctly
|
2287
|
-
<< "("
|
2288
|
-
<< (ttype->is_list() ? "" : "2*" )
|
2289
|
-
<< obj << ".size"
|
2290
|
-
<< ");" << endl;
|
2291
|
-
|
2292
|
-
// For loop iterates over elements
|
2293
|
-
string i = tmp("_i");
|
2294
|
-
indent(out) <<
|
2295
|
-
"for (int " << i << " = 0; " <<
|
2296
|
-
i << " < " << obj << ".size" << "; " <<
|
2297
|
-
"++" << i << ")" << endl;
|
2298
|
-
|
2299
|
-
scope_up(out);
|
2300
|
-
|
2301
|
-
if (ttype->is_map()) {
|
2302
|
-
generate_deserialize_map_element(out, (t_map*)ttype, prefix);
|
2303
|
-
} else if (ttype->is_set()) {
|
2304
|
-
generate_deserialize_set_element(out, (t_set*)ttype, prefix);
|
2305
|
-
} else if (ttype->is_list()) {
|
2306
|
-
generate_deserialize_list_element(out, (t_list*)ttype, prefix);
|
2307
|
-
}
|
2308
|
-
|
2309
|
-
scope_down(out);
|
2310
|
-
|
2311
|
-
// Read container end
|
2312
|
-
if (ttype->is_map()) {
|
2313
|
-
indent(out) << "iprot.readMapEnd();" << endl;
|
2314
|
-
} else if (ttype->is_set()) {
|
2315
|
-
indent(out) << "iprot.readSetEnd();" << endl;
|
2316
|
-
} else if (ttype->is_list()) {
|
2317
|
-
indent(out) << "iprot.readListEnd();" << endl;
|
2318
|
-
}
|
2319
|
-
|
2320
|
-
scope_down(out);
|
2321
|
-
}
|
2322
|
-
|
2323
|
-
|
2324
|
-
/**
|
2325
|
-
* Generates code to deserialize a map
|
2326
|
-
*/
|
2327
|
-
void t_java_generator::generate_deserialize_map_element(ofstream& out,
|
2328
|
-
t_map* tmap,
|
2329
|
-
string prefix) {
|
2330
|
-
string key = tmp("_key");
|
2331
|
-
string val = tmp("_val");
|
2332
|
-
t_field fkey(tmap->get_key_type(), key);
|
2333
|
-
t_field fval(tmap->get_val_type(), val);
|
2334
|
-
|
2335
|
-
indent(out) <<
|
2336
|
-
declare_field(&fkey) << endl;
|
2337
|
-
indent(out) <<
|
2338
|
-
declare_field(&fval) << endl;
|
2339
|
-
|
2340
|
-
generate_deserialize_field(out, &fkey);
|
2341
|
-
generate_deserialize_field(out, &fval);
|
2342
|
-
|
2343
|
-
indent(out) <<
|
2344
|
-
prefix << ".put(" << key << ", " << val << ");" << endl;
|
2345
|
-
}
|
2346
|
-
|
2347
|
-
/**
|
2348
|
-
* Deserializes a set element
|
2349
|
-
*/
|
2350
|
-
void t_java_generator::generate_deserialize_set_element(ofstream& out,
|
2351
|
-
t_set* tset,
|
2352
|
-
string prefix) {
|
2353
|
-
string elem = tmp("_elem");
|
2354
|
-
t_field felem(tset->get_elem_type(), elem);
|
2355
|
-
|
2356
|
-
indent(out) <<
|
2357
|
-
declare_field(&felem) << endl;
|
2358
|
-
|
2359
|
-
generate_deserialize_field(out, &felem);
|
2360
|
-
|
2361
|
-
indent(out) <<
|
2362
|
-
prefix << ".add(" << elem << ");" << endl;
|
2363
|
-
}
|
2364
|
-
|
2365
|
-
/**
|
2366
|
-
* Deserializes a list element
|
2367
|
-
*/
|
2368
|
-
void t_java_generator::generate_deserialize_list_element(ofstream& out,
|
2369
|
-
t_list* tlist,
|
2370
|
-
string prefix) {
|
2371
|
-
string elem = tmp("_elem");
|
2372
|
-
t_field felem(tlist->get_elem_type(), elem);
|
2373
|
-
|
2374
|
-
indent(out) <<
|
2375
|
-
declare_field(&felem) << endl;
|
2376
|
-
|
2377
|
-
generate_deserialize_field(out, &felem);
|
2378
|
-
|
2379
|
-
indent(out) <<
|
2380
|
-
prefix << ".add(" << elem << ");" << endl;
|
2381
|
-
}
|
2382
|
-
|
2383
|
-
|
2384
|
-
/**
|
2385
|
-
* Serializes a field of any type.
|
2386
|
-
*
|
2387
|
-
* @param tfield The field to serialize
|
2388
|
-
* @param prefix Name to prepend to field name
|
2389
|
-
*/
|
2390
|
-
void t_java_generator::generate_serialize_field(ofstream& out,
|
2391
|
-
t_field* tfield,
|
2392
|
-
string prefix) {
|
2393
|
-
t_type* type = get_true_type(tfield->get_type());
|
2394
|
-
|
2395
|
-
// Do nothing for void types
|
2396
|
-
if (type->is_void()) {
|
2397
|
-
throw "CANNOT GENERATE SERIALIZE CODE FOR void TYPE: " +
|
2398
|
-
prefix + tfield->get_name();
|
2399
|
-
}
|
2400
|
-
|
2401
|
-
if (type->is_struct() || type->is_xception()) {
|
2402
|
-
generate_serialize_struct(out,
|
2403
|
-
(t_struct*)type,
|
2404
|
-
prefix + tfield->get_name());
|
2405
|
-
} else if (type->is_container()) {
|
2406
|
-
generate_serialize_container(out,
|
2407
|
-
type,
|
2408
|
-
prefix + tfield->get_name());
|
2409
|
-
} else if (type->is_base_type() || type->is_enum()) {
|
2410
|
-
|
2411
|
-
string name = prefix + tfield->get_name();
|
2412
|
-
indent(out) <<
|
2413
|
-
"oprot.";
|
2414
|
-
|
2415
|
-
if (type->is_base_type()) {
|
2416
|
-
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
|
2417
|
-
switch (tbase) {
|
2418
|
-
case t_base_type::TYPE_VOID:
|
2419
|
-
throw
|
2420
|
-
"compiler error: cannot serialize void field in a struct: " + name;
|
2421
|
-
break;
|
2422
|
-
case t_base_type::TYPE_STRING:
|
2423
|
-
if (((t_base_type*)type)->is_binary()) {
|
2424
|
-
out << "writeBinary(" << name << ");";
|
2425
|
-
} else {
|
2426
|
-
out << "writeString(" << name << ");";
|
2427
|
-
}
|
2428
|
-
break;
|
2429
|
-
case t_base_type::TYPE_BOOL:
|
2430
|
-
out << "writeBool(" << name << ");";
|
2431
|
-
break;
|
2432
|
-
case t_base_type::TYPE_BYTE:
|
2433
|
-
out << "writeByte(" << name << ");";
|
2434
|
-
break;
|
2435
|
-
case t_base_type::TYPE_I16:
|
2436
|
-
out << "writeI16(" << name << ");";
|
2437
|
-
break;
|
2438
|
-
case t_base_type::TYPE_I32:
|
2439
|
-
out << "writeI32(" << name << ");";
|
2440
|
-
break;
|
2441
|
-
case t_base_type::TYPE_I64:
|
2442
|
-
out << "writeI64(" << name << ");";
|
2443
|
-
break;
|
2444
|
-
case t_base_type::TYPE_DOUBLE:
|
2445
|
-
out << "writeDouble(" << name << ");";
|
2446
|
-
break;
|
2447
|
-
default:
|
2448
|
-
throw "compiler error: no Java name for base type " + t_base_type::t_base_name(tbase);
|
2449
|
-
}
|
2450
|
-
} else if (type->is_enum()) {
|
2451
|
-
out << "writeI32(" << name << ");";
|
2452
|
-
}
|
2453
|
-
out << endl;
|
2454
|
-
} else {
|
2455
|
-
printf("DO NOT KNOW HOW TO SERIALIZE FIELD '%s%s' TYPE '%s'\n",
|
2456
|
-
prefix.c_str(),
|
2457
|
-
tfield->get_name().c_str(),
|
2458
|
-
type_name(type).c_str());
|
2459
|
-
}
|
2460
|
-
}
|
2461
|
-
|
2462
|
-
/**
|
2463
|
-
* Serializes all the members of a struct.
|
2464
|
-
*
|
2465
|
-
* @param tstruct The struct to serialize
|
2466
|
-
* @param prefix String prefix to attach to all fields
|
2467
|
-
*/
|
2468
|
-
void t_java_generator::generate_serialize_struct(ofstream& out,
|
2469
|
-
t_struct* tstruct,
|
2470
|
-
string prefix) {
|
2471
|
-
out <<
|
2472
|
-
indent() << prefix << ".write(oprot);" << endl;
|
2473
|
-
}
|
2474
|
-
|
2475
|
-
/**
|
2476
|
-
* Serializes a container by writing its size then the elements.
|
2477
|
-
*
|
2478
|
-
* @param ttype The type of container
|
2479
|
-
* @param prefix String prefix for fields
|
2480
|
-
*/
|
2481
|
-
void t_java_generator::generate_serialize_container(ofstream& out,
|
2482
|
-
t_type* ttype,
|
2483
|
-
string prefix) {
|
2484
|
-
scope_up(out);
|
2485
|
-
|
2486
|
-
if (ttype->is_map()) {
|
2487
|
-
indent(out) <<
|
2488
|
-
"oprot.writeMapBegin(new TMap(" <<
|
2489
|
-
type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
|
2490
|
-
type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
|
2491
|
-
prefix << ".size()));" << endl;
|
2492
|
-
} else if (ttype->is_set()) {
|
2493
|
-
indent(out) <<
|
2494
|
-
"oprot.writeSetBegin(new TSet(" <<
|
2495
|
-
type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " <<
|
2496
|
-
prefix << ".size()));" << endl;
|
2497
|
-
} else if (ttype->is_list()) {
|
2498
|
-
indent(out) <<
|
2499
|
-
"oprot.writeListBegin(new TList(" <<
|
2500
|
-
type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " <<
|
2501
|
-
prefix << ".size()));" << endl;
|
2502
|
-
}
|
2503
|
-
|
2504
|
-
string iter = tmp("_iter");
|
2505
|
-
if (ttype->is_map()) {
|
2506
|
-
indent(out) <<
|
2507
|
-
"for (Map.Entry<" <<
|
2508
|
-
type_name(((t_map*)ttype)->get_key_type(), true, false) << ", " <<
|
2509
|
-
type_name(((t_map*)ttype)->get_val_type(), true, false) << "> " << iter <<
|
2510
|
-
" : " <<
|
2511
|
-
prefix << ".entrySet())";
|
2512
|
-
} else if (ttype->is_set()) {
|
2513
|
-
indent(out) <<
|
2514
|
-
"for (" <<
|
2515
|
-
type_name(((t_set*)ttype)->get_elem_type()) << " " << iter <<
|
2516
|
-
" : " <<
|
2517
|
-
prefix << ")";
|
2518
|
-
} else if (ttype->is_list()) {
|
2519
|
-
indent(out) <<
|
2520
|
-
"for (" <<
|
2521
|
-
type_name(((t_list*)ttype)->get_elem_type()) << " " << iter <<
|
2522
|
-
" : " <<
|
2523
|
-
prefix << ")";
|
2524
|
-
}
|
2525
|
-
|
2526
|
-
scope_up(out);
|
2527
|
-
|
2528
|
-
if (ttype->is_map()) {
|
2529
|
-
generate_serialize_map_element(out, (t_map*)ttype, iter, prefix);
|
2530
|
-
} else if (ttype->is_set()) {
|
2531
|
-
generate_serialize_set_element(out, (t_set*)ttype, iter);
|
2532
|
-
} else if (ttype->is_list()) {
|
2533
|
-
generate_serialize_list_element(out, (t_list*)ttype, iter);
|
2534
|
-
}
|
2535
|
-
|
2536
|
-
scope_down(out);
|
2537
|
-
|
2538
|
-
if (ttype->is_map()) {
|
2539
|
-
indent(out) <<
|
2540
|
-
"oprot.writeMapEnd();" << endl;
|
2541
|
-
} else if (ttype->is_set()) {
|
2542
|
-
indent(out) <<
|
2543
|
-
"oprot.writeSetEnd();" << endl;
|
2544
|
-
} else if (ttype->is_list()) {
|
2545
|
-
indent(out) <<
|
2546
|
-
"oprot.writeListEnd();" << endl;
|
2547
|
-
}
|
2548
|
-
|
2549
|
-
scope_down(out);
|
2550
|
-
}
|
2551
|
-
|
2552
|
-
/**
|
2553
|
-
* Serializes the members of a map.
|
2554
|
-
*/
|
2555
|
-
void t_java_generator::generate_serialize_map_element(ofstream& out,
|
2556
|
-
t_map* tmap,
|
2557
|
-
string iter,
|
2558
|
-
string map) {
|
2559
|
-
t_field kfield(tmap->get_key_type(), iter + ".getKey()");
|
2560
|
-
generate_serialize_field(out, &kfield, "");
|
2561
|
-
t_field vfield(tmap->get_val_type(), iter + ".getValue()");
|
2562
|
-
generate_serialize_field(out, &vfield, "");
|
2563
|
-
}
|
2564
|
-
|
2565
|
-
/**
|
2566
|
-
* Serializes the members of a set.
|
2567
|
-
*/
|
2568
|
-
void t_java_generator::generate_serialize_set_element(ofstream& out,
|
2569
|
-
t_set* tset,
|
2570
|
-
string iter) {
|
2571
|
-
t_field efield(tset->get_elem_type(), iter);
|
2572
|
-
generate_serialize_field(out, &efield, "");
|
2573
|
-
}
|
2574
|
-
|
2575
|
-
/**
|
2576
|
-
* Serializes the members of a list.
|
2577
|
-
*/
|
2578
|
-
void t_java_generator::generate_serialize_list_element(ofstream& out,
|
2579
|
-
t_list* tlist,
|
2580
|
-
string iter) {
|
2581
|
-
t_field efield(tlist->get_elem_type(), iter);
|
2582
|
-
generate_serialize_field(out, &efield, "");
|
2583
|
-
}
|
2584
|
-
|
2585
|
-
/**
|
2586
|
-
* Returns a Java type name
|
2587
|
-
*
|
2588
|
-
* @param ttype The type
|
2589
|
-
* @param container Is the type going inside a container?
|
2590
|
-
* @return Java type name, i.e. HashMap<Key,Value>
|
2591
|
-
*/
|
2592
|
-
string t_java_generator::type_name(t_type* ttype, bool in_container, bool in_init) {
|
2593
|
-
// In Java typedefs are just resolved to their real type
|
2594
|
-
ttype = get_true_type(ttype);
|
2595
|
-
string prefix;
|
2596
|
-
|
2597
|
-
if (ttype->is_base_type()) {
|
2598
|
-
return base_type_name((t_base_type*)ttype, in_container);
|
2599
|
-
} else if (ttype->is_enum()) {
|
2600
|
-
return (in_container ? "Integer" : "int");
|
2601
|
-
} else if (ttype->is_map()) {
|
2602
|
-
t_map* tmap = (t_map*) ttype;
|
2603
|
-
if (in_init) {
|
2604
|
-
prefix = "HashMap";
|
2605
|
-
} else {
|
2606
|
-
prefix = "Map";
|
2607
|
-
}
|
2608
|
-
return prefix + "<" +
|
2609
|
-
type_name(tmap->get_key_type(), true) + "," +
|
2610
|
-
type_name(tmap->get_val_type(), true) + ">";
|
2611
|
-
} else if (ttype->is_set()) {
|
2612
|
-
t_set* tset = (t_set*) ttype;
|
2613
|
-
if (in_init) {
|
2614
|
-
prefix = "HashSet<";
|
2615
|
-
} else {
|
2616
|
-
prefix = "Set<";
|
2617
|
-
}
|
2618
|
-
return prefix + type_name(tset->get_elem_type(), true) + ">";
|
2619
|
-
} else if (ttype->is_list()) {
|
2620
|
-
t_list* tlist = (t_list*) ttype;
|
2621
|
-
if (in_init) {
|
2622
|
-
prefix = "ArrayList<";
|
2623
|
-
} else {
|
2624
|
-
prefix = "List<";
|
2625
|
-
}
|
2626
|
-
return prefix + type_name(tlist->get_elem_type(), true) + ">";
|
2627
|
-
}
|
2628
|
-
|
2629
|
-
// Check for namespacing
|
2630
|
-
t_program* program = ttype->get_program();
|
2631
|
-
if (program != NULL && program != program_) {
|
2632
|
-
string package = program->get_namespace("java");
|
2633
|
-
if (!package.empty()) {
|
2634
|
-
return package + "." + ttype->get_name();
|
2635
|
-
}
|
2636
|
-
}
|
2637
|
-
|
2638
|
-
return ttype->get_name();
|
2639
|
-
}
|
2640
|
-
|
2641
|
-
/**
|
2642
|
-
* Returns the C++ type that corresponds to the thrift type.
|
2643
|
-
*
|
2644
|
-
* @param tbase The base type
|
2645
|
-
* @param container Is it going in a Java container?
|
2646
|
-
*/
|
2647
|
-
string t_java_generator::base_type_name(t_base_type* type,
|
2648
|
-
bool in_container) {
|
2649
|
-
t_base_type::t_base tbase = type->get_base();
|
2650
|
-
|
2651
|
-
switch (tbase) {
|
2652
|
-
case t_base_type::TYPE_VOID:
|
2653
|
-
return "void";
|
2654
|
-
case t_base_type::TYPE_STRING:
|
2655
|
-
if (type->is_binary()) {
|
2656
|
-
return "byte[]";
|
2657
|
-
} else {
|
2658
|
-
return "String";
|
2659
|
-
}
|
2660
|
-
case t_base_type::TYPE_BOOL:
|
2661
|
-
return (in_container ? "Boolean" : "boolean");
|
2662
|
-
case t_base_type::TYPE_BYTE:
|
2663
|
-
return (in_container ? "Byte" : "byte");
|
2664
|
-
case t_base_type::TYPE_I16:
|
2665
|
-
return (in_container ? "Short" : "short");
|
2666
|
-
case t_base_type::TYPE_I32:
|
2667
|
-
return (in_container ? "Integer" : "int");
|
2668
|
-
case t_base_type::TYPE_I64:
|
2669
|
-
return (in_container ? "Long" : "long");
|
2670
|
-
case t_base_type::TYPE_DOUBLE:
|
2671
|
-
return (in_container ? "Double" : "double");
|
2672
|
-
default:
|
2673
|
-
throw "compiler error: no C++ name for base type " + t_base_type::t_base_name(tbase);
|
2674
|
-
}
|
2675
|
-
}
|
2676
|
-
|
2677
|
-
/**
|
2678
|
-
* Declares a field, which may include initialization as necessary.
|
2679
|
-
*
|
2680
|
-
* @param ttype The type
|
2681
|
-
*/
|
2682
|
-
string t_java_generator::declare_field(t_field* tfield, bool init) {
|
2683
|
-
// TODO(mcslee): do we ever need to initialize the field?
|
2684
|
-
string result = type_name(tfield->get_type()) + " " + tfield->get_name();
|
2685
|
-
if (init) {
|
2686
|
-
t_type* ttype = get_true_type(tfield->get_type());
|
2687
|
-
if (ttype->is_base_type() && tfield->get_value() != NULL) {
|
2688
|
-
ofstream dummy;
|
2689
|
-
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
|
2690
|
-
} else if (ttype->is_base_type()) {
|
2691
|
-
t_base_type::t_base tbase = ((t_base_type*)ttype)->get_base();
|
2692
|
-
switch (tbase) {
|
2693
|
-
case t_base_type::TYPE_VOID:
|
2694
|
-
throw "NO T_VOID CONSTRUCT";
|
2695
|
-
case t_base_type::TYPE_STRING:
|
2696
|
-
result += " = null";
|
2697
|
-
break;
|
2698
|
-
case t_base_type::TYPE_BOOL:
|
2699
|
-
result += " = false";
|
2700
|
-
break;
|
2701
|
-
case t_base_type::TYPE_BYTE:
|
2702
|
-
case t_base_type::TYPE_I16:
|
2703
|
-
case t_base_type::TYPE_I32:
|
2704
|
-
case t_base_type::TYPE_I64:
|
2705
|
-
result += " = 0";
|
2706
|
-
break;
|
2707
|
-
case t_base_type::TYPE_DOUBLE:
|
2708
|
-
result += " = (double)0";
|
2709
|
-
break;
|
2710
|
-
}
|
2711
|
-
|
2712
|
-
} else if (ttype->is_enum()) {
|
2713
|
-
result += " = 0";
|
2714
|
-
} else if (ttype->is_container()) {
|
2715
|
-
result += " = new " + type_name(ttype, false, true) + "()";
|
2716
|
-
} else {
|
2717
|
-
result += " = new " + type_name(ttype, false, true) + "()";;
|
2718
|
-
}
|
2719
|
-
}
|
2720
|
-
return result + ";";
|
2721
|
-
}
|
2722
|
-
|
2723
|
-
/**
|
2724
|
-
* Renders a function signature of the form 'type name(args)'
|
2725
|
-
*
|
2726
|
-
* @param tfunction Function definition
|
2727
|
-
* @return String of rendered function definition
|
2728
|
-
*/
|
2729
|
-
string t_java_generator::function_signature(t_function* tfunction,
|
2730
|
-
string prefix) {
|
2731
|
-
t_type* ttype = tfunction->get_returntype();
|
2732
|
-
std::string result =
|
2733
|
-
type_name(ttype) + " " + prefix + tfunction->get_name() + "(" + argument_list(tfunction->get_arglist()) + ") throws ";
|
2734
|
-
t_struct* xs = tfunction->get_xceptions();
|
2735
|
-
const std::vector<t_field*>& xceptions = xs->get_members();
|
2736
|
-
vector<t_field*>::const_iterator x_iter;
|
2737
|
-
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
|
2738
|
-
result += type_name((*x_iter)->get_type(), false, false) + ", ";
|
2739
|
-
}
|
2740
|
-
result += "TException";
|
2741
|
-
return result;
|
2742
|
-
}
|
2743
|
-
|
2744
|
-
/**
|
2745
|
-
* Renders a comma separated field list, with type names
|
2746
|
-
*/
|
2747
|
-
string t_java_generator::argument_list(t_struct* tstruct) {
|
2748
|
-
string result = "";
|
2749
|
-
|
2750
|
-
const vector<t_field*>& fields = tstruct->get_members();
|
2751
|
-
vector<t_field*>::const_iterator f_iter;
|
2752
|
-
bool first = true;
|
2753
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
2754
|
-
if (first) {
|
2755
|
-
first = false;
|
2756
|
-
} else {
|
2757
|
-
result += ", ";
|
2758
|
-
}
|
2759
|
-
result += type_name((*f_iter)->get_type()) + " " + (*f_iter)->get_name();
|
2760
|
-
}
|
2761
|
-
return result;
|
2762
|
-
}
|
2763
|
-
|
2764
|
-
/**
|
2765
|
-
* Converts the parse type to a C++ enum string for the given type.
|
2766
|
-
*/
|
2767
|
-
string t_java_generator::type_to_enum(t_type* type) {
|
2768
|
-
type = get_true_type(type);
|
2769
|
-
|
2770
|
-
if (type->is_base_type()) {
|
2771
|
-
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
|
2772
|
-
switch (tbase) {
|
2773
|
-
case t_base_type::TYPE_VOID:
|
2774
|
-
throw "NO T_VOID CONSTRUCT";
|
2775
|
-
case t_base_type::TYPE_STRING:
|
2776
|
-
return "TType.STRING";
|
2777
|
-
case t_base_type::TYPE_BOOL:
|
2778
|
-
return "TType.BOOL";
|
2779
|
-
case t_base_type::TYPE_BYTE:
|
2780
|
-
return "TType.BYTE";
|
2781
|
-
case t_base_type::TYPE_I16:
|
2782
|
-
return "TType.I16";
|
2783
|
-
case t_base_type::TYPE_I32:
|
2784
|
-
return "TType.I32";
|
2785
|
-
case t_base_type::TYPE_I64:
|
2786
|
-
return "TType.I64";
|
2787
|
-
case t_base_type::TYPE_DOUBLE:
|
2788
|
-
return "TType.DOUBLE";
|
2789
|
-
}
|
2790
|
-
} else if (type->is_enum()) {
|
2791
|
-
return "TType.I32";
|
2792
|
-
} else if (type->is_struct() || type->is_xception()) {
|
2793
|
-
return "TType.STRUCT";
|
2794
|
-
} else if (type->is_map()) {
|
2795
|
-
return "TType.MAP";
|
2796
|
-
} else if (type->is_set()) {
|
2797
|
-
return "TType.SET";
|
2798
|
-
} else if (type->is_list()) {
|
2799
|
-
return "TType.LIST";
|
2800
|
-
}
|
2801
|
-
|
2802
|
-
throw "INVALID TYPE IN type_to_enum: " + type->get_name();
|
2803
|
-
}
|
2804
|
-
|
2805
|
-
/**
|
2806
|
-
* Applies the correct style to a string based on the value of nocamel_style_
|
2807
|
-
*/
|
2808
|
-
std::string t_java_generator::get_cap_name(std::string name){
|
2809
|
-
if (nocamel_style_) {
|
2810
|
-
return "_" + name;
|
2811
|
-
} else {
|
2812
|
-
name[0] = toupper(name[0]);
|
2813
|
-
return name;
|
2814
|
-
}
|
2815
|
-
}
|
2816
|
-
|
2817
|
-
string t_java_generator::constant_name(string name) {
|
2818
|
-
string constant_name;
|
2819
|
-
|
2820
|
-
bool is_first = true;
|
2821
|
-
bool was_previous_char_upper = false;
|
2822
|
-
for (string::iterator iter = name.begin(); iter != name.end(); ++iter) {
|
2823
|
-
string::value_type character = (*iter);
|
2824
|
-
|
2825
|
-
bool is_upper = isupper(character);
|
2826
|
-
|
2827
|
-
if (is_upper && !is_first && !was_previous_char_upper) {
|
2828
|
-
constant_name += '_';
|
2829
|
-
}
|
2830
|
-
constant_name += toupper(character);
|
2831
|
-
|
2832
|
-
is_first = false;
|
2833
|
-
was_previous_char_upper = is_upper;
|
2834
|
-
}
|
2835
|
-
|
2836
|
-
return constant_name;
|
2837
|
-
}
|
2838
|
-
|
2839
|
-
void t_java_generator::generate_java_docstring_comment(ofstream &out, string contents) {
|
2840
|
-
generate_docstring_comment(out,
|
2841
|
-
"/**\n",
|
2842
|
-
" * ", contents,
|
2843
|
-
" */\n");
|
2844
|
-
}
|
2845
|
-
|
2846
|
-
void t_java_generator::generate_java_doc(ofstream &out,
|
2847
|
-
t_field* field) {
|
2848
|
-
if (field->get_type()->is_enum()) {
|
2849
|
-
string combined_message = field->get_doc() + "\n@see " + get_enum_class_name(field->get_type());
|
2850
|
-
generate_java_docstring_comment(out, combined_message);
|
2851
|
-
} else {
|
2852
|
-
generate_java_doc(out, (t_doc*)field);
|
2853
|
-
}
|
2854
|
-
}
|
2855
|
-
|
2856
|
-
/**
|
2857
|
-
* Emits a JavaDoc comment if the provided object has a doc in Thrift
|
2858
|
-
*/
|
2859
|
-
void t_java_generator::generate_java_doc(ofstream &out,
|
2860
|
-
t_doc* tdoc) {
|
2861
|
-
if (tdoc->has_doc()) {
|
2862
|
-
generate_java_docstring_comment(out, tdoc->get_doc());
|
2863
|
-
}
|
2864
|
-
}
|
2865
|
-
|
2866
|
-
/**
|
2867
|
-
* Emits a JavaDoc comment if the provided function object has a doc in Thrift
|
2868
|
-
*/
|
2869
|
-
void t_java_generator::generate_java_doc(ofstream &out,
|
2870
|
-
t_function* tfunction) {
|
2871
|
-
if (tfunction->has_doc()) {
|
2872
|
-
stringstream ss;
|
2873
|
-
ss << tfunction->get_doc();
|
2874
|
-
const vector<t_field*>& fields = tfunction->get_arglist()->get_members();
|
2875
|
-
vector<t_field*>::const_iterator p_iter;
|
2876
|
-
for (p_iter = fields.begin(); p_iter != fields.end(); ++p_iter) {
|
2877
|
-
t_field* p = *p_iter;
|
2878
|
-
ss << "\n@param " << p->get_name();
|
2879
|
-
if (p->has_doc()) {
|
2880
|
-
ss << " " << p->get_doc();
|
2881
|
-
}
|
2882
|
-
}
|
2883
|
-
generate_docstring_comment(out,
|
2884
|
-
"/**\n",
|
2885
|
-
" * ", ss.str(),
|
2886
|
-
" */\n");
|
2887
|
-
}
|
2888
|
-
}
|
2889
|
-
|
2890
|
-
void t_java_generator::generate_deep_copy_container(ofstream &out, std::string source_name_p1, std::string source_name_p2,
|
2891
|
-
std::string result_name, t_type* type) {
|
2892
|
-
|
2893
|
-
t_container* container = (t_container*)type;
|
2894
|
-
std::string source_name;
|
2895
|
-
if (source_name_p2 == "")
|
2896
|
-
source_name = source_name_p1;
|
2897
|
-
else
|
2898
|
-
source_name = source_name_p1 + "." + source_name_p2;
|
2899
|
-
|
2900
|
-
indent(out) << type_name(type, true, false) << " " << result_name << " = new " << type_name(container, false, true) << "();" << endl;
|
2901
|
-
|
2902
|
-
std::string iterator_element_name = source_name_p1 + "_element";
|
2903
|
-
std::string result_element_name = result_name + "_copy";
|
2904
|
-
|
2905
|
-
if(container->is_map()) {
|
2906
|
-
t_type* key_type = ((t_map*)container)->get_key_type();
|
2907
|
-
t_type* val_type = ((t_map*)container)->get_val_type();
|
2908
|
-
|
2909
|
-
indent(out) <<
|
2910
|
-
"for (Map.Entry<" << type_name(key_type, true, false) << ", " << type_name(val_type, true, false) << "> " << iterator_element_name << " : " << source_name << ".entrySet()) {" << endl;
|
2911
|
-
indent_up();
|
2912
|
-
|
2913
|
-
out << endl;
|
2914
|
-
|
2915
|
-
indent(out) << type_name(key_type, true, false) << " " << iterator_element_name << "_key = " << iterator_element_name << ".getKey();" << endl;
|
2916
|
-
indent(out) << type_name(val_type, true, false) << " " << iterator_element_name << "_value = " << iterator_element_name << ".getValue();" << endl;
|
2917
|
-
|
2918
|
-
out << endl;
|
2919
|
-
|
2920
|
-
if (key_type->is_container()) {
|
2921
|
-
generate_deep_copy_container(out, iterator_element_name + "_key", "", result_element_name + "_key", key_type);
|
2922
|
-
} else {
|
2923
|
-
indent(out) << type_name(key_type, true, false) << " " << result_element_name << "_key = ";
|
2924
|
-
generate_deep_copy_non_container(out, iterator_element_name + "_key", result_element_name + "_key", key_type);
|
2925
|
-
out << ";" << endl;
|
2926
|
-
}
|
2927
|
-
|
2928
|
-
out << endl;
|
2929
|
-
|
2930
|
-
if (val_type->is_container()) {
|
2931
|
-
generate_deep_copy_container(out, iterator_element_name + "_value", "", result_element_name + "_value", val_type);
|
2932
|
-
} else {
|
2933
|
-
indent(out) << type_name(val_type, true, false) << " " << result_element_name << "_value = ";
|
2934
|
-
generate_deep_copy_non_container(out, iterator_element_name + "_value", result_element_name + "_value", val_type);
|
2935
|
-
out << ";" << endl;
|
2936
|
-
}
|
2937
|
-
|
2938
|
-
out << endl;
|
2939
|
-
|
2940
|
-
indent(out) << result_name << ".put(" << result_element_name << "_key, " << result_element_name << "_value);" << endl;
|
2941
|
-
|
2942
|
-
indent_down();
|
2943
|
-
indent(out) << "}" << endl;
|
2944
|
-
|
2945
|
-
} else {
|
2946
|
-
t_type* elem_type;
|
2947
|
-
|
2948
|
-
if (container->is_set()) {
|
2949
|
-
elem_type = ((t_set*)container)->get_elem_type();
|
2950
|
-
} else {
|
2951
|
-
elem_type = ((t_list*)container)->get_elem_type();
|
2952
|
-
}
|
2953
|
-
|
2954
|
-
indent(out)
|
2955
|
-
<< "for (" << type_name(elem_type, true, false) << " " << iterator_element_name << " : " << source_name << ") {" << endl;
|
2956
|
-
|
2957
|
-
indent_up();
|
2958
|
-
|
2959
|
-
if (elem_type->is_container()) {
|
2960
|
-
// recursive deep copy
|
2961
|
-
generate_deep_copy_container(out, iterator_element_name, "", result_element_name, elem_type);
|
2962
|
-
indent(out) << result_name << ".add(" << result_element_name << ");" << endl;
|
2963
|
-
} else {
|
2964
|
-
// iterative copy
|
2965
|
-
if(((t_base_type*)elem_type)->is_binary()){
|
2966
|
-
indent(out) << "byte[] temp_binary_element = ";
|
2967
|
-
generate_deep_copy_non_container(out, iterator_element_name, "temp_binary_element", elem_type);
|
2968
|
-
out << ";" << endl;
|
2969
|
-
indent(out) << result_name << ".add(temp_binary_element);" << endl;
|
2970
|
-
}
|
2971
|
-
else{
|
2972
|
-
indent(out) << result_name << ".add(";
|
2973
|
-
generate_deep_copy_non_container(out, iterator_element_name, result_name, elem_type);
|
2974
|
-
out << ");" << endl;
|
2975
|
-
}
|
2976
|
-
}
|
2977
|
-
|
2978
|
-
indent_down();
|
2979
|
-
|
2980
|
-
indent(out) << "}" << endl;
|
2981
|
-
|
2982
|
-
}
|
2983
|
-
}
|
2984
|
-
|
2985
|
-
void t_java_generator::generate_deep_copy_non_container(ofstream& out, std::string source_name, std::string dest_name, t_type* type) {
|
2986
|
-
if (type->is_base_type() || type->is_enum() || type->is_typedef()) {
|
2987
|
-
// binary fields need to be copied with System.arraycopy
|
2988
|
-
if (((t_base_type*)type)->is_binary()){
|
2989
|
-
out << "new byte[" << source_name << ".length];" << endl;
|
2990
|
-
indent(out) << "System.arraycopy(" << source_name << ", 0, " << dest_name << ", 0, " << source_name << ".length)";
|
2991
|
-
}
|
2992
|
-
// everything else can be copied directly
|
2993
|
-
else
|
2994
|
-
out << source_name;
|
2995
|
-
} else {
|
2996
|
-
out << "new " << type_name(type, true, true) << "(" << source_name << ")";
|
2997
|
-
}
|
2998
|
-
}
|
2999
|
-
|
3000
|
-
std::string t_java_generator::generate_isset_check(t_field* field) {
|
3001
|
-
return generate_isset_check(field->get_name());
|
3002
|
-
}
|
3003
|
-
|
3004
|
-
std::string t_java_generator::isset_field_id(t_field* field) {
|
3005
|
-
return "__" + upcase_string(field->get_name() + "_isset_id");
|
3006
|
-
}
|
3007
|
-
|
3008
|
-
std::string t_java_generator::generate_isset_check(std::string field_name) {
|
3009
|
-
return "is" + get_cap_name("set") + get_cap_name(field_name) + "()";
|
3010
|
-
}
|
3011
|
-
|
3012
|
-
void t_java_generator::generate_isset_set(ofstream& out, t_field* field) {
|
3013
|
-
if (!type_can_be_null(field->get_type())) {
|
3014
|
-
indent(out) << "set" << get_cap_name(field->get_name()) << get_cap_name("isSet") << "(true);" << endl;
|
3015
|
-
}
|
3016
|
-
}
|
3017
|
-
|
3018
|
-
std::string t_java_generator::get_enum_class_name(t_type* type) {
|
3019
|
-
string package = "";
|
3020
|
-
t_program* program = type->get_program();
|
3021
|
-
if (program != NULL && program != program_) {
|
3022
|
-
package = program->get_namespace("java") + ".";
|
3023
|
-
}
|
3024
|
-
return package + type->get_name();
|
3025
|
-
}
|
3026
|
-
|
3027
|
-
bool t_java_generator::is_comparable(t_struct* tstruct) {
|
3028
|
-
const vector<t_field*>& members = tstruct->get_members();
|
3029
|
-
vector<t_field*>::const_iterator m_iter;
|
3030
|
-
|
3031
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
3032
|
-
if (!is_comparable((*m_iter)->get_type())) {
|
3033
|
-
return false;
|
3034
|
-
}
|
3035
|
-
}
|
3036
|
-
return true;
|
3037
|
-
}
|
3038
|
-
|
3039
|
-
bool t_java_generator::is_comparable(t_type* type) {
|
3040
|
-
if (type->is_container()) {
|
3041
|
-
if (type->is_list()) {
|
3042
|
-
return is_comparable(((t_list*)type)->get_elem_type());
|
3043
|
-
} else {
|
3044
|
-
return false;
|
3045
|
-
}
|
3046
|
-
} else if (type->is_struct()) {
|
3047
|
-
return is_comparable((t_struct*)type);
|
3048
|
-
} else {
|
3049
|
-
return true;
|
3050
|
-
}
|
3051
|
-
}
|
3052
|
-
|
3053
|
-
bool t_java_generator::has_bit_vector(t_struct* tstruct) {
|
3054
|
-
const vector<t_field*>& members = tstruct->get_members();
|
3055
|
-
vector<t_field*>::const_iterator m_iter;
|
3056
|
-
|
3057
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
3058
|
-
if (!type_can_be_null((*m_iter)->get_type())) {
|
3059
|
-
return true;
|
3060
|
-
}
|
3061
|
-
}
|
3062
|
-
return false;
|
3063
|
-
}
|
3064
|
-
|
3065
|
-
THRIFT_REGISTER_GENERATOR(java, "Java",
|
3066
|
-
" beans: Generate bean-style output files.\n"
|
3067
|
-
" nocamel: Do not use CamelCase field accessors with beans.\n"
|
3068
|
-
" hashcode: Generate quality hashCode methods.\n"
|
3069
|
-
);
|