planetscale 0.3.1 → 0.3.3

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.
Files changed (368) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +9 -1
  3. data/.github/workflows/gem-push.yml +9 -2
  4. data/.licenses/go/github.com/matoous/go-nanoid/v2.dep.yml +34 -0
  5. data/.licenses/go/github.com/planetscale/planetscale-go/planetscale.dep.yml +1 -1
  6. data/.licenses/go/github.com/planetscale/sql-proxy/proxy.dep.yml +1 -1
  7. data/.licenses/go/go.uber.org/zap/buffer.dep.yml +1 -1
  8. data/.licenses/go/go.uber.org/zap/internal/bufferpool.dep.yml +1 -1
  9. data/.licenses/go/go.uber.org/zap/internal/color.dep.yml +1 -1
  10. data/.licenses/go/go.uber.org/zap/internal/exit.dep.yml +1 -1
  11. data/.licenses/go/go.uber.org/zap/zapcore.dep.yml +1 -1
  12. data/.licenses/go/go.uber.org/zap.dep.yml +1 -1
  13. data/README.md +2 -0
  14. data/controller.go +21 -36
  15. data/go.mod +4 -3
  16. data/go.sum +32 -18
  17. data/lib/planetscale/version.rb +1 -1
  18. data/lib/planetscale.rb +2 -3
  19. data/planetscale.gemspec +1 -1
  20. data/proxy/planetscale-darwin.h +1 -1
  21. data/proxy/planetscale-darwin.so +0 -0
  22. data/proxy/planetscale-linux.h +1 -1
  23. data/proxy/planetscale-linux.so +0 -0
  24. data/proxy.go +1 -5
  25. metadata +3 -345
  26. data/vendor/github.com/armon/circbuf/.gitignore +0 -22
  27. data/vendor/github.com/armon/circbuf/LICENSE +0 -20
  28. data/vendor/github.com/armon/circbuf/README.md +0 -28
  29. data/vendor/github.com/armon/circbuf/circbuf.go +0 -92
  30. data/vendor/github.com/armon/circbuf/go.mod +0 -1
  31. data/vendor/github.com/golang/protobuf/AUTHORS +0 -3
  32. data/vendor/github.com/golang/protobuf/CONTRIBUTORS +0 -3
  33. data/vendor/github.com/golang/protobuf/LICENSE +0 -28
  34. data/vendor/github.com/golang/protobuf/proto/buffer.go +0 -324
  35. data/vendor/github.com/golang/protobuf/proto/defaults.go +0 -63
  36. data/vendor/github.com/golang/protobuf/proto/deprecated.go +0 -113
  37. data/vendor/github.com/golang/protobuf/proto/discard.go +0 -58
  38. data/vendor/github.com/golang/protobuf/proto/extensions.go +0 -356
  39. data/vendor/github.com/golang/protobuf/proto/properties.go +0 -306
  40. data/vendor/github.com/golang/protobuf/proto/proto.go +0 -167
  41. data/vendor/github.com/golang/protobuf/proto/registry.go +0 -317
  42. data/vendor/github.com/golang/protobuf/proto/text_decode.go +0 -801
  43. data/vendor/github.com/golang/protobuf/proto/text_encode.go +0 -560
  44. data/vendor/github.com/golang/protobuf/proto/wire.go +0 -78
  45. data/vendor/github.com/golang/protobuf/proto/wrappers.go +0 -34
  46. data/vendor/github.com/gorilla/mux/AUTHORS +0 -8
  47. data/vendor/github.com/gorilla/mux/LICENSE +0 -27
  48. data/vendor/github.com/gorilla/mux/README.md +0 -805
  49. data/vendor/github.com/gorilla/mux/doc.go +0 -306
  50. data/vendor/github.com/gorilla/mux/go.mod +0 -3
  51. data/vendor/github.com/gorilla/mux/middleware.go +0 -74
  52. data/vendor/github.com/gorilla/mux/mux.go +0 -606
  53. data/vendor/github.com/gorilla/mux/regexp.go +0 -388
  54. data/vendor/github.com/gorilla/mux/route.go +0 -736
  55. data/vendor/github.com/gorilla/mux/test_helpers.go +0 -19
  56. data/vendor/github.com/hashicorp/go-cleanhttp/LICENSE +0 -363
  57. data/vendor/github.com/hashicorp/go-cleanhttp/README.md +0 -30
  58. data/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +0 -58
  59. data/vendor/github.com/hashicorp/go-cleanhttp/doc.go +0 -20
  60. data/vendor/github.com/hashicorp/go-cleanhttp/go.mod +0 -3
  61. data/vendor/github.com/hashicorp/go-cleanhttp/handlers.go +0 -48
  62. data/vendor/github.com/mitchellh/go-homedir/LICENSE +0 -21
  63. data/vendor/github.com/mitchellh/go-homedir/README.md +0 -14
  64. data/vendor/github.com/mitchellh/go-homedir/go.mod +0 -1
  65. data/vendor/github.com/mitchellh/go-homedir/homedir.go +0 -167
  66. data/vendor/github.com/pkg/errors/.gitignore +0 -24
  67. data/vendor/github.com/pkg/errors/.travis.yml +0 -10
  68. data/vendor/github.com/pkg/errors/LICENSE +0 -23
  69. data/vendor/github.com/pkg/errors/Makefile +0 -44
  70. data/vendor/github.com/pkg/errors/README.md +0 -59
  71. data/vendor/github.com/pkg/errors/appveyor.yml +0 -32
  72. data/vendor/github.com/pkg/errors/errors.go +0 -288
  73. data/vendor/github.com/pkg/errors/go113.go +0 -38
  74. data/vendor/github.com/pkg/errors/stack.go +0 -177
  75. data/vendor/github.com/planetscale/planetscale-go/LICENSE +0 -202
  76. data/vendor/github.com/planetscale/planetscale-go/planetscale/audit_logs.go +0 -136
  77. data/vendor/github.com/planetscale/planetscale-go/planetscale/backups.go +0 -139
  78. data/vendor/github.com/planetscale/planetscale-go/planetscale/branches.go +0 -252
  79. data/vendor/github.com/planetscale/planetscale-go/planetscale/certs.go +0 -166
  80. data/vendor/github.com/planetscale/planetscale-go/planetscale/client.go +0 -312
  81. data/vendor/github.com/planetscale/planetscale-go/planetscale/databases.go +0 -133
  82. data/vendor/github.com/planetscale/planetscale-go/planetscale/deploy_requests.go +0 -368
  83. data/vendor/github.com/planetscale/planetscale-go/planetscale/organizations.go +0 -103
  84. data/vendor/github.com/planetscale/planetscale-go/planetscale/regions.go +0 -52
  85. data/vendor/github.com/planetscale/planetscale-go/planetscale/service_tokens.go +0 -163
  86. data/vendor/github.com/planetscale/sql-proxy/LICENSE +0 -202
  87. data/vendor/github.com/planetscale/sql-proxy/proxy/client.go +0 -476
  88. data/vendor/github.com/planetscale/sql-proxy/proxy/tls_cache.go +0 -73
  89. data/vendor/go.uber.org/atomic/.codecov.yml +0 -19
  90. data/vendor/go.uber.org/atomic/.gitignore +0 -12
  91. data/vendor/go.uber.org/atomic/.travis.yml +0 -27
  92. data/vendor/go.uber.org/atomic/CHANGELOG.md +0 -76
  93. data/vendor/go.uber.org/atomic/LICENSE.txt +0 -19
  94. data/vendor/go.uber.org/atomic/Makefile +0 -78
  95. data/vendor/go.uber.org/atomic/README.md +0 -63
  96. data/vendor/go.uber.org/atomic/bool.go +0 -81
  97. data/vendor/go.uber.org/atomic/bool_ext.go +0 -53
  98. data/vendor/go.uber.org/atomic/doc.go +0 -23
  99. data/vendor/go.uber.org/atomic/duration.go +0 -82
  100. data/vendor/go.uber.org/atomic/duration_ext.go +0 -40
  101. data/vendor/go.uber.org/atomic/error.go +0 -51
  102. data/vendor/go.uber.org/atomic/error_ext.go +0 -39
  103. data/vendor/go.uber.org/atomic/float64.go +0 -76
  104. data/vendor/go.uber.org/atomic/float64_ext.go +0 -47
  105. data/vendor/go.uber.org/atomic/gen.go +0 -26
  106. data/vendor/go.uber.org/atomic/go.mod +0 -8
  107. data/vendor/go.uber.org/atomic/go.sum +0 -9
  108. data/vendor/go.uber.org/atomic/int32.go +0 -102
  109. data/vendor/go.uber.org/atomic/int64.go +0 -102
  110. data/vendor/go.uber.org/atomic/nocmp.go +0 -35
  111. data/vendor/go.uber.org/atomic/string.go +0 -54
  112. data/vendor/go.uber.org/atomic/string_ext.go +0 -43
  113. data/vendor/go.uber.org/atomic/uint32.go +0 -102
  114. data/vendor/go.uber.org/atomic/uint64.go +0 -102
  115. data/vendor/go.uber.org/atomic/value.go +0 -31
  116. data/vendor/go.uber.org/multierr/.codecov.yml +0 -15
  117. data/vendor/go.uber.org/multierr/.gitignore +0 -4
  118. data/vendor/go.uber.org/multierr/.travis.yml +0 -23
  119. data/vendor/go.uber.org/multierr/CHANGELOG.md +0 -60
  120. data/vendor/go.uber.org/multierr/LICENSE.txt +0 -19
  121. data/vendor/go.uber.org/multierr/Makefile +0 -42
  122. data/vendor/go.uber.org/multierr/README.md +0 -23
  123. data/vendor/go.uber.org/multierr/error.go +0 -449
  124. data/vendor/go.uber.org/multierr/glide.yaml +0 -8
  125. data/vendor/go.uber.org/multierr/go.mod +0 -8
  126. data/vendor/go.uber.org/multierr/go.sum +0 -11
  127. data/vendor/go.uber.org/multierr/go113.go +0 -52
  128. data/vendor/go.uber.org/zap/.codecov.yml +0 -17
  129. data/vendor/go.uber.org/zap/.gitignore +0 -32
  130. data/vendor/go.uber.org/zap/.readme.tmpl +0 -109
  131. data/vendor/go.uber.org/zap/CHANGELOG.md +0 -492
  132. data/vendor/go.uber.org/zap/CODE_OF_CONDUCT.md +0 -75
  133. data/vendor/go.uber.org/zap/CONTRIBUTING.md +0 -75
  134. data/vendor/go.uber.org/zap/FAQ.md +0 -164
  135. data/vendor/go.uber.org/zap/LICENSE.txt +0 -19
  136. data/vendor/go.uber.org/zap/Makefile +0 -73
  137. data/vendor/go.uber.org/zap/README.md +0 -134
  138. data/vendor/go.uber.org/zap/array.go +0 -320
  139. data/vendor/go.uber.org/zap/buffer/buffer.go +0 -141
  140. data/vendor/go.uber.org/zap/buffer/pool.go +0 -49
  141. data/vendor/go.uber.org/zap/checklicense.sh +0 -17
  142. data/vendor/go.uber.org/zap/config.go +0 -264
  143. data/vendor/go.uber.org/zap/doc.go +0 -113
  144. data/vendor/go.uber.org/zap/encoder.go +0 -79
  145. data/vendor/go.uber.org/zap/error.go +0 -80
  146. data/vendor/go.uber.org/zap/field.go +0 -549
  147. data/vendor/go.uber.org/zap/flag.go +0 -39
  148. data/vendor/go.uber.org/zap/glide.yaml +0 -34
  149. data/vendor/go.uber.org/zap/global.go +0 -168
  150. data/vendor/go.uber.org/zap/global_go112.go +0 -26
  151. data/vendor/go.uber.org/zap/global_prego112.go +0 -26
  152. data/vendor/go.uber.org/zap/go.mod +0 -14
  153. data/vendor/go.uber.org/zap/go.sum +0 -54
  154. data/vendor/go.uber.org/zap/http_handler.go +0 -132
  155. data/vendor/go.uber.org/zap/internal/bufferpool/bufferpool.go +0 -31
  156. data/vendor/go.uber.org/zap/internal/color/color.go +0 -44
  157. data/vendor/go.uber.org/zap/internal/exit/exit.go +0 -64
  158. data/vendor/go.uber.org/zap/level.go +0 -132
  159. data/vendor/go.uber.org/zap/logger.go +0 -348
  160. data/vendor/go.uber.org/zap/options.go +0 -148
  161. data/vendor/go.uber.org/zap/sink.go +0 -161
  162. data/vendor/go.uber.org/zap/stacktrace.go +0 -85
  163. data/vendor/go.uber.org/zap/sugar.go +0 -315
  164. data/vendor/go.uber.org/zap/time.go +0 -27
  165. data/vendor/go.uber.org/zap/writer.go +0 -99
  166. data/vendor/go.uber.org/zap/zapcore/buffered_write_syncer.go +0 -188
  167. data/vendor/go.uber.org/zap/zapcore/clock.go +0 -50
  168. data/vendor/go.uber.org/zap/zapcore/console_encoder.go +0 -161
  169. data/vendor/go.uber.org/zap/zapcore/core.go +0 -113
  170. data/vendor/go.uber.org/zap/zapcore/doc.go +0 -24
  171. data/vendor/go.uber.org/zap/zapcore/encoder.go +0 -443
  172. data/vendor/go.uber.org/zap/zapcore/entry.go +0 -264
  173. data/vendor/go.uber.org/zap/zapcore/error.go +0 -132
  174. data/vendor/go.uber.org/zap/zapcore/field.go +0 -233
  175. data/vendor/go.uber.org/zap/zapcore/hook.go +0 -68
  176. data/vendor/go.uber.org/zap/zapcore/increase_level.go +0 -66
  177. data/vendor/go.uber.org/zap/zapcore/json_encoder.go +0 -534
  178. data/vendor/go.uber.org/zap/zapcore/level.go +0 -175
  179. data/vendor/go.uber.org/zap/zapcore/level_strings.go +0 -46
  180. data/vendor/go.uber.org/zap/zapcore/marshaler.go +0 -61
  181. data/vendor/go.uber.org/zap/zapcore/memory_encoder.go +0 -179
  182. data/vendor/go.uber.org/zap/zapcore/sampler.go +0 -208
  183. data/vendor/go.uber.org/zap/zapcore/tee.go +0 -81
  184. data/vendor/go.uber.org/zap/zapcore/write_syncer.go +0 -122
  185. data/vendor/golang.org/x/net/AUTHORS +0 -3
  186. data/vendor/golang.org/x/net/CONTRIBUTORS +0 -3
  187. data/vendor/golang.org/x/net/LICENSE +0 -27
  188. data/vendor/golang.org/x/net/PATENTS +0 -22
  189. data/vendor/golang.org/x/net/context/context.go +0 -56
  190. data/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +0 -71
  191. data/vendor/golang.org/x/net/context/go17.go +0 -73
  192. data/vendor/golang.org/x/net/context/go19.go +0 -21
  193. data/vendor/golang.org/x/net/context/pre_go17.go +0 -301
  194. data/vendor/golang.org/x/net/context/pre_go19.go +0 -110
  195. data/vendor/golang.org/x/oauth2/.travis.yml +0 -13
  196. data/vendor/golang.org/x/oauth2/AUTHORS +0 -3
  197. data/vendor/golang.org/x/oauth2/CONTRIBUTING.md +0 -26
  198. data/vendor/golang.org/x/oauth2/CONTRIBUTORS +0 -3
  199. data/vendor/golang.org/x/oauth2/LICENSE +0 -27
  200. data/vendor/golang.org/x/oauth2/README.md +0 -36
  201. data/vendor/golang.org/x/oauth2/go.mod +0 -9
  202. data/vendor/golang.org/x/oauth2/go.sum +0 -361
  203. data/vendor/golang.org/x/oauth2/internal/client_appengine.go +0 -14
  204. data/vendor/golang.org/x/oauth2/internal/doc.go +0 -6
  205. data/vendor/golang.org/x/oauth2/internal/oauth2.go +0 -37
  206. data/vendor/golang.org/x/oauth2/internal/token.go +0 -294
  207. data/vendor/golang.org/x/oauth2/internal/transport.go +0 -33
  208. data/vendor/golang.org/x/oauth2/oauth2.go +0 -381
  209. data/vendor/golang.org/x/oauth2/token.go +0 -178
  210. data/vendor/golang.org/x/oauth2/transport.go +0 -89
  211. data/vendor/google.golang.org/appengine/LICENSE +0 -202
  212. data/vendor/google.golang.org/appengine/internal/api.go +0 -678
  213. data/vendor/google.golang.org/appengine/internal/api_classic.go +0 -169
  214. data/vendor/google.golang.org/appengine/internal/api_common.go +0 -123
  215. data/vendor/google.golang.org/appengine/internal/app_id.go +0 -28
  216. data/vendor/google.golang.org/appengine/internal/base/api_base.pb.go +0 -308
  217. data/vendor/google.golang.org/appengine/internal/base/api_base.proto +0 -33
  218. data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go +0 -4367
  219. data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto +0 -551
  220. data/vendor/google.golang.org/appengine/internal/identity.go +0 -55
  221. data/vendor/google.golang.org/appengine/internal/identity_classic.go +0 -61
  222. data/vendor/google.golang.org/appengine/internal/identity_flex.go +0 -11
  223. data/vendor/google.golang.org/appengine/internal/identity_vm.go +0 -134
  224. data/vendor/google.golang.org/appengine/internal/internal.go +0 -110
  225. data/vendor/google.golang.org/appengine/internal/log/log_service.pb.go +0 -1313
  226. data/vendor/google.golang.org/appengine/internal/log/log_service.proto +0 -150
  227. data/vendor/google.golang.org/appengine/internal/main.go +0 -16
  228. data/vendor/google.golang.org/appengine/internal/main_common.go +0 -7
  229. data/vendor/google.golang.org/appengine/internal/main_vm.go +0 -69
  230. data/vendor/google.golang.org/appengine/internal/metadata.go +0 -60
  231. data/vendor/google.golang.org/appengine/internal/net.go +0 -56
  232. data/vendor/google.golang.org/appengine/internal/regen.sh +0 -40
  233. data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go +0 -361
  234. data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto +0 -44
  235. data/vendor/google.golang.org/appengine/internal/transaction.go +0 -115
  236. data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.pb.go +0 -527
  237. data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +0 -64
  238. data/vendor/google.golang.org/appengine/urlfetch/urlfetch.go +0 -210
  239. data/vendor/google.golang.org/protobuf/AUTHORS +0 -3
  240. data/vendor/google.golang.org/protobuf/CONTRIBUTORS +0 -3
  241. data/vendor/google.golang.org/protobuf/LICENSE +0 -27
  242. data/vendor/google.golang.org/protobuf/PATENTS +0 -22
  243. data/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +0 -773
  244. data/vendor/google.golang.org/protobuf/encoding/prototext/doc.go +0 -7
  245. data/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +0 -371
  246. data/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +0 -538
  247. data/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +0 -318
  248. data/vendor/google.golang.org/protobuf/internal/descopts/options.go +0 -29
  249. data/vendor/google.golang.org/protobuf/internal/detrand/rand.go +0 -69
  250. data/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +0 -213
  251. data/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go +0 -241
  252. data/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go +0 -207
  253. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go +0 -665
  254. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go +0 -190
  255. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_string.go +0 -161
  256. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_token.go +0 -373
  257. data/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go +0 -29
  258. data/vendor/google.golang.org/protobuf/internal/encoding/text/encode.go +0 -265
  259. data/vendor/google.golang.org/protobuf/internal/errors/errors.go +0 -89
  260. data/vendor/google.golang.org/protobuf/internal/errors/is_go112.go +0 -39
  261. data/vendor/google.golang.org/protobuf/internal/errors/is_go113.go +0 -12
  262. data/vendor/google.golang.org/protobuf/internal/filedesc/build.go +0 -158
  263. data/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +0 -631
  264. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +0 -471
  265. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +0 -704
  266. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go +0 -450
  267. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +0 -356
  268. data/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go +0 -107
  269. data/vendor/google.golang.org/protobuf/internal/filetype/build.go +0 -297
  270. data/vendor/google.golang.org/protobuf/internal/flags/flags.go +0 -24
  271. data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go +0 -9
  272. data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go +0 -9
  273. data/vendor/google.golang.org/protobuf/internal/genid/any_gen.go +0 -34
  274. data/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +0 -106
  275. data/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +0 -829
  276. data/vendor/google.golang.org/protobuf/internal/genid/doc.go +0 -11
  277. data/vendor/google.golang.org/protobuf/internal/genid/duration_gen.go +0 -34
  278. data/vendor/google.golang.org/protobuf/internal/genid/empty_gen.go +0 -19
  279. data/vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go +0 -31
  280. data/vendor/google.golang.org/protobuf/internal/genid/goname.go +0 -25
  281. data/vendor/google.golang.org/protobuf/internal/genid/map_entry.go +0 -16
  282. data/vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go +0 -31
  283. data/vendor/google.golang.org/protobuf/internal/genid/struct_gen.go +0 -116
  284. data/vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go +0 -34
  285. data/vendor/google.golang.org/protobuf/internal/genid/type_gen.go +0 -184
  286. data/vendor/google.golang.org/protobuf/internal/genid/wrappers.go +0 -13
  287. data/vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go +0 -175
  288. data/vendor/google.golang.org/protobuf/internal/impl/api_export.go +0 -177
  289. data/vendor/google.golang.org/protobuf/internal/impl/checkinit.go +0 -141
  290. data/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go +0 -223
  291. data/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +0 -830
  292. data/vendor/google.golang.org/protobuf/internal/impl/codec_gen.go +0 -5637
  293. data/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +0 -388
  294. data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go +0 -37
  295. data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go +0 -11
  296. data/vendor/google.golang.org/protobuf/internal/impl/codec_message.go +0 -217
  297. data/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go +0 -123
  298. data/vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go +0 -209
  299. data/vendor/google.golang.org/protobuf/internal/impl/codec_tables.go +0 -557
  300. data/vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go +0 -17
  301. data/vendor/google.golang.org/protobuf/internal/impl/convert.go +0 -496
  302. data/vendor/google.golang.org/protobuf/internal/impl/convert_list.go +0 -141
  303. data/vendor/google.golang.org/protobuf/internal/impl/convert_map.go +0 -121
  304. data/vendor/google.golang.org/protobuf/internal/impl/decode.go +0 -276
  305. data/vendor/google.golang.org/protobuf/internal/impl/encode.go +0 -201
  306. data/vendor/google.golang.org/protobuf/internal/impl/enum.go +0 -21
  307. data/vendor/google.golang.org/protobuf/internal/impl/extension.go +0 -156
  308. data/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go +0 -219
  309. data/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go +0 -92
  310. data/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go +0 -176
  311. data/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +0 -81
  312. data/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go +0 -558
  313. data/vendor/google.golang.org/protobuf/internal/impl/merge.go +0 -176
  314. data/vendor/google.golang.org/protobuf/internal/impl/merge_gen.go +0 -209
  315. data/vendor/google.golang.org/protobuf/internal/impl/message.go +0 -276
  316. data/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go +0 -465
  317. data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go +0 -543
  318. data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go +0 -249
  319. data/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go +0 -178
  320. data/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go +0 -174
  321. data/vendor/google.golang.org/protobuf/internal/impl/validate.go +0 -576
  322. data/vendor/google.golang.org/protobuf/internal/impl/weak.go +0 -74
  323. data/vendor/google.golang.org/protobuf/internal/order/order.go +0 -89
  324. data/vendor/google.golang.org/protobuf/internal/order/range.go +0 -115
  325. data/vendor/google.golang.org/protobuf/internal/pragma/pragma.go +0 -29
  326. data/vendor/google.golang.org/protobuf/internal/set/ints.go +0 -58
  327. data/vendor/google.golang.org/protobuf/internal/strs/strings.go +0 -196
  328. data/vendor/google.golang.org/protobuf/internal/strs/strings_pure.go +0 -27
  329. data/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe.go +0 -94
  330. data/vendor/google.golang.org/protobuf/internal/version/version.go +0 -79
  331. data/vendor/google.golang.org/protobuf/proto/checkinit.go +0 -71
  332. data/vendor/google.golang.org/protobuf/proto/decode.go +0 -278
  333. data/vendor/google.golang.org/protobuf/proto/decode_gen.go +0 -603
  334. data/vendor/google.golang.org/protobuf/proto/doc.go +0 -94
  335. data/vendor/google.golang.org/protobuf/proto/encode.go +0 -319
  336. data/vendor/google.golang.org/protobuf/proto/encode_gen.go +0 -97
  337. data/vendor/google.golang.org/protobuf/proto/equal.go +0 -167
  338. data/vendor/google.golang.org/protobuf/proto/extension.go +0 -92
  339. data/vendor/google.golang.org/protobuf/proto/merge.go +0 -139
  340. data/vendor/google.golang.org/protobuf/proto/messageset.go +0 -93
  341. data/vendor/google.golang.org/protobuf/proto/proto.go +0 -43
  342. data/vendor/google.golang.org/protobuf/proto/proto_methods.go +0 -19
  343. data/vendor/google.golang.org/protobuf/proto/proto_reflect.go +0 -19
  344. data/vendor/google.golang.org/protobuf/proto/reset.go +0 -43
  345. data/vendor/google.golang.org/protobuf/proto/size.go +0 -97
  346. data/vendor/google.golang.org/protobuf/proto/size_gen.go +0 -55
  347. data/vendor/google.golang.org/protobuf/proto/wrappers.go +0 -29
  348. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go +0 -276
  349. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +0 -248
  350. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go +0 -286
  351. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go +0 -374
  352. data/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go +0 -252
  353. data/vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go +0 -77
  354. data/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go +0 -504
  355. data/vendor/google.golang.org/protobuf/reflect/protoreflect/source.go +0 -128
  356. data/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +0 -461
  357. data/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go +0 -665
  358. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go +0 -285
  359. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go +0 -59
  360. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +0 -411
  361. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe.go +0 -98
  362. data/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +0 -869
  363. data/vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go +0 -15
  364. data/vendor/google.golang.org/protobuf/runtime/protoiface/methods.go +0 -167
  365. data/vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go +0 -44
  366. data/vendor/google.golang.org/protobuf/runtime/protoimpl/version.go +0 -56
  367. data/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +0 -4039
  368. data/vendor/modules.txt +0 -79
@@ -1,190 +0,0 @@
1
- // Copyright 2018 The Go Authors. All rights reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- package text
6
-
7
- // parseNumberValue parses a number from the input and returns a Token object.
8
- func (d *Decoder) parseNumberValue() (Token, bool) {
9
- in := d.in
10
- num := parseNumber(in)
11
- if num.size == 0 {
12
- return Token{}, false
13
- }
14
- numAttrs := num.kind
15
- if num.neg {
16
- numAttrs |= isNegative
17
- }
18
- strSize := num.size
19
- last := num.size - 1
20
- if num.kind == numFloat && (d.in[last] == 'f' || d.in[last] == 'F') {
21
- strSize = last
22
- }
23
- tok := Token{
24
- kind: Scalar,
25
- attrs: numberValue,
26
- pos: len(d.orig) - len(d.in),
27
- raw: d.in[:num.size],
28
- str: string(d.in[:strSize]),
29
- numAttrs: numAttrs,
30
- }
31
- d.consume(num.size)
32
- return tok, true
33
- }
34
-
35
- const (
36
- numDec uint8 = (1 << iota) / 2
37
- numHex
38
- numOct
39
- numFloat
40
- )
41
-
42
- // number is the result of parsing out a valid number from parseNumber. It
43
- // contains data for doing float or integer conversion via the strconv package
44
- // in conjunction with the input bytes.
45
- type number struct {
46
- kind uint8
47
- neg bool
48
- size int
49
- }
50
-
51
- // parseNumber constructs a number object from given input. It allows for the
52
- // following patterns:
53
- // integer: ^-?([1-9][0-9]*|0[xX][0-9a-fA-F]+|0[0-7]*)
54
- // float: ^-?((0|[1-9][0-9]*)?([.][0-9]*)?([eE][+-]?[0-9]+)?[fF]?)
55
- // It also returns the number of parsed bytes for the given number, 0 if it is
56
- // not a number.
57
- func parseNumber(input []byte) number {
58
- kind := numDec
59
- var size int
60
- var neg bool
61
-
62
- s := input
63
- if len(s) == 0 {
64
- return number{}
65
- }
66
-
67
- // Optional -
68
- if s[0] == '-' {
69
- neg = true
70
- s = s[1:]
71
- size++
72
- if len(s) == 0 {
73
- return number{}
74
- }
75
- }
76
-
77
- // C++ allows for whitespace and comments in between the negative sign and
78
- // the rest of the number. This logic currently does not but is consistent
79
- // with v1.
80
-
81
- switch {
82
- case s[0] == '0':
83
- if len(s) > 1 {
84
- switch {
85
- case s[1] == 'x' || s[1] == 'X':
86
- // Parse as hex number.
87
- kind = numHex
88
- n := 2
89
- s = s[2:]
90
- for len(s) > 0 && (('0' <= s[0] && s[0] <= '9') ||
91
- ('a' <= s[0] && s[0] <= 'f') ||
92
- ('A' <= s[0] && s[0] <= 'F')) {
93
- s = s[1:]
94
- n++
95
- }
96
- if n == 2 {
97
- return number{}
98
- }
99
- size += n
100
-
101
- case '0' <= s[1] && s[1] <= '7':
102
- // Parse as octal number.
103
- kind = numOct
104
- n := 2
105
- s = s[2:]
106
- for len(s) > 0 && '0' <= s[0] && s[0] <= '7' {
107
- s = s[1:]
108
- n++
109
- }
110
- size += n
111
- }
112
-
113
- if kind&(numHex|numOct) > 0 {
114
- if len(s) > 0 && !isDelim(s[0]) {
115
- return number{}
116
- }
117
- return number{kind: kind, neg: neg, size: size}
118
- }
119
- }
120
- s = s[1:]
121
- size++
122
-
123
- case '1' <= s[0] && s[0] <= '9':
124
- n := 1
125
- s = s[1:]
126
- for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
127
- s = s[1:]
128
- n++
129
- }
130
- size += n
131
-
132
- case s[0] == '.':
133
- // Set kind to numFloat to signify the intent to parse as float. And
134
- // that it needs to have other digits after '.'.
135
- kind = numFloat
136
-
137
- default:
138
- return number{}
139
- }
140
-
141
- // . followed by 0 or more digits.
142
- if len(s) > 0 && s[0] == '.' {
143
- n := 1
144
- s = s[1:]
145
- // If decimal point was before any digits, it should be followed by
146
- // other digits.
147
- if len(s) == 0 && kind == numFloat {
148
- return number{}
149
- }
150
- for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
151
- s = s[1:]
152
- n++
153
- }
154
- size += n
155
- kind = numFloat
156
- }
157
-
158
- // e or E followed by an optional - or + and 1 or more digits.
159
- if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') {
160
- kind = numFloat
161
- s = s[1:]
162
- n := 1
163
- if s[0] == '+' || s[0] == '-' {
164
- s = s[1:]
165
- n++
166
- if len(s) == 0 {
167
- return number{}
168
- }
169
- }
170
- for len(s) > 0 && '0' <= s[0] && s[0] <= '9' {
171
- s = s[1:]
172
- n++
173
- }
174
- size += n
175
- }
176
-
177
- // Optional suffix f or F for floats.
178
- if len(s) > 0 && (s[0] == 'f' || s[0] == 'F') {
179
- kind = numFloat
180
- s = s[1:]
181
- size++
182
- }
183
-
184
- // Check that next byte is a delimiter or it is at the end.
185
- if len(s) > 0 && !isDelim(s[0]) {
186
- return number{}
187
- }
188
-
189
- return number{kind: kind, neg: neg, size: size}
190
- }
@@ -1,161 +0,0 @@
1
- // Copyright 2018 The Go Authors. All rights reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- package text
6
-
7
- import (
8
- "bytes"
9
- "strconv"
10
- "strings"
11
- "unicode"
12
- "unicode/utf16"
13
- "unicode/utf8"
14
-
15
- "google.golang.org/protobuf/internal/strs"
16
- )
17
-
18
- // parseStringValue parses string field token.
19
- // This differs from parseString since the text format allows
20
- // multiple back-to-back string literals where they are semantically treated
21
- // as a single large string with all values concatenated.
22
- //
23
- // E.g., `"foo" "bar" "baz"` => "foobarbaz"
24
- func (d *Decoder) parseStringValue() (Token, error) {
25
- // Note that the ending quote is sufficient to unambiguously mark the end
26
- // of a string. Thus, the text grammar does not require intervening
27
- // whitespace or control characters in-between strings.
28
- // Thus, the following is valid:
29
- // `"foo"'bar'"baz"` => "foobarbaz"
30
- in0 := d.in
31
- var ss []string
32
- for len(d.in) > 0 && (d.in[0] == '"' || d.in[0] == '\'') {
33
- s, err := d.parseString()
34
- if err != nil {
35
- return Token{}, err
36
- }
37
- ss = append(ss, s)
38
- }
39
- // d.in already points to the end of the value at this point.
40
- return Token{
41
- kind: Scalar,
42
- attrs: stringValue,
43
- pos: len(d.orig) - len(in0),
44
- raw: in0[:len(in0)-len(d.in)],
45
- str: strings.Join(ss, ""),
46
- }, nil
47
- }
48
-
49
- // parseString parses a string value enclosed in " or '.
50
- func (d *Decoder) parseString() (string, error) {
51
- in := d.in
52
- if len(in) == 0 {
53
- return "", ErrUnexpectedEOF
54
- }
55
- quote := in[0]
56
- in = in[1:]
57
- i := indexNeedEscapeInBytes(in)
58
- in, out := in[i:], in[:i:i] // set cap to prevent mutations
59
- for len(in) > 0 {
60
- switch r, n := utf8.DecodeRune(in); {
61
- case r == utf8.RuneError && n == 1:
62
- return "", d.newSyntaxError("invalid UTF-8 detected")
63
- case r == 0 || r == '\n':
64
- return "", d.newSyntaxError("invalid character %q in string", r)
65
- case r == rune(quote):
66
- in = in[1:]
67
- d.consume(len(d.in) - len(in))
68
- return string(out), nil
69
- case r == '\\':
70
- if len(in) < 2 {
71
- return "", ErrUnexpectedEOF
72
- }
73
- switch r := in[1]; r {
74
- case '"', '\'', '\\', '?':
75
- in, out = in[2:], append(out, r)
76
- case 'a':
77
- in, out = in[2:], append(out, '\a')
78
- case 'b':
79
- in, out = in[2:], append(out, '\b')
80
- case 'n':
81
- in, out = in[2:], append(out, '\n')
82
- case 'r':
83
- in, out = in[2:], append(out, '\r')
84
- case 't':
85
- in, out = in[2:], append(out, '\t')
86
- case 'v':
87
- in, out = in[2:], append(out, '\v')
88
- case 'f':
89
- in, out = in[2:], append(out, '\f')
90
- case '0', '1', '2', '3', '4', '5', '6', '7':
91
- // One, two, or three octal characters.
92
- n := len(in[1:]) - len(bytes.TrimLeft(in[1:], "01234567"))
93
- if n > 3 {
94
- n = 3
95
- }
96
- v, err := strconv.ParseUint(string(in[1:1+n]), 8, 8)
97
- if err != nil {
98
- return "", d.newSyntaxError("invalid octal escape code %q in string", in[:1+n])
99
- }
100
- in, out = in[1+n:], append(out, byte(v))
101
- case 'x':
102
- // One or two hexadecimal characters.
103
- n := len(in[2:]) - len(bytes.TrimLeft(in[2:], "0123456789abcdefABCDEF"))
104
- if n > 2 {
105
- n = 2
106
- }
107
- v, err := strconv.ParseUint(string(in[2:2+n]), 16, 8)
108
- if err != nil {
109
- return "", d.newSyntaxError("invalid hex escape code %q in string", in[:2+n])
110
- }
111
- in, out = in[2+n:], append(out, byte(v))
112
- case 'u', 'U':
113
- // Four or eight hexadecimal characters
114
- n := 6
115
- if r == 'U' {
116
- n = 10
117
- }
118
- if len(in) < n {
119
- return "", ErrUnexpectedEOF
120
- }
121
- v, err := strconv.ParseUint(string(in[2:n]), 16, 32)
122
- if utf8.MaxRune < v || err != nil {
123
- return "", d.newSyntaxError("invalid Unicode escape code %q in string", in[:n])
124
- }
125
- in = in[n:]
126
-
127
- r := rune(v)
128
- if utf16.IsSurrogate(r) {
129
- if len(in) < 6 {
130
- return "", ErrUnexpectedEOF
131
- }
132
- v, err := strconv.ParseUint(string(in[2:6]), 16, 16)
133
- r = utf16.DecodeRune(r, rune(v))
134
- if in[0] != '\\' || in[1] != 'u' || r == unicode.ReplacementChar || err != nil {
135
- return "", d.newSyntaxError("invalid Unicode escape code %q in string", in[:6])
136
- }
137
- in = in[6:]
138
- }
139
- out = append(out, string(r)...)
140
- default:
141
- return "", d.newSyntaxError("invalid escape code %q in string", in[:2])
142
- }
143
- default:
144
- i := indexNeedEscapeInBytes(in[n:])
145
- in, out = in[n+i:], append(out, in[:n+i]...)
146
- }
147
- }
148
- return "", ErrUnexpectedEOF
149
- }
150
-
151
- // indexNeedEscapeInString returns the index of the character that needs
152
- // escaping. If no characters need escaping, this returns the input length.
153
- func indexNeedEscapeInBytes(b []byte) int { return indexNeedEscapeInString(strs.UnsafeString(b)) }
154
-
155
- // UnmarshalString returns an unescaped string given a textproto string value.
156
- // String value needs to contain single or double quotes. This is only used by
157
- // internal/encoding/defval package for unmarshaling bytes.
158
- func UnmarshalString(s string) (string, error) {
159
- d := NewDecoder([]byte(s))
160
- return d.parseString()
161
- }
@@ -1,373 +0,0 @@
1
- // Copyright 2018 The Go Authors. All rights reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- package text
6
-
7
- import (
8
- "bytes"
9
- "fmt"
10
- "math"
11
- "strconv"
12
- "strings"
13
-
14
- "google.golang.org/protobuf/internal/flags"
15
- )
16
-
17
- // Kind represents a token kind expressible in the textproto format.
18
- type Kind uint8
19
-
20
- // Kind values.
21
- const (
22
- Invalid Kind = iota
23
- EOF
24
- Name // Name indicates the field name.
25
- Scalar // Scalar are scalar values, e.g. "string", 47, ENUM_LITERAL, true.
26
- MessageOpen
27
- MessageClose
28
- ListOpen
29
- ListClose
30
-
31
- // comma and semi-colon are only for parsing in between values and should not be exposed.
32
- comma
33
- semicolon
34
-
35
- // bof indicates beginning of file, which is the default token
36
- // kind at the beginning of parsing.
37
- bof = Invalid
38
- )
39
-
40
- func (t Kind) String() string {
41
- switch t {
42
- case Invalid:
43
- return "<invalid>"
44
- case EOF:
45
- return "eof"
46
- case Scalar:
47
- return "scalar"
48
- case Name:
49
- return "name"
50
- case MessageOpen:
51
- return "{"
52
- case MessageClose:
53
- return "}"
54
- case ListOpen:
55
- return "["
56
- case ListClose:
57
- return "]"
58
- case comma:
59
- return ","
60
- case semicolon:
61
- return ";"
62
- default:
63
- return fmt.Sprintf("<invalid:%v>", uint8(t))
64
- }
65
- }
66
-
67
- // NameKind represents different types of field names.
68
- type NameKind uint8
69
-
70
- // NameKind values.
71
- const (
72
- IdentName NameKind = iota + 1
73
- TypeName
74
- FieldNumber
75
- )
76
-
77
- func (t NameKind) String() string {
78
- switch t {
79
- case IdentName:
80
- return "IdentName"
81
- case TypeName:
82
- return "TypeName"
83
- case FieldNumber:
84
- return "FieldNumber"
85
- default:
86
- return fmt.Sprintf("<invalid:%v>", uint8(t))
87
- }
88
- }
89
-
90
- // Bit mask in Token.attrs to indicate if a Name token is followed by the
91
- // separator char ':'. The field name separator char is optional for message
92
- // field or repeated message field, but required for all other types. Decoder
93
- // simply indicates whether a Name token is followed by separator or not. It is
94
- // up to the prototext package to validate.
95
- const hasSeparator = 1 << 7
96
-
97
- // Scalar value types.
98
- const (
99
- numberValue = iota + 1
100
- stringValue
101
- literalValue
102
- )
103
-
104
- // Bit mask in Token.numAttrs to indicate that the number is a negative.
105
- const isNegative = 1 << 7
106
-
107
- // Token provides a parsed token kind and value. Values are provided by the
108
- // different accessor methods.
109
- type Token struct {
110
- // Kind of the Token object.
111
- kind Kind
112
- // attrs contains metadata for the following Kinds:
113
- // Name: hasSeparator bit and one of NameKind.
114
- // Scalar: one of numberValue, stringValue, literalValue.
115
- attrs uint8
116
- // numAttrs contains metadata for numberValue:
117
- // - highest bit is whether negative or positive.
118
- // - lower bits indicate one of numDec, numHex, numOct, numFloat.
119
- numAttrs uint8
120
- // pos provides the position of the token in the original input.
121
- pos int
122
- // raw bytes of the serialized token.
123
- // This is a subslice into the original input.
124
- raw []byte
125
- // str contains parsed string for the following:
126
- // - stringValue of Scalar kind
127
- // - numberValue of Scalar kind
128
- // - TypeName of Name kind
129
- str string
130
- }
131
-
132
- // Kind returns the token kind.
133
- func (t Token) Kind() Kind {
134
- return t.kind
135
- }
136
-
137
- // RawString returns the read value in string.
138
- func (t Token) RawString() string {
139
- return string(t.raw)
140
- }
141
-
142
- // Pos returns the token position from the input.
143
- func (t Token) Pos() int {
144
- return t.pos
145
- }
146
-
147
- // NameKind returns IdentName, TypeName or FieldNumber.
148
- // It panics if type is not Name.
149
- func (t Token) NameKind() NameKind {
150
- if t.kind == Name {
151
- return NameKind(t.attrs &^ hasSeparator)
152
- }
153
- panic(fmt.Sprintf("Token is not a Name type: %s", t.kind))
154
- }
155
-
156
- // HasSeparator returns true if the field name is followed by the separator char
157
- // ':', else false. It panics if type is not Name.
158
- func (t Token) HasSeparator() bool {
159
- if t.kind == Name {
160
- return t.attrs&hasSeparator != 0
161
- }
162
- panic(fmt.Sprintf("Token is not a Name type: %s", t.kind))
163
- }
164
-
165
- // IdentName returns the value for IdentName type.
166
- func (t Token) IdentName() string {
167
- if t.kind == Name && t.attrs&uint8(IdentName) != 0 {
168
- return string(t.raw)
169
- }
170
- panic(fmt.Sprintf("Token is not an IdentName: %s:%s", t.kind, NameKind(t.attrs&^hasSeparator)))
171
- }
172
-
173
- // TypeName returns the value for TypeName type.
174
- func (t Token) TypeName() string {
175
- if t.kind == Name && t.attrs&uint8(TypeName) != 0 {
176
- return t.str
177
- }
178
- panic(fmt.Sprintf("Token is not a TypeName: %s:%s", t.kind, NameKind(t.attrs&^hasSeparator)))
179
- }
180
-
181
- // FieldNumber returns the value for FieldNumber type. It returns a
182
- // non-negative int32 value. Caller will still need to validate for the correct
183
- // field number range.
184
- func (t Token) FieldNumber() int32 {
185
- if t.kind != Name || t.attrs&uint8(FieldNumber) == 0 {
186
- panic(fmt.Sprintf("Token is not a FieldNumber: %s:%s", t.kind, NameKind(t.attrs&^hasSeparator)))
187
- }
188
- // Following should not return an error as it had already been called right
189
- // before this Token was constructed.
190
- num, _ := strconv.ParseInt(string(t.raw), 10, 32)
191
- return int32(num)
192
- }
193
-
194
- // String returns the string value for a Scalar type.
195
- func (t Token) String() (string, bool) {
196
- if t.kind != Scalar || t.attrs != stringValue {
197
- return "", false
198
- }
199
- return t.str, true
200
- }
201
-
202
- // Enum returns the literal value for a Scalar type for use as enum literals.
203
- func (t Token) Enum() (string, bool) {
204
- if t.kind != Scalar || t.attrs != literalValue || (len(t.raw) > 0 && t.raw[0] == '-') {
205
- return "", false
206
- }
207
- return string(t.raw), true
208
- }
209
-
210
- // Bool returns the bool value for a Scalar type.
211
- func (t Token) Bool() (bool, bool) {
212
- if t.kind != Scalar {
213
- return false, false
214
- }
215
- switch t.attrs {
216
- case literalValue:
217
- if b, ok := boolLits[string(t.raw)]; ok {
218
- return b, true
219
- }
220
- case numberValue:
221
- // Unsigned integer representation of 0 or 1 is permitted: 00, 0x0, 01,
222
- // 0x1, etc.
223
- n, err := strconv.ParseUint(t.str, 0, 64)
224
- if err == nil {
225
- switch n {
226
- case 0:
227
- return false, true
228
- case 1:
229
- return true, true
230
- }
231
- }
232
- }
233
- return false, false
234
- }
235
-
236
- // These exact boolean literals are the ones supported in C++.
237
- var boolLits = map[string]bool{
238
- "t": true,
239
- "true": true,
240
- "True": true,
241
- "f": false,
242
- "false": false,
243
- "False": false,
244
- }
245
-
246
- // Uint64 returns the uint64 value for a Scalar type.
247
- func (t Token) Uint64() (uint64, bool) {
248
- if t.kind != Scalar || t.attrs != numberValue ||
249
- t.numAttrs&isNegative > 0 || t.numAttrs&numFloat > 0 {
250
- return 0, false
251
- }
252
- n, err := strconv.ParseUint(t.str, 0, 64)
253
- if err != nil {
254
- return 0, false
255
- }
256
- return n, true
257
- }
258
-
259
- // Uint32 returns the uint32 value for a Scalar type.
260
- func (t Token) Uint32() (uint32, bool) {
261
- if t.kind != Scalar || t.attrs != numberValue ||
262
- t.numAttrs&isNegative > 0 || t.numAttrs&numFloat > 0 {
263
- return 0, false
264
- }
265
- n, err := strconv.ParseUint(t.str, 0, 32)
266
- if err != nil {
267
- return 0, false
268
- }
269
- return uint32(n), true
270
- }
271
-
272
- // Int64 returns the int64 value for a Scalar type.
273
- func (t Token) Int64() (int64, bool) {
274
- if t.kind != Scalar || t.attrs != numberValue || t.numAttrs&numFloat > 0 {
275
- return 0, false
276
- }
277
- if n, err := strconv.ParseInt(t.str, 0, 64); err == nil {
278
- return n, true
279
- }
280
- // C++ accepts large positive hex numbers as negative values.
281
- // This feature is here for proto1 backwards compatibility purposes.
282
- if flags.ProtoLegacy && (t.numAttrs == numHex) {
283
- if n, err := strconv.ParseUint(t.str, 0, 64); err == nil {
284
- return int64(n), true
285
- }
286
- }
287
- return 0, false
288
- }
289
-
290
- // Int32 returns the int32 value for a Scalar type.
291
- func (t Token) Int32() (int32, bool) {
292
- if t.kind != Scalar || t.attrs != numberValue || t.numAttrs&numFloat > 0 {
293
- return 0, false
294
- }
295
- if n, err := strconv.ParseInt(t.str, 0, 32); err == nil {
296
- return int32(n), true
297
- }
298
- // C++ accepts large positive hex numbers as negative values.
299
- // This feature is here for proto1 backwards compatibility purposes.
300
- if flags.ProtoLegacy && (t.numAttrs == numHex) {
301
- if n, err := strconv.ParseUint(t.str, 0, 32); err == nil {
302
- return int32(n), true
303
- }
304
- }
305
- return 0, false
306
- }
307
-
308
- // Float64 returns the float64 value for a Scalar type.
309
- func (t Token) Float64() (float64, bool) {
310
- if t.kind != Scalar {
311
- return 0, false
312
- }
313
- switch t.attrs {
314
- case literalValue:
315
- if f, ok := floatLits[strings.ToLower(string(t.raw))]; ok {
316
- return f, true
317
- }
318
- case numberValue:
319
- n, err := strconv.ParseFloat(t.str, 64)
320
- if err == nil {
321
- return n, true
322
- }
323
- nerr := err.(*strconv.NumError)
324
- if nerr.Err == strconv.ErrRange {
325
- return n, true
326
- }
327
- }
328
- return 0, false
329
- }
330
-
331
- // Float32 returns the float32 value for a Scalar type.
332
- func (t Token) Float32() (float32, bool) {
333
- if t.kind != Scalar {
334
- return 0, false
335
- }
336
- switch t.attrs {
337
- case literalValue:
338
- if f, ok := floatLits[strings.ToLower(string(t.raw))]; ok {
339
- return float32(f), true
340
- }
341
- case numberValue:
342
- n, err := strconv.ParseFloat(t.str, 64)
343
- if err == nil {
344
- // Overflows are treated as (-)infinity.
345
- return float32(n), true
346
- }
347
- nerr := err.(*strconv.NumError)
348
- if nerr.Err == strconv.ErrRange {
349
- return float32(n), true
350
- }
351
- }
352
- return 0, false
353
- }
354
-
355
- // These are the supported float literals which C++ permits case-insensitive
356
- // variants of these.
357
- var floatLits = map[string]float64{
358
- "nan": math.NaN(),
359
- "inf": math.Inf(1),
360
- "infinity": math.Inf(1),
361
- "-inf": math.Inf(-1),
362
- "-infinity": math.Inf(-1),
363
- }
364
-
365
- // TokenEquals returns true if given Tokens are equal, else false.
366
- func TokenEquals(x, y Token) bool {
367
- return x.kind == y.kind &&
368
- x.attrs == y.attrs &&
369
- x.numAttrs == y.numAttrs &&
370
- x.pos == y.pos &&
371
- bytes.Equal(x.raw, y.raw) &&
372
- x.str == y.str
373
- }