auser-poolparty 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,1207 +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
|
-
/**
|
|
21
|
-
* thrift - a lightweight cross-language rpc/serialization tool
|
|
22
|
-
*
|
|
23
|
-
* This file contains the main compiler engine for Thrift, which invokes the
|
|
24
|
-
* scanner/parser to build the thrift object tree. The interface generation
|
|
25
|
-
* code for each language lives in a file by the language name under the
|
|
26
|
-
* generate/ folder, and all parse structures live in parse/
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
#include <cassert>
|
|
31
|
-
#include <stdlib.h>
|
|
32
|
-
#include <stdio.h>
|
|
33
|
-
#include <stdarg.h>
|
|
34
|
-
#include <string>
|
|
35
|
-
#include <algorithm>
|
|
36
|
-
#include <sys/types.h>
|
|
37
|
-
#include <sys/stat.h>
|
|
38
|
-
#include <errno.h>
|
|
39
|
-
#include <limits.h>
|
|
40
|
-
|
|
41
|
-
#ifdef MINGW
|
|
42
|
-
# include <windows.h> /* for GetFullPathName */
|
|
43
|
-
#endif
|
|
44
|
-
|
|
45
|
-
// Careful: must include globals first for extern definitions
|
|
46
|
-
#include "globals.h"
|
|
47
|
-
|
|
48
|
-
#include "main.h"
|
|
49
|
-
#include "parse/t_program.h"
|
|
50
|
-
#include "parse/t_scope.h"
|
|
51
|
-
#include "generate/t_generator.h"
|
|
52
|
-
|
|
53
|
-
#include "version.h"
|
|
54
|
-
|
|
55
|
-
using namespace std;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Global program tree
|
|
59
|
-
*/
|
|
60
|
-
t_program* g_program;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Global types
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
t_type* g_type_void;
|
|
67
|
-
t_type* g_type_string;
|
|
68
|
-
t_type* g_type_binary;
|
|
69
|
-
t_type* g_type_slist;
|
|
70
|
-
t_type* g_type_bool;
|
|
71
|
-
t_type* g_type_byte;
|
|
72
|
-
t_type* g_type_i16;
|
|
73
|
-
t_type* g_type_i32;
|
|
74
|
-
t_type* g_type_i64;
|
|
75
|
-
t_type* g_type_double;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Global scope
|
|
79
|
-
*/
|
|
80
|
-
t_scope* g_scope;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Parent scope to also parse types
|
|
84
|
-
*/
|
|
85
|
-
t_scope* g_parent_scope;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Prefix for putting types in parent scope
|
|
89
|
-
*/
|
|
90
|
-
string g_parent_prefix;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Parsing pass
|
|
94
|
-
*/
|
|
95
|
-
PARSE_MODE g_parse_mode;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Current directory of file being parsed
|
|
99
|
-
*/
|
|
100
|
-
string g_curdir;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Current file being parsed
|
|
104
|
-
*/
|
|
105
|
-
string g_curpath;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Search path for inclusions
|
|
109
|
-
*/
|
|
110
|
-
vector<string> g_incl_searchpath;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Should C++ include statements use path prefixes for other thrift-generated
|
|
114
|
-
* header files
|
|
115
|
-
*/
|
|
116
|
-
bool g_cpp_use_include_prefix = false;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Global debug state
|
|
120
|
-
*/
|
|
121
|
-
int g_debug = 0;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Strictness level
|
|
125
|
-
*/
|
|
126
|
-
int g_strict = 127;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Warning level
|
|
130
|
-
*/
|
|
131
|
-
int g_warn = 1;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Verbose output
|
|
135
|
-
*/
|
|
136
|
-
int g_verbose = 0;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Global time string
|
|
140
|
-
*/
|
|
141
|
-
char* g_time_str;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* The last parsed doctext comment.
|
|
145
|
-
*/
|
|
146
|
-
char* g_doctext;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* The location of the last parsed doctext comment.
|
|
150
|
-
*/
|
|
151
|
-
int g_doctext_lineno;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Flags to control code generation
|
|
155
|
-
*/
|
|
156
|
-
bool gen_cpp = false;
|
|
157
|
-
bool gen_dense = false;
|
|
158
|
-
bool gen_java = false;
|
|
159
|
-
bool gen_javabean = false;
|
|
160
|
-
bool gen_rb = false;
|
|
161
|
-
bool gen_py = false;
|
|
162
|
-
bool gen_py_newstyle = false;
|
|
163
|
-
bool gen_xsd = false;
|
|
164
|
-
bool gen_php = false;
|
|
165
|
-
bool gen_phpi = false;
|
|
166
|
-
bool gen_phps = true;
|
|
167
|
-
bool gen_phpa = false;
|
|
168
|
-
bool gen_phpo = false;
|
|
169
|
-
bool gen_rest = false;
|
|
170
|
-
bool gen_perl = false;
|
|
171
|
-
bool gen_erl = false;
|
|
172
|
-
bool gen_ocaml = false;
|
|
173
|
-
bool gen_hs = false;
|
|
174
|
-
bool gen_cocoa = false;
|
|
175
|
-
bool gen_csharp = false;
|
|
176
|
-
bool gen_st = false;
|
|
177
|
-
bool gen_recurse = false;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* MinGW doesn't have realpath, so use fallback implementation in that case,
|
|
181
|
-
* otherwise this just calls through to realpath
|
|
182
|
-
*/
|
|
183
|
-
char *saferealpath(const char *path, char *resolved_path) {
|
|
184
|
-
#ifdef MINGW
|
|
185
|
-
char buf[MAX_PATH];
|
|
186
|
-
char* basename;
|
|
187
|
-
DWORD len = GetFullPathName(path, MAX_PATH, buf, &basename);
|
|
188
|
-
if (len == 0 || len > MAX_PATH - 1){
|
|
189
|
-
strcpy(resolved_path, path);
|
|
190
|
-
} else {
|
|
191
|
-
CharLowerBuff(buf, len);
|
|
192
|
-
strcpy(resolved_path, buf);
|
|
193
|
-
}
|
|
194
|
-
return resolved_path;
|
|
195
|
-
#else
|
|
196
|
-
return realpath(path, resolved_path);
|
|
197
|
-
#endif
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Report an error to the user. This is called yyerror for historical
|
|
203
|
-
* reasons (lex and yacc expect the error reporting routine to be called
|
|
204
|
-
* this). Call this function to report any errors to the user.
|
|
205
|
-
* yyerror takes printf style arguments.
|
|
206
|
-
*
|
|
207
|
-
* @param fmt C format string followed by additional arguments
|
|
208
|
-
*/
|
|
209
|
-
void yyerror(const char* fmt, ...) {
|
|
210
|
-
va_list args;
|
|
211
|
-
fprintf(stderr,
|
|
212
|
-
"[ERROR:%s:%d] (last token was '%s')\n",
|
|
213
|
-
g_curpath.c_str(),
|
|
214
|
-
yylineno,
|
|
215
|
-
yytext);
|
|
216
|
-
|
|
217
|
-
va_start(args, fmt);
|
|
218
|
-
vfprintf(stderr, fmt, args);
|
|
219
|
-
va_end(args);
|
|
220
|
-
|
|
221
|
-
fprintf(stderr, "\n");
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Prints a debug message from the parser.
|
|
226
|
-
*
|
|
227
|
-
* @param fmt C format string followed by additional arguments
|
|
228
|
-
*/
|
|
229
|
-
void pdebug(const char* fmt, ...) {
|
|
230
|
-
if (g_debug == 0) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
va_list args;
|
|
234
|
-
printf("[PARSE:%d] ", yylineno);
|
|
235
|
-
va_start(args, fmt);
|
|
236
|
-
vprintf(fmt, args);
|
|
237
|
-
va_end(args);
|
|
238
|
-
printf("\n");
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Prints a verbose output mode message
|
|
243
|
-
*
|
|
244
|
-
* @param fmt C format string followed by additional arguments
|
|
245
|
-
*/
|
|
246
|
-
void pverbose(const char* fmt, ...) {
|
|
247
|
-
if (g_verbose == 0) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
va_list args;
|
|
251
|
-
va_start(args, fmt);
|
|
252
|
-
vprintf(fmt, args);
|
|
253
|
-
va_end(args);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Prints a warning message
|
|
258
|
-
*
|
|
259
|
-
* @param fmt C format string followed by additional arguments
|
|
260
|
-
*/
|
|
261
|
-
void pwarning(int level, const char* fmt, ...) {
|
|
262
|
-
if (g_warn < level) {
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
va_list args;
|
|
266
|
-
printf("[WARNING:%s:%d] ", g_curpath.c_str(), yylineno);
|
|
267
|
-
va_start(args, fmt);
|
|
268
|
-
vprintf(fmt, args);
|
|
269
|
-
va_end(args);
|
|
270
|
-
printf("\n");
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Prints a failure message and exits
|
|
275
|
-
*
|
|
276
|
-
* @param fmt C format string followed by additional arguments
|
|
277
|
-
*/
|
|
278
|
-
void failure(const char* fmt, ...) {
|
|
279
|
-
va_list args;
|
|
280
|
-
fprintf(stderr, "[FAILURE:%s:%d] ", g_curpath.c_str(), yylineno);
|
|
281
|
-
va_start(args, fmt);
|
|
282
|
-
vfprintf(stderr, fmt, args);
|
|
283
|
-
va_end(args);
|
|
284
|
-
printf("\n");
|
|
285
|
-
exit(1);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Converts a string filename into a thrift program name
|
|
290
|
-
*/
|
|
291
|
-
string program_name(string filename) {
|
|
292
|
-
string::size_type slash = filename.rfind("/");
|
|
293
|
-
if (slash != string::npos) {
|
|
294
|
-
filename = filename.substr(slash+1);
|
|
295
|
-
}
|
|
296
|
-
string::size_type dot = filename.rfind(".");
|
|
297
|
-
if (dot != string::npos) {
|
|
298
|
-
filename = filename.substr(0, dot);
|
|
299
|
-
}
|
|
300
|
-
return filename;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Gets the directory path of a filename
|
|
305
|
-
*/
|
|
306
|
-
string directory_name(string filename) {
|
|
307
|
-
string::size_type slash = filename.rfind("/");
|
|
308
|
-
// No slash, just use the current directory
|
|
309
|
-
if (slash == string::npos) {
|
|
310
|
-
return ".";
|
|
311
|
-
}
|
|
312
|
-
return filename.substr(0, slash);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Finds the appropriate file path for the given filename
|
|
317
|
-
*/
|
|
318
|
-
string include_file(string filename) {
|
|
319
|
-
// Absolute path? Just try that
|
|
320
|
-
if (filename[0] == '/') {
|
|
321
|
-
// Realpath!
|
|
322
|
-
char rp[PATH_MAX];
|
|
323
|
-
if (saferealpath(filename.c_str(), rp) == NULL) {
|
|
324
|
-
pwarning(0, "Cannot open include file %s\n", filename.c_str());
|
|
325
|
-
return std::string();
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Stat this file
|
|
329
|
-
struct stat finfo;
|
|
330
|
-
if (stat(rp, &finfo) == 0) {
|
|
331
|
-
return rp;
|
|
332
|
-
}
|
|
333
|
-
} else { // relative path, start searching
|
|
334
|
-
// new search path with current dir global
|
|
335
|
-
vector<string> sp = g_incl_searchpath;
|
|
336
|
-
sp.insert(sp.begin(), g_curdir);
|
|
337
|
-
|
|
338
|
-
// iterate through paths
|
|
339
|
-
vector<string>::iterator it;
|
|
340
|
-
for (it = sp.begin(); it != sp.end(); it++) {
|
|
341
|
-
string sfilename = *(it) + "/" + filename;
|
|
342
|
-
|
|
343
|
-
// Realpath!
|
|
344
|
-
char rp[PATH_MAX];
|
|
345
|
-
if (saferealpath(sfilename.c_str(), rp) == NULL) {
|
|
346
|
-
continue;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Stat this files
|
|
350
|
-
struct stat finfo;
|
|
351
|
-
if (stat(rp, &finfo) == 0) {
|
|
352
|
-
return rp;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// Uh oh
|
|
358
|
-
pwarning(0, "Could not find include file %s\n", filename.c_str());
|
|
359
|
-
return std::string();
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* Clears any previously stored doctext string.
|
|
364
|
-
* Also prints a warning if we are discarding information.
|
|
365
|
-
*/
|
|
366
|
-
void clear_doctext() {
|
|
367
|
-
if (g_doctext != NULL) {
|
|
368
|
-
pwarning(2, "Uncaptured doctext at on line %d.", g_doctext_lineno);
|
|
369
|
-
}
|
|
370
|
-
free(g_doctext);
|
|
371
|
-
g_doctext = NULL;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Cleans up text commonly found in doxygen-like comments
|
|
376
|
-
*
|
|
377
|
-
* Warning: if you mix tabs and spaces in a non-uniform way,
|
|
378
|
-
* you will get what you deserve.
|
|
379
|
-
*/
|
|
380
|
-
char* clean_up_doctext(char* doctext) {
|
|
381
|
-
// Convert to C++ string, and remove Windows's carriage returns.
|
|
382
|
-
string docstring = doctext;
|
|
383
|
-
docstring.erase(
|
|
384
|
-
remove(docstring.begin(), docstring.end(), '\r'),
|
|
385
|
-
docstring.end());
|
|
386
|
-
|
|
387
|
-
// Separate into lines.
|
|
388
|
-
vector<string> lines;
|
|
389
|
-
string::size_type pos = string::npos;
|
|
390
|
-
string::size_type last;
|
|
391
|
-
while (true) {
|
|
392
|
-
last = (pos == string::npos) ? 0 : pos+1;
|
|
393
|
-
pos = docstring.find('\n', last);
|
|
394
|
-
if (pos == string::npos) {
|
|
395
|
-
// First bit of cleaning. If the last line is only whitespace, drop it.
|
|
396
|
-
string::size_type nonwhite = docstring.find_first_not_of(" \t", last);
|
|
397
|
-
if (nonwhite != string::npos) {
|
|
398
|
-
lines.push_back(docstring.substr(last));
|
|
399
|
-
}
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
lines.push_back(docstring.substr(last, pos-last));
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// A very profound docstring.
|
|
406
|
-
if (lines.empty()) {
|
|
407
|
-
return NULL;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Clear leading whitespace from the first line.
|
|
411
|
-
pos = lines.front().find_first_not_of(" \t");
|
|
412
|
-
lines.front().erase(0, pos);
|
|
413
|
-
|
|
414
|
-
// If every nonblank line after the first has the same number of spaces/tabs,
|
|
415
|
-
// then a star, remove them.
|
|
416
|
-
bool have_prefix = true;
|
|
417
|
-
bool found_prefix = false;
|
|
418
|
-
string::size_type prefix_len = 0;
|
|
419
|
-
vector<string>::iterator l_iter;
|
|
420
|
-
for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
|
|
421
|
-
if (l_iter->empty()) {
|
|
422
|
-
continue;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
pos = l_iter->find_first_not_of(" \t");
|
|
426
|
-
if (!found_prefix) {
|
|
427
|
-
if (pos != string::npos) {
|
|
428
|
-
if (l_iter->at(pos) == '*') {
|
|
429
|
-
found_prefix = true;
|
|
430
|
-
prefix_len = pos;
|
|
431
|
-
} else {
|
|
432
|
-
have_prefix = false;
|
|
433
|
-
break;
|
|
434
|
-
}
|
|
435
|
-
} else {
|
|
436
|
-
// Whitespace-only line. Truncate it.
|
|
437
|
-
l_iter->clear();
|
|
438
|
-
}
|
|
439
|
-
} else if (l_iter->size() > pos
|
|
440
|
-
&& l_iter->at(pos) == '*'
|
|
441
|
-
&& pos == prefix_len) {
|
|
442
|
-
// Business as usual.
|
|
443
|
-
} else if (pos == string::npos) {
|
|
444
|
-
// Whitespace-only line. Let's truncate it for them.
|
|
445
|
-
l_iter->clear();
|
|
446
|
-
} else {
|
|
447
|
-
// The pattern has been broken.
|
|
448
|
-
have_prefix = false;
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
// If our prefix survived, delete it from every line.
|
|
454
|
-
if (have_prefix) {
|
|
455
|
-
// Get the star too.
|
|
456
|
-
prefix_len++;
|
|
457
|
-
for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
|
|
458
|
-
l_iter->erase(0, prefix_len);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// Now delete the minimum amount of leading whitespace from each line.
|
|
463
|
-
prefix_len = string::npos;
|
|
464
|
-
for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
|
|
465
|
-
if (l_iter->empty()) {
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
pos = l_iter->find_first_not_of(" \t");
|
|
469
|
-
if (pos != string::npos
|
|
470
|
-
&& (prefix_len == string::npos || pos < prefix_len)) {
|
|
471
|
-
prefix_len = pos;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// If our prefix survived, delete it from every line.
|
|
476
|
-
if (prefix_len != string::npos) {
|
|
477
|
-
for (l_iter = lines.begin()+1; l_iter != lines.end(); ++l_iter) {
|
|
478
|
-
l_iter->erase(0, prefix_len);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// Remove trailing whitespace from every line.
|
|
483
|
-
for (l_iter = lines.begin(); l_iter != lines.end(); ++l_iter) {
|
|
484
|
-
pos = l_iter->find_last_not_of(" \t");
|
|
485
|
-
if (pos != string::npos && pos != l_iter->length()-1) {
|
|
486
|
-
l_iter->erase(pos+1);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// If the first line is empty, remove it.
|
|
491
|
-
// Don't do this earlier because a lot of steps skip the first line.
|
|
492
|
-
if (lines.front().empty()) {
|
|
493
|
-
lines.erase(lines.begin());
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// Now rejoin the lines and copy them back into doctext.
|
|
497
|
-
docstring.clear();
|
|
498
|
-
for (l_iter = lines.begin(); l_iter != lines.end(); ++l_iter) {
|
|
499
|
-
docstring += *l_iter;
|
|
500
|
-
docstring += '\n';
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
assert(docstring.length() <= strlen(doctext));
|
|
504
|
-
strcpy(doctext, docstring.c_str());
|
|
505
|
-
return doctext;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
/** Set to true to debug docstring parsing */
|
|
509
|
-
static bool dump_docs = false;
|
|
510
|
-
|
|
511
|
-
/**
|
|
512
|
-
* Dumps docstrings to stdout
|
|
513
|
-
* Only works for top-level definitions and the whole program doc
|
|
514
|
-
* (i.e., not enum constants, struct fields, or functions.
|
|
515
|
-
*/
|
|
516
|
-
void dump_docstrings(t_program* program) {
|
|
517
|
-
string progdoc = program->get_doc();
|
|
518
|
-
if (!progdoc.empty()) {
|
|
519
|
-
printf("Whole program doc:\n%s\n", progdoc.c_str());
|
|
520
|
-
}
|
|
521
|
-
const vector<t_typedef*>& typedefs = program->get_typedefs();
|
|
522
|
-
vector<t_typedef*>::const_iterator t_iter;
|
|
523
|
-
for (t_iter = typedefs.begin(); t_iter != typedefs.end(); ++t_iter) {
|
|
524
|
-
t_typedef* td = *t_iter;
|
|
525
|
-
if (td->has_doc()) {
|
|
526
|
-
printf("typedef %s:\n%s\n", td->get_name().c_str(), td->get_doc().c_str());
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
const vector<t_enum*>& enums = program->get_enums();
|
|
530
|
-
vector<t_enum*>::const_iterator e_iter;
|
|
531
|
-
for (e_iter = enums.begin(); e_iter != enums.end(); ++e_iter) {
|
|
532
|
-
t_enum* en = *e_iter;
|
|
533
|
-
if (en->has_doc()) {
|
|
534
|
-
printf("enum %s:\n%s\n", en->get_name().c_str(), en->get_doc().c_str());
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
const vector<t_const*>& consts = program->get_consts();
|
|
538
|
-
vector<t_const*>::const_iterator c_iter;
|
|
539
|
-
for (c_iter = consts.begin(); c_iter != consts.end(); ++c_iter) {
|
|
540
|
-
t_const* co = *c_iter;
|
|
541
|
-
if (co->has_doc()) {
|
|
542
|
-
printf("const %s:\n%s\n", co->get_name().c_str(), co->get_doc().c_str());
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
const vector<t_struct*>& structs = program->get_structs();
|
|
546
|
-
vector<t_struct*>::const_iterator s_iter;
|
|
547
|
-
for (s_iter = structs.begin(); s_iter != structs.end(); ++s_iter) {
|
|
548
|
-
t_struct* st = *s_iter;
|
|
549
|
-
if (st->has_doc()) {
|
|
550
|
-
printf("struct %s:\n%s\n", st->get_name().c_str(), st->get_doc().c_str());
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
const vector<t_struct*>& xceptions = program->get_xceptions();
|
|
554
|
-
vector<t_struct*>::const_iterator x_iter;
|
|
555
|
-
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
|
|
556
|
-
t_struct* xn = *x_iter;
|
|
557
|
-
if (xn->has_doc()) {
|
|
558
|
-
printf("xception %s:\n%s\n", xn->get_name().c_str(), xn->get_doc().c_str());
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
const vector<t_service*>& services = program->get_services();
|
|
562
|
-
vector<t_service*>::const_iterator v_iter;
|
|
563
|
-
for (v_iter = services.begin(); v_iter != services.end(); ++v_iter) {
|
|
564
|
-
t_service* sv = *v_iter;
|
|
565
|
-
if (sv->has_doc()) {
|
|
566
|
-
printf("service %s:\n%s\n", sv->get_name().c_str(), sv->get_doc().c_str());
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Call generate_fingerprint for every structure and enum.
|
|
573
|
-
*/
|
|
574
|
-
void generate_all_fingerprints(t_program* program) {
|
|
575
|
-
const vector<t_struct*>& structs = program->get_structs();
|
|
576
|
-
vector<t_struct*>::const_iterator s_iter;
|
|
577
|
-
for (s_iter = structs.begin(); s_iter != structs.end(); ++s_iter) {
|
|
578
|
-
t_struct* st = *s_iter;
|
|
579
|
-
st->generate_fingerprint();
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
const vector<t_struct*>& xceptions = program->get_xceptions();
|
|
583
|
-
vector<t_struct*>::const_iterator x_iter;
|
|
584
|
-
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) {
|
|
585
|
-
t_struct* st = *x_iter;
|
|
586
|
-
st->generate_fingerprint();
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
const vector<t_enum*>& enums = program->get_enums();
|
|
590
|
-
vector<t_enum*>::const_iterator e_iter;
|
|
591
|
-
for (e_iter = enums.begin(); e_iter != enums.end(); ++e_iter) {
|
|
592
|
-
t_enum* e = *e_iter;
|
|
593
|
-
e->generate_fingerprint();
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
g_type_void->generate_fingerprint();
|
|
597
|
-
|
|
598
|
-
// If you want to generate fingerprints for implicit structures, start here.
|
|
599
|
-
/*
|
|
600
|
-
const vector<t_service*>& services = program->get_services();
|
|
601
|
-
vector<t_service*>::const_iterator v_iter;
|
|
602
|
-
for (v_iter = services.begin(); v_iter != services.end(); ++v_iter) {
|
|
603
|
-
t_service* sv = *v_iter;
|
|
604
|
-
}
|
|
605
|
-
*/
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* Prints the version number
|
|
610
|
-
*/
|
|
611
|
-
void version() {
|
|
612
|
-
printf("Thrift version %s-%s\n", THRIFT_VERSION, THRIFT_REVISION);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* Diplays the usage message and then exits with an error code.
|
|
617
|
-
*/
|
|
618
|
-
void usage() {
|
|
619
|
-
fprintf(stderr, "Usage: thrift [options] file\n");
|
|
620
|
-
fprintf(stderr, "Options:\n");
|
|
621
|
-
fprintf(stderr, " -version Print the compiler version\n");
|
|
622
|
-
fprintf(stderr, " -o dir Set the output directory for gen-* packages\n");
|
|
623
|
-
fprintf(stderr, " (default: current directory)\n");
|
|
624
|
-
fprintf(stderr, " -I dir Add a directory to the list of directories\n");
|
|
625
|
-
fprintf(stderr, " searched for include directives\n");
|
|
626
|
-
fprintf(stderr, " -nowarn Suppress all compiler warnings (BAD!)\n");
|
|
627
|
-
fprintf(stderr, " -strict Strict compiler warnings on\n");
|
|
628
|
-
fprintf(stderr, " -v[erbose] Verbose mode\n");
|
|
629
|
-
fprintf(stderr, " -r[ecurse] Also generate included files\n");
|
|
630
|
-
fprintf(stderr, " -debug Parse debug trace to stdout\n");
|
|
631
|
-
fprintf(stderr, " --gen STR Generate code with a dynamically-registered generator.\n");
|
|
632
|
-
fprintf(stderr, " STR has the form language[:key1=val1[,key2,[key3=val3]]].\n");
|
|
633
|
-
fprintf(stderr, " Keys and values are options passed to the generator.\n");
|
|
634
|
-
fprintf(stderr, " Many options will not require values.\n");
|
|
635
|
-
fprintf(stderr, "\n");
|
|
636
|
-
fprintf(stderr, "Available generators (and options):\n");
|
|
637
|
-
|
|
638
|
-
t_generator_registry::gen_map_t gen_map = t_generator_registry::get_generator_map();
|
|
639
|
-
t_generator_registry::gen_map_t::iterator iter;
|
|
640
|
-
for (iter = gen_map.begin(); iter != gen_map.end(); ++iter) {
|
|
641
|
-
fprintf(stderr, " %s (%s):\n",
|
|
642
|
-
iter->second->get_short_name().c_str(),
|
|
643
|
-
iter->second->get_long_name().c_str());
|
|
644
|
-
fprintf(stderr, "%s", iter->second->get_documentation().c_str());
|
|
645
|
-
}
|
|
646
|
-
exit(1);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* You know, when I started working on Thrift I really thought it wasn't going
|
|
651
|
-
* to become a programming language because it was just a generator and it
|
|
652
|
-
* wouldn't need runtime type information and all that jazz. But then we
|
|
653
|
-
* decided to add constants, and all of a sudden that means runtime type
|
|
654
|
-
* validation and inference, except the "runtime" is the code generator
|
|
655
|
-
* runtime. Shit. I've been had.
|
|
656
|
-
*/
|
|
657
|
-
void validate_const_rec(std::string name, t_type* type, t_const_value* value) {
|
|
658
|
-
if (type->is_void()) {
|
|
659
|
-
throw "type error: cannot declare a void const: " + name;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
if (type->is_base_type()) {
|
|
663
|
-
t_base_type::t_base tbase = ((t_base_type*)type)->get_base();
|
|
664
|
-
switch (tbase) {
|
|
665
|
-
case t_base_type::TYPE_STRING:
|
|
666
|
-
if (value->get_type() != t_const_value::CV_STRING) {
|
|
667
|
-
throw "type error: const \"" + name + "\" was declared as string";
|
|
668
|
-
}
|
|
669
|
-
break;
|
|
670
|
-
case t_base_type::TYPE_BOOL:
|
|
671
|
-
if (value->get_type() != t_const_value::CV_INTEGER) {
|
|
672
|
-
throw "type error: const \"" + name + "\" was declared as bool";
|
|
673
|
-
}
|
|
674
|
-
break;
|
|
675
|
-
case t_base_type::TYPE_BYTE:
|
|
676
|
-
if (value->get_type() != t_const_value::CV_INTEGER) {
|
|
677
|
-
throw "type error: const \"" + name + "\" was declared as byte";
|
|
678
|
-
}
|
|
679
|
-
break;
|
|
680
|
-
case t_base_type::TYPE_I16:
|
|
681
|
-
if (value->get_type() != t_const_value::CV_INTEGER) {
|
|
682
|
-
throw "type error: const \"" + name + "\" was declared as i16";
|
|
683
|
-
}
|
|
684
|
-
break;
|
|
685
|
-
case t_base_type::TYPE_I32:
|
|
686
|
-
if (value->get_type() != t_const_value::CV_INTEGER) {
|
|
687
|
-
throw "type error: const \"" + name + "\" was declared as i32";
|
|
688
|
-
}
|
|
689
|
-
break;
|
|
690
|
-
case t_base_type::TYPE_I64:
|
|
691
|
-
if (value->get_type() != t_const_value::CV_INTEGER) {
|
|
692
|
-
throw "type error: const \"" + name + "\" was declared as i64";
|
|
693
|
-
}
|
|
694
|
-
break;
|
|
695
|
-
case t_base_type::TYPE_DOUBLE:
|
|
696
|
-
if (value->get_type() != t_const_value::CV_INTEGER &&
|
|
697
|
-
value->get_type() != t_const_value::CV_DOUBLE) {
|
|
698
|
-
throw "type error: const \"" + name + "\" was declared as double";
|
|
699
|
-
}
|
|
700
|
-
break;
|
|
701
|
-
default:
|
|
702
|
-
throw "compiler error: no const of base type " + t_base_type::t_base_name(tbase) + name;
|
|
703
|
-
}
|
|
704
|
-
} else if (type->is_enum()) {
|
|
705
|
-
if (value->get_type() != t_const_value::CV_INTEGER) {
|
|
706
|
-
throw "type error: const \"" + name + "\" was declared as enum";
|
|
707
|
-
}
|
|
708
|
-
} else if (type->is_struct() || type->is_xception()) {
|
|
709
|
-
if (value->get_type() != t_const_value::CV_MAP) {
|
|
710
|
-
throw "type error: const \"" + name + "\" was declared as struct/xception";
|
|
711
|
-
}
|
|
712
|
-
const vector<t_field*>& fields = ((t_struct*)type)->get_members();
|
|
713
|
-
vector<t_field*>::const_iterator f_iter;
|
|
714
|
-
|
|
715
|
-
const map<t_const_value*, t_const_value*>& val = value->get_map();
|
|
716
|
-
map<t_const_value*, t_const_value*>::const_iterator v_iter;
|
|
717
|
-
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
|
|
718
|
-
if (v_iter->first->get_type() != t_const_value::CV_STRING) {
|
|
719
|
-
throw "type error: " + name + " struct key must be string";
|
|
720
|
-
}
|
|
721
|
-
t_type* field_type = NULL;
|
|
722
|
-
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
|
|
723
|
-
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
|
|
724
|
-
field_type = (*f_iter)->get_type();
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
if (field_type == NULL) {
|
|
728
|
-
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
validate_const_rec(name + "." + v_iter->first->get_string(), field_type, v_iter->second);
|
|
732
|
-
}
|
|
733
|
-
} else if (type->is_map()) {
|
|
734
|
-
t_type* k_type = ((t_map*)type)->get_key_type();
|
|
735
|
-
t_type* v_type = ((t_map*)type)->get_val_type();
|
|
736
|
-
const map<t_const_value*, t_const_value*>& val = value->get_map();
|
|
737
|
-
map<t_const_value*, t_const_value*>::const_iterator v_iter;
|
|
738
|
-
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
|
|
739
|
-
validate_const_rec(name + "<key>", k_type, v_iter->first);
|
|
740
|
-
validate_const_rec(name + "<val>", v_type, v_iter->second);
|
|
741
|
-
}
|
|
742
|
-
} else if (type->is_list() || type->is_set()) {
|
|
743
|
-
t_type* e_type;
|
|
744
|
-
if (type->is_list()) {
|
|
745
|
-
e_type = ((t_list*)type)->get_elem_type();
|
|
746
|
-
} else {
|
|
747
|
-
e_type = ((t_set*)type)->get_elem_type();
|
|
748
|
-
}
|
|
749
|
-
const vector<t_const_value*>& val = value->get_list();
|
|
750
|
-
vector<t_const_value*>::const_iterator v_iter;
|
|
751
|
-
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
|
|
752
|
-
validate_const_rec(name + "<elem>", e_type, *v_iter);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* Check the type of the parsed const information against its declared type
|
|
759
|
-
*/
|
|
760
|
-
void validate_const_type(t_const* c) {
|
|
761
|
-
validate_const_rec(c->get_name(), c->get_type(), c->get_value());
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* Check the type of a default value assigned to a field.
|
|
766
|
-
*/
|
|
767
|
-
void validate_field_value(t_field* field, t_const_value* cv) {
|
|
768
|
-
validate_const_rec(field->get_name(), field->get_type(), cv);
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* Check that all the elements of a throws block are actually exceptions.
|
|
773
|
-
*/
|
|
774
|
-
bool validate_throws(t_struct* throws) {
|
|
775
|
-
const vector<t_field*>& members = throws->get_members();
|
|
776
|
-
vector<t_field*>::const_iterator m_iter;
|
|
777
|
-
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
|
|
778
|
-
if (!(*m_iter)->get_type()->is_xception()) {
|
|
779
|
-
return false;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
return true;
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* Parses a program
|
|
787
|
-
*/
|
|
788
|
-
void parse(t_program* program, t_program* parent_program) {
|
|
789
|
-
// Get scope file path
|
|
790
|
-
string path = program->get_path();
|
|
791
|
-
|
|
792
|
-
// Set current dir global, which is used in the include_file function
|
|
793
|
-
g_curdir = directory_name(path);
|
|
794
|
-
g_curpath = path;
|
|
795
|
-
|
|
796
|
-
// Open the file
|
|
797
|
-
yyin = fopen(path.c_str(), "r");
|
|
798
|
-
if (yyin == 0) {
|
|
799
|
-
failure("Could not open input file: \"%s\"", path.c_str());
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
// Create new scope and scan for includes
|
|
803
|
-
pverbose("Scanning %s for includes\n", path.c_str());
|
|
804
|
-
g_parse_mode = INCLUDES;
|
|
805
|
-
g_program = program;
|
|
806
|
-
g_scope = program->scope();
|
|
807
|
-
try {
|
|
808
|
-
yylineno = 1;
|
|
809
|
-
if (yyparse() != 0) {
|
|
810
|
-
failure("Parser error during include pass.");
|
|
811
|
-
}
|
|
812
|
-
} catch (string x) {
|
|
813
|
-
failure(x.c_str());
|
|
814
|
-
}
|
|
815
|
-
fclose(yyin);
|
|
816
|
-
|
|
817
|
-
// Recursively parse all the include programs
|
|
818
|
-
vector<t_program*>& includes = program->get_includes();
|
|
819
|
-
vector<t_program*>::iterator iter;
|
|
820
|
-
for (iter = includes.begin(); iter != includes.end(); ++iter) {
|
|
821
|
-
parse(*iter, program);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// Parse the program file
|
|
825
|
-
g_parse_mode = PROGRAM;
|
|
826
|
-
g_program = program;
|
|
827
|
-
g_scope = program->scope();
|
|
828
|
-
g_parent_scope = (parent_program != NULL) ? parent_program->scope() : NULL;
|
|
829
|
-
g_parent_prefix = program->get_name() + ".";
|
|
830
|
-
g_curpath = path;
|
|
831
|
-
yyin = fopen(path.c_str(), "r");
|
|
832
|
-
if (yyin == 0) {
|
|
833
|
-
failure("Could not open input file: \"%s\"", path.c_str());
|
|
834
|
-
}
|
|
835
|
-
pverbose("Parsing %s for types\n", path.c_str());
|
|
836
|
-
yylineno = 1;
|
|
837
|
-
try {
|
|
838
|
-
if (yyparse() != 0) {
|
|
839
|
-
failure("Parser error during types pass.");
|
|
840
|
-
}
|
|
841
|
-
} catch (string x) {
|
|
842
|
-
failure(x.c_str());
|
|
843
|
-
}
|
|
844
|
-
fclose(yyin);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
* Generate code
|
|
849
|
-
*/
|
|
850
|
-
void generate(t_program* program, const vector<string>& generator_strings) {
|
|
851
|
-
// Oooohh, recursive code generation, hot!!
|
|
852
|
-
if (gen_recurse) {
|
|
853
|
-
const vector<t_program*>& includes = program->get_includes();
|
|
854
|
-
for (size_t i = 0; i < includes.size(); ++i) {
|
|
855
|
-
// Propogate output path from parent to child programs
|
|
856
|
-
includes[i]->set_out_path(program->get_out_path());
|
|
857
|
-
|
|
858
|
-
generate(includes[i], generator_strings);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
// Generate code!
|
|
863
|
-
try {
|
|
864
|
-
pverbose("Program: %s\n", program->get_path().c_str());
|
|
865
|
-
|
|
866
|
-
// Compute fingerprints.
|
|
867
|
-
generate_all_fingerprints(program);
|
|
868
|
-
|
|
869
|
-
if (dump_docs) {
|
|
870
|
-
dump_docstrings(program);
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
vector<string>::const_iterator iter;
|
|
874
|
-
for (iter = generator_strings.begin(); iter != generator_strings.end(); ++iter) {
|
|
875
|
-
t_generator* generator = t_generator_registry::get_generator(program, *iter);
|
|
876
|
-
|
|
877
|
-
if (generator == NULL) {
|
|
878
|
-
pwarning(1, "Unable to get a generator for \"%s\".\n", iter->c_str());
|
|
879
|
-
} else {
|
|
880
|
-
pverbose("Generating \"%s\"\n", iter->c_str());
|
|
881
|
-
generator->generate_program();
|
|
882
|
-
delete generator;
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
} catch (string s) {
|
|
887
|
-
printf("Error: %s\n", s.c_str());
|
|
888
|
-
} catch (const char* exc) {
|
|
889
|
-
printf("Error: %s\n", exc);
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* Parse it up.. then spit it back out, in pretty much every language. Alright
|
|
896
|
-
* not that many languages, but the cool ones that we care about.
|
|
897
|
-
*/
|
|
898
|
-
int main(int argc, char** argv) {
|
|
899
|
-
int i;
|
|
900
|
-
std::string out_path;
|
|
901
|
-
|
|
902
|
-
// Setup time string
|
|
903
|
-
time_t now = time(NULL);
|
|
904
|
-
g_time_str = ctime(&now);
|
|
905
|
-
|
|
906
|
-
// Check for necessary arguments, you gotta have at least a filename and
|
|
907
|
-
// an output language flag
|
|
908
|
-
if (argc < 2) {
|
|
909
|
-
usage();
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
vector<string> generator_strings;
|
|
913
|
-
|
|
914
|
-
// Set the current path to a dummy value to make warning messages clearer.
|
|
915
|
-
g_curpath = "arguments";
|
|
916
|
-
|
|
917
|
-
// Hacky parameter handling... I didn't feel like using a library sorry!
|
|
918
|
-
for (i = 1; i < argc-1; i++) {
|
|
919
|
-
char* arg;
|
|
920
|
-
|
|
921
|
-
arg = strtok(argv[i], " ");
|
|
922
|
-
while (arg != NULL) {
|
|
923
|
-
// Treat double dashes as single dashes
|
|
924
|
-
if (arg[0] == '-' && arg[1] == '-') {
|
|
925
|
-
++arg;
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
if (strcmp(arg, "-version") == 0) {
|
|
929
|
-
version();
|
|
930
|
-
exit(1);
|
|
931
|
-
} else if (strcmp(arg, "-debug") == 0) {
|
|
932
|
-
g_debug = 1;
|
|
933
|
-
} else if (strcmp(arg, "-nowarn") == 0) {
|
|
934
|
-
g_warn = 0;
|
|
935
|
-
} else if (strcmp(arg, "-strict") == 0) {
|
|
936
|
-
g_strict = 255;
|
|
937
|
-
g_warn = 2;
|
|
938
|
-
} else if (strcmp(arg, "-v") == 0 || strcmp(arg, "-verbose") == 0 ) {
|
|
939
|
-
g_verbose = 1;
|
|
940
|
-
} else if (strcmp(arg, "-r") == 0 || strcmp(arg, "-recurse") == 0 ) {
|
|
941
|
-
gen_recurse = true;
|
|
942
|
-
} else if (strcmp(arg, "-gen") == 0) {
|
|
943
|
-
arg = argv[++i];
|
|
944
|
-
if (arg == NULL) {
|
|
945
|
-
fprintf(stderr, "!!! Missing generator specification\n");
|
|
946
|
-
usage();
|
|
947
|
-
}
|
|
948
|
-
generator_strings.push_back(arg);
|
|
949
|
-
} else if (strcmp(arg, "-dense") == 0) {
|
|
950
|
-
gen_dense = true;
|
|
951
|
-
} else if (strcmp(arg, "-cpp") == 0) {
|
|
952
|
-
gen_cpp = true;
|
|
953
|
-
} else if (strcmp(arg, "-javabean") == 0) {
|
|
954
|
-
gen_javabean = true;
|
|
955
|
-
} else if (strcmp(arg, "-java") == 0) {
|
|
956
|
-
gen_java = true;
|
|
957
|
-
} else if (strcmp(arg, "-php") == 0) {
|
|
958
|
-
gen_php = true;
|
|
959
|
-
} else if (strcmp(arg, "-phpi") == 0) {
|
|
960
|
-
gen_phpi = true;
|
|
961
|
-
} else if (strcmp(arg, "-phps") == 0) {
|
|
962
|
-
gen_php = true;
|
|
963
|
-
gen_phps = true;
|
|
964
|
-
} else if (strcmp(arg, "-phpl") == 0) {
|
|
965
|
-
gen_php = true;
|
|
966
|
-
gen_phps = false;
|
|
967
|
-
} else if (strcmp(arg, "-phpa") == 0) {
|
|
968
|
-
gen_php = true;
|
|
969
|
-
gen_phps = false;
|
|
970
|
-
gen_phpa = true;
|
|
971
|
-
} else if (strcmp(arg, "-phpo") == 0) {
|
|
972
|
-
gen_php = true;
|
|
973
|
-
gen_phpo = true;
|
|
974
|
-
} else if (strcmp(arg, "-rest") == 0) {
|
|
975
|
-
gen_rest = true;
|
|
976
|
-
} else if (strcmp(arg, "-py") == 0) {
|
|
977
|
-
gen_py = true;
|
|
978
|
-
} else if (strcmp(arg, "-pyns") == 0) {
|
|
979
|
-
gen_py = true;
|
|
980
|
-
gen_py_newstyle = true;
|
|
981
|
-
} else if (strcmp(arg, "-rb") == 0) {
|
|
982
|
-
gen_rb = true;
|
|
983
|
-
} else if (strcmp(arg, "-xsd") == 0) {
|
|
984
|
-
gen_xsd = true;
|
|
985
|
-
} else if (strcmp(arg, "-perl") == 0) {
|
|
986
|
-
gen_perl = true;
|
|
987
|
-
} else if (strcmp(arg, "-erl") == 0) {
|
|
988
|
-
gen_erl = true;
|
|
989
|
-
} else if (strcmp(arg, "-ocaml") == 0) {
|
|
990
|
-
gen_ocaml = true;
|
|
991
|
-
} else if (strcmp(arg, "-hs") == 0) {
|
|
992
|
-
gen_hs = true;
|
|
993
|
-
} else if (strcmp(arg, "-cocoa") == 0) {
|
|
994
|
-
gen_cocoa = true;
|
|
995
|
-
} else if (strcmp(arg, "-st") == 0) {
|
|
996
|
-
gen_st = true;
|
|
997
|
-
} else if (strcmp(arg, "-csharp") == 0) {
|
|
998
|
-
gen_csharp = true;
|
|
999
|
-
} else if (strcmp(arg, "-cpp_use_include_prefix") == 0) {
|
|
1000
|
-
g_cpp_use_include_prefix = true;
|
|
1001
|
-
} else if (strcmp(arg, "-I") == 0) {
|
|
1002
|
-
// An argument of "-I\ asdf" is invalid and has unknown results
|
|
1003
|
-
arg = argv[++i];
|
|
1004
|
-
|
|
1005
|
-
if (arg == NULL) {
|
|
1006
|
-
fprintf(stderr, "!!! Missing Include directory\n");
|
|
1007
|
-
usage();
|
|
1008
|
-
}
|
|
1009
|
-
g_incl_searchpath.push_back(arg);
|
|
1010
|
-
} else if (strcmp(arg, "-o") == 0) {
|
|
1011
|
-
arg = argv[++i];
|
|
1012
|
-
if (arg == NULL) {
|
|
1013
|
-
fprintf(stderr, "-o: missing output directory\n");
|
|
1014
|
-
usage();
|
|
1015
|
-
}
|
|
1016
|
-
out_path = arg;
|
|
1017
|
-
|
|
1018
|
-
#ifdef MINGW
|
|
1019
|
-
//strip out trailing \ on Windows
|
|
1020
|
-
int last = out_path.length()-1;
|
|
1021
|
-
if (out_path[last] == '\\')
|
|
1022
|
-
{
|
|
1023
|
-
out_path.erase(last);
|
|
1024
|
-
}
|
|
1025
|
-
#endif
|
|
1026
|
-
|
|
1027
|
-
struct stat sb;
|
|
1028
|
-
if (stat(out_path.c_str(), &sb) < 0) {
|
|
1029
|
-
fprintf(stderr, "Output directory %s is unusable: %s\n", out_path.c_str(), strerror(errno));
|
|
1030
|
-
return -1;
|
|
1031
|
-
}
|
|
1032
|
-
if (! S_ISDIR(sb.st_mode)) {
|
|
1033
|
-
fprintf(stderr, "Output directory %s exists but is not a directory\n", out_path.c_str());
|
|
1034
|
-
return -1;
|
|
1035
|
-
}
|
|
1036
|
-
} else {
|
|
1037
|
-
fprintf(stderr, "!!! Unrecognized option: %s\n", arg);
|
|
1038
|
-
usage();
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
// Tokenize more
|
|
1042
|
-
arg = strtok(NULL, " ");
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
// if you're asking for version, you have a right not to pass a file
|
|
1047
|
-
if (strcmp(argv[argc-1], "-version") == 0) {
|
|
1048
|
-
version();
|
|
1049
|
-
exit(1);
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
// TODO(dreiss): Delete these when everyone is using the new hotness.
|
|
1053
|
-
if (gen_cpp) {
|
|
1054
|
-
pwarning(1, "-cpp is deprecated. Use --gen cpp");
|
|
1055
|
-
string gen_string = "cpp:";
|
|
1056
|
-
if (gen_dense) {
|
|
1057
|
-
gen_string.append("dense,");
|
|
1058
|
-
}
|
|
1059
|
-
if (g_cpp_use_include_prefix) {
|
|
1060
|
-
gen_string.append("include_prefix,");
|
|
1061
|
-
}
|
|
1062
|
-
generator_strings.push_back(gen_string);
|
|
1063
|
-
}
|
|
1064
|
-
if (gen_java) {
|
|
1065
|
-
pwarning(1, "-java is deprecated. Use --gen java");
|
|
1066
|
-
generator_strings.push_back("java");
|
|
1067
|
-
}
|
|
1068
|
-
if (gen_javabean) {
|
|
1069
|
-
pwarning(1, "-javabean is deprecated. Use --gen java:beans");
|
|
1070
|
-
generator_strings.push_back("java:beans");
|
|
1071
|
-
}
|
|
1072
|
-
if (gen_csharp) {
|
|
1073
|
-
pwarning(1, "-csharp is deprecated. Use --gen csharp");
|
|
1074
|
-
generator_strings.push_back("csharp");
|
|
1075
|
-
}
|
|
1076
|
-
if (gen_py) {
|
|
1077
|
-
pwarning(1, "-py is deprecated. Use --gen py");
|
|
1078
|
-
generator_strings.push_back("py");
|
|
1079
|
-
}
|
|
1080
|
-
if (gen_rb) {
|
|
1081
|
-
pwarning(1, "-rb is deprecated. Use --gen rb");
|
|
1082
|
-
generator_strings.push_back("rb");
|
|
1083
|
-
}
|
|
1084
|
-
if (gen_perl) {
|
|
1085
|
-
pwarning(1, "-perl is deprecated. Use --gen perl");
|
|
1086
|
-
generator_strings.push_back("perl");
|
|
1087
|
-
}
|
|
1088
|
-
if (gen_php || gen_phpi) {
|
|
1089
|
-
pwarning(1, "-php is deprecated. Use --gen php");
|
|
1090
|
-
string gen_string = "php:";
|
|
1091
|
-
if (gen_phpi) {
|
|
1092
|
-
gen_string.append("inlined,");
|
|
1093
|
-
} else if(gen_phps) {
|
|
1094
|
-
gen_string.append("server,");
|
|
1095
|
-
} else if(gen_phpa) {
|
|
1096
|
-
gen_string.append("autoload,");
|
|
1097
|
-
} else if(gen_phpo) {
|
|
1098
|
-
gen_string.append("oop,");
|
|
1099
|
-
} else if(gen_rest) {
|
|
1100
|
-
gen_string.append("rest,");
|
|
1101
|
-
}
|
|
1102
|
-
generator_strings.push_back(gen_string);
|
|
1103
|
-
}
|
|
1104
|
-
if (gen_cocoa) {
|
|
1105
|
-
pwarning(1, "-cocoa is deprecated. Use --gen cocoa");
|
|
1106
|
-
generator_strings.push_back("cocoa");
|
|
1107
|
-
}
|
|
1108
|
-
if (gen_erl) {
|
|
1109
|
-
pwarning(1, "-erl is deprecated. Use --gen erl");
|
|
1110
|
-
generator_strings.push_back("erl");
|
|
1111
|
-
}
|
|
1112
|
-
if (gen_st) {
|
|
1113
|
-
pwarning(1, "-st is deprecated. Use --gen st");
|
|
1114
|
-
generator_strings.push_back("st");
|
|
1115
|
-
}
|
|
1116
|
-
if (gen_ocaml) {
|
|
1117
|
-
pwarning(1, "-ocaml is deprecated. Use --gen ocaml");
|
|
1118
|
-
generator_strings.push_back("ocaml");
|
|
1119
|
-
}
|
|
1120
|
-
if (gen_hs) {
|
|
1121
|
-
pwarning(1, "-hs is deprecated. Use --gen hs");
|
|
1122
|
-
generator_strings.push_back("hs");
|
|
1123
|
-
}
|
|
1124
|
-
if (gen_xsd) {
|
|
1125
|
-
pwarning(1, "-xsd is deprecated. Use --gen xsd");
|
|
1126
|
-
generator_strings.push_back("xsd");
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
// You gotta generate something!
|
|
1130
|
-
if (generator_strings.empty()) {
|
|
1131
|
-
fprintf(stderr, "!!! No output language(s) specified\n\n");
|
|
1132
|
-
usage();
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
// Real-pathify it
|
|
1136
|
-
char rp[PATH_MAX];
|
|
1137
|
-
if (argv[i] == NULL) {
|
|
1138
|
-
fprintf(stderr, "!!! Missing file name\n");
|
|
1139
|
-
usage();
|
|
1140
|
-
}
|
|
1141
|
-
if (saferealpath(argv[i], rp) == NULL) {
|
|
1142
|
-
failure("Could not open input file with realpath: %s", argv[i]);
|
|
1143
|
-
}
|
|
1144
|
-
string input_file(rp);
|
|
1145
|
-
|
|
1146
|
-
// Instance of the global parse tree
|
|
1147
|
-
t_program* program = new t_program(input_file);
|
|
1148
|
-
if (out_path.size()) {
|
|
1149
|
-
program->set_out_path(out_path);
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
// Compute the cpp include prefix.
|
|
1153
|
-
// infer this from the filename passed in
|
|
1154
|
-
string input_filename = argv[i];
|
|
1155
|
-
string include_prefix;
|
|
1156
|
-
|
|
1157
|
-
string::size_type last_slash = string::npos;
|
|
1158
|
-
if ((last_slash = input_filename.rfind("/")) != string::npos) {
|
|
1159
|
-
include_prefix = input_filename.substr(0, last_slash);
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
program->set_include_prefix(include_prefix);
|
|
1163
|
-
|
|
1164
|
-
// Initialize global types
|
|
1165
|
-
g_type_void = new t_base_type("void", t_base_type::TYPE_VOID);
|
|
1166
|
-
g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);
|
|
1167
|
-
g_type_binary = new t_base_type("string", t_base_type::TYPE_STRING);
|
|
1168
|
-
((t_base_type*)g_type_binary)->set_binary(true);
|
|
1169
|
-
g_type_slist = new t_base_type("string", t_base_type::TYPE_STRING);
|
|
1170
|
-
((t_base_type*)g_type_slist)->set_string_list(true);
|
|
1171
|
-
g_type_bool = new t_base_type("bool", t_base_type::TYPE_BOOL);
|
|
1172
|
-
g_type_byte = new t_base_type("byte", t_base_type::TYPE_BYTE);
|
|
1173
|
-
g_type_i16 = new t_base_type("i16", t_base_type::TYPE_I16);
|
|
1174
|
-
g_type_i32 = new t_base_type("i32", t_base_type::TYPE_I32);
|
|
1175
|
-
g_type_i64 = new t_base_type("i64", t_base_type::TYPE_I64);
|
|
1176
|
-
g_type_double = new t_base_type("double", t_base_type::TYPE_DOUBLE);
|
|
1177
|
-
|
|
1178
|
-
// Parse it!
|
|
1179
|
-
parse(program, NULL);
|
|
1180
|
-
|
|
1181
|
-
// The current path is not really relevant when we are doing generation.
|
|
1182
|
-
// Reset the variable to make warning messages clearer.
|
|
1183
|
-
g_curpath = "generation";
|
|
1184
|
-
// Reset yylineno for the heck of it. Use 1 instead of 0 because
|
|
1185
|
-
// That is what shows up during argument parsing.
|
|
1186
|
-
yylineno = 1;
|
|
1187
|
-
|
|
1188
|
-
// Generate it!
|
|
1189
|
-
generate(program, generator_strings);
|
|
1190
|
-
|
|
1191
|
-
// Clean up. Who am I kidding... this program probably orphans heap memory
|
|
1192
|
-
// all over the place, but who cares because it is about to exit and it is
|
|
1193
|
-
// all referenced and used by this wacky parse tree up until now anyways.
|
|
1194
|
-
|
|
1195
|
-
delete program;
|
|
1196
|
-
delete g_type_void;
|
|
1197
|
-
delete g_type_string;
|
|
1198
|
-
delete g_type_bool;
|
|
1199
|
-
delete g_type_byte;
|
|
1200
|
-
delete g_type_i16;
|
|
1201
|
-
delete g_type_i32;
|
|
1202
|
-
delete g_type_i64;
|
|
1203
|
-
delete g_type_double;
|
|
1204
|
-
|
|
1205
|
-
// Finished
|
|
1206
|
-
return 0;
|
|
1207
|
-
}
|