diff --git a/CHANGELOG.md b/CHANGELOG.md index 157acb0..ca2a7c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org). +## [v0.0.2](https://github.com/puppetlabs/puppet-lint-check_unsafe_interpolations/tree/v0.0.2) - 2022-12-06 + +[Full Changelog](https://github.com/puppetlabs/puppet-lint-check_unsafe_interpolations/compare/v0.0.1...v0.0.2) + +### Changed +- (CONT-332) Change puppet-lint version dependency [#24](https://github.com/puppetlabs/puppet-lint-check_unsafe_interpolations/pull/24) ([GSPatton](https://github.com/GSPatton)) + ## [v0.0.1](https://github.com/puppetlabs/puppet-lint-check_unsafe_interpolations/tree/v0.0.1) - 2022-12-01 [Full Changelog](https://github.com/puppetlabs/puppet-lint-check_unsafe_interpolations/compare/6fdffece89c70b016174b766d57ecf22064b20d2...v0.0.1) diff --git a/vendor/bundle/ruby/2.7.0/cache/json-2.6.3.gem b/vendor/bundle/ruby/2.7.0/cache/json-2.6.3.gem new file mode 100644 index 0000000..f76ee74 Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/cache/json-2.6.3.gem differ diff --git a/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/gem.build_complete b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/gem.build_complete new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/gem_make.out b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/gem_make.out new file mode 100644 index 0000000..3bed4f7 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/gem_make.out @@ -0,0 +1,13 @@ +current directory: /home/runner/work/puppet-lint-check_unsafe_interpolations/puppet-lint-check_unsafe_interpolations/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json +/opt/hostedtoolcache/Ruby/2.7.7/x64/bin/ruby -I /opt/hostedtoolcache/Ruby/2.7.7/x64/lib/ruby/2.7.0 -r ./siteconf20221206-1722-1a7l1pa.rb extconf.rb +creating Makefile + +current directory: /home/runner/work/puppet-lint-check_unsafe_interpolations/puppet-lint-check_unsafe_interpolations/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json +make "DESTDIR=" clean + +current directory: /home/runner/work/puppet-lint-check_unsafe_interpolations/puppet-lint-check_unsafe_interpolations/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json +make "DESTDIR=" +make: Nothing to be done for 'all'. + +current directory: /home/runner/work/puppet-lint-check_unsafe_interpolations/puppet-lint-check_unsafe_interpolations/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json +make "DESTDIR=" install diff --git a/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/json/ext/generator.so b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/json/ext/generator.so new file mode 100755 index 0000000..d8731fc Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/json/ext/generator.so differ diff --git a/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/json/ext/parser.so b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/json/ext/parser.so new file mode 100755 index 0000000..0938a60 Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/json/ext/parser.so differ diff --git a/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/mkmf.log b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/mkmf.log new file mode 100644 index 0000000..a7a14f4 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux/2.7.0/json-2.6.3/mkmf.log @@ -0,0 +1,120 @@ +have_func: checking for rb_enc_raise() in ruby.h... -------------------- yes + +"gcc -o conftest -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/ruby/backward -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 -I. -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 -g -O2 -fPIC conftest.c -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -lruby -lm -lc" +checked program was: +/* begin */ +1: #include "ruby.h" +2: +3: int main(int argc, char **argv) +4: { +5: return !!argv[argc]; +6: } +/* end */ + +"gcc -o conftest -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/ruby/backward -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 -I. -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 -g -O2 -fPIC conftest.c -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -lruby -lm -lc" +conftest.c: In function ‘t’: +conftest.c:16:57: error: ‘rb_enc_raise’ undeclared (first use in this function); did you mean ‘rb_exc_raise’? + 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } + | ^~~~~~~~~~~~ + | rb_exc_raise +conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_raise; return !p; } +/* end */ + +"gcc -o conftest -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/ruby/backward -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 -I. -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 -g -O2 -fPIC conftest.c -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -lruby -lm -lc" +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void rb_enc_raise(); +17: int t(void) { rb_enc_raise(); return 0; } +/* end */ + +-------------------- + +have_func: checking for rb_enc_interned_str() in ruby.h... -------------------- no + +"gcc -o conftest -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/ruby/backward -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 -I. -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 -g -O2 -fPIC conftest.c -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -lruby -lm -lc" +conftest.c: In function ‘t’: +conftest.c:16:57: error: ‘rb_enc_interned_str’ undeclared (first use in this function); did you mean ‘rb_sym_interned_p’? + 16 | int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_interned_str; return !p; } + | ^~~~~~~~~~~~~~~~~~~ + | rb_sym_interned_p +conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_enc_interned_str; return !p; } +/* end */ + +"gcc -o conftest -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/ruby/backward -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 -I. -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 -g -O2 -fPIC conftest.c -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -lruby -lm -lc" +/usr/bin/ld: /tmp/cc6RUtBd.o: in function `t': +/home/runner/work/puppet-lint-check_unsafe_interpolations/puppet-lint-check_unsafe_interpolations/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/conftest.c:17: undefined reference to `rb_enc_interned_str' +collect2: error: ld returned 1 exit status +checked program was: +/* begin */ + 1: #include "ruby.h" + 2: + 3: #include + 4: + 5: /*top*/ + 6: extern int t(void); + 7: int main(int argc, char **argv) + 8: { + 9: if (argc > 1000000) { +10: int (* volatile tp)(void)=(int (*)(void))&t; +11: printf("%d", (*tp)()); +12: } +13: +14: return !!argv[argc]; +15: } +16: extern void rb_enc_interned_str(); +17: int t(void) { rb_enc_interned_str(); return 0; } +/* end */ + +-------------------- + diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/CHANGES.md b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/CHANGES.md new file mode 100644 index 0000000..ba66514 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/CHANGES.md @@ -0,0 +1,457 @@ +# Changes + +### 2021-10-24 (2.6.1) + +* Restore version.rb with 2.6.1 + +### 2021-10-14 (2.6.0) + +* Use `rb_enc_interned_str` if available to reduce allocations in `freeze: true` mode. #451. +* Bump required_ruby_version to 2.3. +* Fix compatibility with `GC.compact`. +* Fix some compilation warnings. #469 + +## 2020-12-22 (2.5.1) + +* Restore the compatibility for constants of JSON class. + +## 2020-12-22 (2.5.0) + +* Ready to Ractor-safe at Ruby 3.0. + +## 2020-12-17 (2.4.1) + +* Restore version.rb with 2.4.1 + +## 2020-12-15 (2.4.0) + +* Implement a freeze: parser option #447 +* Fix an issue with generate_pretty and empty objects in the Ruby and Java implementations #449 +* Fix JSON.load_file doc #448 +* Fix pure parser with unclosed arrays / objects #425 +* bundle the LICENSE file in the gem #444 +* Add an option to escape forward slash character #405 +* RDoc for JSON #439 #446 #442 #434 #433 #430 + +## 2020-06-30 (2.3.1) + +* Spelling and grammar fixes for comments. Pull request #191 by Josh + Kline. +* Enhance generic JSON and #generate docs. Pull request #347 by Victor + Shepelev. +* Add :nodoc: for GeneratorMethods. Pull request #349 by Victor Shepelev. +* Baseline changes to help (JRuby) development. Pull request #371 by Karol + Bucek. +* Add metadata for rubygems.org. Pull request #379 by Alexandre ZANNI. +* Remove invalid JSON.generate description from JSON module rdoc. Pull + request #384 by Jeremy Evans. +* Test with TruffleRuby in CI. Pull request #402 by Benoit Daloze. +* Rdoc enhancements. Pull request #413 by Burdette Lamar. +* Fixtures/ are not being tested... Pull request #416 by Marc-André + Lafortune. +* Use frozen string for hash key. Pull request #420 by Marc-André + Lafortune. +* Added :call-seq: to RDoc for some methods. Pull request #422 by Burdette + Lamar. +* Small typo fix. Pull request #423 by Marc-André Lafortune. + +## 2019-12-11 (2.3.0) + * Fix default of `create_additions` to always be `false` for `JSON(user_input)` + and `JSON.parse(user_input, nil)`. + Note that `JSON.load` remains with default `true` and is meant for internal + serialization of trusted data. [CVE-2020-10663] + * Fix passing args all #to_json in json/add/*. + * Fix encoding issues + * Fix issues of keyword vs positional parameter + * Fix JSON::Parser against bigdecimal updates + * Bug fixes to JRuby port + +## 2019-02-21 (2.2.0) + * Adds support for 2.6 BigDecimal and ruby standard library Set datetype. + +## 2017-04-18 (2.1.0) + * Allow passing of `decimal_class` option to specify a class as which to parse + JSON float numbers. +## 2017-03-23 (2.0.4) + * Raise exception for incomplete unicode surrogates/character escape + sequences. This problem was reported by Daniel Gollahon (dgollahon). + * Fix arbitrary heap exposure problem. This problem was reported by Ahmad + Sherif (ahmadsherif). + +## 2017-01-12 (2.0.3) + * Set `required_ruby_version` to 1.9 + * Some small fixes + +## 2016-07-26 (2.0.2) + * Specify `required_ruby_version` for json\_pure. + * Fix issue #295 failure when parsing frozen strings. + +## 2016-07-01 (2.0.1) + * Fix problem when requiring json\_pure and Parser constant was defined top + level. + * Add `RB_GC_GUARD` to avoid possible GC problem via Pete Johns. + * Store `current_nesting` on stack by Aaron Patterson. + +## 2015-09-11 (2.0.0) + * Now complies to newest JSON RFC 7159. + * Implements compatibility to ruby 2.4 integer unification. + * Drops support for old rubies whose life has ended, that is rubies < 2.0. + Also see https://www.ruby-lang.org/en/news/2014/07/01/eol-for-1-8-7-and-1-9-2/ + * There were still some mentions of dual GPL licensing in the source, but JSON + has just the Ruby license that itself includes an explicit dual-licensing + clause that allows covered software to be distributed under the terms of + the Simplified BSD License instead for all ruby versions >= 1.9.3. This is + however a GPL compatible license according to the Free Software Foundation. + I changed these mentions to be consistent with the Ruby license setting in + the gemspec files which were already correct now. + +## 2015-06-01 (1.8.3) + * Fix potential memory leak, thx to nobu. + +## 2015-01-08 (1.8.2) + * Some performance improvements by Vipul A M . + * Fix by Jason R. Clark to avoid mutation of + `JSON.dump_default_options`. + * More tests by Michael Mac-Vicar and fixing + `space_before` accessor in generator. + * Performance on Jruby improved by Ben Browning . + * Some fixes to be compatible with the new Ruby 2.2 by Zachary Scott + and SHIBATA Hiroshi . + +## 2013-05-13 (1.8.1) + * Remove Rubinius exception since transcoding should be working now. + +## 2013-05-13 (1.8.0) + * Fix https://github.com/flori/json/issues/162 reported by Marc-Andre + Lafortune . Thanks! + * Applied patches by Yui NARUSE to suppress warning with + -Wchar-subscripts and better validate UTF-8 strings. + * Applied patch by ginriki@github to remove unnecessary if. + * Add load/dump interface to `JSON::GenericObject` to make + serialize :some_attribute, `JSON::GenericObject` + work in Rails active models for convenient `SomeModel#some_attribute.foo.bar` + access to serialised JSON data. + +## 2013-02-04 (1.7.7) + * Security fix for JSON create_additions default value and + `JSON::GenericObject`. It should not be possible to create additions unless + explicitly requested by setting the create_additions argument to true or + using the JSON.load/dump interface. If `JSON::GenericObject` is supposed to + be automatically deserialised, this has to be explicitly enabled by + setting + JSON::GenericObject.json_creatable = true + as well. + * Remove useless assert in fbuffer implementation. + * Apply patch attached to https://github.com/flori/json/issues#issue/155 + provided by John Shahid , Thx! + * Add license information to rubygems spec data, reported by Jordi Massaguer Pla . + * Improve documentation, thx to Zachary Scott . + +## 2012-11-29 (1.7.6) + * Add `GeneratorState#merge` alias for JRuby, fix state accessor methods. Thx to + jvshahid@github. + * Increase hash likeness of state objects. + +## 2012-08-17 (1.7.5) + * Fix compilation of extension on older rubies. + +## 2012-07-26 (1.7.4) + * Fix compilation problem on AIX, see https://github.com/flori/json/issues/142 + +## 2012-05-12 (1.7.3) + * Work around Rubinius encoding issues using iconv for conversion instead. + +## 2012-05-11 (1.7.2) + * Fix some encoding issues, that cause problems for the pure and the + extension variant in jruby 1.9 mode. + +## 2012-04-28 (1.7.1) + * Some small fixes for building + +## 2012-04-28 (1.7.0) + * Add `JSON::GenericObject` for method access to objects transmitted via JSON. + +## 2012-04-27 (1.6.7) + * Fix possible crash when trying to parse nil value. + +## 2012-02-11 (1.6.6) + * Propagate src encoding to values made from it (fixes 1.9 mode converting + everything to ascii-8bit; harmless for 1.8 mode too) (Thomas E. Enebo + ), should fix + https://github.com/flori/json/issues#issue/119. + * Fix https://github.com/flori/json/issues#issue/124 Thx to Jason Hutchens. + * Fix https://github.com/flori/json/issues#issue/117 + +## 2012-01-15 (1.6.5) + * Vit Ondruch reported a bug that shows up when using + optimisation under GCC 4.7. Thx to him, Bohuslav Kabrda + and Yui NARUSE for debugging and + developing a patch fix. + +## 2011-12-24 (1.6.4) + * Patches that improve speed on JRuby contributed by Charles Oliver Nutter + . + * Support `object_class`/`array_class` with duck typed hash/array. + +## 2011-12-01 (1.6.3) + * Let `JSON.load('')` return nil as well to make mysql text columns (default to + `''`) work better for serialization. + +## 2011-11-21 (1.6.2) + * Add support for OpenStruct and BigDecimal. + * Fix bug when parsing nil in `quirks_mode`. + * Make JSON.dump and JSON.load methods better cooperate with Rails' serialize + method. Just use: + serialize :value, JSON + * Fix bug with time serialization concerning nanoseconds. Thanks for the + patch go to Josh Partlow (jpartlow@github). + * Improve parsing speed for JSON numbers (integers and floats) in a similar way to + what Evan Phoenix suggested in: + https://github.com/flori/json/pull/103 + +## 2011-09-18 (1.6.1) + * Using -target 1.5 to force Java bits to compile with 1.5. + +## 2011-09-12 (1.6.0) + * Extract utilities (prettifier and GUI-editor) in its own gem json-utils. + * Split json/add/core into different files for classes to be serialised. + +## 2011-08-31 (1.5.4) + * Fix memory leak when used from multiple JRuby. (Patch by + jfirebaugh@github). + * Apply patch by Eric Wong that fixes garbage collection problem + reported in https://github.com/flori/json/issues/46. + * Add :quirks_mode option to parser and generator. + * Add support for Rational and Complex number additions via json/add/complex + and json/add/rational requires. + +## 2011-06-20 (1.5.3) + * Alias State#configure method as State#merge to increase duck type synonymy with Hash. + * Add `as_json` methods in json/add/core, so rails can create its json objects + the new way. + +## 2011-05-11 (1.5.2) + * Apply documentation patch by Cory Monty . + * Add gemspecs for json and json\_pure. + * Fix bug in jruby pretty printing. + * Fix bug in `object_class` and `array_class` when inheriting from Hash or + Array. + +## 2011-01-24 (1.5.1) + * Made rake-compiler build a fat binary gem. This should fix issue + https://github.com/flori/json/issues#issue/54. + +## 2011-01-22 (1.5.0) + * Included Java source codes for the Jruby extension made by Daniel Luz + . + * Output full exception message of `deep_const_get` to aid debugging. + * Fixed an issue with ruby 1.9 `Module#const_defined?` method, that was + reported by Riley Goodside. + +## 2010-08-09 (1.4.6) + * Fixed oversight reported in http://github.com/flori/json/issues/closed#issue/23, + always create a new object from the state prototype. + * Made pure and ext api more similar again. + +## 2010-08-07 (1.4.5) + * Manage data structure nesting depth in state object during generation. This + should reduce problems with `to_json` method definіtions that only have one + argument. + * Some fixes in the state objects and additional tests. +## 2010-08-06 (1.4.4) + * Fixes build problem for rubinius under OS X, http://github.com/flori/json/issues/closed#issue/25 + * Fixes crashes described in http://github.com/flori/json/issues/closed#issue/21 and + http://github.com/flori/json/issues/closed#issue/23 +## 2010-05-05 (1.4.3) + * Fixed some test assertions, from Ruby r27587 and r27590, patch by nobu. + * Fixed issue http://github.com/flori/json/issues/#issue/20 reported by + electronicwhisper@github. Thx! + +## 2010-04-26 (1.4.2) + * Applied patch from naruse Yui NARUSE to make building with + Microsoft Visual C possible again. + * Applied patch from devrandom in order to allow building of + json_pure if extensiontask is not present. + * Thanks to Dustin Schneider , who reported a memory + leak, which is fixed in this release. + * Applied 993f261ccb8f911d2ae57e9db48ec7acd0187283 patch from josh@github. + +## 2010-04-25 (1.4.1) + * Fix for a bug reported by Dan DeLeo , caused by T_FIXNUM + being different on 32bit/64bit architectures. + +## 2010-04-23 (1.4.0) + * Major speed improvements and building with simplified + directory/file-structure. + * Extension should at least be compatible with MRI, YARV and Rubinius. + +## 2010-04-07 (1.2.4) + * Triger const_missing callback to make Rails' dynamic class loading work. + +## 2010-03-11 (1.2.3) + * Added a `State#[]` method which returns an attribute's value in order to + increase duck type compatibility to Hash. + +## 2010-02-27 (1.2.2) + * Made some changes to make the building of the parser/generator compatible + to Rubinius. + +## 2009-11-25 (1.2.1) + * Added `:symbolize_names` option to Parser, which returns symbols instead of + strings in object names/keys. + +## 2009-10-01 (1.2.0) + * `fast_generate` now raises an exception for nan and infinite floats. + * On Ruby 1.8 json supports parsing of UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, + and UTF-32LE JSON documents now. Under Ruby 1.9 the M17n conversion + functions are used to convert from all supported encodings. ASCII-8BIT + encoded strings are handled like all strings under Ruby 1.8 were. + * Better documentation + +## 2009-08-23 (1.1.9) + * Added forgotten main doc file `extra_rdoc_files`. + +## 2009-08-23 (1.1.8) + * Applied a patch by OZAWA Sakuro to make json/pure + work in environments that don't provide iconv. + * Applied patch by okkez_ in order to fix Ruby Bug #1768: + http://redmine.ruby-lang.org/issues/show/1768. + * Finally got around to avoid the rather paranoid escaping of ?/ characters + in the generator's output. The parsers aren't affected by this change. + Thanks to Rich Apodaca for the suggestion. + +## 2009-06-29 (1.1.7) + * Security Fix for JSON::Pure::Parser. A specially designed string could + cause catastrophic backtracking in one of the parser's regular expressions + in earlier 1.1.x versions. JSON::Ext::Parser isn't affected by this issue. + Thanks to Bartosz Blimke for reporting this + problem. + * This release also uses a less strict ruby version requirement for the + creation of the mswin32 native gem. + +## 2009-05-10 (1.1.6) + * No changes. І tested native linux gems in the last release and they don't + play well with different ruby versions other than the one the gem was built + with. This release is just to bump the version number in order to skip the + native gem on rubyforge. + +## 2009-05-10 (1.1.5) + * Started to build gems with rake-compiler gem. + * Applied patch object/array class patch from Brian Candler + and fixes. + +## 2009-04-01 (1.1.4) + * Fixed a bug in the creation of serialized generic rails objects reported by + Friedrich Graeter . + * Deleted tests/runner.rb, we're using testrb instead. + * Editor supports Infinity in numbers now. + * Made some changes in order to get the library to compile/run under Ruby + 1.9. + * Improved speed of the code path for the fast_generate method in the pure + variant. + +## 2008-07-10 (1.1.3) + * Wesley Beary reported a bug in json/add/core's DateTime + handling: If the nominator and denominator of the offset were divisible by + each other Ruby's Rational#to_s returns them as an integer not a fraction + with '/'. This caused a ZeroDivisionError during parsing. + * Use Date#start and DateTime#start instead of sg method, while + remaining backwards compatible. + * Supports ragel >= 6.0 now. + * Corrected some tests. + * Some minor changes. + +## 2007-11-27 (1.1.2) + * Remember default dir (last used directory) in editor. + * JSON::Editor.edit method added, the editor can now receive json texts from + the clipboard via C-v. + * Load json texts from an URL pasted via middle button press. + * Added :create_additions option to Parser. This makes it possible to disable + the creation of additions by force, in order to treat json texts as data + while having additions loaded. + * Jacob Maine reported, that JSON(:foo) outputs a JSON + object if the rails addition is enabled, which is wrong. It now outputs a + JSON string "foo" instead, like suggested by Jacob Maine. + * Discovered a bug in the Ruby Bugs Tracker on rubyforge, that was reported + by John Evans lgastako@gmail.com. He could produce a crash in the JSON + generator by returning something other than a String instance from a + to_json method. I now guard against this by doing a rather crude type + check, which raises an exception instead of crashing. + +## 2007-07-06 (1.1.1) + * Yui NARUSE sent some patches to fix tests for Ruby + 1.9. I applied them and adapted some of them a bit to run both on 1.8 and + 1.9. + * Introduced a `JSON.parse!` method without depth checking for people who + like danger. + * Made generate and `pretty_generate` methods configurable by an options hash. + * Added :allow_nan option to parser and generator in order to handle NaN, + Infinity, and -Infinity correctly - if requested. Floats, which aren't numbers, + aren't valid JSON according to RFC4627, so by default an exception will be + raised if any of these symbols are encountered. Thanks to Andrea Censi + for his hint about this. + * Fixed some more tests for Ruby 1.9. + * Implemented dump/load interface of Marshal as suggested in ruby-core:11405 + by murphy . + * Implemented the `max_nesting` feature for generate methods, too. + * Added some implementations for ruby core's custom objects for + serialisation/deserialisation purposes. + +## 2007-05-21 (1.1.0) + * Implemented max_nesting feature for parser to avoid stack overflows for + data from untrusted sources. If you trust the source, you can disable it + with the option max_nesting => false. + * Piers Cawley reported a bug, that not every + character can be escaped by `\` as required by RFC4627. There's a + contradiction between David Crockford's JSON checker test vectors (in + tests/fixtures) and RFC4627, though. I decided to stick to the RFC, because + the JSON checker seems to be a bit older than the RFC. + * Extended license to Ruby License, which includes the GPL. + * Added keyboard shortcuts, and 'Open location' menu item to edit_json.rb. + +## 2007-05-09 (1.0.4) + * Applied a patch from Yui NARUSE to make JSON compile + under Ruby 1.9. Thank you very much for mailing it to me! + * Made binary variants of JSON fail early, instead of falling back to the + pure version. This should avoid overshadowing of eventual problems while + loading of the binary. + +## 2007-03-24 (1.0.3) + * Improved performance of pure variant a bit. + * The ext variant of this release supports the mswin32 platform. Ugh! + +## 2007-03-24 (1.0.2) + * Ext Parser didn't parse 0e0 correctly into 0.0: Fixed! + +## 2007-03-24 (1.0.1) + * Forgot some object files in the build dir. I really like that - not! + +## 2007-03-24 (1.0.0) + * Added C implementations for the JSON generator and a ragel based JSON + parser in C. + * Much more tests, especially fixtures from json.org. + * Further improved conformance to RFC4627. + +## 2007-02-09 (0.4.3) + * Conform more to RFC4627 for JSON: This means JSON strings + now always must contain exactly one object `"{ ... }"` or array `"[ ... ]"` in + order to be parsed without raising an exception. The definition of what + constitutes a whitespace is narrower in JSON than in Ruby ([ \t\r\n]), and + there are differences in floats and integers (no octals or hexadecimals) as + well. + * Added aliases generate and `pretty_generate` of unparse and `pretty_unparse`. + * Fixed a test case. + * Catch an `Iconv::InvalidEncoding` exception, that seems to occur on some Sun + boxes with SunOS 5.8, if iconv doesn't support utf16 conversions. This was + reported by Andrew R Jackson , thanks a bunch! + +## 2006-08-25 (0.4.2) + * Fixed a bug in handling solidi (/-characters), that was reported by + Kevin Gilpin . + +## 2006-02-06 (0.4.1) + * Fixed a bug related to escaping with backslashes. Thanks for the report go + to Florian Munz . + +## 2005-09-23 (0.4.0) + * Initial Rubyforge Version diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/LICENSE b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/LICENSE new file mode 100644 index 0000000..426810a --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/LICENSE @@ -0,0 +1,56 @@ +Ruby is copyrighted free software by Yukihiro Matsumoto . +You can redistribute it and/or modify it under either the terms of the +2-clause BSDL (see the file BSDL), or the conditions below: + + 1. You may make and give away verbatim copies of the source form of the + software without restriction, provided that you duplicate all of the + original copyright notices and associated disclaimers. + + 2. You may modify your copy of the software in any way, provided that + you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said + modifications to Usenet or an equivalent medium, or by allowing + the author to include your modifications in the software. + + b) use the modified software only within your corporation or + organization. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 3. You may distribute the software in object code or binary form, + provided that you do at least ONE of the following: + + a) distribute the binaries and library files of the software, + together with instructions (in the manual page or equivalent) + on where to get the original distribution. + + b) accompany the distribution with the machine-readable source of + the software. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 4. You may modify and include the part of the software into any other + software (possibly commercial). But some files in the distribution + are not written by the author, so that they are not under these terms. + + For the list of those files and their copying conditions, see the + file LEGAL. + + 5. The scripts and library files supplied as input to or produced as + output from the software do not automatically fall under the + copyright of the software, but belong to whomever generated them, + and may be sold commercially, and may be aggregated with this + software. + + 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/README.md b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/README.md new file mode 100644 index 0000000..288ccdf --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/README.md @@ -0,0 +1,425 @@ +# JSON implementation for Ruby + +[![CI](https://github.com/flori/json/actions/workflows/ci.yml/badge.svg)](https://github.com/flori/json/actions/workflows/ci.yml) + +## Description + +This is a implementation of the JSON specification according to RFC 7159 +http://www.ietf.org/rfc/rfc7159.txt . Starting from version 1.0.0 on there +will be two variants available: + +* A pure ruby variant, that relies on the iconv and the stringscan + extensions, which are both part of the ruby standard library. +* The quite a bit faster native extension variant, which is in parts + implemented in C or Java and comes with its own unicode conversion + functions and a parser generated by the ragel state machine compiler + http://www.complang.org/ragel/ . + +Both variants of the JSON generator generate UTF-8 character sequences by +default. If an :ascii\_only option with a true value is given, they escape all +non-ASCII and control characters with \uXXXX escape sequences, and support +UTF-16 surrogate pairs in order to be able to generate the whole range of +unicode code points. + +All strings, that are to be encoded as JSON strings, should be UTF-8 byte +sequences on the Ruby side. To encode raw binary strings, that aren't UTF-8 +encoded, please use the to\_json\_raw\_object method of String (which produces +an object, that contains a byte array) and decode the result on the receiving +endpoint. + +## Installation + +It's recommended to use the extension variant of JSON, because it's faster than +the pure ruby variant. If you cannot build it on your system, you can settle +for the latter. + +Just type into the command line as root: + +``` +# rake install +``` + +The above command will build the extensions and install them on your system. + +``` +# rake install_pure +``` + +or + +``` +# ruby install.rb +``` + +will just install the pure ruby implementation of JSON. + +If you use Rubygems you can type + +``` +# gem install json +``` + +instead, to install the newest JSON version. + +There is also a pure ruby json only variant of the gem, that can be installed +with: + +``` +# gem install json_pure +``` + +## Compiling the extensions yourself + +If you want to create the `parser.c` file from its `parser.rl` file or draw nice +graphviz images of the state machines, you need ragel from: +http://www.complang.org/ragel/ + +## Usage + +To use JSON you can + +```ruby +require 'json' +``` + +to load the installed variant (either the extension `'json'` or the pure +variant `'json_pure'`). If you have installed the extension variant, you can +pick either the extension variant or the pure variant by typing + +```ruby +require 'json/ext' +``` + +or + +```ruby +require 'json/pure' +``` + +Now you can parse a JSON document into a ruby data structure by calling + +```ruby +JSON.parse(document) +``` + +If you want to generate a JSON document from a ruby data structure call +```ruby +JSON.generate(data) +``` + +You can also use the `pretty_generate` method (which formats the output more +verbosely and nicely) or `fast_generate` (which doesn't do any of the security +checks generate performs, e. g. nesting deepness checks). + +There are also the JSON and JSON[] methods which use parse on a String or +generate a JSON document from an array or hash: + +```ruby +document = JSON 'test' => 23 # => "{\"test\":23}" +document = JSON['test' => 23] # => "{\"test\":23}" +``` + +and + +```ruby +data = JSON '{"test":23}' # => {"test"=>23} +data = JSON['{"test":23}'] # => {"test"=>23} +``` + +You can choose to load a set of common additions to ruby core's objects if +you + +```ruby +require 'json/add/core' +``` + +After requiring this you can, e. g., serialise/deserialise Ruby ranges: + +```ruby +JSON JSON(1..10) # => 1..10 +``` + +To find out how to add JSON support to other or your own classes, read the +section "More Examples" below. + +To get the best compatibility to rails' JSON implementation, you can + +```ruby +require 'json/add/rails' +``` + +Both of the additions attempt to require `'json'` (like above) first, if it has +not been required yet. + +## Serializing exceptions + +The JSON module doesn't extend `Exception` by default. If you convert an `Exception` +object to JSON, it will by default only include the exception message. + +To include the full details, you must either load the `json/add/core` mentioned +above, or specifically load the exception addition: + +```ruby +require 'json/add/exception' +``` + +## More Examples + +To create a JSON document from a ruby data structure, you can call +`JSON.generate` like that: + +```ruby +json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10] +# => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]" +``` + +To get back a ruby data structure from a JSON document, you have to call +JSON.parse on it: + +```ruby +JSON.parse json +# => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"] +``` + +Note, that the range from the original data structure is a simple +string now. The reason for this is, that JSON doesn't support ranges +or arbitrary classes. In this case the json library falls back to call +`Object#to_json`, which is the same as `#to_s.to_json`. + +It's possible to add JSON support serialization to arbitrary classes by +simply implementing a more specialized version of the `#to_json method`, that +should return a JSON object (a hash converted to JSON with `#to_json`) like +this (don't forget the `*a` for all the arguments): + +```ruby +class Range + def to_json(*a) + { + 'json_class' => self.class.name, # = 'Range' + 'data' => [ first, last, exclude_end? ] + }.to_json(*a) + end +end +``` + +The hash key `json_class` is the class, that will be asked to deserialise the +JSON representation later. In this case it's `Range`, but any namespace of +the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be +used to store the necessary data to configure the object to be deserialised. + +If the key `json_class` is found in a JSON object, the JSON parser checks +if the given class responds to the `json_create` class method. If so, it is +called with the JSON object converted to a Ruby hash. So a range can +be deserialised by implementing `Range.json_create` like this: + +```ruby +class Range + def self.json_create(o) + new(*o['data']) + end +end +``` + +Now it possible to serialise/deserialise ranges as well: + +```ruby +json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10] +# => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]" +JSON.parse json +# => [1, 2, {"a"=>3.141}, false, true, nil, 4..10] +json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10] +# => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]" +JSON.parse json, :create_additions => true +# => [1, 2, {"a"=>3.141}, false, true, nil, 4..10] +``` + +`JSON.generate` always creates the shortest possible string representation of a +ruby data structure in one line. This is good for data storage or network +protocols, but not so good for humans to read. Fortunately there's also +`JSON.pretty_generate` (or `JSON.pretty_generate`) that creates a more readable +output: + +```ruby + puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10]) + [ + 1, + 2, + { + "a": 3.141 + }, + false, + true, + null, + { + "json_class": "Range", + "data": [ + 4, + 10, + false + ] + } + ] +``` + +There are also the methods `Kernel#j` for generate, and `Kernel#jj` for +`pretty_generate` output to the console, that work analogous to Core Ruby's `p` and +the `pp` library's `pp` methods. + +The script `tools/server.rb` contains a small example if you want to test, how +receiving a JSON object from a webrick server in your browser with the +JavaScript prototype library http://www.prototypejs.org works. + +## Speed Comparisons + +I have created some benchmark results (see the benchmarks/data-p4-3Ghz +subdir of the package) for the JSON-parser to estimate the speed up in the C +extension: + +``` + Comparing times (call_time_mean): + 1 ParserBenchmarkExt#parser 900 repeats: + 553.922304770 ( real) -> 21.500x + 0.001805307 + 2 ParserBenchmarkYAML#parser 1000 repeats: + 224.513358139 ( real) -> 8.714x + 0.004454078 + 3 ParserBenchmarkPure#parser 1000 repeats: + 26.755020642 ( real) -> 1.038x + 0.037376163 + 4 ParserBenchmarkRails#parser 1000 repeats: + 25.763381731 ( real) -> 1.000x + 0.038814780 + calls/sec ( time) -> speed covers + secs/call +``` + +In the table above 1 is `JSON::Ext::Parser`, 2 is `YAML.load` with YAML +compatible JSON document, 3 is is `JSON::Pure::Parser`, and 4 is +`ActiveSupport::JSON.decode`. The ActiveSupport JSON-decoder converts the +input first to YAML and then uses the YAML-parser, the conversion seems to +slow it down so much that it is only as fast as the `JSON::Pure::Parser`! + +If you look at the benchmark data you can see that this is mostly caused by +the frequent high outliers - the median of the Rails-parser runs is still +overall smaller than the median of the `JSON::Pure::Parser` runs: + +``` + Comparing times (call_time_median): + 1 ParserBenchmarkExt#parser 900 repeats: + 800.592479481 ( real) -> 26.936x + 0.001249075 + 2 ParserBenchmarkYAML#parser 1000 repeats: + 271.002390644 ( real) -> 9.118x + 0.003690004 + 3 ParserBenchmarkRails#parser 1000 repeats: + 30.227910865 ( real) -> 1.017x + 0.033082008 + 4 ParserBenchmarkPure#parser 1000 repeats: + 29.722384421 ( real) -> 1.000x + 0.033644676 + calls/sec ( time) -> speed covers + secs/call +``` + +I have benchmarked the `JSON-Generator` as well. This generated a few more +values, because there are different modes that also influence the achieved +speed: + +``` + Comparing times (call_time_mean): + 1 GeneratorBenchmarkExt#generator_fast 1000 repeats: + 547.354332608 ( real) -> 15.090x + 0.001826970 + 2 GeneratorBenchmarkExt#generator_safe 1000 repeats: + 443.968212317 ( real) -> 12.240x + 0.002252414 + 3 GeneratorBenchmarkExt#generator_pretty 900 repeats: + 375.104545883 ( real) -> 10.341x + 0.002665923 + 4 GeneratorBenchmarkPure#generator_fast 1000 repeats: + 49.978706968 ( real) -> 1.378x + 0.020008521 + 5 GeneratorBenchmarkRails#generator 1000 repeats: + 38.531868759 ( real) -> 1.062x + 0.025952543 + 6 GeneratorBenchmarkPure#generator_safe 1000 repeats: + 36.927649925 ( real) -> 1.018x 7 (>=3859) + 0.027079979 + 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats: + 36.272134441 ( real) -> 1.000x 6 (>=3859) + 0.027569373 + calls/sec ( time) -> speed covers + secs/call +``` + +In the table above 1-3 are `JSON::Ext::Generator` methods. 4, 6, and 7 are +`JSON::Pure::Generator` methods and 5 is the Rails JSON generator. It is now a +bit faster than the `generator_safe` and `generator_pretty` methods of the pure +variant but slower than the others. + +To achieve the fastest JSON document output, you can use the `fast_generate` +method. Beware, that this will disable the checking for circular Ruby data +structures, which may cause JSON to go into an infinite loop. + +Here are the median comparisons for completeness' sake: + +``` + Comparing times (call_time_median): + 1 GeneratorBenchmarkExt#generator_fast 1000 repeats: + 708.258020939 ( real) -> 16.547x + 0.001411915 + 2 GeneratorBenchmarkExt#generator_safe 1000 repeats: + 569.105020353 ( real) -> 13.296x + 0.001757145 + 3 GeneratorBenchmarkExt#generator_pretty 900 repeats: + 482.825371244 ( real) -> 11.280x + 0.002071142 + 4 GeneratorBenchmarkPure#generator_fast 1000 repeats: + 62.717626652 ( real) -> 1.465x + 0.015944481 + 5 GeneratorBenchmarkRails#generator 1000 repeats: + 43.965681162 ( real) -> 1.027x + 0.022745013 + 6 GeneratorBenchmarkPure#generator_safe 1000 repeats: + 43.929073409 ( real) -> 1.026x 7 (>=3859) + 0.022763968 + 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats: + 42.802514491 ( real) -> 1.000x 6 (>=3859) + 0.023363113 + calls/sec ( time) -> speed covers + secs/call +``` + +## Development + +### Release + +Update the json.gemspec and json-java.gemspec. + +``` +rbenv shell 2.6.5 +rake build +gem push pkg/json-2.3.0.gem + +rbenv shell jruby-9.2.9.0 +rake build +gem push pkg/json-2.3.0-java.gem +``` + +## Author + +Florian Frank + +## License + +Ruby License, see https://www.ruby-lang.org/en/about/license.txt. + +## Download + +The latest version of this library can be downloaded at + +* https://rubygems.org/gems/json + +Online Documentation should be located at + +* https://www.rubydoc.info/gems/json diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/VERSION b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/VERSION new file mode 100644 index 0000000..ec1cf33 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/VERSION @@ -0,0 +1 @@ +2.6.3 diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/Makefile b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/Makefile new file mode 100644 index 0000000..0cfb845 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/Makefile @@ -0,0 +1,203 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@ :) +ECHO = $(ECHO1:0=@ echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 +hdrdir = $(topdir) +arch_hdrdir = /opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/opt/hostedtoolcache/Ruby/2.7.7/x64 +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(prefix) +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(DESTDIR)./.gem.20221206-1722-34paq +sitelibdir = $(DESTDIR)./.gem.20221206-1722-34paq +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(datarootdir)/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(datarootdir)/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(prefix)/include +runstatedir = $(localstatedir)/run +localstatedir = $(prefix)/var +sharedstatedir = $(prefix)/com +sysconfdir = $(prefix)/etc +datadir = $(datarootdir) +datarootdir = $(prefix)/share +libexecdir = $(exec_prefix)/libexec +sbindir = $(exec_prefix)/sbin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC_WRAPPER = +CC = gcc +CXX = g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static $(MAINLIBS) +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) +CSRCFLAG = $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = +optflags = -O3 +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable +cppflags = +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -g -O2 -fPIC $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -g -O2 $(ARCH_FLAG) +ldflags = -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic +dldflags = -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,--compress-debug-sections=zlib +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CC) -shared +LDSHAREDXX = $(CXX) -shared +AR = ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 2.7.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = $(RUBY) -run -e rm -- -rf +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lm -lc +ORIG_SRCS = +SRCS = $(ORIG_SRCS) +OBJS = +HDRS = +LOCAL_HDRS = +TARGET = +TARGET_NAME = +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(rubyhdrdir)/ruby$(target_prefix) +ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix) +TARGET_SO_DIR = +TARGET_SO = $(TARGET_SO_DIR)$(DLLIB) +CLEANLIBS = +CLEANOBJS = *.o *.bak + +all: Makefile +static: $(STATIC_LIB) +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: Makefile +install-rb: pre-install-rb do-install-rb install-rb-default +install-rb-default: pre-install-rb-default do-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +do-install-rb: +do-install-rb-default: +pre-install-rb-default: + @$(NULLCMD) + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/fbuffer/fbuffer.h b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/fbuffer/fbuffer.h new file mode 100644 index 0000000..dc8f406 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/fbuffer/fbuffer.h @@ -0,0 +1,187 @@ + +#ifndef _FBUFFER_H_ +#define _FBUFFER_H_ + +#include "ruby.h" + +#ifndef RHASH_SIZE +#define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries) +#endif + +#ifndef RFLOAT_VALUE +#define RFLOAT_VALUE(val) (RFLOAT(val)->value) +#endif + +#ifndef RARRAY_LEN +#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len +#endif +#ifndef RSTRING_PTR +#define RSTRING_PTR(string) RSTRING(string)->ptr +#endif +#ifndef RSTRING_LEN +#define RSTRING_LEN(string) RSTRING(string)->len +#endif + +#ifdef PRIsVALUE +# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj) +# define RB_OBJ_STRING(obj) (obj) +#else +# define PRIsVALUE "s" +# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj) +# define RB_OBJ_STRING(obj) StringValueCStr(obj) +#endif + +#ifdef HAVE_RUBY_ENCODING_H +#include "ruby/encoding.h" +#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding()) +#else +#define FORCE_UTF8(obj) +#endif + +/* We don't need to guard objects for rbx, so let's do nothing at all. */ +#ifndef RB_GC_GUARD +#define RB_GC_GUARD(object) +#endif + +typedef struct FBufferStruct { + unsigned long initial_length; + char *ptr; + unsigned long len; + unsigned long capa; +} FBuffer; + +#define FBUFFER_INITIAL_LENGTH_DEFAULT 1024 + +#define FBUFFER_PTR(fb) (fb->ptr) +#define FBUFFER_LEN(fb) (fb->len) +#define FBUFFER_CAPA(fb) (fb->capa) +#define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb) + +static FBuffer *fbuffer_alloc(unsigned long initial_length); +static void fbuffer_free(FBuffer *fb); +static void fbuffer_clear(FBuffer *fb); +static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len); +#ifdef JSON_GENERATOR +static void fbuffer_append_long(FBuffer *fb, long number); +#endif +static void fbuffer_append_char(FBuffer *fb, char newchr); +#ifdef JSON_GENERATOR +static FBuffer *fbuffer_dup(FBuffer *fb); +static VALUE fbuffer_to_s(FBuffer *fb); +#endif + +static FBuffer *fbuffer_alloc(unsigned long initial_length) +{ + FBuffer *fb; + if (initial_length <= 0) initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT; + fb = ALLOC(FBuffer); + memset((void *) fb, 0, sizeof(FBuffer)); + fb->initial_length = initial_length; + return fb; +} + +static void fbuffer_free(FBuffer *fb) +{ + if (fb->ptr) ruby_xfree(fb->ptr); + ruby_xfree(fb); +} + +static void fbuffer_clear(FBuffer *fb) +{ + fb->len = 0; +} + +static void fbuffer_inc_capa(FBuffer *fb, unsigned long requested) +{ + unsigned long required; + + if (!fb->ptr) { + fb->ptr = ALLOC_N(char, fb->initial_length); + fb->capa = fb->initial_length; + } + + for (required = fb->capa; requested > required - fb->len; required <<= 1); + + if (required > fb->capa) { + REALLOC_N(fb->ptr, char, required); + fb->capa = required; + } +} + +static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len) +{ + if (len > 0) { + fbuffer_inc_capa(fb, len); + MEMCPY(fb->ptr + fb->len, newstr, char, len); + fb->len += len; + } +} + +#ifdef JSON_GENERATOR +static void fbuffer_append_str(FBuffer *fb, VALUE str) +{ + const char *newstr = StringValuePtr(str); + unsigned long len = RSTRING_LEN(str); + + RB_GC_GUARD(str); + + fbuffer_append(fb, newstr, len); +} +#endif + +static void fbuffer_append_char(FBuffer *fb, char newchr) +{ + fbuffer_inc_capa(fb, 1); + *(fb->ptr + fb->len) = newchr; + fb->len++; +} + +#ifdef JSON_GENERATOR +static void freverse(char *start, char *end) +{ + char c; + + while (end > start) { + c = *end, *end-- = *start, *start++ = c; + } +} + +static long fltoa(long number, char *buf) +{ + static char digits[] = "0123456789"; + long sign = number; + char* tmp = buf; + + if (sign < 0) number = -number; + do *tmp++ = digits[number % 10]; while (number /= 10); + if (sign < 0) *tmp++ = '-'; + freverse(buf, tmp - 1); + return tmp - buf; +} + +static void fbuffer_append_long(FBuffer *fb, long number) +{ + char buf[20]; + unsigned long len = fltoa(number, buf); + fbuffer_append(fb, buf, len); +} + +static FBuffer *fbuffer_dup(FBuffer *fb) +{ + unsigned long len = fb->len; + FBuffer *result; + + result = fbuffer_alloc(len); + fbuffer_append(result, FBUFFER_PAIR(fb)); + return result; +} + +static VALUE fbuffer_to_s(FBuffer *fb) +{ + VALUE result = rb_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb)); + fbuffer_free(fb); + FORCE_UTF8(result); + return result; +} +#endif +#endif diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/.sitearchdir.-.json.-.ext.time b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/.sitearchdir.-.json.-.ext.time new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/Makefile b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/Makefile new file mode 100644 index 0000000..b361731 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/Makefile @@ -0,0 +1,268 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@ :) +ECHO = $(ECHO1:0=@ echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 +hdrdir = $(topdir) +arch_hdrdir = /opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/opt/hostedtoolcache/Ruby/2.7.7/x64 +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(prefix) +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(DESTDIR)./.gem.20221206-1722-1uxqcka +sitelibdir = $(DESTDIR)./.gem.20221206-1722-1uxqcka +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(datarootdir)/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(datarootdir)/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(prefix)/include +runstatedir = $(localstatedir)/run +localstatedir = $(prefix)/var +sharedstatedir = $(prefix)/com +sysconfdir = $(prefix)/etc +datadir = $(datarootdir) +datarootdir = $(prefix)/share +libexecdir = $(exec_prefix)/libexec +sbindir = $(exec_prefix)/sbin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC_WRAPPER = +CC = gcc +CXX = g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static $(MAINLIBS) +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) +CSRCFLAG = $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = +optflags = -O3 +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable +cppflags = +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -g -O2 -fPIC $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -DJSON_GENERATOR -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -g -O2 $(ARCH_FLAG) +ldflags = -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic +dldflags = -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,--compress-debug-sections=zlib +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CC) -shared +LDSHAREDXX = $(CXX) -shared +AR = ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 2.7.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = $(RUBY) -run -e rm -- -rf +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = /json/ext +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lm -lc +ORIG_SRCS = generator.c +SRCS = $(ORIG_SRCS) +OBJS = generator.o +HDRS = $(srcdir)/generator.h +LOCAL_HDRS = +TARGET = generator +TARGET_NAME = generator +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = $(TARGET).so +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(rubyhdrdir)/ruby$(target_prefix) +ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix) +TARGET_SO_DIR = +TARGET_SO = $(TARGET_SO_DIR)$(DLLIB) +CLEANLIBS = $(TARGET_SO) +CLEANOBJS = *.o *.bak + +all: $(DLLIB) +static: $(STATIC_LIB) +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.-.json.-.ext.time + $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) +clean-static:: + -$(Q)$(RM) $(STATIC_LIB) +install-rb: pre-install-rb do-install-rb install-rb-default +install-rb-default: pre-install-rb-default do-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +do-install-rb: +do-install-rb-default: +pre-install-rb-default: + @$(NULLCMD) +$(TIMESTAMP_DIR)/.sitearchdir.-.json.-.ext.time: + $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) + $(Q) $(TOUCH) $@ + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + +.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S + +.cc.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cc.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.mm.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.mm.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cxx.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cxx.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cpp.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cpp.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.c.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.c.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.m.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.m.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +$(TARGET_SO): $(OBJS) Makefile + $(ECHO) linking shared-object json/ext/$(DLLIB) + -$(Q)$(RM) $(@) + $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) + + + +### +generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/depend b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/depend new file mode 100644 index 0000000..1a042a2 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/depend @@ -0,0 +1 @@ +generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/extconf.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/extconf.rb new file mode 100644 index 0000000..8627c5f --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/extconf.rb @@ -0,0 +1,4 @@ +require 'mkmf' + +$defs << "-DJSON_GENERATOR" +create_makefile 'json/ext/generator' diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.c b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.c new file mode 100644 index 0000000..98d0ea4 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.c @@ -0,0 +1,1608 @@ +#include "../fbuffer/fbuffer.h" +#include "generator.h" + +static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject, + mHash, mArray, +#ifdef RUBY_INTEGER_UNIFICATION + mInteger, +#else + mFixnum, mBignum, +#endif + mFloat, mString, mString_Extend, + mTrueClass, mFalseClass, mNilClass, eGeneratorError, + eNestingError; + +static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before, + i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only, + i_pack, i_unpack, i_create_id, i_extend, i_key_p, + i_aref, i_send, i_respond_to_p, i_match, i_keys, i_depth, + i_buffer_initial_length, i_dup, i_escape_slash; + +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* + * Index into the table below with the first byte of a UTF-8 sequence to + * get the number of trailing bytes that are supposed to follow it. + * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is + * left as-is for anyone who may want to do such conversion, which was + * allowed in earlier algorithms. + */ +static const char trailingBytesForUTF8[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 +}; + +/* + * Magic values subtracted from a buffer value during UTF8 conversion. + * This table contains as many values as there might be trailing bytes + * in a UTF-8 sequence. + */ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, + 0x03C82080UL, 0xFA082080UL, 0x82082080UL }; + +/* + * Utility routine to tell whether a sequence of bytes is legal UTF-8. + * This must be called with the length pre-determined by the first byte. + * If not calling this from ConvertUTF8to*, then the length can be set by: + * length = trailingBytesForUTF8[*source]+1; + * and the sequence is illegal right away if there aren't that many bytes + * available. + * If presented with a length > 4, this returns 0. The Unicode + * definition of UTF-8 goes up to 4-byte sequences. + */ +static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length) +{ + UTF8 a; + const UTF8 *srcptr = source+length; + switch (length) { + default: return 0; + /* Everything else falls through when "1"... */ + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0; + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0; + case 2: if ((a = (*--srcptr)) > 0xBF) return 0; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: if (a < 0xA0) return 0; break; + case 0xED: if (a > 0x9F) return 0; break; + case 0xF0: if (a < 0x90) return 0; break; + case 0xF4: if (a > 0x8F) return 0; break; + default: if (a < 0x80) return 0; + } + + case 1: if (*source >= 0x80 && *source < 0xC2) return 0; + } + if (*source > 0xF4) return 0; + return 1; +} + +/* Escapes the UTF16 character and stores the result in the buffer buf. */ +static void unicode_escape(char *buf, UTF16 character) +{ + const char *digits = "0123456789abcdef"; + + buf[2] = digits[character >> 12]; + buf[3] = digits[(character >> 8) & 0xf]; + buf[4] = digits[(character >> 4) & 0xf]; + buf[5] = digits[character & 0xf]; +} + +/* Escapes the UTF16 character and stores the result in the buffer buf, then + * the buffer buf is appended to the FBuffer buffer. */ +static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 + character) +{ + unicode_escape(buf, character); + fbuffer_append(buffer, buf, 6); +} + +/* Converts string to a JSON string in FBuffer buffer, where all but the ASCII + * and control characters are JSON escaped. */ +static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escape_slash) +{ + const UTF8 *source = (UTF8 *) RSTRING_PTR(string); + const UTF8 *sourceEnd = source + RSTRING_LEN(string); + char buf[6] = { '\\', 'u' }; + + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + rb_raise(rb_path2class("JSON::GeneratorError"), + "partial character in source, but hit end"); + } + if (!isLegalUTF8(source, extraBytesToRead+1)) { + rb_raise(rb_path2class("JSON::GeneratorError"), + "source sequence is illegal/malformed utf-8"); + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { +#if UNI_STRICT_CONVERSION + source -= (extraBytesToRead+1); /* return to the illegal value itself */ + rb_raise(rb_path2class("JSON::GeneratorError"), + "source sequence is illegal/malformed utf-8"); +#else + unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR); +#endif + } else { + /* normal case */ + if (ch >= 0x20 && ch <= 0x7f) { + switch (ch) { + case '\\': + fbuffer_append(buffer, "\\\\", 2); + break; + case '"': + fbuffer_append(buffer, "\\\"", 2); + break; + case '/': + if(escape_slash) { + fbuffer_append(buffer, "\\/", 2); + break; + } + default: + fbuffer_append_char(buffer, (char)ch); + break; + } + } else { + switch (ch) { + case '\n': + fbuffer_append(buffer, "\\n", 2); + break; + case '\r': + fbuffer_append(buffer, "\\r", 2); + break; + case '\t': + fbuffer_append(buffer, "\\t", 2); + break; + case '\f': + fbuffer_append(buffer, "\\f", 2); + break; + case '\b': + fbuffer_append(buffer, "\\b", 2); + break; + default: + unicode_escape_to_buffer(buffer, buf, (UTF16) ch); + break; + } + } + } + } else if (ch > UNI_MAX_UTF16) { +#if UNI_STRICT_CONVERSION + source -= (extraBytesToRead+1); /* return to the start */ + rb_raise(rb_path2class("JSON::GeneratorError"), + "source sequence is illegal/malformed utf8"); +#else + unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR); +#endif + } else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + ch -= halfBase; + unicode_escape_to_buffer(buffer, buf, (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START)); + unicode_escape_to_buffer(buffer, buf, (UTF16)((ch & halfMask) + UNI_SUR_LOW_START)); + } + } + RB_GC_GUARD(string); +} + +/* Converts string to a JSON string in FBuffer buffer, where only the + * characters required by the JSON standard are JSON escaped. The remaining + * characters (should be UTF8) are just passed through and appended to the + * result. */ +static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash) +{ + const char *ptr = RSTRING_PTR(string), *p; + unsigned long len = RSTRING_LEN(string), start = 0, end = 0; + const char *escape = NULL; + int escape_len; + unsigned char c; + char buf[6] = { '\\', 'u' }; + int ascii_only = rb_enc_str_asciionly_p(string); + + for (start = 0, end = 0; end < len;) { + p = ptr + end; + c = (unsigned char) *p; + if (c < 0x20) { + switch (c) { + case '\n': + escape = "\\n"; + escape_len = 2; + break; + case '\r': + escape = "\\r"; + escape_len = 2; + break; + case '\t': + escape = "\\t"; + escape_len = 2; + break; + case '\f': + escape = "\\f"; + escape_len = 2; + break; + case '\b': + escape = "\\b"; + escape_len = 2; + break; + default: + unicode_escape(buf, (UTF16) *p); + escape = buf; + escape_len = 6; + break; + } + } else { + switch (c) { + case '\\': + escape = "\\\\"; + escape_len = 2; + break; + case '"': + escape = "\\\""; + escape_len = 2; + break; + case '/': + if(escape_slash) { + escape = "\\/"; + escape_len = 2; + break; + } + default: + { + unsigned short clen = 1; + if (!ascii_only) { + clen += trailingBytesForUTF8[c]; + if (end + clen > len) { + rb_raise(rb_path2class("JSON::GeneratorError"), + "partial character in source, but hit end"); + } + if (!isLegalUTF8((UTF8 *) p, clen)) { + rb_raise(rb_path2class("JSON::GeneratorError"), + "source sequence is illegal/malformed utf-8"); + } + } + end += clen; + } + continue; + break; + } + } + fbuffer_append(buffer, ptr + start, end - start); + fbuffer_append(buffer, escape, escape_len); + start = ++end; + escape = NULL; + } + fbuffer_append(buffer, ptr + start, end - start); +} + +static char *fstrndup(const char *ptr, unsigned long len) { + char *result; + if (len <= 0) return NULL; + result = ALLOC_N(char, len); + memcpy(result, ptr, len); + return result; +} + +/* + * Document-module: JSON::Ext::Generator + * + * This is the JSON generator implemented as a C extension. It can be + * configured to be used by setting + * + * JSON.generator = JSON::Ext::Generator + * + * with the method generator= in JSON. + * + */ + +/* Explanation of the following: that's the only way to not pollute + * standard library's docs with GeneratorMethods:: which + * are uninformative and take a large place in a list of classes + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::Array + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::Bignum + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::FalseClass + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::Fixnum + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::Float + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::Hash + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::Integer + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::NilClass + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::Object + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::String + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::String::Extend + * :nodoc: + */ + +/* + * Document-module: JSON::Ext::Generator::GeneratorMethods::TrueClass + * :nodoc: + */ + +/* + * call-seq: to_json(state = nil) + * + * Returns a JSON string containing a JSON object, that is generated from + * this Hash instance. + * _state_ is a JSON::State object, that can also be used to configure the + * produced JSON string output further. + */ +static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(object); +} + +/* + * call-seq: to_json(state = nil) + * + * Returns a JSON string containing a JSON array, that is generated from + * this Array instance. + * _state_ is a JSON::State object, that can also be used to configure the + * produced JSON string output further. + */ +static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) { + GENERATE_JSON(array); +} + +#ifdef RUBY_INTEGER_UNIFICATION +/* + * call-seq: to_json(*) + * + * Returns a JSON string representation for this Integer number. + */ +static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(integer); +} + +#else +/* + * call-seq: to_json(*) + * + * Returns a JSON string representation for this Integer number. + */ +static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(fixnum); +} + +/* + * call-seq: to_json(*) + * + * Returns a JSON string representation for this Integer number. + */ +static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(bignum); +} +#endif + +/* + * call-seq: to_json(*) + * + * Returns a JSON string representation for this Float number. + */ +static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(float); +} + +/* + * call-seq: String.included(modul) + * + * Extends _modul_ with the String::Extend module. + */ +static VALUE mString_included_s(VALUE self, VALUE modul) { + VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend); + return result; +} + +/* + * call-seq: to_json(*) + * + * This string should be encoded with UTF-8 A call to this method + * returns a JSON string encoded with UTF16 big endian characters as + * \u????. + */ +static VALUE mString_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(string); +} + +/* + * call-seq: to_json_raw_object() + * + * This method creates a raw object hash, that can be nested into + * other data structures and will be generated as a raw string. This + * method should be used, if you want to convert raw strings to JSON + * instead of UTF-8 strings, e. g. binary data. + */ +static VALUE mString_to_json_raw_object(VALUE self) +{ + VALUE ary; + VALUE result = rb_hash_new(); + rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self))); + ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*")); + rb_hash_aset(result, rb_str_new2("raw"), ary); + return result; +} + +/* + * call-seq: to_json_raw(*args) + * + * This method creates a JSON text from the result of a call to + * to_json_raw_object of this String. + */ +static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self) +{ + VALUE obj = mString_to_json_raw_object(self); + Check_Type(obj, T_HASH); + return mHash_to_json(argc, argv, obj); +} + +/* + * call-seq: json_create(o) + * + * Raw Strings are JSON Objects (the raw bytes are stored in an array for the + * key "raw"). The Ruby String can be created by this module method. + */ +static VALUE mString_Extend_json_create(VALUE self, VALUE o) +{ + VALUE ary; + Check_Type(o, T_HASH); + ary = rb_hash_aref(o, rb_str_new2("raw")); + return rb_funcall(ary, i_pack, 1, rb_str_new2("C*")); +} + +/* + * call-seq: to_json(*) + * + * Returns a JSON string for true: 'true'. + */ +static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(true); +} + +/* + * call-seq: to_json(*) + * + * Returns a JSON string for false: 'false'. + */ +static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(false); +} + +/* + * call-seq: to_json(*) + * + * Returns a JSON string for nil: 'null'. + */ +static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self) +{ + GENERATE_JSON(null); +} + +/* + * call-seq: to_json(*) + * + * Converts this object to a string (calling #to_s), converts + * it to a JSON string, and returns the result. This is a fallback, if no + * special method #to_json was defined for some object. + */ +static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self) +{ + VALUE state; + VALUE string = rb_funcall(self, i_to_s, 0); + rb_scan_args(argc, argv, "01", &state); + Check_Type(string, T_STRING); + state = cState_from_state_s(cState, state); + return cState_partial_generate(state, string); +} + +static void State_free(void *ptr) +{ + JSON_Generator_State *state = ptr; + if (state->indent) ruby_xfree(state->indent); + if (state->space) ruby_xfree(state->space); + if (state->space_before) ruby_xfree(state->space_before); + if (state->object_nl) ruby_xfree(state->object_nl); + if (state->array_nl) ruby_xfree(state->array_nl); + if (state->array_delim) fbuffer_free(state->array_delim); + if (state->object_delim) fbuffer_free(state->object_delim); + if (state->object_delim2) fbuffer_free(state->object_delim2); + ruby_xfree(state); +} + +static size_t State_memsize(const void *ptr) +{ + const JSON_Generator_State *state = ptr; + size_t size = sizeof(*state); + if (state->indent) size += state->indent_len + 1; + if (state->space) size += state->space_len + 1; + if (state->space_before) size += state->space_before_len + 1; + if (state->object_nl) size += state->object_nl_len + 1; + if (state->array_nl) size += state->array_nl_len + 1; + if (state->array_delim) size += FBUFFER_CAPA(state->array_delim); + if (state->object_delim) size += FBUFFER_CAPA(state->object_delim); + if (state->object_delim2) size += FBUFFER_CAPA(state->object_delim2); + return size; +} + +#ifndef HAVE_RB_EXT_RACTOR_SAFE +# undef RUBY_TYPED_FROZEN_SHAREABLE +# define RUBY_TYPED_FROZEN_SHAREABLE 0 +#endif + +#ifdef NEW_TYPEDDATA_WRAPPER +static const rb_data_type_t JSON_Generator_State_type = { + "JSON/Generator/State", + {NULL, State_free, State_memsize,}, +#ifdef RUBY_TYPED_FREE_IMMEDIATELY + 0, 0, + RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE, +#endif +}; +#endif + +static VALUE cState_s_allocate(VALUE klass) +{ + JSON_Generator_State *state; + return TypedData_Make_Struct(klass, JSON_Generator_State, + &JSON_Generator_State_type, state); +} + +/* + * call-seq: configure(opts) + * + * Configure this State instance with the Hash _opts_, and return + * itself. + */ +static VALUE cState_configure(VALUE self, VALUE opts) +{ + VALUE tmp; + GET_STATE(self); + tmp = rb_check_convert_type(opts, T_HASH, "Hash", "to_hash"); + if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h"); + opts = tmp; + tmp = rb_hash_aref(opts, ID2SYM(i_indent)); + if (RTEST(tmp)) { + unsigned long len; + Check_Type(tmp, T_STRING); + len = RSTRING_LEN(tmp); + state->indent = fstrndup(RSTRING_PTR(tmp), len + 1); + state->indent_len = len; + } + tmp = rb_hash_aref(opts, ID2SYM(i_space)); + if (RTEST(tmp)) { + unsigned long len; + Check_Type(tmp, T_STRING); + len = RSTRING_LEN(tmp); + state->space = fstrndup(RSTRING_PTR(tmp), len + 1); + state->space_len = len; + } + tmp = rb_hash_aref(opts, ID2SYM(i_space_before)); + if (RTEST(tmp)) { + unsigned long len; + Check_Type(tmp, T_STRING); + len = RSTRING_LEN(tmp); + state->space_before = fstrndup(RSTRING_PTR(tmp), len + 1); + state->space_before_len = len; + } + tmp = rb_hash_aref(opts, ID2SYM(i_array_nl)); + if (RTEST(tmp)) { + unsigned long len; + Check_Type(tmp, T_STRING); + len = RSTRING_LEN(tmp); + state->array_nl = fstrndup(RSTRING_PTR(tmp), len + 1); + state->array_nl_len = len; + } + tmp = rb_hash_aref(opts, ID2SYM(i_object_nl)); + if (RTEST(tmp)) { + unsigned long len; + Check_Type(tmp, T_STRING); + len = RSTRING_LEN(tmp); + state->object_nl = fstrndup(RSTRING_PTR(tmp), len + 1); + state->object_nl_len = len; + } + tmp = ID2SYM(i_max_nesting); + state->max_nesting = 100; + if (option_given_p(opts, tmp)) { + VALUE max_nesting = rb_hash_aref(opts, tmp); + if (RTEST(max_nesting)) { + Check_Type(max_nesting, T_FIXNUM); + state->max_nesting = FIX2LONG(max_nesting); + } else { + state->max_nesting = 0; + } + } + tmp = ID2SYM(i_depth); + state->depth = 0; + if (option_given_p(opts, tmp)) { + VALUE depth = rb_hash_aref(opts, tmp); + if (RTEST(depth)) { + Check_Type(depth, T_FIXNUM); + state->depth = FIX2LONG(depth); + } else { + state->depth = 0; + } + } + tmp = ID2SYM(i_buffer_initial_length); + if (option_given_p(opts, tmp)) { + VALUE buffer_initial_length = rb_hash_aref(opts, tmp); + if (RTEST(buffer_initial_length)) { + long initial_length; + Check_Type(buffer_initial_length, T_FIXNUM); + initial_length = FIX2LONG(buffer_initial_length); + if (initial_length > 0) state->buffer_initial_length = initial_length; + } + } + tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan)); + state->allow_nan = RTEST(tmp); + tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only)); + state->ascii_only = RTEST(tmp); + tmp = rb_hash_aref(opts, ID2SYM(i_escape_slash)); + state->escape_slash = RTEST(tmp); + return self; +} + +static void set_state_ivars(VALUE hash, VALUE state) +{ + VALUE ivars = rb_obj_instance_variables(state); + int i = 0; + for (i = 0; i < RARRAY_LEN(ivars); i++) { + VALUE key = rb_funcall(rb_ary_entry(ivars, i), i_to_s, 0); + long key_len = RSTRING_LEN(key); + VALUE value = rb_iv_get(state, StringValueCStr(key)); + rb_hash_aset(hash, rb_str_intern(rb_str_substr(key, 1, key_len - 1)), value); + } +} + +/* + * call-seq: to_h + * + * Returns the configuration instance variables as a hash, that can be + * passed to the configure method. + */ +static VALUE cState_to_h(VALUE self) +{ + VALUE result = rb_hash_new(); + GET_STATE(self); + set_state_ivars(result, self); + rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state->indent, state->indent_len)); + rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state->space, state->space_len)); + rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state->space_before, state->space_before_len)); + rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state->object_nl, state->object_nl_len)); + rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len)); + rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse); + rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse); + rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting)); + rb_hash_aset(result, ID2SYM(i_escape_slash), state->escape_slash ? Qtrue : Qfalse); + rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth)); + rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length)); + return result; +} + +/* +* call-seq: [](name) +* +* Returns the value returned by method +name+. +*/ +static VALUE cState_aref(VALUE self, VALUE name) +{ + name = rb_funcall(name, i_to_s, 0); + if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) { + return rb_funcall(self, i_send, 1, name); + } else { + return rb_attr_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name))); + } +} + +/* +* call-seq: []=(name, value) +* +* Sets the attribute name to value. +*/ +static VALUE cState_aset(VALUE self, VALUE name, VALUE value) +{ + VALUE name_writer; + + name = rb_funcall(name, i_to_s, 0); + name_writer = rb_str_cat2(rb_str_dup(name), "="); + if (RTEST(rb_funcall(self, i_respond_to_p, 1, name_writer))) { + return rb_funcall(self, i_send, 2, name_writer, value); + } else { + rb_ivar_set(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)), value); + } + return Qnil; +} + +struct hash_foreach_arg { + FBuffer *buffer; + JSON_Generator_State *state; + VALUE Vstate; + int iter; +}; + +static int +json_object_i(VALUE key, VALUE val, VALUE _arg) +{ + struct hash_foreach_arg *arg = (struct hash_foreach_arg *)_arg; + FBuffer *buffer = arg->buffer; + JSON_Generator_State *state = arg->state; + VALUE Vstate = arg->Vstate; + + char *object_nl = state->object_nl; + long object_nl_len = state->object_nl_len; + char *indent = state->indent; + long indent_len = state->indent_len; + char *delim = FBUFFER_PTR(state->object_delim); + long delim_len = FBUFFER_LEN(state->object_delim); + char *delim2 = FBUFFER_PTR(state->object_delim2); + long delim2_len = FBUFFER_LEN(state->object_delim2); + long depth = state->depth; + int j; + VALUE klass, key_to_s; + + if (arg->iter > 0) fbuffer_append(buffer, delim, delim_len); + if (object_nl) { + fbuffer_append(buffer, object_nl, object_nl_len); + } + if (indent) { + for (j = 0; j < depth; j++) { + fbuffer_append(buffer, indent, indent_len); + } + } + + klass = CLASS_OF(key); + if (klass == rb_cString) { + key_to_s = key; + } else if (klass == rb_cSymbol) { + key_to_s = rb_id2str(SYM2ID(key)); + } else { + key_to_s = rb_funcall(key, i_to_s, 0); + } + Check_Type(key_to_s, T_STRING); + generate_json(buffer, Vstate, state, key_to_s); + fbuffer_append(buffer, delim2, delim2_len); + generate_json(buffer, Vstate, state, val); + + arg->iter++; + return ST_CONTINUE; +} + +static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + char *object_nl = state->object_nl; + long object_nl_len = state->object_nl_len; + char *indent = state->indent; + long indent_len = state->indent_len; + long max_nesting = state->max_nesting; + long depth = ++state->depth; + int j; + struct hash_foreach_arg arg; + + if (max_nesting != 0 && depth > max_nesting) { + fbuffer_free(buffer); + rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth); + } + fbuffer_append_char(buffer, '{'); + + arg.buffer = buffer; + arg.state = state; + arg.Vstate = Vstate; + arg.iter = 0; + rb_hash_foreach(obj, json_object_i, (VALUE)&arg); + + depth = --state->depth; + if (object_nl) { + fbuffer_append(buffer, object_nl, object_nl_len); + if (indent) { + for (j = 0; j < depth; j++) { + fbuffer_append(buffer, indent, indent_len); + } + } + } + fbuffer_append_char(buffer, '}'); +} + +static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + char *array_nl = state->array_nl; + long array_nl_len = state->array_nl_len; + char *indent = state->indent; + long indent_len = state->indent_len; + long max_nesting = state->max_nesting; + char *delim = FBUFFER_PTR(state->array_delim); + long delim_len = FBUFFER_LEN(state->array_delim); + long depth = ++state->depth; + int i, j; + if (max_nesting != 0 && depth > max_nesting) { + fbuffer_free(buffer); + rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth); + } + fbuffer_append_char(buffer, '['); + if (array_nl) fbuffer_append(buffer, array_nl, array_nl_len); + for(i = 0; i < RARRAY_LEN(obj); i++) { + if (i > 0) fbuffer_append(buffer, delim, delim_len); + if (indent) { + for (j = 0; j < depth; j++) { + fbuffer_append(buffer, indent, indent_len); + } + } + generate_json(buffer, Vstate, state, rb_ary_entry(obj, i)); + } + state->depth = --depth; + if (array_nl) { + fbuffer_append(buffer, array_nl, array_nl_len); + if (indent) { + for (j = 0; j < depth; j++) { + fbuffer_append(buffer, indent, indent_len); + } + } + } + fbuffer_append_char(buffer, ']'); +} + +#ifdef HAVE_RUBY_ENCODING_H +static int enc_utf8_compatible_p(rb_encoding *enc) +{ + if (enc == rb_usascii_encoding()) return 1; + if (enc == rb_utf8_encoding()) return 1; + return 0; +} +#endif + +static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + fbuffer_append_char(buffer, '"'); +#ifdef HAVE_RUBY_ENCODING_H + if (!enc_utf8_compatible_p(rb_enc_get(obj))) { + obj = rb_str_export_to_enc(obj, rb_utf8_encoding()); + } +#endif + if (state->ascii_only) { + convert_UTF8_to_JSON_ASCII(buffer, obj, state->escape_slash); + } else { + convert_UTF8_to_JSON(buffer, obj, state->escape_slash); + } + fbuffer_append_char(buffer, '"'); +} + +static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + fbuffer_append(buffer, "null", 4); +} + +static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + fbuffer_append(buffer, "false", 5); +} + +static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + fbuffer_append(buffer, "true", 4); +} + +static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + fbuffer_append_long(buffer, FIX2LONG(obj)); +} + +static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + VALUE tmp = rb_funcall(obj, i_to_s, 0); + fbuffer_append_str(buffer, tmp); +} + +#ifdef RUBY_INTEGER_UNIFICATION +static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + if (FIXNUM_P(obj)) + generate_json_fixnum(buffer, Vstate, state, obj); + else + generate_json_bignum(buffer, Vstate, state, obj); +} +#endif +static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + double value = RFLOAT_VALUE(obj); + char allow_nan = state->allow_nan; + VALUE tmp = rb_funcall(obj, i_to_s, 0); + if (!allow_nan) { + if (isinf(value)) { + fbuffer_free(buffer); + rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp)); + } else if (isnan(value)) { + fbuffer_free(buffer); + rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp)); + } + } + fbuffer_append_str(buffer, tmp); +} + +static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj) +{ + VALUE tmp; + VALUE klass = CLASS_OF(obj); + if (klass == rb_cHash) { + generate_json_object(buffer, Vstate, state, obj); + } else if (klass == rb_cArray) { + generate_json_array(buffer, Vstate, state, obj); + } else if (klass == rb_cString) { + generate_json_string(buffer, Vstate, state, obj); + } else if (obj == Qnil) { + generate_json_null(buffer, Vstate, state, obj); + } else if (obj == Qfalse) { + generate_json_false(buffer, Vstate, state, obj); + } else if (obj == Qtrue) { + generate_json_true(buffer, Vstate, state, obj); + } else if (FIXNUM_P(obj)) { + generate_json_fixnum(buffer, Vstate, state, obj); + } else if (RB_TYPE_P(obj, T_BIGNUM)) { + generate_json_bignum(buffer, Vstate, state, obj); + } else if (klass == rb_cFloat) { + generate_json_float(buffer, Vstate, state, obj); + } else if (rb_respond_to(obj, i_to_json)) { + tmp = rb_funcall(obj, i_to_json, 1, Vstate); + Check_Type(tmp, T_STRING); + fbuffer_append_str(buffer, tmp); + } else { + tmp = rb_funcall(obj, i_to_s, 0); + Check_Type(tmp, T_STRING); + generate_json_string(buffer, Vstate, state, tmp); + } +} + +static FBuffer *cState_prepare_buffer(VALUE self) +{ + FBuffer *buffer; + GET_STATE(self); + buffer = fbuffer_alloc(state->buffer_initial_length); + + if (state->object_delim) { + fbuffer_clear(state->object_delim); + } else { + state->object_delim = fbuffer_alloc(16); + } + fbuffer_append_char(state->object_delim, ','); + if (state->object_delim2) { + fbuffer_clear(state->object_delim2); + } else { + state->object_delim2 = fbuffer_alloc(16); + } + if (state->space_before) fbuffer_append(state->object_delim2, state->space_before, state->space_before_len); + fbuffer_append_char(state->object_delim2, ':'); + if (state->space) fbuffer_append(state->object_delim2, state->space, state->space_len); + + if (state->array_delim) { + fbuffer_clear(state->array_delim); + } else { + state->array_delim = fbuffer_alloc(16); + } + fbuffer_append_char(state->array_delim, ','); + if (state->array_nl) fbuffer_append(state->array_delim, state->array_nl, state->array_nl_len); + return buffer; +} + +static VALUE cState_partial_generate(VALUE self, VALUE obj) +{ + FBuffer *buffer = cState_prepare_buffer(self); + GET_STATE(self); + generate_json(buffer, self, state, obj); + return fbuffer_to_s(buffer); +} + +/* + * call-seq: generate(obj) + * + * Generates a valid JSON document from object +obj+ and returns the + * result. If no valid JSON document can be created this method raises a + * GeneratorError exception. + */ +static VALUE cState_generate(VALUE self, VALUE obj) +{ + VALUE result = cState_partial_generate(self, obj); + GET_STATE(self); + (void)state; + return result; +} + +/* + * call-seq: new(opts = {}) + * + * Instantiates a new State object, configured by _opts_. + * + * _opts_ can have the following keys: + * + * * *indent*: a string used to indent levels (default: ''), + * * *space*: a string that is put after, a : or , delimiter (default: ''), + * * *space_before*: a string that is put before a : pair delimiter (default: ''), + * * *object_nl*: a string that is put at the end of a JSON object (default: ''), + * * *array_nl*: a string that is put at the end of a JSON array (default: ''), + * * *allow_nan*: true if NaN, Infinity, and -Infinity should be + * generated, otherwise an exception is thrown, if these values are + * encountered. This options defaults to false. + * * *ascii_only*: true if only ASCII characters should be generated. This + * option defaults to false. + * * *buffer_initial_length*: sets the initial length of the generator's + * internal buffer. + */ +static VALUE cState_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE opts; + GET_STATE(self); + state->max_nesting = 100; + state->buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT; + rb_scan_args(argc, argv, "01", &opts); + if (!NIL_P(opts)) cState_configure(self, opts); + return self; +} + +/* + * call-seq: initialize_copy(orig) + * + * Initializes this object from orig if it can be duplicated/cloned and returns + * it. +*/ +static VALUE cState_init_copy(VALUE obj, VALUE orig) +{ + JSON_Generator_State *objState, *origState; + + if (obj == orig) return obj; + GET_STATE_TO(obj, objState); + GET_STATE_TO(orig, origState); + if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State"); + + MEMCPY(objState, origState, JSON_Generator_State, 1); + objState->indent = fstrndup(origState->indent, origState->indent_len); + objState->space = fstrndup(origState->space, origState->space_len); + objState->space_before = fstrndup(origState->space_before, origState->space_before_len); + objState->object_nl = fstrndup(origState->object_nl, origState->object_nl_len); + objState->array_nl = fstrndup(origState->array_nl, origState->array_nl_len); + if (origState->array_delim) objState->array_delim = fbuffer_dup(origState->array_delim); + if (origState->object_delim) objState->object_delim = fbuffer_dup(origState->object_delim); + if (origState->object_delim2) objState->object_delim2 = fbuffer_dup(origState->object_delim2); + return obj; +} + +/* + * call-seq: from_state(opts) + * + * Creates a State object from _opts_, which ought to be Hash to create a + * new State instance configured by _opts_, something else to create an + * unconfigured instance. If _opts_ is a State object, it is just returned. + */ +static VALUE cState_from_state_s(VALUE self, VALUE opts) +{ + if (rb_obj_is_kind_of(opts, self)) { + return opts; + } else if (rb_obj_is_kind_of(opts, rb_cHash)) { + return rb_funcall(self, i_new, 1, opts); + } else { + return rb_class_new_instance(0, NULL, cState); + } +} + +/* + * call-seq: indent() + * + * Returns the string that is used to indent levels in the JSON text. + */ +static VALUE cState_indent(VALUE self) +{ + GET_STATE(self); + return state->indent ? rb_str_new(state->indent, state->indent_len) : rb_str_new2(""); +} + +/* + * call-seq: indent=(indent) + * + * Sets the string that is used to indent levels in the JSON text. + */ +static VALUE cState_indent_set(VALUE self, VALUE indent) +{ + unsigned long len; + GET_STATE(self); + Check_Type(indent, T_STRING); + len = RSTRING_LEN(indent); + if (len == 0) { + if (state->indent) { + ruby_xfree(state->indent); + state->indent = NULL; + state->indent_len = 0; + } + } else { + if (state->indent) ruby_xfree(state->indent); + state->indent = fstrndup(RSTRING_PTR(indent), len); + state->indent_len = len; + } + return Qnil; +} + +/* + * call-seq: space() + * + * Returns the string that is used to insert a space between the tokens in a JSON + * string. + */ +static VALUE cState_space(VALUE self) +{ + GET_STATE(self); + return state->space ? rb_str_new(state->space, state->space_len) : rb_str_new2(""); +} + +/* + * call-seq: space=(space) + * + * Sets _space_ to the string that is used to insert a space between the tokens in a JSON + * string. + */ +static VALUE cState_space_set(VALUE self, VALUE space) +{ + unsigned long len; + GET_STATE(self); + Check_Type(space, T_STRING); + len = RSTRING_LEN(space); + if (len == 0) { + if (state->space) { + ruby_xfree(state->space); + state->space = NULL; + state->space_len = 0; + } + } else { + if (state->space) ruby_xfree(state->space); + state->space = fstrndup(RSTRING_PTR(space), len); + state->space_len = len; + } + return Qnil; +} + +/* + * call-seq: space_before() + * + * Returns the string that is used to insert a space before the ':' in JSON objects. + */ +static VALUE cState_space_before(VALUE self) +{ + GET_STATE(self); + return state->space_before ? rb_str_new(state->space_before, state->space_before_len) : rb_str_new2(""); +} + +/* + * call-seq: space_before=(space_before) + * + * Sets the string that is used to insert a space before the ':' in JSON objects. + */ +static VALUE cState_space_before_set(VALUE self, VALUE space_before) +{ + unsigned long len; + GET_STATE(self); + Check_Type(space_before, T_STRING); + len = RSTRING_LEN(space_before); + if (len == 0) { + if (state->space_before) { + ruby_xfree(state->space_before); + state->space_before = NULL; + state->space_before_len = 0; + } + } else { + if (state->space_before) ruby_xfree(state->space_before); + state->space_before = fstrndup(RSTRING_PTR(space_before), len); + state->space_before_len = len; + } + return Qnil; +} + +/* + * call-seq: object_nl() + * + * This string is put at the end of a line that holds a JSON object (or + * Hash). + */ +static VALUE cState_object_nl(VALUE self) +{ + GET_STATE(self); + return state->object_nl ? rb_str_new(state->object_nl, state->object_nl_len) : rb_str_new2(""); +} + +/* + * call-seq: object_nl=(object_nl) + * + * This string is put at the end of a line that holds a JSON object (or + * Hash). + */ +static VALUE cState_object_nl_set(VALUE self, VALUE object_nl) +{ + unsigned long len; + GET_STATE(self); + Check_Type(object_nl, T_STRING); + len = RSTRING_LEN(object_nl); + if (len == 0) { + if (state->object_nl) { + ruby_xfree(state->object_nl); + state->object_nl = NULL; + } + } else { + if (state->object_nl) ruby_xfree(state->object_nl); + state->object_nl = fstrndup(RSTRING_PTR(object_nl), len); + state->object_nl_len = len; + } + return Qnil; +} + +/* + * call-seq: array_nl() + * + * This string is put at the end of a line that holds a JSON array. + */ +static VALUE cState_array_nl(VALUE self) +{ + GET_STATE(self); + return state->array_nl ? rb_str_new(state->array_nl, state->array_nl_len) : rb_str_new2(""); +} + +/* + * call-seq: array_nl=(array_nl) + * + * This string is put at the end of a line that holds a JSON array. + */ +static VALUE cState_array_nl_set(VALUE self, VALUE array_nl) +{ + unsigned long len; + GET_STATE(self); + Check_Type(array_nl, T_STRING); + len = RSTRING_LEN(array_nl); + if (len == 0) { + if (state->array_nl) { + ruby_xfree(state->array_nl); + state->array_nl = NULL; + } + } else { + if (state->array_nl) ruby_xfree(state->array_nl); + state->array_nl = fstrndup(RSTRING_PTR(array_nl), len); + state->array_nl_len = len; + } + return Qnil; +} + + +/* +* call-seq: check_circular? +* +* Returns true, if circular data structures should be checked, +* otherwise returns false. +*/ +static VALUE cState_check_circular_p(VALUE self) +{ + GET_STATE(self); + return state->max_nesting ? Qtrue : Qfalse; +} + +/* + * call-seq: max_nesting + * + * This integer returns the maximum level of data structure nesting in + * the generated JSON, max_nesting = 0 if no maximum is checked. + */ +static VALUE cState_max_nesting(VALUE self) +{ + GET_STATE(self); + return LONG2FIX(state->max_nesting); +} + +/* + * call-seq: max_nesting=(depth) + * + * This sets the maximum level of data structure nesting in the generated JSON + * to the integer depth, max_nesting = 0 if no maximum should be checked. + */ +static VALUE cState_max_nesting_set(VALUE self, VALUE depth) +{ + GET_STATE(self); + Check_Type(depth, T_FIXNUM); + return state->max_nesting = FIX2LONG(depth); +} + +/* + * call-seq: escape_slash + * + * If this boolean is true, the forward slashes will be escaped in + * the json output. + */ +static VALUE cState_escape_slash(VALUE self) +{ + GET_STATE(self); + return state->escape_slash ? Qtrue : Qfalse; +} + +/* + * call-seq: escape_slash=(depth) + * + * This sets whether or not the forward slashes will be escaped in + * the json output. + */ +static VALUE cState_escape_slash_set(VALUE self, VALUE enable) +{ + GET_STATE(self); + state->escape_slash = RTEST(enable); + return Qnil; +} + +/* + * call-seq: allow_nan? + * + * Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise + * returns false. + */ +static VALUE cState_allow_nan_p(VALUE self) +{ + GET_STATE(self); + return state->allow_nan ? Qtrue : Qfalse; +} + +/* + * call-seq: ascii_only? + * + * Returns true, if only ASCII characters should be generated. Otherwise + * returns false. + */ +static VALUE cState_ascii_only_p(VALUE self) +{ + GET_STATE(self); + return state->ascii_only ? Qtrue : Qfalse; +} + +/* + * call-seq: depth + * + * This integer returns the current depth of data structure nesting. + */ +static VALUE cState_depth(VALUE self) +{ + GET_STATE(self); + return LONG2FIX(state->depth); +} + +/* + * call-seq: depth=(depth) + * + * This sets the maximum level of data structure nesting in the generated JSON + * to the integer depth, max_nesting = 0 if no maximum should be checked. + */ +static VALUE cState_depth_set(VALUE self, VALUE depth) +{ + GET_STATE(self); + Check_Type(depth, T_FIXNUM); + state->depth = FIX2LONG(depth); + return Qnil; +} + +/* + * call-seq: buffer_initial_length + * + * This integer returns the current initial length of the buffer. + */ +static VALUE cState_buffer_initial_length(VALUE self) +{ + GET_STATE(self); + return LONG2FIX(state->buffer_initial_length); +} + +/* + * call-seq: buffer_initial_length=(length) + * + * This sets the initial length of the buffer to +length+, if +length+ > 0, + * otherwise its value isn't changed. + */ +static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_length) +{ + long initial_length; + GET_STATE(self); + Check_Type(buffer_initial_length, T_FIXNUM); + initial_length = FIX2LONG(buffer_initial_length); + if (initial_length > 0) { + state->buffer_initial_length = initial_length; + } + return Qnil; +} + +/* + * + */ +void Init_generator(void) +{ +#ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); +#endif + +#undef rb_intern + rb_require("json/common"); + + mJSON = rb_define_module("JSON"); + mExt = rb_define_module_under(mJSON, "Ext"); + mGenerator = rb_define_module_under(mExt, "Generator"); + + eGeneratorError = rb_path2class("JSON::GeneratorError"); + eNestingError = rb_path2class("JSON::NestingError"); + rb_gc_register_mark_object(eGeneratorError); + rb_gc_register_mark_object(eNestingError); + + cState = rb_define_class_under(mGenerator, "State", rb_cObject); + rb_define_alloc_func(cState, cState_s_allocate); + rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1); + rb_define_method(cState, "initialize", cState_initialize, -1); + rb_define_method(cState, "initialize_copy", cState_init_copy, 1); + rb_define_method(cState, "indent", cState_indent, 0); + rb_define_method(cState, "indent=", cState_indent_set, 1); + rb_define_method(cState, "space", cState_space, 0); + rb_define_method(cState, "space=", cState_space_set, 1); + rb_define_method(cState, "space_before", cState_space_before, 0); + rb_define_method(cState, "space_before=", cState_space_before_set, 1); + rb_define_method(cState, "object_nl", cState_object_nl, 0); + rb_define_method(cState, "object_nl=", cState_object_nl_set, 1); + rb_define_method(cState, "array_nl", cState_array_nl, 0); + rb_define_method(cState, "array_nl=", cState_array_nl_set, 1); + rb_define_method(cState, "max_nesting", cState_max_nesting, 0); + rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1); + rb_define_method(cState, "escape_slash", cState_escape_slash, 0); + rb_define_method(cState, "escape_slash?", cState_escape_slash, 0); + rb_define_method(cState, "escape_slash=", cState_escape_slash_set, 1); + rb_define_method(cState, "check_circular?", cState_check_circular_p, 0); + rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0); + rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0); + rb_define_method(cState, "depth", cState_depth, 0); + rb_define_method(cState, "depth=", cState_depth_set, 1); + rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0); + rb_define_method(cState, "buffer_initial_length=", cState_buffer_initial_length_set, 1); + rb_define_method(cState, "configure", cState_configure, 1); + rb_define_alias(cState, "merge", "configure"); + rb_define_method(cState, "to_h", cState_to_h, 0); + rb_define_alias(cState, "to_hash", "to_h"); + rb_define_method(cState, "[]", cState_aref, 1); + rb_define_method(cState, "[]=", cState_aset, 2); + rb_define_method(cState, "generate", cState_generate, 1); + + mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods"); + mObject = rb_define_module_under(mGeneratorMethods, "Object"); + rb_define_method(mObject, "to_json", mObject_to_json, -1); + mHash = rb_define_module_under(mGeneratorMethods, "Hash"); + rb_define_method(mHash, "to_json", mHash_to_json, -1); + mArray = rb_define_module_under(mGeneratorMethods, "Array"); + rb_define_method(mArray, "to_json", mArray_to_json, -1); +#ifdef RUBY_INTEGER_UNIFICATION + mInteger = rb_define_module_under(mGeneratorMethods, "Integer"); + rb_define_method(mInteger, "to_json", mInteger_to_json, -1); +#else + mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum"); + rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1); + mBignum = rb_define_module_under(mGeneratorMethods, "Bignum"); + rb_define_method(mBignum, "to_json", mBignum_to_json, -1); +#endif + mFloat = rb_define_module_under(mGeneratorMethods, "Float"); + rb_define_method(mFloat, "to_json", mFloat_to_json, -1); + mString = rb_define_module_under(mGeneratorMethods, "String"); + rb_define_singleton_method(mString, "included", mString_included_s, 1); + rb_define_method(mString, "to_json", mString_to_json, -1); + rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1); + rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0); + mString_Extend = rb_define_module_under(mString, "Extend"); + rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1); + mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass"); + rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1); + mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass"); + rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1); + mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass"); + rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1); + + i_to_s = rb_intern("to_s"); + i_to_json = rb_intern("to_json"); + i_new = rb_intern("new"); + i_indent = rb_intern("indent"); + i_space = rb_intern("space"); + i_space_before = rb_intern("space_before"); + i_object_nl = rb_intern("object_nl"); + i_array_nl = rb_intern("array_nl"); + i_max_nesting = rb_intern("max_nesting"); + i_escape_slash = rb_intern("escape_slash"); + i_allow_nan = rb_intern("allow_nan"); + i_ascii_only = rb_intern("ascii_only"); + i_depth = rb_intern("depth"); + i_buffer_initial_length = rb_intern("buffer_initial_length"); + i_pack = rb_intern("pack"); + i_unpack = rb_intern("unpack"); + i_create_id = rb_intern("create_id"); + i_extend = rb_intern("extend"); + i_key_p = rb_intern("key?"); + i_aref = rb_intern("[]"); + i_send = rb_intern("__send__"); + i_respond_to_p = rb_intern("respond_to?"); + i_match = rb_intern("match"); + i_keys = rb_intern("keys"); + i_dup = rb_intern("dup"); +} diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.h b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.h new file mode 100644 index 0000000..3ebd622 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.h @@ -0,0 +1,174 @@ +#ifndef _GENERATOR_H_ +#define _GENERATOR_H_ + +#include +#include + +#include "ruby.h" + +#ifdef HAVE_RUBY_RE_H +#include "ruby/re.h" +#else +#include "re.h" +#endif + +#ifndef rb_intern_str +#define rb_intern_str(string) SYM2ID(rb_str_intern(string)) +#endif + +#ifndef rb_obj_instance_variables +#define rb_obj_instance_variables(object) rb_funcall(object, rb_intern("instance_variables"), 0) +#endif + +#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key)) + +/* unicode definitions */ + +#define UNI_STRICT_CONVERSION 1 + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ + +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length); +static void unicode_escape(char *buf, UTF16 character); +static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character); +static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escape_slash); +static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash); +static char *fstrndup(const char *ptr, unsigned long len); + +/* ruby api and some helpers */ + +typedef struct JSON_Generator_StateStruct { + char *indent; + long indent_len; + char *space; + long space_len; + char *space_before; + long space_before_len; + char *object_nl; + long object_nl_len; + char *array_nl; + long array_nl_len; + FBuffer *array_delim; + FBuffer *object_delim; + FBuffer *object_delim2; + long max_nesting; + char allow_nan; + char ascii_only; + char escape_slash; + long depth; + long buffer_initial_length; +} JSON_Generator_State; + +#define GET_STATE_TO(self, state) \ + TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state) + +#define GET_STATE(self) \ + JSON_Generator_State *state; \ + GET_STATE_TO(self, state) + +#define GENERATE_JSON(type) \ + FBuffer *buffer; \ + VALUE Vstate; \ + JSON_Generator_State *state; \ + \ + rb_scan_args(argc, argv, "01", &Vstate); \ + Vstate = cState_from_state_s(cState, Vstate); \ + TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state); \ + buffer = cState_prepare_buffer(Vstate); \ + generate_json_##type(buffer, Vstate, state, self); \ + return fbuffer_to_s(buffer) + +static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self); +static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self); +#ifdef RUBY_INTEGER_UNIFICATION +static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self); +#else +static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self); +static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self); +#endif +static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self); +static VALUE mString_included_s(VALUE self, VALUE modul); +static VALUE mString_to_json(int argc, VALUE *argv, VALUE self); +static VALUE mString_to_json_raw_object(VALUE self); +static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self); +static VALUE mString_Extend_json_create(VALUE self, VALUE o); +static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self); +static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self); +static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self); +static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self); +static void State_free(void *state); +static VALUE cState_s_allocate(VALUE klass); +static VALUE cState_configure(VALUE self, VALUE opts); +static VALUE cState_to_h(VALUE self); +static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +#ifdef RUBY_INTEGER_UNIFICATION +static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +#endif +static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj); +static VALUE cState_partial_generate(VALUE self, VALUE obj); +static VALUE cState_generate(VALUE self, VALUE obj); +static VALUE cState_initialize(int argc, VALUE *argv, VALUE self); +static VALUE cState_from_state_s(VALUE self, VALUE opts); +static VALUE cState_indent(VALUE self); +static VALUE cState_indent_set(VALUE self, VALUE indent); +static VALUE cState_space(VALUE self); +static VALUE cState_space_set(VALUE self, VALUE space); +static VALUE cState_space_before(VALUE self); +static VALUE cState_space_before_set(VALUE self, VALUE space_before); +static VALUE cState_object_nl(VALUE self); +static VALUE cState_object_nl_set(VALUE self, VALUE object_nl); +static VALUE cState_array_nl(VALUE self); +static VALUE cState_array_nl_set(VALUE self, VALUE array_nl); +static VALUE cState_max_nesting(VALUE self); +static VALUE cState_max_nesting_set(VALUE self, VALUE depth); +static VALUE cState_allow_nan_p(VALUE self); +static VALUE cState_ascii_only_p(VALUE self); +static VALUE cState_depth(VALUE self); +static VALUE cState_depth_set(VALUE self, VALUE depth); +static VALUE cState_escape_slash(VALUE self); +static VALUE cState_escape_slash_set(VALUE self, VALUE depth); +static FBuffer *cState_prepare_buffer(VALUE self); +#ifndef ZALLOC +#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type))) +static inline void *ruby_zalloc(size_t n) +{ + void *p = ruby_xmalloc(n); + memset(p, 0, n); + return p; +} +#endif +#ifdef TypedData_Make_Struct +static const rb_data_type_t JSON_Generator_State_type; +#define NEW_TYPEDDATA_WRAPPER 1 +#else +#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, State_free, json) +#define TypedData_Get_Struct(self, JSON_Generator_State, ignore, json) Data_Get_Struct(self, JSON_Generator_State, json) +#endif + +#endif diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.o b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.o new file mode 100644 index 0000000..c07db53 Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.o differ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.so b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.so new file mode 100755 index 0000000..d8731fc Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/generator/generator.so differ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/.sitearchdir.-.json.-.ext.time b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/.sitearchdir.-.json.-.ext.time new file mode 100644 index 0000000..e69de29 diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/Makefile b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/Makefile new file mode 100644 index 0000000..a30be36 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/Makefile @@ -0,0 +1,268 @@ + +SHELL = /bin/sh + +# V=0 quiet, V=1 verbose. other values don't work. +V = 0 +Q1 = $(V:1=) +Q = $(Q1:0=@) +ECHO1 = $(V:1=@ :) +ECHO = $(ECHO1:0=@ echo) +NULLCMD = : + +#### Start of system configuration section. #### + +srcdir = . +topdir = /opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0 +hdrdir = $(topdir) +arch_hdrdir = /opt/hostedtoolcache/Ruby/2.7.7/x64/include/ruby-2.7.0/x86_64-linux +PATH_SEPARATOR = : +VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby +prefix = $(DESTDIR)/opt/hostedtoolcache/Ruby/2.7.7/x64 +rubysitearchprefix = $(rubylibprefix)/$(sitearch) +rubyarchprefix = $(rubylibprefix)/$(arch) +rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) +exec_prefix = $(prefix) +vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) +sitearchhdrdir = $(sitehdrdir)/$(sitearch) +rubyarchhdrdir = $(rubyhdrdir)/$(arch) +vendorhdrdir = $(rubyhdrdir)/vendor_ruby +sitehdrdir = $(rubyhdrdir)/site_ruby +rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) +vendorarchdir = $(vendorlibdir)/$(sitearch) +vendorlibdir = $(vendordir)/$(ruby_version) +vendordir = $(rubylibprefix)/vendor_ruby +sitearchdir = $(DESTDIR)./.gem.20221206-1722-pjmzva +sitelibdir = $(DESTDIR)./.gem.20221206-1722-pjmzva +sitedir = $(rubylibprefix)/site_ruby +rubyarchdir = $(rubylibdir)/$(arch) +rubylibdir = $(rubylibprefix)/$(ruby_version) +sitearchincludedir = $(includedir)/$(sitearch) +archincludedir = $(includedir)/$(arch) +sitearchlibdir = $(libdir)/$(sitearch) +archlibdir = $(libdir)/$(arch) +ridir = $(datarootdir)/$(RI_BASE_NAME) +mandir = $(datarootdir)/man +localedir = $(datarootdir)/locale +libdir = $(exec_prefix)/lib +psdir = $(docdir) +pdfdir = $(docdir) +dvidir = $(docdir) +htmldir = $(docdir) +infodir = $(datarootdir)/info +docdir = $(datarootdir)/doc/$(PACKAGE) +oldincludedir = $(DESTDIR)/usr/include +includedir = $(prefix)/include +runstatedir = $(localstatedir)/run +localstatedir = $(prefix)/var +sharedstatedir = $(prefix)/com +sysconfdir = $(prefix)/etc +datadir = $(datarootdir) +datarootdir = $(prefix)/share +libexecdir = $(exec_prefix)/libexec +sbindir = $(exec_prefix)/sbin +bindir = $(exec_prefix)/bin +archdir = $(rubyarchdir) + + +CC_WRAPPER = +CC = gcc +CXX = g++ +LIBRUBY = $(LIBRUBY_SO) +LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a +LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME) +LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static $(MAINLIBS) +empty = +OUTFLAG = -o $(empty) +COUTFLAG = -o $(empty) +CSRCFLAG = $(empty) + +RUBY_EXTCONF_H = +cflags = $(optflags) $(debugflags) $(warnflags) +cxxflags = +optflags = -O3 +debugflags = -ggdb3 +warnflags = -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable +cppflags = +CCDLFLAGS = -fPIC +CFLAGS = $(CCDLFLAGS) -g -O2 -fPIC -DSTR_UMINUS_DEDUPE=1 -DSTR_UMINUS_DEDUPE_FROZEN=0 $(ARCH_FLAG) +INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) +DEFS = +CPPFLAGS = -DHAVE_RB_ENC_RAISE -I/opt/hostedtoolcache/Ruby/2.7.7/x64/include -DENABLE_PATH_CHECK=0 $(DEFS) $(cppflags) +CXXFLAGS = $(CCDLFLAGS) -g -O2 $(ARCH_FLAG) +ldflags = -L. -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -fstack-protector-strong -rdynamic -Wl,-export-dynamic +dldflags = -L/opt/hostedtoolcache/Ruby/2.7.7/x64/lib -Wl,--compress-debug-sections=zlib +ARCH_FLAG = +DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) +LDSHARED = $(CC) -shared +LDSHAREDXX = $(CXX) -shared +AR = ar +EXEEXT = + +RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) +RUBY_SO_NAME = ruby +RUBYW_INSTALL_NAME = +RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) +RUBYW_BASE_NAME = rubyw +RUBY_BASE_NAME = ruby + +arch = x86_64-linux +sitearch = $(arch) +ruby_version = 2.7.0 +ruby = $(bindir)/$(RUBY_BASE_NAME) +RUBY = $(ruby) +BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME) +ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h + +RM = rm -f +RM_RF = $(RUBY) -run -e rm -- -rf +RMDIRS = rmdir --ignore-fail-on-non-empty -p +MAKEDIRS = /usr/bin/mkdir -p +INSTALL = /usr/bin/install -c +INSTALL_PROG = $(INSTALL) -m 0755 +INSTALL_DATA = $(INSTALL) -m 644 +COPY = cp +TOUCH = exit > + +#### End of system configuration section. #### + +preload = +libpath = . $(libdir) +LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir) +DEFFILE = + +CLEANFILES = mkmf.log +DISTCLEANFILES = +DISTCLEANDIRS = + +extout = +extout_prefix = +target_prefix = /json/ext +LOCAL_LIBS = +LIBS = $(LIBRUBYARG_SHARED) -lm -lc +ORIG_SRCS = parser.c +SRCS = $(ORIG_SRCS) +OBJS = parser.o +HDRS = $(srcdir)/parser.h +LOCAL_HDRS = +TARGET = parser +TARGET_NAME = parser +TARGET_ENTRY = Init_$(TARGET_NAME) +DLLIB = $(TARGET).so +EXTSTATIC = +STATIC_LIB = + +TIMESTAMP_DIR = . +BINDIR = $(bindir) +RUBYCOMMONDIR = $(sitedir)$(target_prefix) +RUBYLIBDIR = $(sitelibdir)$(target_prefix) +RUBYARCHDIR = $(sitearchdir)$(target_prefix) +HDRDIR = $(rubyhdrdir)/ruby$(target_prefix) +ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix) +TARGET_SO_DIR = +TARGET_SO = $(TARGET_SO_DIR)$(DLLIB) +CLEANLIBS = $(TARGET_SO) +CLEANOBJS = *.o *.bak + +all: $(DLLIB) +static: $(STATIC_LIB) +.PHONY: all install static install-so install-rb +.PHONY: clean clean-so clean-static clean-rb + +clean-static:: +clean-rb-default:: +clean-rb:: +clean-so:: +clean: clean-so clean-static clean-rb-default clean-rb + -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time + +distclean-rb-default:: +distclean-rb:: +distclean-so:: +distclean-static:: +distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb + -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log + -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) + -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true + +realclean: distclean +install: install-so install-rb + +install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.-.json.-.ext.time + $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) +clean-static:: + -$(Q)$(RM) $(STATIC_LIB) +install-rb: pre-install-rb do-install-rb install-rb-default +install-rb-default: pre-install-rb-default do-install-rb-default +pre-install-rb: Makefile +pre-install-rb-default: Makefile +do-install-rb: +do-install-rb-default: +pre-install-rb-default: + @$(NULLCMD) +$(TIMESTAMP_DIR)/.sitearchdir.-.json.-.ext.time: + $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) + $(Q) $(TOUCH) $@ + +site-install: site-install-so site-install-rb +site-install-so: install-so +site-install-rb: install-rb + +.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S + +.cc.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cc.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.mm.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.mm.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cxx.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cxx.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.cpp.o: + $(ECHO) compiling $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.cpp.S: + $(ECHO) translating $(<) + $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.c.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.c.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +.m.o: + $(ECHO) compiling $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$< + +.m.S: + $(ECHO) translating $(<) + $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$< + +$(TARGET_SO): $(OBJS) Makefile + $(ECHO) linking shared-object json/ext/$(DLLIB) + -$(Q)$(RM) $(@) + $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) + + + +### +parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/depend b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/depend new file mode 100644 index 0000000..498ffa9 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/depend @@ -0,0 +1 @@ +parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/extconf.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/extconf.rb new file mode 100644 index 0000000..feb586e --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/extconf.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: false +require 'mkmf' + +have_func("rb_enc_raise", "ruby.h") +have_func("rb_enc_interned_str", "ruby.h") + +# checking if String#-@ (str_uminus) dedupes... ' +begin + a = -(%w(t e s t).join) + b = -(%w(t e s t).join) + if a.equal?(b) + $CFLAGS << ' -DSTR_UMINUS_DEDUPE=1 ' + else + $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 ' + end +rescue NoMethodError + $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 ' +end + +# checking if String#-@ (str_uminus) directly interns frozen strings... ' +begin + s = rand.to_s.freeze + if (-s).equal?(s) && (-s.dup).equal?(s) + $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 ' + else + $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 ' + end +rescue NoMethodError + $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 ' +end + +create_makefile 'json/ext/parser' diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.c b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.c new file mode 100644 index 0000000..9bd7f19 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.c @@ -0,0 +1,3347 @@ +/* This file is automatically generated from parser.rl by using ragel */ +#line 1 "parser.rl" +#include "../fbuffer/fbuffer.h" +#include "parser.h" + +#if defined HAVE_RUBY_ENCODING_H +# define EXC_ENCODING rb_utf8_encoding(), +# ifndef HAVE_RB_ENC_RAISE +static void +enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...) +{ + va_list args; + VALUE mesg; + + va_start(args, fmt); + mesg = rb_enc_vsprintf(enc, fmt, args); + va_end(args); + + rb_exc_raise(rb_exc_new3(exc, mesg)); +} +# define rb_enc_raise enc_raise +# endif +#else +# define EXC_ENCODING /* nothing */ +# define rb_enc_raise rb_raise +#endif + +/* unicode */ + +static const signed char digit_values[256] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, + -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1 +}; + +static UTF32 unescape_unicode(const unsigned char *p) +{ + signed char b; + UTF32 result = 0; + b = digit_values[p[0]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + b = digit_values[p[1]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + b = digit_values[p[2]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + b = digit_values[p[3]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + return result; +} + +static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) +{ + int len = 1; + if (ch <= 0x7F) { + buf[0] = (char) ch; + } else if (ch <= 0x07FF) { + buf[0] = (char) ((ch >> 6) | 0xC0); + buf[1] = (char) ((ch & 0x3F) | 0x80); + len++; + } else if (ch <= 0xFFFF) { + buf[0] = (char) ((ch >> 12) | 0xE0); + buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80); + buf[2] = (char) ((ch & 0x3F) | 0x80); + len += 2; + } else if (ch <= 0x1fffff) { + buf[0] =(char) ((ch >> 18) | 0xF0); + buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80); + buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80); + buf[3] =(char) ((ch & 0x3F) | 0x80); + len += 3; + } else { + buf[0] = '?'; + } + return len; +} + +static VALUE mJSON, mExt, cParser, eParserError, eNestingError; +static VALUE CNaN, CInfinity, CMinusInfinity; + +static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, +i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, +i_object_class, i_array_class, i_decimal_class, i_key_p, +i_deep_const_get, i_match, i_match_string, i_aset, i_aref, +i_leftshift, i_new, i_try_convert, i_freeze, i_uminus; + + +#line 125 "parser.rl" + + + +enum {JSON_object_start = 1}; +enum {JSON_object_first_final = 27}; +enum {JSON_object_error = 0}; + +enum {JSON_object_en_main = 1}; + +static const char MAYBE_UNUSED(_JSON_object_nfa_targs)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_object_nfa_offsets)[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_object_nfa_push_actions)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_object_nfa_pop_trans)[] = { + 0, 0 +}; + + +#line 167 "parser.rl" + + +static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) +{ + int cs = EVIL; + VALUE last_name = Qnil; + VALUE object_class = json->object_class; + + if (json->max_nesting && current_nesting > json->max_nesting) { + rb_raise(eNestingError, "nesting of %d is too deep", current_nesting); + } + + *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class); + + + { + cs = (int)JSON_object_start; + } + + #line 182 "parser.rl" + + + { + if ( p == pe ) + goto _test_eof; + switch ( cs ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 2: + goto st_case_2; + case 3: + goto st_case_3; + case 4: + goto st_case_4; + case 5: + goto st_case_5; + case 6: + goto st_case_6; + case 7: + goto st_case_7; + case 8: + goto st_case_8; + case 9: + goto st_case_9; + case 10: + goto st_case_10; + case 11: + goto st_case_11; + case 12: + goto st_case_12; + case 13: + goto st_case_13; + case 14: + goto st_case_14; + case 15: + goto st_case_15; + case 16: + goto st_case_16; + case 17: + goto st_case_17; + case 18: + goto st_case_18; + case 27: + goto st_case_27; + case 19: + goto st_case_19; + case 20: + goto st_case_20; + case 21: + goto st_case_21; + case 22: + goto st_case_22; + case 23: + goto st_case_23; + case 24: + goto st_case_24; + case 25: + goto st_case_25; + case 26: + goto st_case_26; + } + goto st_out; + st_case_1: + if ( ( (*( p))) == 123 ) { + goto st2; + } + { + goto st0; + } + st_case_0: + st0: + cs = 0; + goto _out; + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + switch( ( (*( p))) ) { + case 13: { + goto st2; + } + case 32: { + goto st2; + } + case 34: { + goto ctr2; + } + case 47: { + goto st23; + } + case 125: { + goto ctr4; + } + } + if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { + goto st2; + } + { + goto st0; + } + ctr2: + { + #line 149 "parser.rl" + + char *np; + json->parsing_name = 1; + np = JSON_parse_string(json, p, pe, &last_name); + json->parsing_name = 0; + if (np == NULL) { {p = p - 1; } {p+= 1; cs = 3; goto _out;} } else {p = (( np))-1;} + + } + + goto st3; + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + switch( ( (*( p))) ) { + case 13: { + goto st3; + } + case 32: { + goto st3; + } + case 47: { + goto st4; + } + case 58: { + goto st8; + } + } + if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { + goto st3; + } + { + goto st0; + } + st4: + p+= 1; + if ( p == pe ) + goto _test_eof4; + st_case_4: + switch( ( (*( p))) ) { + case 42: { + goto st5; + } + case 47: { + goto st7; + } + } + { + goto st0; + } + st5: + p+= 1; + if ( p == pe ) + goto _test_eof5; + st_case_5: + if ( ( (*( p))) == 42 ) { + goto st6; + } + { + goto st5; + } + st6: + p+= 1; + if ( p == pe ) + goto _test_eof6; + st_case_6: + switch( ( (*( p))) ) { + case 42: { + goto st6; + } + case 47: { + goto st3; + } + } + { + goto st5; + } + st7: + p+= 1; + if ( p == pe ) + goto _test_eof7; + st_case_7: + if ( ( (*( p))) == 10 ) { + goto st3; + } + { + goto st7; + } + st8: + p+= 1; + if ( p == pe ) + goto _test_eof8; + st_case_8: + switch( ( (*( p))) ) { + case 13: { + goto st8; + } + case 32: { + goto st8; + } + case 34: { + goto ctr11; + } + case 45: { + goto ctr11; + } + case 47: { + goto st19; + } + case 73: { + goto ctr11; + } + case 78: { + goto ctr11; + } + case 91: { + goto ctr11; + } + case 102: { + goto ctr11; + } + case 110: { + goto ctr11; + } + case 116: { + goto ctr11; + } + case 123: { + goto ctr11; + } + } + if ( ( (*( p))) > 10 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto ctr11; + } + } else if ( ( (*( p))) >= 9 ) { + goto st8; + } + { + goto st0; + } + ctr11: + { + #line 133 "parser.rl" + + VALUE v = Qnil; + char *np = JSON_parse_value(json, p, pe, &v, current_nesting); + if (np == NULL) { + {p = p - 1; } {p+= 1; cs = 9; goto _out;} + } else { + if (NIL_P(json->object_class)) { + OBJ_FREEZE(last_name); + rb_hash_aset(*result, last_name, v); + } else { + rb_funcall(*result, i_aset, 2, last_name, v); + } + {p = (( np))-1;} + + } + } + + goto st9; + st9: + p+= 1; + if ( p == pe ) + goto _test_eof9; + st_case_9: + switch( ( (*( p))) ) { + case 13: { + goto st9; + } + case 32: { + goto st9; + } + case 44: { + goto st10; + } + case 47: { + goto st15; + } + case 125: { + goto ctr4; + } + } + if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { + goto st9; + } + { + goto st0; + } + st10: + p+= 1; + if ( p == pe ) + goto _test_eof10; + st_case_10: + switch( ( (*( p))) ) { + case 13: { + goto st10; + } + case 32: { + goto st10; + } + case 34: { + goto ctr2; + } + case 47: { + goto st11; + } + } + if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { + goto st10; + } + { + goto st0; + } + st11: + p+= 1; + if ( p == pe ) + goto _test_eof11; + st_case_11: + switch( ( (*( p))) ) { + case 42: { + goto st12; + } + case 47: { + goto st14; + } + } + { + goto st0; + } + st12: + p+= 1; + if ( p == pe ) + goto _test_eof12; + st_case_12: + if ( ( (*( p))) == 42 ) { + goto st13; + } + { + goto st12; + } + st13: + p+= 1; + if ( p == pe ) + goto _test_eof13; + st_case_13: + switch( ( (*( p))) ) { + case 42: { + goto st13; + } + case 47: { + goto st10; + } + } + { + goto st12; + } + st14: + p+= 1; + if ( p == pe ) + goto _test_eof14; + st_case_14: + if ( ( (*( p))) == 10 ) { + goto st10; + } + { + goto st14; + } + st15: + p+= 1; + if ( p == pe ) + goto _test_eof15; + st_case_15: + switch( ( (*( p))) ) { + case 42: { + goto st16; + } + case 47: { + goto st18; + } + } + { + goto st0; + } + st16: + p+= 1; + if ( p == pe ) + goto _test_eof16; + st_case_16: + if ( ( (*( p))) == 42 ) { + goto st17; + } + { + goto st16; + } + st17: + p+= 1; + if ( p == pe ) + goto _test_eof17; + st_case_17: + switch( ( (*( p))) ) { + case 42: { + goto st17; + } + case 47: { + goto st9; + } + } + { + goto st16; + } + st18: + p+= 1; + if ( p == pe ) + goto _test_eof18; + st_case_18: + if ( ( (*( p))) == 10 ) { + goto st9; + } + { + goto st18; + } + ctr4: + { + #line 157 "parser.rl" + {p = p - 1; } {p+= 1; cs = 27; goto _out;} } + + goto st27; + st27: + p+= 1; + if ( p == pe ) + goto _test_eof27; + st_case_27: + { + goto st0; + } + st19: + p+= 1; + if ( p == pe ) + goto _test_eof19; + st_case_19: + switch( ( (*( p))) ) { + case 42: { + goto st20; + } + case 47: { + goto st22; + } + } + { + goto st0; + } + st20: + p+= 1; + if ( p == pe ) + goto _test_eof20; + st_case_20: + if ( ( (*( p))) == 42 ) { + goto st21; + } + { + goto st20; + } + st21: + p+= 1; + if ( p == pe ) + goto _test_eof21; + st_case_21: + switch( ( (*( p))) ) { + case 42: { + goto st21; + } + case 47: { + goto st8; + } + } + { + goto st20; + } + st22: + p+= 1; + if ( p == pe ) + goto _test_eof22; + st_case_22: + if ( ( (*( p))) == 10 ) { + goto st8; + } + { + goto st22; + } + st23: + p+= 1; + if ( p == pe ) + goto _test_eof23; + st_case_23: + switch( ( (*( p))) ) { + case 42: { + goto st24; + } + case 47: { + goto st26; + } + } + { + goto st0; + } + st24: + p+= 1; + if ( p == pe ) + goto _test_eof24; + st_case_24: + if ( ( (*( p))) == 42 ) { + goto st25; + } + { + goto st24; + } + st25: + p+= 1; + if ( p == pe ) + goto _test_eof25; + st_case_25: + switch( ( (*( p))) ) { + case 42: { + goto st25; + } + case 47: { + goto st2; + } + } + { + goto st24; + } + st26: + p+= 1; + if ( p == pe ) + goto _test_eof26; + st_case_26: + if ( ( (*( p))) == 10 ) { + goto st2; + } + { + goto st26; + } + st_out: + _test_eof2: cs = 2; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof9: cs = 9; goto _test_eof; + _test_eof10: cs = 10; goto _test_eof; + _test_eof11: cs = 11; goto _test_eof; + _test_eof12: cs = 12; goto _test_eof; + _test_eof13: cs = 13; goto _test_eof; + _test_eof14: cs = 14; goto _test_eof; + _test_eof15: cs = 15; goto _test_eof; + _test_eof16: cs = 16; goto _test_eof; + _test_eof17: cs = 17; goto _test_eof; + _test_eof18: cs = 18; goto _test_eof; + _test_eof27: cs = 27; goto _test_eof; + _test_eof19: cs = 19; goto _test_eof; + _test_eof20: cs = 20; goto _test_eof; + _test_eof21: cs = 21; goto _test_eof; + _test_eof22: cs = 22; goto _test_eof; + _test_eof23: cs = 23; goto _test_eof; + _test_eof24: cs = 24; goto _test_eof; + _test_eof25: cs = 25; goto _test_eof; + _test_eof26: cs = 26; goto _test_eof; + + _test_eof: {} + _out: {} + } + + #line 183 "parser.rl" + + + if (cs >= JSON_object_first_final) { + if (json->create_additions) { + VALUE klassname; + if (NIL_P(json->object_class)) { + klassname = rb_hash_aref(*result, json->create_id); + } else { + klassname = rb_funcall(*result, i_aref, 1, json->create_id); + } + if (!NIL_P(klassname)) { + VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname); + if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) { + *result = rb_funcall(klass, i_json_create, 1, *result); + } + } + } + return p + 1; + } else { + return NULL; + } +} + + + +enum {JSON_value_start = 1}; +enum {JSON_value_first_final = 29}; +enum {JSON_value_error = 0}; + +enum {JSON_value_en_main = 1}; + +static const char MAYBE_UNUSED(_JSON_value_nfa_targs)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_value_nfa_offsets)[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_value_nfa_push_actions)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_value_nfa_pop_trans)[] = { + 0, 0 +}; + + +#line 283 "parser.rl" + + +static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) +{ + int cs = EVIL; + + + { + cs = (int)JSON_value_start; + } + + #line 290 "parser.rl" + + + { + if ( p == pe ) + goto _test_eof; + switch ( cs ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 29: + goto st_case_29; + case 2: + goto st_case_2; + case 3: + goto st_case_3; + case 4: + goto st_case_4; + case 5: + goto st_case_5; + case 6: + goto st_case_6; + case 7: + goto st_case_7; + case 8: + goto st_case_8; + case 9: + goto st_case_9; + case 10: + goto st_case_10; + case 11: + goto st_case_11; + case 12: + goto st_case_12; + case 13: + goto st_case_13; + case 14: + goto st_case_14; + case 15: + goto st_case_15; + case 16: + goto st_case_16; + case 17: + goto st_case_17; + case 18: + goto st_case_18; + case 19: + goto st_case_19; + case 20: + goto st_case_20; + case 21: + goto st_case_21; + case 22: + goto st_case_22; + case 23: + goto st_case_23; + case 24: + goto st_case_24; + case 25: + goto st_case_25; + case 26: + goto st_case_26; + case 27: + goto st_case_27; + case 28: + goto st_case_28; + } + goto st_out; + st1: + p+= 1; + if ( p == pe ) + goto _test_eof1; + st_case_1: + switch( ( (*( p))) ) { + case 13: { + goto st1; + } + case 32: { + goto st1; + } + case 34: { + goto ctr2; + } + case 45: { + goto ctr3; + } + case 47: { + goto st6; + } + case 73: { + goto st10; + } + case 78: { + goto st17; + } + case 91: { + goto ctr7; + } + case 102: { + goto st19; + } + case 110: { + goto st23; + } + case 116: { + goto st26; + } + case 123: { + goto ctr11; + } + } + if ( ( (*( p))) > 10 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto ctr3; + } + } else if ( ( (*( p))) >= 9 ) { + goto st1; + } + { + goto st0; + } + st_case_0: + st0: + cs = 0; + goto _out; + ctr2: + { + #line 235 "parser.rl" + + char *np = JSON_parse_string(json, p, pe, result); + if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;} + + } + + goto st29; + ctr3: + { + #line 240 "parser.rl" + + char *np; + if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) { + if (json->allow_nan) { + *result = CMinusInfinity; + {p = (( p + 10))-1;} + + {p = p - 1; } {p+= 1; cs = 29; goto _out;} + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p); + } + } + np = JSON_parse_float(json, p, pe, result); + if (np != NULL) {p = (( np))-1;} + + np = JSON_parse_integer(json, p, pe, result); + if (np != NULL) {p = (( np))-1;} + + {p = p - 1; } {p+= 1; cs = 29; goto _out;} + } + + goto st29; + ctr7: + { + #line 258 "parser.rl" + + char *np; + np = JSON_parse_array(json, p, pe, result, current_nesting + 1); + if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;} + + } + + goto st29; + ctr11: + { + #line 264 "parser.rl" + + char *np; + np = JSON_parse_object(json, p, pe, result, current_nesting + 1); + if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;} + + } + + goto st29; + ctr25: + { + #line 228 "parser.rl" + + if (json->allow_nan) { + *result = CInfinity; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8); + } + } + + goto st29; + ctr27: + { + #line 221 "parser.rl" + + if (json->allow_nan) { + *result = CNaN; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2); + } + } + + goto st29; + ctr31: + { + #line 215 "parser.rl" + + *result = Qfalse; + } + + goto st29; + ctr34: + { + #line 212 "parser.rl" + + *result = Qnil; + } + + goto st29; + ctr37: + { + #line 218 "parser.rl" + + *result = Qtrue; + } + + goto st29; + st29: + p+= 1; + if ( p == pe ) + goto _test_eof29; + st_case_29: + { + #line 270 "parser.rl" + {p = p - 1; } {p+= 1; cs = 29; goto _out;} } + switch( ( (*( p))) ) { + case 13: { + goto st29; + } + case 32: { + goto st29; + } + case 47: { + goto st2; + } + } + if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { + goto st29; + } + { + goto st0; + } + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + switch( ( (*( p))) ) { + case 42: { + goto st3; + } + case 47: { + goto st5; + } + } + { + goto st0; + } + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + if ( ( (*( p))) == 42 ) { + goto st4; + } + { + goto st3; + } + st4: + p+= 1; + if ( p == pe ) + goto _test_eof4; + st_case_4: + switch( ( (*( p))) ) { + case 42: { + goto st4; + } + case 47: { + goto st29; + } + } + { + goto st3; + } + st5: + p+= 1; + if ( p == pe ) + goto _test_eof5; + st_case_5: + if ( ( (*( p))) == 10 ) { + goto st29; + } + { + goto st5; + } + st6: + p+= 1; + if ( p == pe ) + goto _test_eof6; + st_case_6: + switch( ( (*( p))) ) { + case 42: { + goto st7; + } + case 47: { + goto st9; + } + } + { + goto st0; + } + st7: + p+= 1; + if ( p == pe ) + goto _test_eof7; + st_case_7: + if ( ( (*( p))) == 42 ) { + goto st8; + } + { + goto st7; + } + st8: + p+= 1; + if ( p == pe ) + goto _test_eof8; + st_case_8: + switch( ( (*( p))) ) { + case 42: { + goto st8; + } + case 47: { + goto st1; + } + } + { + goto st7; + } + st9: + p+= 1; + if ( p == pe ) + goto _test_eof9; + st_case_9: + if ( ( (*( p))) == 10 ) { + goto st1; + } + { + goto st9; + } + st10: + p+= 1; + if ( p == pe ) + goto _test_eof10; + st_case_10: + if ( ( (*( p))) == 110 ) { + goto st11; + } + { + goto st0; + } + st11: + p+= 1; + if ( p == pe ) + goto _test_eof11; + st_case_11: + if ( ( (*( p))) == 102 ) { + goto st12; + } + { + goto st0; + } + st12: + p+= 1; + if ( p == pe ) + goto _test_eof12; + st_case_12: + if ( ( (*( p))) == 105 ) { + goto st13; + } + { + goto st0; + } + st13: + p+= 1; + if ( p == pe ) + goto _test_eof13; + st_case_13: + if ( ( (*( p))) == 110 ) { + goto st14; + } + { + goto st0; + } + st14: + p+= 1; + if ( p == pe ) + goto _test_eof14; + st_case_14: + if ( ( (*( p))) == 105 ) { + goto st15; + } + { + goto st0; + } + st15: + p+= 1; + if ( p == pe ) + goto _test_eof15; + st_case_15: + if ( ( (*( p))) == 116 ) { + goto st16; + } + { + goto st0; + } + st16: + p+= 1; + if ( p == pe ) + goto _test_eof16; + st_case_16: + if ( ( (*( p))) == 121 ) { + goto ctr25; + } + { + goto st0; + } + st17: + p+= 1; + if ( p == pe ) + goto _test_eof17; + st_case_17: + if ( ( (*( p))) == 97 ) { + goto st18; + } + { + goto st0; + } + st18: + p+= 1; + if ( p == pe ) + goto _test_eof18; + st_case_18: + if ( ( (*( p))) == 78 ) { + goto ctr27; + } + { + goto st0; + } + st19: + p+= 1; + if ( p == pe ) + goto _test_eof19; + st_case_19: + if ( ( (*( p))) == 97 ) { + goto st20; + } + { + goto st0; + } + st20: + p+= 1; + if ( p == pe ) + goto _test_eof20; + st_case_20: + if ( ( (*( p))) == 108 ) { + goto st21; + } + { + goto st0; + } + st21: + p+= 1; + if ( p == pe ) + goto _test_eof21; + st_case_21: + if ( ( (*( p))) == 115 ) { + goto st22; + } + { + goto st0; + } + st22: + p+= 1; + if ( p == pe ) + goto _test_eof22; + st_case_22: + if ( ( (*( p))) == 101 ) { + goto ctr31; + } + { + goto st0; + } + st23: + p+= 1; + if ( p == pe ) + goto _test_eof23; + st_case_23: + if ( ( (*( p))) == 117 ) { + goto st24; + } + { + goto st0; + } + st24: + p+= 1; + if ( p == pe ) + goto _test_eof24; + st_case_24: + if ( ( (*( p))) == 108 ) { + goto st25; + } + { + goto st0; + } + st25: + p+= 1; + if ( p == pe ) + goto _test_eof25; + st_case_25: + if ( ( (*( p))) == 108 ) { + goto ctr34; + } + { + goto st0; + } + st26: + p+= 1; + if ( p == pe ) + goto _test_eof26; + st_case_26: + if ( ( (*( p))) == 114 ) { + goto st27; + } + { + goto st0; + } + st27: + p+= 1; + if ( p == pe ) + goto _test_eof27; + st_case_27: + if ( ( (*( p))) == 117 ) { + goto st28; + } + { + goto st0; + } + st28: + p+= 1; + if ( p == pe ) + goto _test_eof28; + st_case_28: + if ( ( (*( p))) == 101 ) { + goto ctr37; + } + { + goto st0; + } + st_out: + _test_eof1: cs = 1; goto _test_eof; + _test_eof29: cs = 29; goto _test_eof; + _test_eof2: cs = 2; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof9: cs = 9; goto _test_eof; + _test_eof10: cs = 10; goto _test_eof; + _test_eof11: cs = 11; goto _test_eof; + _test_eof12: cs = 12; goto _test_eof; + _test_eof13: cs = 13; goto _test_eof; + _test_eof14: cs = 14; goto _test_eof; + _test_eof15: cs = 15; goto _test_eof; + _test_eof16: cs = 16; goto _test_eof; + _test_eof17: cs = 17; goto _test_eof; + _test_eof18: cs = 18; goto _test_eof; + _test_eof19: cs = 19; goto _test_eof; + _test_eof20: cs = 20; goto _test_eof; + _test_eof21: cs = 21; goto _test_eof; + _test_eof22: cs = 22; goto _test_eof; + _test_eof23: cs = 23; goto _test_eof; + _test_eof24: cs = 24; goto _test_eof; + _test_eof25: cs = 25; goto _test_eof; + _test_eof26: cs = 26; goto _test_eof; + _test_eof27: cs = 27; goto _test_eof; + _test_eof28: cs = 28; goto _test_eof; + + _test_eof: {} + _out: {} + } + + #line 291 "parser.rl" + + + if (json->freeze) { + OBJ_FREEZE(*result); + } + + if (cs >= JSON_value_first_final) { + return p; + } else { + return NULL; + } +} + + +enum {JSON_integer_start = 1}; +enum {JSON_integer_first_final = 3}; +enum {JSON_integer_error = 0}; + +enum {JSON_integer_en_main = 1}; + +static const char MAYBE_UNUSED(_JSON_integer_nfa_targs)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_integer_nfa_offsets)[] = { + 0, 0, 0, 0, 0, 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_integer_nfa_push_actions)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_integer_nfa_pop_trans)[] = { + 0, 0 +}; + + +#line 311 "parser.rl" + + +static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result) +{ + int cs = EVIL; + + + { + cs = (int)JSON_integer_start; + } + + #line 318 "parser.rl" + + json->memo = p; + + { + if ( p == pe ) + goto _test_eof; + switch ( cs ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 2: + goto st_case_2; + case 3: + goto st_case_3; + case 4: + goto st_case_4; + case 5: + goto st_case_5; + } + goto st_out; + st_case_1: + switch( ( (*( p))) ) { + case 45: { + goto st2; + } + case 48: { + goto st3; + } + } + if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st5; + } + { + goto st0; + } + st_case_0: + st0: + cs = 0; + goto _out; + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + if ( ( (*( p))) == 48 ) { + goto st3; + } + if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st5; + } + { + goto st0; + } + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st0; + } + { + goto ctr4; + } + ctr4: + { + #line 308 "parser.rl" + {p = p - 1; } {p+= 1; cs = 4; goto _out;} } + + goto st4; + st4: + p+= 1; + if ( p == pe ) + goto _test_eof4; + st_case_4: + { + goto st0; + } + st5: + p+= 1; + if ( p == pe ) + goto _test_eof5; + st_case_5: + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st5; + } + { + goto ctr4; + } + st_out: + _test_eof2: cs = 2; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + + _test_eof: {} + _out: {} + } + + #line 320 "parser.rl" + + + if (cs >= JSON_integer_first_final) { + long len = p - json->memo; + fbuffer_clear(json->fbuffer); + fbuffer_append(json->fbuffer, json->memo, len); + fbuffer_append_char(json->fbuffer, '\0'); + *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10); + return p + 1; + } else { + return NULL; + } +} + + +enum {JSON_float_start = 1}; +enum {JSON_float_first_final = 8}; +enum {JSON_float_error = 0}; + +enum {JSON_float_en_main = 1}; + +static const char MAYBE_UNUSED(_JSON_float_nfa_targs)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_float_nfa_offsets)[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_float_nfa_push_actions)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_float_nfa_pop_trans)[] = { + 0, 0 +}; + + +#line 345 "parser.rl" + + +static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) +{ + int cs = EVIL; + + + { + cs = (int)JSON_float_start; + } + + #line 352 "parser.rl" + + json->memo = p; + + { + if ( p == pe ) + goto _test_eof; + switch ( cs ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 2: + goto st_case_2; + case 3: + goto st_case_3; + case 4: + goto st_case_4; + case 8: + goto st_case_8; + case 9: + goto st_case_9; + case 5: + goto st_case_5; + case 6: + goto st_case_6; + case 10: + goto st_case_10; + case 7: + goto st_case_7; + } + goto st_out; + st_case_1: + switch( ( (*( p))) ) { + case 45: { + goto st2; + } + case 48: { + goto st3; + } + } + if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st7; + } + { + goto st0; + } + st_case_0: + st0: + cs = 0; + goto _out; + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + if ( ( (*( p))) == 48 ) { + goto st3; + } + if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st7; + } + { + goto st0; + } + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + switch( ( (*( p))) ) { + case 46: { + goto st4; + } + case 69: { + goto st5; + } + case 101: { + goto st5; + } + } + { + goto st0; + } + st4: + p+= 1; + if ( p == pe ) + goto _test_eof4; + st_case_4: + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st8; + } + { + goto st0; + } + st8: + p+= 1; + if ( p == pe ) + goto _test_eof8; + st_case_8: + switch( ( (*( p))) ) { + case 69: { + goto st5; + } + case 101: { + goto st5; + } + } + if ( ( (*( p))) > 46 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st8; + } + } else if ( ( (*( p))) >= 45 ) { + goto st0; + } + { + goto ctr9; + } + ctr9: + { + #line 339 "parser.rl" + {p = p - 1; } {p+= 1; cs = 9; goto _out;} } + + goto st9; + st9: + p+= 1; + if ( p == pe ) + goto _test_eof9; + st_case_9: + { + goto st0; + } + st5: + p+= 1; + if ( p == pe ) + goto _test_eof5; + st_case_5: + switch( ( (*( p))) ) { + case 43: { + goto st6; + } + case 45: { + goto st6; + } + } + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st10; + } + { + goto st0; + } + st6: + p+= 1; + if ( p == pe ) + goto _test_eof6; + st_case_6: + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st10; + } + { + goto st0; + } + st10: + p+= 1; + if ( p == pe ) + goto _test_eof10; + st_case_10: + switch( ( (*( p))) ) { + case 69: { + goto st0; + } + case 101: { + goto st0; + } + } + if ( ( (*( p))) > 46 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st10; + } + } else if ( ( (*( p))) >= 45 ) { + goto st0; + } + { + goto ctr9; + } + st7: + p+= 1; + if ( p == pe ) + goto _test_eof7; + st_case_7: + switch( ( (*( p))) ) { + case 46: { + goto st4; + } + case 69: { + goto st5; + } + case 101: { + goto st5; + } + } + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st7; + } + { + goto st0; + } + st_out: + _test_eof2: cs = 2; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof9: cs = 9; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof10: cs = 10; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + + _test_eof: {} + _out: {} + } + + #line 354 "parser.rl" + + + if (cs >= JSON_float_first_final) { + VALUE mod = Qnil; + ID method_id = 0; + if (rb_respond_to(json->decimal_class, i_try_convert)) { + mod = json->decimal_class; + method_id = i_try_convert; + } else if (rb_respond_to(json->decimal_class, i_new)) { + mod = json->decimal_class; + method_id = i_new; + } else if (RB_TYPE_P(json->decimal_class, T_CLASS)) { + VALUE name = rb_class_name(json->decimal_class); + const char *name_cstr = RSTRING_PTR(name); + const char *last_colon = strrchr(name_cstr, ':'); + if (last_colon) { + const char *mod_path_end = last_colon - 1; + VALUE mod_path = rb_str_substr(name, 0, mod_path_end - name_cstr); + mod = rb_path_to_class(mod_path); + + const char *method_name_beg = last_colon + 1; + long before_len = method_name_beg - name_cstr; + long len = RSTRING_LEN(name) - before_len; + VALUE method_name = rb_str_substr(name, before_len, len); + method_id = SYM2ID(rb_str_intern(method_name)); + } else { + mod = rb_mKernel; + method_id = SYM2ID(rb_str_intern(name)); + } + } + + long len = p - json->memo; + fbuffer_clear(json->fbuffer); + fbuffer_append(json->fbuffer, json->memo, len); + fbuffer_append_char(json->fbuffer, '\0'); + + if (method_id) { + VALUE text = rb_str_new2(FBUFFER_PTR(json->fbuffer)); + *result = rb_funcallv(mod, method_id, 1, &text); + } else { + *result = DBL2NUM(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1)); + } + + return p + 1; + } else { + return NULL; + } +} + + + +enum {JSON_array_start = 1}; +enum {JSON_array_first_final = 17}; +enum {JSON_array_error = 0}; + +enum {JSON_array_en_main = 1}; + +static const char MAYBE_UNUSED(_JSON_array_nfa_targs)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_array_nfa_offsets)[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_array_nfa_push_actions)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_array_nfa_pop_trans)[] = { + 0, 0 +}; + + +#line 432 "parser.rl" + + +static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) +{ + int cs = EVIL; + VALUE array_class = json->array_class; + + if (json->max_nesting && current_nesting > json->max_nesting) { + rb_raise(eNestingError, "nesting of %d is too deep", current_nesting); + } + *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class); + + + { + cs = (int)JSON_array_start; + } + + #line 445 "parser.rl" + + + { + if ( p == pe ) + goto _test_eof; + switch ( cs ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 2: + goto st_case_2; + case 3: + goto st_case_3; + case 4: + goto st_case_4; + case 5: + goto st_case_5; + case 6: + goto st_case_6; + case 7: + goto st_case_7; + case 8: + goto st_case_8; + case 9: + goto st_case_9; + case 10: + goto st_case_10; + case 11: + goto st_case_11; + case 12: + goto st_case_12; + case 17: + goto st_case_17; + case 13: + goto st_case_13; + case 14: + goto st_case_14; + case 15: + goto st_case_15; + case 16: + goto st_case_16; + } + goto st_out; + st_case_1: + if ( ( (*( p))) == 91 ) { + goto st2; + } + { + goto st0; + } + st_case_0: + st0: + cs = 0; + goto _out; + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + switch( ( (*( p))) ) { + case 13: { + goto st2; + } + case 32: { + goto st2; + } + case 34: { + goto ctr2; + } + case 45: { + goto ctr2; + } + case 47: { + goto st13; + } + case 73: { + goto ctr2; + } + case 78: { + goto ctr2; + } + case 91: { + goto ctr2; + } + case 93: { + goto ctr4; + } + case 102: { + goto ctr2; + } + case 110: { + goto ctr2; + } + case 116: { + goto ctr2; + } + case 123: { + goto ctr2; + } + } + if ( ( (*( p))) > 10 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto ctr2; + } + } else if ( ( (*( p))) >= 9 ) { + goto st2; + } + { + goto st0; + } + ctr2: + { + #line 409 "parser.rl" + + VALUE v = Qnil; + char *np = JSON_parse_value(json, p, pe, &v, current_nesting); + if (np == NULL) { + {p = p - 1; } {p+= 1; cs = 3; goto _out;} + } else { + if (NIL_P(json->array_class)) { + rb_ary_push(*result, v); + } else { + rb_funcall(*result, i_leftshift, 1, v); + } + {p = (( np))-1;} + + } + } + + goto st3; + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + switch( ( (*( p))) ) { + case 13: { + goto st3; + } + case 32: { + goto st3; + } + case 44: { + goto st4; + } + case 47: { + goto st9; + } + case 93: { + goto ctr4; + } + } + if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { + goto st3; + } + { + goto st0; + } + st4: + p+= 1; + if ( p == pe ) + goto _test_eof4; + st_case_4: + switch( ( (*( p))) ) { + case 13: { + goto st4; + } + case 32: { + goto st4; + } + case 34: { + goto ctr2; + } + case 45: { + goto ctr2; + } + case 47: { + goto st5; + } + case 73: { + goto ctr2; + } + case 78: { + goto ctr2; + } + case 91: { + goto ctr2; + } + case 102: { + goto ctr2; + } + case 110: { + goto ctr2; + } + case 116: { + goto ctr2; + } + case 123: { + goto ctr2; + } + } + if ( ( (*( p))) > 10 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto ctr2; + } + } else if ( ( (*( p))) >= 9 ) { + goto st4; + } + { + goto st0; + } + st5: + p+= 1; + if ( p == pe ) + goto _test_eof5; + st_case_5: + switch( ( (*( p))) ) { + case 42: { + goto st6; + } + case 47: { + goto st8; + } + } + { + goto st0; + } + st6: + p+= 1; + if ( p == pe ) + goto _test_eof6; + st_case_6: + if ( ( (*( p))) == 42 ) { + goto st7; + } + { + goto st6; + } + st7: + p+= 1; + if ( p == pe ) + goto _test_eof7; + st_case_7: + switch( ( (*( p))) ) { + case 42: { + goto st7; + } + case 47: { + goto st4; + } + } + { + goto st6; + } + st8: + p+= 1; + if ( p == pe ) + goto _test_eof8; + st_case_8: + if ( ( (*( p))) == 10 ) { + goto st4; + } + { + goto st8; + } + st9: + p+= 1; + if ( p == pe ) + goto _test_eof9; + st_case_9: + switch( ( (*( p))) ) { + case 42: { + goto st10; + } + case 47: { + goto st12; + } + } + { + goto st0; + } + st10: + p+= 1; + if ( p == pe ) + goto _test_eof10; + st_case_10: + if ( ( (*( p))) == 42 ) { + goto st11; + } + { + goto st10; + } + st11: + p+= 1; + if ( p == pe ) + goto _test_eof11; + st_case_11: + switch( ( (*( p))) ) { + case 42: { + goto st11; + } + case 47: { + goto st3; + } + } + { + goto st10; + } + st12: + p+= 1; + if ( p == pe ) + goto _test_eof12; + st_case_12: + if ( ( (*( p))) == 10 ) { + goto st3; + } + { + goto st12; + } + ctr4: + { + #line 424 "parser.rl" + {p = p - 1; } {p+= 1; cs = 17; goto _out;} } + + goto st17; + st17: + p+= 1; + if ( p == pe ) + goto _test_eof17; + st_case_17: + { + goto st0; + } + st13: + p+= 1; + if ( p == pe ) + goto _test_eof13; + st_case_13: + switch( ( (*( p))) ) { + case 42: { + goto st14; + } + case 47: { + goto st16; + } + } + { + goto st0; + } + st14: + p+= 1; + if ( p == pe ) + goto _test_eof14; + st_case_14: + if ( ( (*( p))) == 42 ) { + goto st15; + } + { + goto st14; + } + st15: + p+= 1; + if ( p == pe ) + goto _test_eof15; + st_case_15: + switch( ( (*( p))) ) { + case 42: { + goto st15; + } + case 47: { + goto st2; + } + } + { + goto st14; + } + st16: + p+= 1; + if ( p == pe ) + goto _test_eof16; + st_case_16: + if ( ( (*( p))) == 10 ) { + goto st2; + } + { + goto st16; + } + st_out: + _test_eof2: cs = 2; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof9: cs = 9; goto _test_eof; + _test_eof10: cs = 10; goto _test_eof; + _test_eof11: cs = 11; goto _test_eof; + _test_eof12: cs = 12; goto _test_eof; + _test_eof17: cs = 17; goto _test_eof; + _test_eof13: cs = 13; goto _test_eof; + _test_eof14: cs = 14; goto _test_eof; + _test_eof15: cs = 15; goto _test_eof; + _test_eof16: cs = 16; goto _test_eof; + + _test_eof: {} + _out: {} + } + + #line 446 "parser.rl" + + + if(cs >= JSON_array_first_final) { + return p + 1; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p); + return NULL; + } +} + +static const size_t MAX_STACK_BUFFER_SIZE = 128; +static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize) +{ + VALUE result = Qnil; + size_t bufferSize = stringEnd - string; + char *p = string, *pe = string, *unescape, *bufferStart, *buffer; + int unescape_len; + char buf[4]; + + if (bufferSize > MAX_STACK_BUFFER_SIZE) { +# ifdef HAVE_RB_ENC_INTERNED_STR + bufferStart = buffer = ALLOC_N(char, bufferSize ? bufferSize : 1); +# else + bufferStart = buffer = ALLOC_N(char, bufferSize); +# endif + } else { +# ifdef HAVE_RB_ENC_INTERNED_STR + bufferStart = buffer = ALLOCA_N(char, bufferSize ? bufferSize : 1); +# else + bufferStart = buffer = ALLOCA_N(char, bufferSize); +# endif + } + + while (pe < stringEnd) { + if (*pe == '\\') { + unescape = (char *) "?"; + unescape_len = 1; + if (pe > p) { + MEMCPY(buffer, p, char, pe - p); + buffer += pe - p; + } + switch (*++pe) { + case 'n': + unescape = (char *) "\n"; + break; + case 'r': + unescape = (char *) "\r"; + break; + case 't': + unescape = (char *) "\t"; + break; + case '"': + unescape = (char *) "\""; + break; + case '\\': + unescape = (char *) "\\"; + break; + case 'b': + unescape = (char *) "\b"; + break; + case 'f': + unescape = (char *) "\f"; + break; + case 'u': + if (pe > stringEnd - 4) { + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } + rb_enc_raise( + EXC_ENCODING eParserError, + "incomplete unicode character escape sequence at '%s'", p + ); + } else { + UTF32 ch = unescape_unicode((unsigned char *) ++pe); + pe += 3; + if (UNI_SUR_HIGH_START == (ch & 0xFC00)) { + pe++; + if (pe > stringEnd - 6) { + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } + rb_enc_raise( + EXC_ENCODING eParserError, + "incomplete surrogate pair at '%s'", p + ); + } + if (pe[0] == '\\' && pe[1] == 'u') { + UTF32 sur = unescape_unicode((unsigned char *) pe + 2); + ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16) + | (sur & 0x3FF)); + pe += 5; + } else { + unescape = (char *) "?"; + break; + } + } + unescape_len = convert_UTF32_to_UTF8(buf, ch); + unescape = buf; + } + break; + default: + p = pe; + continue; + } + MEMCPY(buffer, unescape, char, unescape_len); + buffer += unescape_len; + p = ++pe; + } else { + pe++; + } + } + + if (pe > p) { + MEMCPY(buffer, p, char, pe - p); + buffer += pe - p; + } + + # ifdef HAVE_RB_ENC_INTERNED_STR + if (intern) { + result = rb_enc_interned_str(bufferStart, (long)(buffer - bufferStart), rb_utf8_encoding()); + } else { + result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart)); + } + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } + # else + result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart)); + + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } + + if (intern) { + # if STR_UMINUS_DEDUPE_FROZEN + // Starting from MRI 2.8 it is preferable to freeze the string + // before deduplication so that it can be interned directly + // otherwise it would be duplicated first which is wasteful. + result = rb_funcall(rb_str_freeze(result), i_uminus, 0); + # elif STR_UMINUS_DEDUPE + // MRI 2.5 and older do not deduplicate strings that are already + // frozen. + result = rb_funcall(result, i_uminus, 0); + # else + result = rb_str_freeze(result); + # endif + } + # endif + + if (symbolize) { + result = rb_str_intern(result); + } + + return result; +} + + +enum {JSON_string_start = 1}; +enum {JSON_string_first_final = 8}; +enum {JSON_string_error = 0}; + +enum {JSON_string_en_main = 1}; + +static const char MAYBE_UNUSED(_JSON_string_nfa_targs)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_string_nfa_offsets)[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_string_nfa_push_actions)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_string_nfa_pop_trans)[] = { + 0, 0 +}; + + +#line 612 "parser.rl" + + +static int +match_i(VALUE regexp, VALUE klass, VALUE memo) +{ + if (regexp == Qundef) return ST_STOP; + if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) && + RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) { + rb_ary_push(memo, klass); + return ST_STOP; + } + return ST_CONTINUE; +} + +static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result) +{ + int cs = EVIL; + VALUE match_string; + + + { + cs = (int)JSON_string_start; + } + + #line 632 "parser.rl" + + json->memo = p; + + { + if ( p == pe ) + goto _test_eof; + switch ( cs ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 2: + goto st_case_2; + case 8: + goto st_case_8; + case 3: + goto st_case_3; + case 4: + goto st_case_4; + case 5: + goto st_case_5; + case 6: + goto st_case_6; + case 7: + goto st_case_7; + } + goto st_out; + st_case_1: + if ( ( (*( p))) == 34 ) { + goto st2; + } + { + goto st0; + } + st_case_0: + st0: + cs = 0; + goto _out; + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + switch( ( (*( p))) ) { + case 34: { + goto ctr2; + } + case 92: { + goto st3; + } + } + if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 ) { + goto st0; + } + { + goto st2; + } + ctr2: + { + #line 599 "parser.rl" + + *result = json_string_unescape(json->memo + 1, p, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names); + if (NIL_P(*result)) { + {p = p - 1; } + {p+= 1; cs = 8; goto _out;} + } else { + {p = (( p + 1))-1;} + + } + } + { + #line 609 "parser.rl" + {p = p - 1; } {p+= 1; cs = 8; goto _out;} } + + goto st8; + st8: + p+= 1; + if ( p == pe ) + goto _test_eof8; + st_case_8: + { + goto st0; + } + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + if ( ( (*( p))) == 117 ) { + goto st4; + } + if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 ) { + goto st0; + } + { + goto st2; + } + st4: + p+= 1; + if ( p == pe ) + goto _test_eof4; + st_case_4: + if ( ( (*( p))) < 65 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st5; + } + } else if ( ( (*( p))) > 70 ) { + if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) { + goto st5; + } + } else { + goto st5; + } + { + goto st0; + } + st5: + p+= 1; + if ( p == pe ) + goto _test_eof5; + st_case_5: + if ( ( (*( p))) < 65 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st6; + } + } else if ( ( (*( p))) > 70 ) { + if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) { + goto st6; + } + } else { + goto st6; + } + { + goto st0; + } + st6: + p+= 1; + if ( p == pe ) + goto _test_eof6; + st_case_6: + if ( ( (*( p))) < 65 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st7; + } + } else if ( ( (*( p))) > 70 ) { + if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) { + goto st7; + } + } else { + goto st7; + } + { + goto st0; + } + st7: + p+= 1; + if ( p == pe ) + goto _test_eof7; + st_case_7: + if ( ( (*( p))) < 65 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto st2; + } + } else if ( ( (*( p))) > 70 ) { + if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) { + goto st2; + } + } else { + goto st2; + } + { + goto st0; + } + st_out: + _test_eof2: cs = 2; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + + _test_eof: {} + _out: {} + } + + #line 634 "parser.rl" + + + if (json->create_additions && RTEST(match_string = json->match_string)) { + VALUE klass; + VALUE memo = rb_ary_new2(2); + rb_ary_push(memo, *result); + rb_hash_foreach(match_string, match_i, memo); + klass = rb_ary_entry(memo, 1); + if (RTEST(klass)) { + *result = rb_funcall(klass, i_json_create, 1, *result); + } + } + + if (cs >= JSON_string_first_final) { + return p + 1; + } else { + return NULL; + } +} + +/* +* Document-class: JSON::Ext::Parser +* +* This is the JSON parser implemented as a C extension. It can be configured +* to be used by setting +* +* JSON.parser = JSON::Ext::Parser +* +* with the method parser= in JSON. +* +*/ + +static VALUE convert_encoding(VALUE source) +{ + #ifdef HAVE_RUBY_ENCODING_H + rb_encoding *enc = rb_enc_get(source); + if (enc == rb_ascii8bit_encoding()) { + if (OBJ_FROZEN(source)) { + source = rb_str_dup(source); + } + FORCE_UTF8(source); + } else { + source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding()); + } + #endif + return source; +} + +/* +* call-seq: new(source, opts => {}) +* +* Creates a new JSON::Ext::Parser instance for the string _source_. +* +* Creates a new JSON::Ext::Parser instance for the string _source_. +* +* It will be configured by the _opts_ hash. _opts_ can have the following +* keys: +* +* _opts_ can have the following keys: +* * *max_nesting*: The maximum depth of nesting allowed in the parsed data +* structures. Disable depth checking with :max_nesting => false|nil|0, it +* defaults to 100. +* * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in +* defiance of RFC 4627 to be parsed by the Parser. This option defaults to +* false. +* * *symbolize_names*: If set to true, returns symbols for the names +* (keys) in a JSON object. Otherwise strings are returned, which is +* also the default. It's not possible to use this option in +* conjunction with the *create_additions* option. +* * *create_additions*: If set to false, the Parser doesn't create +* additions even if a matching class and create_id was found. This option +* defaults to false. +* * *object_class*: Defaults to Hash +* * *array_class*: Defaults to Array +*/ +static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE source, opts; + GET_PARSER_INIT; + + if (json->Vsource) { + rb_raise(rb_eTypeError, "already initialized instance"); + } + #ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + rb_scan_args(argc, argv, "1:", &source, &opts); + #else + rb_scan_args(argc, argv, "11", &source, &opts); + #endif + if (!NIL_P(opts)) { + #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash"); + if (NIL_P(opts)) { + rb_raise(rb_eArgError, "opts needs to be like a hash"); + } else { + #endif + VALUE tmp = ID2SYM(i_max_nesting); + if (option_given_p(opts, tmp)) { + VALUE max_nesting = rb_hash_aref(opts, tmp); + if (RTEST(max_nesting)) { + Check_Type(max_nesting, T_FIXNUM); + json->max_nesting = FIX2INT(max_nesting); + } else { + json->max_nesting = 0; + } + } else { + json->max_nesting = 100; + } + tmp = ID2SYM(i_allow_nan); + if (option_given_p(opts, tmp)) { + json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; + } else { + json->allow_nan = 0; + } + tmp = ID2SYM(i_symbolize_names); + if (option_given_p(opts, tmp)) { + json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; + } else { + json->symbolize_names = 0; + } + tmp = ID2SYM(i_freeze); + if (option_given_p(opts, tmp)) { + json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; + } else { + json->freeze = 0; + } + tmp = ID2SYM(i_create_additions); + if (option_given_p(opts, tmp)) { + json->create_additions = RTEST(rb_hash_aref(opts, tmp)); + } else { + json->create_additions = 0; + } + if (json->symbolize_names && json->create_additions) { + rb_raise(rb_eArgError, + "options :symbolize_names and :create_additions cannot be " + " used in conjunction"); + } + tmp = ID2SYM(i_create_id); + if (option_given_p(opts, tmp)) { + json->create_id = rb_hash_aref(opts, tmp); + } else { + json->create_id = rb_funcall(mJSON, i_create_id, 0); + } + tmp = ID2SYM(i_object_class); + if (option_given_p(opts, tmp)) { + json->object_class = rb_hash_aref(opts, tmp); + } else { + json->object_class = Qnil; + } + tmp = ID2SYM(i_array_class); + if (option_given_p(opts, tmp)) { + json->array_class = rb_hash_aref(opts, tmp); + } else { + json->array_class = Qnil; + } + tmp = ID2SYM(i_decimal_class); + if (option_given_p(opts, tmp)) { + json->decimal_class = rb_hash_aref(opts, tmp); + } else { + json->decimal_class = Qnil; + } + tmp = ID2SYM(i_match_string); + if (option_given_p(opts, tmp)) { + VALUE match_string = rb_hash_aref(opts, tmp); + json->match_string = RTEST(match_string) ? match_string : Qnil; + } else { + json->match_string = Qnil; + } + #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + } + #endif + } else { + json->max_nesting = 100; + json->allow_nan = 0; + json->create_additions = 0; + json->create_id = rb_funcall(mJSON, i_create_id, 0); + json->object_class = Qnil; + json->array_class = Qnil; + json->decimal_class = Qnil; + } + source = convert_encoding(StringValue(source)); + StringValue(source); + json->len = RSTRING_LEN(source); + json->source = RSTRING_PTR(source);; + json->Vsource = source; + return self; +} + + +enum {JSON_start = 1}; +enum {JSON_first_final = 10}; +enum {JSON_error = 0}; + +enum {JSON_en_main = 1}; + +static const char MAYBE_UNUSED(_JSON_nfa_targs)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_nfa_offsets)[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_nfa_push_actions)[] = { + 0, 0 +}; + +static const char MAYBE_UNUSED(_JSON_nfa_pop_trans)[] = { + 0, 0 +}; + + +#line 835 "parser.rl" + + +/* +* call-seq: parse() +* +* Parses the current JSON text _source_ and returns the complete data +* structure as a result. +* It raises JSON::ParseError if fail to parse. +*/ +static VALUE cParser_parse(VALUE self) +{ + char *p, *pe; + int cs = EVIL; + VALUE result = Qnil; + GET_PARSER; + + + { + cs = (int)JSON_start; + } + + #line 851 "parser.rl" + + p = json->source; + pe = p + json->len; + + { + if ( p == pe ) + goto _test_eof; + switch ( cs ) + { + case 1: + goto st_case_1; + case 0: + goto st_case_0; + case 10: + goto st_case_10; + case 2: + goto st_case_2; + case 3: + goto st_case_3; + case 4: + goto st_case_4; + case 5: + goto st_case_5; + case 6: + goto st_case_6; + case 7: + goto st_case_7; + case 8: + goto st_case_8; + case 9: + goto st_case_9; + } + goto st_out; + st1: + p+= 1; + if ( p == pe ) + goto _test_eof1; + st_case_1: + switch( ( (*( p))) ) { + case 13: { + goto st1; + } + case 32: { + goto st1; + } + case 34: { + goto ctr2; + } + case 45: { + goto ctr2; + } + case 47: { + goto st6; + } + case 73: { + goto ctr2; + } + case 78: { + goto ctr2; + } + case 91: { + goto ctr2; + } + case 102: { + goto ctr2; + } + case 110: { + goto ctr2; + } + case 116: { + goto ctr2; + } + case 123: { + goto ctr2; + } + } + if ( ( (*( p))) > 10 ) { + if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) { + goto ctr2; + } + } else if ( ( (*( p))) >= 9 ) { + goto st1; + } + { + goto st0; + } + st_case_0: + st0: + cs = 0; + goto _out; + ctr2: + { + #line 827 "parser.rl" + + char *np = JSON_parse_value(json, p, pe, &result, 0); + if (np == NULL) { {p = p - 1; } {p+= 1; cs = 10; goto _out;} } else {p = (( np))-1;} + + } + + goto st10; + st10: + p+= 1; + if ( p == pe ) + goto _test_eof10; + st_case_10: + switch( ( (*( p))) ) { + case 13: { + goto st10; + } + case 32: { + goto st10; + } + case 47: { + goto st2; + } + } + if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) { + goto st10; + } + { + goto st0; + } + st2: + p+= 1; + if ( p == pe ) + goto _test_eof2; + st_case_2: + switch( ( (*( p))) ) { + case 42: { + goto st3; + } + case 47: { + goto st5; + } + } + { + goto st0; + } + st3: + p+= 1; + if ( p == pe ) + goto _test_eof3; + st_case_3: + if ( ( (*( p))) == 42 ) { + goto st4; + } + { + goto st3; + } + st4: + p+= 1; + if ( p == pe ) + goto _test_eof4; + st_case_4: + switch( ( (*( p))) ) { + case 42: { + goto st4; + } + case 47: { + goto st10; + } + } + { + goto st3; + } + st5: + p+= 1; + if ( p == pe ) + goto _test_eof5; + st_case_5: + if ( ( (*( p))) == 10 ) { + goto st10; + } + { + goto st5; + } + st6: + p+= 1; + if ( p == pe ) + goto _test_eof6; + st_case_6: + switch( ( (*( p))) ) { + case 42: { + goto st7; + } + case 47: { + goto st9; + } + } + { + goto st0; + } + st7: + p+= 1; + if ( p == pe ) + goto _test_eof7; + st_case_7: + if ( ( (*( p))) == 42 ) { + goto st8; + } + { + goto st7; + } + st8: + p+= 1; + if ( p == pe ) + goto _test_eof8; + st_case_8: + switch( ( (*( p))) ) { + case 42: { + goto st8; + } + case 47: { + goto st1; + } + } + { + goto st7; + } + st9: + p+= 1; + if ( p == pe ) + goto _test_eof9; + st_case_9: + if ( ( (*( p))) == 10 ) { + goto st1; + } + { + goto st9; + } + st_out: + _test_eof1: cs = 1; goto _test_eof; + _test_eof10: cs = 10; goto _test_eof; + _test_eof2: cs = 2; goto _test_eof; + _test_eof3: cs = 3; goto _test_eof; + _test_eof4: cs = 4; goto _test_eof; + _test_eof5: cs = 5; goto _test_eof; + _test_eof6: cs = 6; goto _test_eof; + _test_eof7: cs = 7; goto _test_eof; + _test_eof8: cs = 8; goto _test_eof; + _test_eof9: cs = 9; goto _test_eof; + + _test_eof: {} + _out: {} + } + + #line 854 "parser.rl" + + + if (cs >= JSON_first_final && p == pe) { + return result; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p); + return Qnil; + } +} + +static void JSON_mark(void *ptr) +{ + JSON_Parser *json = ptr; + rb_gc_mark_maybe(json->Vsource); + rb_gc_mark_maybe(json->create_id); + rb_gc_mark_maybe(json->object_class); + rb_gc_mark_maybe(json->array_class); + rb_gc_mark_maybe(json->decimal_class); + rb_gc_mark_maybe(json->match_string); +} + +static void JSON_free(void *ptr) +{ + JSON_Parser *json = ptr; + fbuffer_free(json->fbuffer); + ruby_xfree(json); +} + +static size_t JSON_memsize(const void *ptr) +{ + const JSON_Parser *json = ptr; + return sizeof(*json) + FBUFFER_CAPA(json->fbuffer); +} + +#ifdef NEW_TYPEDDATA_WRAPPER +static const rb_data_type_t JSON_Parser_type = { + "JSON/Parser", + {JSON_mark, JSON_free, JSON_memsize,}, + #ifdef RUBY_TYPED_FREE_IMMEDIATELY + 0, 0, + RUBY_TYPED_FREE_IMMEDIATELY, + #endif +}; +#endif + +static VALUE cJSON_parser_s_allocate(VALUE klass) +{ + JSON_Parser *json; + VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json); + json->fbuffer = fbuffer_alloc(0); + return obj; +} + +/* +* call-seq: source() +* +* Returns a copy of the current _source_ string, that was used to construct +* this Parser. +*/ +static VALUE cParser_source(VALUE self) +{ + GET_PARSER; + return rb_str_dup(json->Vsource); +} + +void Init_parser(void) +{ + #ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); + #endif + + #undef rb_intern + rb_require("json/common"); + mJSON = rb_define_module("JSON"); + mExt = rb_define_module_under(mJSON, "Ext"); + cParser = rb_define_class_under(mExt, "Parser", rb_cObject); + eParserError = rb_path2class("JSON::ParserError"); + eNestingError = rb_path2class("JSON::NestingError"); + rb_gc_register_mark_object(eParserError); + rb_gc_register_mark_object(eNestingError); + rb_define_alloc_func(cParser, cJSON_parser_s_allocate); + rb_define_method(cParser, "initialize", cParser_initialize, -1); + rb_define_method(cParser, "parse", cParser_parse, 0); + rb_define_method(cParser, "source", cParser_source, 0); + + CNaN = rb_const_get(mJSON, rb_intern("NaN")); + rb_gc_register_mark_object(CNaN); + + CInfinity = rb_const_get(mJSON, rb_intern("Infinity")); + rb_gc_register_mark_object(CInfinity); + + CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity")); + rb_gc_register_mark_object(CMinusInfinity); + + i_json_creatable_p = rb_intern("json_creatable?"); + i_json_create = rb_intern("json_create"); + i_create_id = rb_intern("create_id"); + i_create_additions = rb_intern("create_additions"); + i_chr = rb_intern("chr"); + i_max_nesting = rb_intern("max_nesting"); + i_allow_nan = rb_intern("allow_nan"); + i_symbolize_names = rb_intern("symbolize_names"); + i_object_class = rb_intern("object_class"); + i_array_class = rb_intern("array_class"); + i_decimal_class = rb_intern("decimal_class"); + i_match = rb_intern("match"); + i_match_string = rb_intern("match_string"); + i_key_p = rb_intern("key?"); + i_deep_const_get = rb_intern("deep_const_get"); + i_aset = rb_intern("[]="); + i_aref = rb_intern("[]"); + i_leftshift = rb_intern("<<"); + i_new = rb_intern("new"); + i_try_convert = rb_intern("try_convert"); + i_freeze = rb_intern("freeze"); + i_uminus = rb_intern("-@"); +} + +/* +* Local variables: +* mode: c +* c-file-style: ruby +* indent-tabs-mode: nil +* End: +*/ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.h b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.h new file mode 100644 index 0000000..92ed3fd --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.h @@ -0,0 +1,96 @@ +#ifndef _PARSER_H_ +#define _PARSER_H_ + +#include "ruby.h" + +#ifndef HAVE_RUBY_RE_H +#include "re.h" +#endif + +#ifdef HAVE_RUBY_ST_H +#include "ruby/st.h" +#else +#include "st.h" +#endif + +#ifndef MAYBE_UNUSED +# define MAYBE_UNUSED(x) x +#endif + +#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key)) + +/* unicode */ + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ + +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF + +typedef struct JSON_ParserStruct { + VALUE Vsource; + char *source; + long len; + char *memo; + VALUE create_id; + int max_nesting; + int allow_nan; + int parsing_name; + int symbolize_names; + int freeze; + VALUE object_class; + VALUE array_class; + VALUE decimal_class; + int create_additions; + VALUE match_string; + FBuffer *fbuffer; +} JSON_Parser; + +#define GET_PARSER \ + GET_PARSER_INIT; \ + if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance") +#define GET_PARSER_INIT \ + JSON_Parser *json; \ + TypedData_Get_Struct(self, JSON_Parser, &JSON_Parser_type, json) + +#define MinusInfinity "-Infinity" +#define EVIL 0x666 + +static UTF32 unescape_unicode(const unsigned char *p); +static int convert_UTF32_to_UTF8(char *buf, UTF32 ch); +static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting); +static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting); +static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result); +static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result); +static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting); +static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize); +static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result); +static VALUE convert_encoding(VALUE source); +static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self); +static VALUE cParser_parse(VALUE self); +static void JSON_mark(void *json); +static void JSON_free(void *json); +static VALUE cJSON_parser_s_allocate(VALUE klass); +static VALUE cParser_source(VALUE self); +#ifndef ZALLOC +#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type))) +static inline void *ruby_zalloc(size_t n) +{ + void *p = ruby_xmalloc(n); + memset(p, 0, n); + return p; +} +#endif +#ifdef TypedData_Make_Struct +static const rb_data_type_t JSON_Parser_type; +#define NEW_TYPEDDATA_WRAPPER 1 +#else +#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, JSON_free, json) +#define TypedData_Get_Struct(self, JSON_Parser, ignore, json) Data_Get_Struct(self, JSON_Parser, json) +#endif + +#endif diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.o b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.o new file mode 100644 index 0000000..300c32b Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.o differ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.rl b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.rl new file mode 100644 index 0000000..2dbdc7e --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.rl @@ -0,0 +1,986 @@ +#include "../fbuffer/fbuffer.h" +#include "parser.h" + +#if defined HAVE_RUBY_ENCODING_H +# define EXC_ENCODING rb_utf8_encoding(), +# ifndef HAVE_RB_ENC_RAISE +static void +enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...) +{ + va_list args; + VALUE mesg; + + va_start(args, fmt); + mesg = rb_enc_vsprintf(enc, fmt, args); + va_end(args); + + rb_exc_raise(rb_exc_new3(exc, mesg)); +} +# define rb_enc_raise enc_raise +# endif +#else +# define EXC_ENCODING /* nothing */ +# define rb_enc_raise rb_raise +#endif + +/* unicode */ + +static const signed char digit_values[256] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, + -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1 +}; + +static UTF32 unescape_unicode(const unsigned char *p) +{ + signed char b; + UTF32 result = 0; + b = digit_values[p[0]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + b = digit_values[p[1]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + b = digit_values[p[2]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + b = digit_values[p[3]]; + if (b < 0) return UNI_REPLACEMENT_CHAR; + result = (result << 4) | (unsigned char)b; + return result; +} + +static int convert_UTF32_to_UTF8(char *buf, UTF32 ch) +{ + int len = 1; + if (ch <= 0x7F) { + buf[0] = (char) ch; + } else if (ch <= 0x07FF) { + buf[0] = (char) ((ch >> 6) | 0xC0); + buf[1] = (char) ((ch & 0x3F) | 0x80); + len++; + } else if (ch <= 0xFFFF) { + buf[0] = (char) ((ch >> 12) | 0xE0); + buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80); + buf[2] = (char) ((ch & 0x3F) | 0x80); + len += 2; + } else if (ch <= 0x1fffff) { + buf[0] =(char) ((ch >> 18) | 0xF0); + buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80); + buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80); + buf[3] =(char) ((ch & 0x3F) | 0x80); + len += 3; + } else { + buf[0] = '?'; + } + return len; +} + +static VALUE mJSON, mExt, cParser, eParserError, eNestingError; +static VALUE CNaN, CInfinity, CMinusInfinity; + +static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions, + i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, + i_object_class, i_array_class, i_decimal_class, i_key_p, + i_deep_const_get, i_match, i_match_string, i_aset, i_aref, + i_leftshift, i_new, i_try_convert, i_freeze, i_uminus; + +%%{ + machine JSON_common; + + cr = '\n'; + cr_neg = [^\n]; + ws = [ \t\r\n]; + c_comment = '/*' ( any* - (any* '*/' any* ) ) '*/'; + cpp_comment = '//' cr_neg* cr; + comment = c_comment | cpp_comment; + ignore = ws | comment; + name_separator = ':'; + value_separator = ','; + Vnull = 'null'; + Vfalse = 'false'; + Vtrue = 'true'; + VNaN = 'NaN'; + VInfinity = 'Infinity'; + VMinusInfinity = '-Infinity'; + begin_value = [nft\"\-\[\{NI] | digit; + begin_object = '{'; + end_object = '}'; + begin_array = '['; + end_array = ']'; + begin_string = '"'; + begin_name = begin_string; + begin_number = digit | '-'; +}%% + +%%{ + machine JSON_object; + include JSON_common; + + write data; + + action parse_value { + VALUE v = Qnil; + char *np = JSON_parse_value(json, fpc, pe, &v, current_nesting); + if (np == NULL) { + fhold; fbreak; + } else { + if (NIL_P(json->object_class)) { + OBJ_FREEZE(last_name); + rb_hash_aset(*result, last_name, v); + } else { + rb_funcall(*result, i_aset, 2, last_name, v); + } + fexec np; + } + } + + action parse_name { + char *np; + json->parsing_name = 1; + np = JSON_parse_string(json, fpc, pe, &last_name); + json->parsing_name = 0; + if (np == NULL) { fhold; fbreak; } else fexec np; + } + + action exit { fhold; fbreak; } + + pair = ignore* begin_name >parse_name ignore* name_separator ignore* begin_value >parse_value; + next_pair = ignore* value_separator pair; + + main := ( + begin_object + (pair (next_pair)*)? ignore* + end_object + ) @exit; +}%% + +static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) +{ + int cs = EVIL; + VALUE last_name = Qnil; + VALUE object_class = json->object_class; + + if (json->max_nesting && current_nesting > json->max_nesting) { + rb_raise(eNestingError, "nesting of %d is too deep", current_nesting); + } + + *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class); + + %% write init; + %% write exec; + + if (cs >= JSON_object_first_final) { + if (json->create_additions) { + VALUE klassname; + if (NIL_P(json->object_class)) { + klassname = rb_hash_aref(*result, json->create_id); + } else { + klassname = rb_funcall(*result, i_aref, 1, json->create_id); + } + if (!NIL_P(klassname)) { + VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname); + if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) { + *result = rb_funcall(klass, i_json_create, 1, *result); + } + } + } + return p + 1; + } else { + return NULL; + } +} + + +%%{ + machine JSON_value; + include JSON_common; + + write data; + + action parse_null { + *result = Qnil; + } + action parse_false { + *result = Qfalse; + } + action parse_true { + *result = Qtrue; + } + action parse_nan { + if (json->allow_nan) { + *result = CNaN; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2); + } + } + action parse_infinity { + if (json->allow_nan) { + *result = CInfinity; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8); + } + } + action parse_string { + char *np = JSON_parse_string(json, fpc, pe, result); + if (np == NULL) { fhold; fbreak; } else fexec np; + } + + action parse_number { + char *np; + if(pe > fpc + 8 && !strncmp(MinusInfinity, fpc, 9)) { + if (json->allow_nan) { + *result = CMinusInfinity; + fexec p + 10; + fhold; fbreak; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p); + } + } + np = JSON_parse_float(json, fpc, pe, result); + if (np != NULL) fexec np; + np = JSON_parse_integer(json, fpc, pe, result); + if (np != NULL) fexec np; + fhold; fbreak; + } + + action parse_array { + char *np; + np = JSON_parse_array(json, fpc, pe, result, current_nesting + 1); + if (np == NULL) { fhold; fbreak; } else fexec np; + } + + action parse_object { + char *np; + np = JSON_parse_object(json, fpc, pe, result, current_nesting + 1); + if (np == NULL) { fhold; fbreak; } else fexec np; + } + + action exit { fhold; fbreak; } + +main := ignore* ( + Vnull @parse_null | + Vfalse @parse_false | + Vtrue @parse_true | + VNaN @parse_nan | + VInfinity @parse_infinity | + begin_number >parse_number | + begin_string >parse_string | + begin_array >parse_array | + begin_object >parse_object + ) ignore* %*exit; +}%% + +static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) +{ + int cs = EVIL; + + %% write init; + %% write exec; + + if (json->freeze) { + OBJ_FREEZE(*result); + } + + if (cs >= JSON_value_first_final) { + return p; + } else { + return NULL; + } +} + +%%{ + machine JSON_integer; + + write data; + + action exit { fhold; fbreak; } + + main := '-'? ('0' | [1-9][0-9]*) (^[0-9]? @exit); +}%% + +static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result) +{ + int cs = EVIL; + + %% write init; + json->memo = p; + %% write exec; + + if (cs >= JSON_integer_first_final) { + long len = p - json->memo; + fbuffer_clear(json->fbuffer); + fbuffer_append(json->fbuffer, json->memo, len); + fbuffer_append_char(json->fbuffer, '\0'); + *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10); + return p + 1; + } else { + return NULL; + } +} + +%%{ + machine JSON_float; + include JSON_common; + + write data; + + action exit { fhold; fbreak; } + + main := '-'? ( + (('0' | [1-9][0-9]*) '.' [0-9]+ ([Ee] [+\-]?[0-9]+)?) + | (('0' | [1-9][0-9]*) ([Ee] [+\-]?[0-9]+)) + ) (^[0-9Ee.\-]? @exit ); +}%% + +static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result) +{ + int cs = EVIL; + + %% write init; + json->memo = p; + %% write exec; + + if (cs >= JSON_float_first_final) { + VALUE mod = Qnil; + ID method_id = 0; + if (rb_respond_to(json->decimal_class, i_try_convert)) { + mod = json->decimal_class; + method_id = i_try_convert; + } else if (rb_respond_to(json->decimal_class, i_new)) { + mod = json->decimal_class; + method_id = i_new; + } else if (RB_TYPE_P(json->decimal_class, T_CLASS)) { + VALUE name = rb_class_name(json->decimal_class); + const char *name_cstr = RSTRING_PTR(name); + const char *last_colon = strrchr(name_cstr, ':'); + if (last_colon) { + const char *mod_path_end = last_colon - 1; + VALUE mod_path = rb_str_substr(name, 0, mod_path_end - name_cstr); + mod = rb_path_to_class(mod_path); + + const char *method_name_beg = last_colon + 1; + long before_len = method_name_beg - name_cstr; + long len = RSTRING_LEN(name) - before_len; + VALUE method_name = rb_str_substr(name, before_len, len); + method_id = SYM2ID(rb_str_intern(method_name)); + } else { + mod = rb_mKernel; + method_id = SYM2ID(rb_str_intern(name)); + } + } + + long len = p - json->memo; + fbuffer_clear(json->fbuffer); + fbuffer_append(json->fbuffer, json->memo, len); + fbuffer_append_char(json->fbuffer, '\0'); + + if (method_id) { + VALUE text = rb_str_new2(FBUFFER_PTR(json->fbuffer)); + *result = rb_funcallv(mod, method_id, 1, &text); + } else { + *result = DBL2NUM(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1)); + } + + return p + 1; + } else { + return NULL; + } +} + + +%%{ + machine JSON_array; + include JSON_common; + + write data; + + action parse_value { + VALUE v = Qnil; + char *np = JSON_parse_value(json, fpc, pe, &v, current_nesting); + if (np == NULL) { + fhold; fbreak; + } else { + if (NIL_P(json->array_class)) { + rb_ary_push(*result, v); + } else { + rb_funcall(*result, i_leftshift, 1, v); + } + fexec np; + } + } + + action exit { fhold; fbreak; } + + next_element = value_separator ignore* begin_value >parse_value; + + main := begin_array ignore* + ((begin_value >parse_value ignore*) + (ignore* next_element ignore*)*)? + end_array @exit; +}%% + +static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting) +{ + int cs = EVIL; + VALUE array_class = json->array_class; + + if (json->max_nesting && current_nesting > json->max_nesting) { + rb_raise(eNestingError, "nesting of %d is too deep", current_nesting); + } + *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class); + + %% write init; + %% write exec; + + if(cs >= JSON_array_first_final) { + return p + 1; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p); + return NULL; + } +} + +static const size_t MAX_STACK_BUFFER_SIZE = 128; +static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize) +{ + VALUE result = Qnil; + size_t bufferSize = stringEnd - string; + char *p = string, *pe = string, *unescape, *bufferStart, *buffer; + int unescape_len; + char buf[4]; + + if (bufferSize > MAX_STACK_BUFFER_SIZE) { +# ifdef HAVE_RB_ENC_INTERNED_STR + bufferStart = buffer = ALLOC_N(char, bufferSize ? bufferSize : 1); +# else + bufferStart = buffer = ALLOC_N(char, bufferSize); +# endif + } else { +# ifdef HAVE_RB_ENC_INTERNED_STR + bufferStart = buffer = ALLOCA_N(char, bufferSize ? bufferSize : 1); +# else + bufferStart = buffer = ALLOCA_N(char, bufferSize); +# endif + } + + while (pe < stringEnd) { + if (*pe == '\\') { + unescape = (char *) "?"; + unescape_len = 1; + if (pe > p) { + MEMCPY(buffer, p, char, pe - p); + buffer += pe - p; + } + switch (*++pe) { + case 'n': + unescape = (char *) "\n"; + break; + case 'r': + unescape = (char *) "\r"; + break; + case 't': + unescape = (char *) "\t"; + break; + case '"': + unescape = (char *) "\""; + break; + case '\\': + unescape = (char *) "\\"; + break; + case 'b': + unescape = (char *) "\b"; + break; + case 'f': + unescape = (char *) "\f"; + break; + case 'u': + if (pe > stringEnd - 4) { + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } + rb_enc_raise( + EXC_ENCODING eParserError, + "incomplete unicode character escape sequence at '%s'", p + ); + } else { + UTF32 ch = unescape_unicode((unsigned char *) ++pe); + pe += 3; + if (UNI_SUR_HIGH_START == (ch & 0xFC00)) { + pe++; + if (pe > stringEnd - 6) { + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } + rb_enc_raise( + EXC_ENCODING eParserError, + "incomplete surrogate pair at '%s'", p + ); + } + if (pe[0] == '\\' && pe[1] == 'u') { + UTF32 sur = unescape_unicode((unsigned char *) pe + 2); + ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16) + | (sur & 0x3FF)); + pe += 5; + } else { + unescape = (char *) "?"; + break; + } + } + unescape_len = convert_UTF32_to_UTF8(buf, ch); + unescape = buf; + } + break; + default: + p = pe; + continue; + } + MEMCPY(buffer, unescape, char, unescape_len); + buffer += unescape_len; + p = ++pe; + } else { + pe++; + } + } + + if (pe > p) { + MEMCPY(buffer, p, char, pe - p); + buffer += pe - p; + } + +# ifdef HAVE_RB_ENC_INTERNED_STR + if (intern) { + result = rb_enc_interned_str(bufferStart, (long)(buffer - bufferStart), rb_utf8_encoding()); + } else { + result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart)); + } + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } +# else + result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart)); + + if (bufferSize > MAX_STACK_BUFFER_SIZE) { + free(bufferStart); + } + + if (intern) { + # if STR_UMINUS_DEDUPE_FROZEN + // Starting from MRI 2.8 it is preferable to freeze the string + // before deduplication so that it can be interned directly + // otherwise it would be duplicated first which is wasteful. + result = rb_funcall(rb_str_freeze(result), i_uminus, 0); + # elif STR_UMINUS_DEDUPE + // MRI 2.5 and older do not deduplicate strings that are already + // frozen. + result = rb_funcall(result, i_uminus, 0); + # else + result = rb_str_freeze(result); + # endif + } +# endif + + if (symbolize) { + result = rb_str_intern(result); + } + + return result; +} + +%%{ + machine JSON_string; + include JSON_common; + + write data; + + action parse_string { + *result = json_string_unescape(json->memo + 1, p, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names); + if (NIL_P(*result)) { + fhold; + fbreak; + } else { + fexec p + 1; + } + } + + action exit { fhold; fbreak; } + + main := '"' ((^([\"\\] | 0..0x1f) | '\\'[\"\\/bfnrt] | '\\u'[0-9a-fA-F]{4} | '\\'^([\"\\/bfnrtu]|0..0x1f))* %parse_string) '"' @exit; +}%% + +static int +match_i(VALUE regexp, VALUE klass, VALUE memo) +{ + if (regexp == Qundef) return ST_STOP; + if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) && + RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) { + rb_ary_push(memo, klass); + return ST_STOP; + } + return ST_CONTINUE; +} + +static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result) +{ + int cs = EVIL; + VALUE match_string; + + %% write init; + json->memo = p; + %% write exec; + + if (json->create_additions && RTEST(match_string = json->match_string)) { + VALUE klass; + VALUE memo = rb_ary_new2(2); + rb_ary_push(memo, *result); + rb_hash_foreach(match_string, match_i, memo); + klass = rb_ary_entry(memo, 1); + if (RTEST(klass)) { + *result = rb_funcall(klass, i_json_create, 1, *result); + } + } + + if (cs >= JSON_string_first_final) { + return p + 1; + } else { + return NULL; + } +} + +/* + * Document-class: JSON::Ext::Parser + * + * This is the JSON parser implemented as a C extension. It can be configured + * to be used by setting + * + * JSON.parser = JSON::Ext::Parser + * + * with the method parser= in JSON. + * + */ + +static VALUE convert_encoding(VALUE source) +{ +#ifdef HAVE_RUBY_ENCODING_H + rb_encoding *enc = rb_enc_get(source); + if (enc == rb_ascii8bit_encoding()) { + if (OBJ_FROZEN(source)) { + source = rb_str_dup(source); + } + FORCE_UTF8(source); + } else { + source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding()); + } +#endif + return source; +} + +/* + * call-seq: new(source, opts => {}) + * + * Creates a new JSON::Ext::Parser instance for the string _source_. + * + * Creates a new JSON::Ext::Parser instance for the string _source_. + * + * It will be configured by the _opts_ hash. _opts_ can have the following + * keys: + * + * _opts_ can have the following keys: + * * *max_nesting*: The maximum depth of nesting allowed in the parsed data + * structures. Disable depth checking with :max_nesting => false|nil|0, it + * defaults to 100. + * * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in + * defiance of RFC 4627 to be parsed by the Parser. This option defaults to + * false. + * * *symbolize_names*: If set to true, returns symbols for the names + * (keys) in a JSON object. Otherwise strings are returned, which is + * also the default. It's not possible to use this option in + * conjunction with the *create_additions* option. + * * *create_additions*: If set to false, the Parser doesn't create + * additions even if a matching class and create_id was found. This option + * defaults to false. + * * *object_class*: Defaults to Hash + * * *array_class*: Defaults to Array + */ +static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE source, opts; + GET_PARSER_INIT; + + if (json->Vsource) { + rb_raise(rb_eTypeError, "already initialized instance"); + } +#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + rb_scan_args(argc, argv, "1:", &source, &opts); +#else + rb_scan_args(argc, argv, "11", &source, &opts); +#endif + if (!NIL_P(opts)) { +#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash"); + if (NIL_P(opts)) { + rb_raise(rb_eArgError, "opts needs to be like a hash"); + } else { +#endif + VALUE tmp = ID2SYM(i_max_nesting); + if (option_given_p(opts, tmp)) { + VALUE max_nesting = rb_hash_aref(opts, tmp); + if (RTEST(max_nesting)) { + Check_Type(max_nesting, T_FIXNUM); + json->max_nesting = FIX2INT(max_nesting); + } else { + json->max_nesting = 0; + } + } else { + json->max_nesting = 100; + } + tmp = ID2SYM(i_allow_nan); + if (option_given_p(opts, tmp)) { + json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; + } else { + json->allow_nan = 0; + } + tmp = ID2SYM(i_symbolize_names); + if (option_given_p(opts, tmp)) { + json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; + } else { + json->symbolize_names = 0; + } + tmp = ID2SYM(i_freeze); + if (option_given_p(opts, tmp)) { + json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0; + } else { + json->freeze = 0; + } + tmp = ID2SYM(i_create_additions); + if (option_given_p(opts, tmp)) { + json->create_additions = RTEST(rb_hash_aref(opts, tmp)); + } else { + json->create_additions = 0; + } + if (json->symbolize_names && json->create_additions) { + rb_raise(rb_eArgError, + "options :symbolize_names and :create_additions cannot be " + " used in conjunction"); + } + tmp = ID2SYM(i_create_id); + if (option_given_p(opts, tmp)) { + json->create_id = rb_hash_aref(opts, tmp); + } else { + json->create_id = rb_funcall(mJSON, i_create_id, 0); + } + tmp = ID2SYM(i_object_class); + if (option_given_p(opts, tmp)) { + json->object_class = rb_hash_aref(opts, tmp); + } else { + json->object_class = Qnil; + } + tmp = ID2SYM(i_array_class); + if (option_given_p(opts, tmp)) { + json->array_class = rb_hash_aref(opts, tmp); + } else { + json->array_class = Qnil; + } + tmp = ID2SYM(i_decimal_class); + if (option_given_p(opts, tmp)) { + json->decimal_class = rb_hash_aref(opts, tmp); + } else { + json->decimal_class = Qnil; + } + tmp = ID2SYM(i_match_string); + if (option_given_p(opts, tmp)) { + VALUE match_string = rb_hash_aref(opts, tmp); + json->match_string = RTEST(match_string) ? match_string : Qnil; + } else { + json->match_string = Qnil; + } +#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH + } +#endif + } else { + json->max_nesting = 100; + json->allow_nan = 0; + json->create_additions = 0; + json->create_id = rb_funcall(mJSON, i_create_id, 0); + json->object_class = Qnil; + json->array_class = Qnil; + json->decimal_class = Qnil; + } + source = convert_encoding(StringValue(source)); + StringValue(source); + json->len = RSTRING_LEN(source); + json->source = RSTRING_PTR(source);; + json->Vsource = source; + return self; +} + +%%{ + machine JSON; + + write data; + + include JSON_common; + + action parse_value { + char *np = JSON_parse_value(json, fpc, pe, &result, 0); + if (np == NULL) { fhold; fbreak; } else fexec np; + } + + main := ignore* ( + begin_value >parse_value + ) ignore*; +}%% + +/* + * call-seq: parse() + * + * Parses the current JSON text _source_ and returns the complete data + * structure as a result. + * It raises JSON::ParseError if fail to parse. + */ +static VALUE cParser_parse(VALUE self) +{ + char *p, *pe; + int cs = EVIL; + VALUE result = Qnil; + GET_PARSER; + + %% write init; + p = json->source; + pe = p + json->len; + %% write exec; + + if (cs >= JSON_first_final && p == pe) { + return result; + } else { + rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p); + return Qnil; + } +} + +static void JSON_mark(void *ptr) +{ + JSON_Parser *json = ptr; + rb_gc_mark_maybe(json->Vsource); + rb_gc_mark_maybe(json->create_id); + rb_gc_mark_maybe(json->object_class); + rb_gc_mark_maybe(json->array_class); + rb_gc_mark_maybe(json->decimal_class); + rb_gc_mark_maybe(json->match_string); +} + +static void JSON_free(void *ptr) +{ + JSON_Parser *json = ptr; + fbuffer_free(json->fbuffer); + ruby_xfree(json); +} + +static size_t JSON_memsize(const void *ptr) +{ + const JSON_Parser *json = ptr; + return sizeof(*json) + FBUFFER_CAPA(json->fbuffer); +} + +#ifdef NEW_TYPEDDATA_WRAPPER +static const rb_data_type_t JSON_Parser_type = { + "JSON/Parser", + {JSON_mark, JSON_free, JSON_memsize,}, +#ifdef RUBY_TYPED_FREE_IMMEDIATELY + 0, 0, + RUBY_TYPED_FREE_IMMEDIATELY, +#endif +}; +#endif + +static VALUE cJSON_parser_s_allocate(VALUE klass) +{ + JSON_Parser *json; + VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json); + json->fbuffer = fbuffer_alloc(0); + return obj; +} + +/* + * call-seq: source() + * + * Returns a copy of the current _source_ string, that was used to construct + * this Parser. + */ +static VALUE cParser_source(VALUE self) +{ + GET_PARSER; + return rb_str_dup(json->Vsource); +} + +void Init_parser(void) +{ +#ifdef HAVE_RB_EXT_RACTOR_SAFE + rb_ext_ractor_safe(true); +#endif + +#undef rb_intern + rb_require("json/common"); + mJSON = rb_define_module("JSON"); + mExt = rb_define_module_under(mJSON, "Ext"); + cParser = rb_define_class_under(mExt, "Parser", rb_cObject); + eParserError = rb_path2class("JSON::ParserError"); + eNestingError = rb_path2class("JSON::NestingError"); + rb_gc_register_mark_object(eParserError); + rb_gc_register_mark_object(eNestingError); + rb_define_alloc_func(cParser, cJSON_parser_s_allocate); + rb_define_method(cParser, "initialize", cParser_initialize, -1); + rb_define_method(cParser, "parse", cParser_parse, 0); + rb_define_method(cParser, "source", cParser_source, 0); + + CNaN = rb_const_get(mJSON, rb_intern("NaN")); + rb_gc_register_mark_object(CNaN); + + CInfinity = rb_const_get(mJSON, rb_intern("Infinity")); + rb_gc_register_mark_object(CInfinity); + + CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity")); + rb_gc_register_mark_object(CMinusInfinity); + + i_json_creatable_p = rb_intern("json_creatable?"); + i_json_create = rb_intern("json_create"); + i_create_id = rb_intern("create_id"); + i_create_additions = rb_intern("create_additions"); + i_chr = rb_intern("chr"); + i_max_nesting = rb_intern("max_nesting"); + i_allow_nan = rb_intern("allow_nan"); + i_symbolize_names = rb_intern("symbolize_names"); + i_object_class = rb_intern("object_class"); + i_array_class = rb_intern("array_class"); + i_decimal_class = rb_intern("decimal_class"); + i_match = rb_intern("match"); + i_match_string = rb_intern("match_string"); + i_key_p = rb_intern("key?"); + i_deep_const_get = rb_intern("deep_const_get"); + i_aset = rb_intern("[]="); + i_aref = rb_intern("[]"); + i_leftshift = rb_intern("<<"); + i_new = rb_intern("new"); + i_try_convert = rb_intern("try_convert"); + i_freeze = rb_intern("freeze"); + i_uminus = rb_intern("-@"); +} + +/* + * Local variables: + * mode: c + * c-file-style: ruby + * indent-tabs-mode: nil + * End: + */ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.so b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.so new file mode 100755 index 0000000..0938a60 Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/ext/parser/parser.so differ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/extconf.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/extconf.rb new file mode 100644 index 0000000..8a99b6a --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/ext/json/extconf.rb @@ -0,0 +1,3 @@ +require 'mkmf' + +create_makefile('json') diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/json.gemspec b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/json.gemspec new file mode 100644 index 0000000..948e92c --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/json.gemspec @@ -0,0 +1,67 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = "json" + s.version = File.read(File.expand_path('../VERSION', __FILE__)).chomp + + s.summary = "JSON Implementation for Ruby" + s.description = "This is a JSON implementation as a Ruby extension in C." + s.licenses = ["Ruby"] + s.authors = ["Florian Frank"] + s.email = "flori@ping.de" + + s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb", "ext/json/extconf.rb"] + s.extra_rdoc_files = ["README.md"] + s.rdoc_options = ["--title", "JSON implementation for Ruby", "--main", "README.md"] + s.files = [ + "CHANGES.md", + "LICENSE", + "README.md", + "VERSION", + "ext/json/ext/fbuffer/fbuffer.h", + "ext/json/ext/generator/depend", + "ext/json/ext/generator/extconf.rb", + "ext/json/ext/generator/generator.c", + "ext/json/ext/generator/generator.h", + "ext/json/ext/parser/depend", + "ext/json/ext/parser/extconf.rb", + "ext/json/ext/parser/parser.c", + "ext/json/ext/parser/parser.h", + "ext/json/ext/parser/parser.rl", + "ext/json/extconf.rb", + "json.gemspec", + "lib/json.rb", + "lib/json/add/bigdecimal.rb", + "lib/json/add/complex.rb", + "lib/json/add/core.rb", + "lib/json/add/date.rb", + "lib/json/add/date_time.rb", + "lib/json/add/exception.rb", + "lib/json/add/ostruct.rb", + "lib/json/add/range.rb", + "lib/json/add/rational.rb", + "lib/json/add/regexp.rb", + "lib/json/add/set.rb", + "lib/json/add/struct.rb", + "lib/json/add/symbol.rb", + "lib/json/add/time.rb", + "lib/json/common.rb", + "lib/json/ext.rb", + "lib/json/generic_object.rb", + "lib/json/pure.rb", + "lib/json/pure/generator.rb", + "lib/json/pure/parser.rb", + "lib/json/version.rb", + ] + s.homepage = "http://flori.github.com/json" + s.metadata = { + 'bug_tracker_uri' => 'https://github.com/flori/json/issues', + 'changelog_uri' => 'https://github.com/flori/json/blob/master/CHANGES.md', + 'documentation_uri' => 'http://flori.github.io/json/doc/index.html', + 'homepage_uri' => 'http://flori.github.io/json/', + 'source_code_uri' => 'https://github.com/flori/json', + 'wiki_uri' => 'https://github.com/flori/json/wiki' + } + + s.required_ruby_version = Gem::Requirement.new(">= 2.3") +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json.rb new file mode 100644 index 0000000..1e64bfc --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json.rb @@ -0,0 +1,583 @@ +#frozen_string_literal: false +require 'json/common' + +## +# = JavaScript \Object Notation (\JSON) +# +# \JSON is a lightweight data-interchange format. +# +# A \JSON value is one of the following: +# - Double-quoted text: "foo". +# - Number: +1+, +1.0+, +2.0e2+. +# - Boolean: +true+, +false+. +# - Null: +null+. +# - \Array: an ordered list of values, enclosed by square brackets: +# ["foo", 1, 1.0, 2.0e2, true, false, null] +# +# - \Object: a collection of name/value pairs, enclosed by curly braces; +# each name is double-quoted text; +# the values may be any \JSON values: +# {"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null} +# +# A \JSON array or object may contain nested arrays, objects, and scalars +# to any depth: +# {"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]} +# [{"foo": 0, "bar": 1}, ["baz", 2]] +# +# == Using \Module \JSON +# +# To make module \JSON available in your code, begin with: +# require 'json' +# +# All examples here assume that this has been done. +# +# === Parsing \JSON +# +# You can parse a \String containing \JSON data using +# either of two methods: +# - JSON.parse(source, opts) +# - JSON.parse!(source, opts) +# +# where +# - +source+ is a Ruby object. +# - +opts+ is a \Hash object containing options +# that control both input allowed and output formatting. +# +# The difference between the two methods +# is that JSON.parse! omits some checks +# and may not be safe for some +source+ data; +# use it only for data from trusted sources. +# Use the safer method JSON.parse for less trusted sources. +# +# ==== Parsing \JSON Arrays +# +# When +source+ is a \JSON array, JSON.parse by default returns a Ruby \Array: +# json = '["foo", 1, 1.0, 2.0e2, true, false, null]' +# ruby = JSON.parse(json) +# ruby # => ["foo", 1, 1.0, 200.0, true, false, nil] +# ruby.class # => Array +# +# The \JSON array may contain nested arrays, objects, and scalars +# to any depth: +# json = '[{"foo": 0, "bar": 1}, ["baz", 2]]' +# JSON.parse(json) # => [{"foo"=>0, "bar"=>1}, ["baz", 2]] +# +# ==== Parsing \JSON \Objects +# +# When the source is a \JSON object, JSON.parse by default returns a Ruby \Hash: +# json = '{"a": "foo", "b": 1, "c": 1.0, "d": 2.0e2, "e": true, "f": false, "g": null}' +# ruby = JSON.parse(json) +# ruby # => {"a"=>"foo", "b"=>1, "c"=>1.0, "d"=>200.0, "e"=>true, "f"=>false, "g"=>nil} +# ruby.class # => Hash +# +# The \JSON object may contain nested arrays, objects, and scalars +# to any depth: +# json = '{"foo": {"bar": 1, "baz": 2}, "bat": [0, 1, 2]}' +# JSON.parse(json) # => {"foo"=>{"bar"=>1, "baz"=>2}, "bat"=>[0, 1, 2]} +# +# ==== Parsing \JSON Scalars +# +# When the source is a \JSON scalar (not an array or object), +# JSON.parse returns a Ruby scalar. +# +# \String: +# ruby = JSON.parse('"foo"') +# ruby # => 'foo' +# ruby.class # => String +# \Integer: +# ruby = JSON.parse('1') +# ruby # => 1 +# ruby.class # => Integer +# \Float: +# ruby = JSON.parse('1.0') +# ruby # => 1.0 +# ruby.class # => Float +# ruby = JSON.parse('2.0e2') +# ruby # => 200 +# ruby.class # => Float +# Boolean: +# ruby = JSON.parse('true') +# ruby # => true +# ruby.class # => TrueClass +# ruby = JSON.parse('false') +# ruby # => false +# ruby.class # => FalseClass +# Null: +# ruby = JSON.parse('null') +# ruby # => nil +# ruby.class # => NilClass +# +# ==== Parsing Options +# +# ====== Input Options +# +# Option +max_nesting+ (\Integer) specifies the maximum nesting depth allowed; +# defaults to +100+; specify +false+ to disable depth checking. +# +# With the default, +false+: +# source = '[0, [1, [2, [3]]]]' +# ruby = JSON.parse(source) +# ruby # => [0, [1, [2, [3]]]] +# Too deep: +# # Raises JSON::NestingError (nesting of 2 is too deep): +# JSON.parse(source, {max_nesting: 1}) +# Bad value: +# # Raises TypeError (wrong argument type Symbol (expected Fixnum)): +# JSON.parse(source, {max_nesting: :foo}) +# +# --- +# +# Option +allow_nan+ (boolean) specifies whether to allow +# NaN, Infinity, and MinusInfinity in +source+; +# defaults to +false+. +# +# With the default, +false+: +# # Raises JSON::ParserError (225: unexpected token at '[NaN]'): +# JSON.parse('[NaN]') +# # Raises JSON::ParserError (232: unexpected token at '[Infinity]'): +# JSON.parse('[Infinity]') +# # Raises JSON::ParserError (248: unexpected token at '[-Infinity]'): +# JSON.parse('[-Infinity]') +# Allow: +# source = '[NaN, Infinity, -Infinity]' +# ruby = JSON.parse(source, {allow_nan: true}) +# ruby # => [NaN, Infinity, -Infinity] +# +# ====== Output Options +# +# Option +symbolize_names+ (boolean) specifies whether returned \Hash keys +# should be Symbols; +# defaults to +false+ (use Strings). +# +# With the default, +false+: +# source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}' +# ruby = JSON.parse(source) +# ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil} +# Use Symbols: +# ruby = JSON.parse(source, {symbolize_names: true}) +# ruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil} +# +# --- +# +# Option +object_class+ (\Class) specifies the Ruby class to be used +# for each \JSON object; +# defaults to \Hash. +# +# With the default, \Hash: +# source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}' +# ruby = JSON.parse(source) +# ruby.class # => Hash +# Use class \OpenStruct: +# ruby = JSON.parse(source, {object_class: OpenStruct}) +# ruby # => # +# +# --- +# +# Option +array_class+ (\Class) specifies the Ruby class to be used +# for each \JSON array; +# defaults to \Array. +# +# With the default, \Array: +# source = '["foo", 1.0, true, false, null]' +# ruby = JSON.parse(source) +# ruby.class # => Array +# Use class \Set: +# ruby = JSON.parse(source, {array_class: Set}) +# ruby # => # +# +# --- +# +# Option +create_additions+ (boolean) specifies whether to use \JSON additions in parsing. +# See {\JSON Additions}[#module-JSON-label-JSON+Additions]. +# +# === Generating \JSON +# +# To generate a Ruby \String containing \JSON data, +# use method JSON.generate(source, opts), where +# - +source+ is a Ruby object. +# - +opts+ is a \Hash object containing options +# that control both input allowed and output formatting. +# +# ==== Generating \JSON from Arrays +# +# When the source is a Ruby \Array, JSON.generate returns +# a \String containing a \JSON array: +# ruby = [0, 's', :foo] +# json = JSON.generate(ruby) +# json # => '[0,"s","foo"]' +# +# The Ruby \Array array may contain nested arrays, hashes, and scalars +# to any depth: +# ruby = [0, [1, 2], {foo: 3, bar: 4}] +# json = JSON.generate(ruby) +# json # => '[0,[1,2],{"foo":3,"bar":4}]' +# +# ==== Generating \JSON from Hashes +# +# When the source is a Ruby \Hash, JSON.generate returns +# a \String containing a \JSON object: +# ruby = {foo: 0, bar: 's', baz: :bat} +# json = JSON.generate(ruby) +# json # => '{"foo":0,"bar":"s","baz":"bat"}' +# +# The Ruby \Hash array may contain nested arrays, hashes, and scalars +# to any depth: +# ruby = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad} +# json = JSON.generate(ruby) +# json # => '{"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}' +# +# ==== Generating \JSON from Other Objects +# +# When the source is neither an \Array nor a \Hash, +# the generated \JSON data depends on the class of the source. +# +# When the source is a Ruby \Integer or \Float, JSON.generate returns +# a \String containing a \JSON number: +# JSON.generate(42) # => '42' +# JSON.generate(0.42) # => '0.42' +# +# When the source is a Ruby \String, JSON.generate returns +# a \String containing a \JSON string (with double-quotes): +# JSON.generate('A string') # => '"A string"' +# +# When the source is +true+, +false+ or +nil+, JSON.generate returns +# a \String containing the corresponding \JSON token: +# JSON.generate(true) # => 'true' +# JSON.generate(false) # => 'false' +# JSON.generate(nil) # => 'null' +# +# When the source is none of the above, JSON.generate returns +# a \String containing a \JSON string representation of the source: +# JSON.generate(:foo) # => '"foo"' +# JSON.generate(Complex(0, 0)) # => '"0+0i"' +# JSON.generate(Dir.new('.')) # => '"#"' +# +# ==== Generating Options +# +# ====== Input Options +# +# Option +allow_nan+ (boolean) specifies whether +# +NaN+, +Infinity+, and -Infinity may be generated; +# defaults to +false+. +# +# With the default, +false+: +# # Raises JSON::GeneratorError (920: NaN not allowed in JSON): +# JSON.generate(JSON::NaN) +# # Raises JSON::GeneratorError (917: Infinity not allowed in JSON): +# JSON.generate(JSON::Infinity) +# # Raises JSON::GeneratorError (917: -Infinity not allowed in JSON): +# JSON.generate(JSON::MinusInfinity) +# +# Allow: +# ruby = [Float::NaN, Float::Infinity, Float::MinusInfinity] +# JSON.generate(ruby, allow_nan: true) # => '[NaN,Infinity,-Infinity]' +# +# --- +# +# Option +max_nesting+ (\Integer) specifies the maximum nesting depth +# in +obj+; defaults to +100+. +# +# With the default, +100+: +# obj = [[[[[[0]]]]]] +# JSON.generate(obj) # => '[[[[[[0]]]]]]' +# +# Too deep: +# # Raises JSON::NestingError (nesting of 2 is too deep): +# JSON.generate(obj, max_nesting: 2) +# +# ====== Output Options +# +# The default formatting options generate the most compact +# \JSON data, all on one line and with no whitespace. +# +# You can use these formatting options to generate +# \JSON data in a more open format, using whitespace. +# See also JSON.pretty_generate. +# +# - Option +array_nl+ (\String) specifies a string (usually a newline) +# to be inserted after each \JSON array; defaults to the empty \String, ''. +# - Option +object_nl+ (\String) specifies a string (usually a newline) +# to be inserted after each \JSON object; defaults to the empty \String, ''. +# - Option +indent+ (\String) specifies the string (usually spaces) to be +# used for indentation; defaults to the empty \String, ''; +# defaults to the empty \String, ''; +# has no effect unless options +array_nl+ or +object_nl+ specify newlines. +# - Option +space+ (\String) specifies a string (usually a space) to be +# inserted after the colon in each \JSON object's pair; +# defaults to the empty \String, ''. +# - Option +space_before+ (\String) specifies a string (usually a space) to be +# inserted before the colon in each \JSON object's pair; +# defaults to the empty \String, ''. +# +# In this example, +obj+ is used first to generate the shortest +# \JSON data (no whitespace), then again with all formatting options +# specified: +# +# obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}} +# json = JSON.generate(obj) +# puts 'Compact:', json +# opts = { +# array_nl: "\n", +# object_nl: "\n", +# indent: ' ', +# space_before: ' ', +# space: ' ' +# } +# puts 'Open:', JSON.generate(obj, opts) +# +# Output: +# Compact: +# {"foo":["bar","baz"],"bat":{"bam":0,"bad":1}} +# Open: +# { +# "foo" : [ +# "bar", +# "baz" +# ], +# "bat" : { +# "bam" : 0, +# "bad" : 1 +# } +# } +# +# == \JSON Additions +# +# When you "round trip" a non-\String object from Ruby to \JSON and back, +# you have a new \String, instead of the object you began with: +# ruby0 = Range.new(0, 2) +# json = JSON.generate(ruby0) +# json # => '0..2"' +# ruby1 = JSON.parse(json) +# ruby1 # => '0..2' +# ruby1.class # => String +# +# You can use \JSON _additions_ to preserve the original object. +# The addition is an extension of a ruby class, so that: +# - \JSON.generate stores more information in the \JSON string. +# - \JSON.parse, called with option +create_additions+, +# uses that information to create a proper Ruby object. +# +# This example shows a \Range being generated into \JSON +# and parsed back into Ruby, both without and with +# the addition for \Range: +# ruby = Range.new(0, 2) +# # This passage does not use the addition for Range. +# json0 = JSON.generate(ruby) +# ruby0 = JSON.parse(json0) +# # This passage uses the addition for Range. +# require 'json/add/range' +# json1 = JSON.generate(ruby) +# ruby1 = JSON.parse(json1, create_additions: true) +# # Make a nice display. +# display = <require 'json/add/bigdecimal' +# - Complex: require 'json/add/complex' +# - Date: require 'json/add/date' +# - DateTime: require 'json/add/date_time' +# - Exception: require 'json/add/exception' +# - OpenStruct: require 'json/add/ostruct' +# - Range: require 'json/add/range' +# - Rational: require 'json/add/rational' +# - Regexp: require 'json/add/regexp' +# - Set: require 'json/add/set' +# - Struct: require 'json/add/struct' +# - Symbol: require 'json/add/symbol' +# - Time: require 'json/add/time' +# +# To reduce punctuation clutter, the examples below +# show the generated \JSON via +puts+, rather than the usual +inspect+, +# +# \BigDecimal: +# require 'json/add/bigdecimal' +# ruby0 = BigDecimal(0) # 0.0 +# json = JSON.generate(ruby0) # {"json_class":"BigDecimal","b":"27:0.0"} +# ruby1 = JSON.parse(json, create_additions: true) # 0.0 +# ruby1.class # => BigDecimal +# +# \Complex: +# require 'json/add/complex' +# ruby0 = Complex(1+0i) # 1+0i +# json = JSON.generate(ruby0) # {"json_class":"Complex","r":1,"i":0} +# ruby1 = JSON.parse(json, create_additions: true) # 1+0i +# ruby1.class # Complex +# +# \Date: +# require 'json/add/date' +# ruby0 = Date.today # 2020-05-02 +# json = JSON.generate(ruby0) # {"json_class":"Date","y":2020,"m":5,"d":2,"sg":2299161.0} +# ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 +# ruby1.class # Date +# +# \DateTime: +# require 'json/add/date_time' +# ruby0 = DateTime.now # 2020-05-02T10:38:13-05:00 +# json = JSON.generate(ruby0) # {"json_class":"DateTime","y":2020,"m":5,"d":2,"H":10,"M":38,"S":13,"of":"-5/24","sg":2299161.0} +# ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02T10:38:13-05:00 +# ruby1.class # DateTime +# +# \Exception (and its subclasses including \RuntimeError): +# require 'json/add/exception' +# ruby0 = Exception.new('A message') # A message +# json = JSON.generate(ruby0) # {"json_class":"Exception","m":"A message","b":null} +# ruby1 = JSON.parse(json, create_additions: true) # A message +# ruby1.class # Exception +# ruby0 = RuntimeError.new('Another message') # Another message +# json = JSON.generate(ruby0) # {"json_class":"RuntimeError","m":"Another message","b":null} +# ruby1 = JSON.parse(json, create_additions: true) # Another message +# ruby1.class # RuntimeError +# +# \OpenStruct: +# require 'json/add/ostruct' +# ruby0 = OpenStruct.new(name: 'Matz', language: 'Ruby') # # +# json = JSON.generate(ruby0) # {"json_class":"OpenStruct","t":{"name":"Matz","language":"Ruby"}} +# ruby1 = JSON.parse(json, create_additions: true) # # +# ruby1.class # OpenStruct +# +# \Range: +# require 'json/add/range' +# ruby0 = Range.new(0, 2) # 0..2 +# json = JSON.generate(ruby0) # {"json_class":"Range","a":[0,2,false]} +# ruby1 = JSON.parse(json, create_additions: true) # 0..2 +# ruby1.class # Range +# +# \Rational: +# require 'json/add/rational' +# ruby0 = Rational(1, 3) # 1/3 +# json = JSON.generate(ruby0) # {"json_class":"Rational","n":1,"d":3} +# ruby1 = JSON.parse(json, create_additions: true) # 1/3 +# ruby1.class # Rational +# +# \Regexp: +# require 'json/add/regexp' +# ruby0 = Regexp.new('foo') # (?-mix:foo) +# json = JSON.generate(ruby0) # {"json_class":"Regexp","o":0,"s":"foo"} +# ruby1 = JSON.parse(json, create_additions: true) # (?-mix:foo) +# ruby1.class # Regexp +# +# \Set: +# require 'json/add/set' +# ruby0 = Set.new([0, 1, 2]) # # +# json = JSON.generate(ruby0) # {"json_class":"Set","a":[0,1,2]} +# ruby1 = JSON.parse(json, create_additions: true) # # +# ruby1.class # Set +# +# \Struct: +# require 'json/add/struct' +# Customer = Struct.new(:name, :address) # Customer +# ruby0 = Customer.new("Dave", "123 Main") # # +# json = JSON.generate(ruby0) # {"json_class":"Customer","v":["Dave","123 Main"]} +# ruby1 = JSON.parse(json, create_additions: true) # # +# ruby1.class # Customer +# +# \Symbol: +# require 'json/add/symbol' +# ruby0 = :foo # foo +# json = JSON.generate(ruby0) # {"json_class":"Symbol","s":"foo"} +# ruby1 = JSON.parse(json, create_additions: true) # foo +# ruby1.class # Symbol +# +# \Time: +# require 'json/add/time' +# ruby0 = Time.now # 2020-05-02 11:28:26 -0500 +# json = JSON.generate(ruby0) # {"json_class":"Time","s":1588436906,"n":840560000} +# ruby1 = JSON.parse(json, create_additions: true) # 2020-05-02 11:28:26 -0500 +# ruby1.class # Time +# +# +# === Custom \JSON Additions +# +# In addition to the \JSON additions provided, +# you can craft \JSON additions of your own, +# either for Ruby built-in classes or for user-defined classes. +# +# Here's a user-defined class +Foo+: +# class Foo +# attr_accessor :bar, :baz +# def initialize(bar, baz) +# self.bar = bar +# self.baz = baz +# end +# end +# +# Here's the \JSON addition for it: +# # Extend class Foo with JSON addition. +# class Foo +# # Serialize Foo object with its class name and arguments +# def to_json(*args) +# { +# JSON.create_id => self.class.name, +# 'a' => [ bar, baz ] +# }.to_json(*args) +# end +# # Deserialize JSON string by constructing new Foo object with arguments. +# def self.json_create(object) +# new(*object['a']) +# end +# end +# +# Demonstration: +# require 'json' +# # This Foo object has no custom addition. +# foo0 = Foo.new(0, 1) +# json0 = JSON.generate(foo0) +# obj0 = JSON.parse(json0) +# # Lood the custom addition. +# require_relative 'foo_addition' +# # This foo has the custom addition. +# foo1 = Foo.new(0, 1) +# json1 = JSON.generate(foo1) +# obj1 = JSON.parse(json1, create_additions: true) +# # Make a nice display. +# display = <" (String) +# With custom addition: {"json_class":"Foo","a":[0,1]} (String) +# Parsed JSON: +# Without custom addition: "#" (String) +# With custom addition: # (Foo) +# +module JSON + require 'json/version' + + begin + require 'json/ext' + rescue LoadError + require 'json/pure' + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/bigdecimal.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/bigdecimal.rb new file mode 100644 index 0000000..c8b4f56 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/bigdecimal.rb @@ -0,0 +1,29 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end +defined?(::BigDecimal) or require 'bigdecimal' + +class BigDecimal + # Import a JSON Marshalled object. + # + # method used for JSON marshalling support. + def self.json_create(object) + BigDecimal._load object['b'] + end + + # Marshal the object to JSON. + # + # method used for JSON marshalling support. + def as_json(*) + { + JSON.create_id => self.class.name, + 'b' => _dump, + } + end + + # return the JSON value + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/complex.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/complex.rb new file mode 100644 index 0000000..e63e29f --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/complex.rb @@ -0,0 +1,28 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Complex + + # Deserializes JSON string by converting Real value r, imaginary + # value i, to a Complex object. + def self.json_create(object) + Complex(object['r'], object['i']) + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 'r' => real, + 'i' => imag, + } + end + + # Stores class name (Complex) along with real value r and imaginary value i as JSON string + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/core.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/core.rb new file mode 100644 index 0000000..bfb017c --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/core.rb @@ -0,0 +1,12 @@ +#frozen_string_literal: false +# This file requires the implementations of ruby core's custom objects for +# serialisation/deserialisation. + +require 'json/add/date' +require 'json/add/date_time' +require 'json/add/exception' +require 'json/add/range' +require 'json/add/regexp' +require 'json/add/struct' +require 'json/add/symbol' +require 'json/add/time' diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/date.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/date.rb new file mode 100644 index 0000000..2552356 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/date.rb @@ -0,0 +1,34 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end +require 'date' + +class Date + + # Deserializes JSON string by converting Julian year y, month + # m, day d and Day of Calendar Reform sg to Date. + def self.json_create(object) + civil(*object.values_at('y', 'm', 'd', 'sg')) + end + + alias start sg unless method_defined?(:start) + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 'y' => year, + 'm' => month, + 'd' => day, + 'sg' => start, + } + end + + # Stores class name (Date) with Julian year y, month m, day + # d and Day of Calendar Reform sg as JSON string + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/date_time.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/date_time.rb new file mode 100644 index 0000000..38b0e86 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/date_time.rb @@ -0,0 +1,50 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end +require 'date' + +class DateTime + + # Deserializes JSON string by converting year y, month m, + # day d, hour H, minute M, second S, + # offset of and Day of Calendar Reform sg to DateTime. + def self.json_create(object) + args = object.values_at('y', 'm', 'd', 'H', 'M', 'S') + of_a, of_b = object['of'].split('/') + if of_b and of_b != '0' + args << Rational(of_a.to_i, of_b.to_i) + else + args << of_a + end + args << object['sg'] + civil(*args) + end + + alias start sg unless method_defined?(:start) + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 'y' => year, + 'm' => month, + 'd' => day, + 'H' => hour, + 'M' => min, + 'S' => sec, + 'of' => offset.to_s, + 'sg' => start, + } + end + + # Stores class name (DateTime) with Julian year y, month m, + # day d, hour H, minute M, second S, + # offset of and Day of Calendar Reform sg as JSON string + def to_json(*args) + as_json.to_json(*args) + end +end + + diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/exception.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/exception.rb new file mode 100644 index 0000000..a107e5b --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/exception.rb @@ -0,0 +1,31 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Exception + + # Deserializes JSON string by constructing new Exception object with message + # m and backtrace b serialized with to_json + def self.json_create(object) + result = new(object['m']) + result.set_backtrace object['b'] + result + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 'm' => message, + 'b' => backtrace, + } + end + + # Stores class name (Exception) with message m and backtrace array + # b as JSON string + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/ostruct.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/ostruct.rb new file mode 100644 index 0000000..686cf00 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/ostruct.rb @@ -0,0 +1,31 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end +require 'ostruct' + +class OpenStruct + + # Deserializes JSON string by constructing new Struct object with values + # t serialized by to_json. + def self.json_create(object) + new(object['t'] || object[:t]) + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + klass = self.class.name + klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!" + { + JSON.create_id => klass, + 't' => table, + } + end + + # Stores class name (OpenStruct) with this struct's values t as a + # JSON string. + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/range.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/range.rb new file mode 100644 index 0000000..93529fb --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/range.rb @@ -0,0 +1,29 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Range + + # Deserializes JSON string by constructing new Range object with arguments + # a serialized by to_json. + def self.json_create(object) + new(*object['a']) + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 'a' => [ first, last, exclude_end? ] + } + end + + # Stores class name (Range) with JSON array of arguments a which + # include first (integer), last (integer), and + # exclude_end? (boolean) as JSON string. + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/rational.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/rational.rb new file mode 100644 index 0000000..f776226 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/rational.rb @@ -0,0 +1,27 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Rational + # Deserializes JSON string by converting numerator value n, + # denominator value d, to a Rational object. + def self.json_create(object) + Rational(object['n'], object['d']) + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 'n' => numerator, + 'd' => denominator, + } + end + + # Stores class name (Rational) along with numerator value n and denominator value d as JSON string + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/regexp.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/regexp.rb new file mode 100644 index 0000000..39d69fe --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/regexp.rb @@ -0,0 +1,30 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Regexp + + # Deserializes JSON string by constructing new Regexp object with source + # s (Regexp or String) and options o serialized by + # to_json + def self.json_create(object) + new(object['s'], object['o']) + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 'o' => options, + 's' => source, + } + end + + # Stores class name (Regexp) with options o and source s + # (Regexp or String) as JSON string + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/set.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/set.rb new file mode 100644 index 0000000..71e2a0a --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/set.rb @@ -0,0 +1,29 @@ +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end +defined?(::Set) or require 'set' + +class Set + # Import a JSON Marshalled object. + # + # method used for JSON marshalling support. + def self.json_create(object) + new object['a'] + end + + # Marshal the object to JSON. + # + # method used for JSON marshalling support. + def as_json(*) + { + JSON.create_id => self.class.name, + 'a' => to_a, + } + end + + # return the JSON value + def to_json(*args) + as_json.to_json(*args) + end +end + diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/struct.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/struct.rb new file mode 100644 index 0000000..e8395ed --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/struct.rb @@ -0,0 +1,30 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Struct + + # Deserializes JSON string by constructing new Struct object with values + # v serialized by to_json. + def self.json_create(object) + new(*object['v']) + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + klass = self.class.name + klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!" + { + JSON.create_id => klass, + 'v' => values, + } + end + + # Stores class name (Struct) with Struct values v as a JSON string. + # Only named structs are supported. + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/symbol.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/symbol.rb new file mode 100644 index 0000000..74b13a4 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/symbol.rb @@ -0,0 +1,25 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Symbol + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + { + JSON.create_id => self.class.name, + 's' => to_s, + } + end + + # Stores class name (Symbol) with String representation of Symbol as a JSON string. + def to_json(*a) + as_json.to_json(*a) + end + + # Deserializes JSON string by converting the string value stored in the object to a Symbol + def self.json_create(o) + o['s'].to_sym + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/time.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/time.rb new file mode 100644 index 0000000..b73acc4 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/add/time.rb @@ -0,0 +1,38 @@ +#frozen_string_literal: false +unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED + require 'json' +end + +class Time + + # Deserializes JSON string by converting time since epoch to Time + def self.json_create(object) + if usec = object.delete('u') # used to be tv_usec -> tv_nsec + object['n'] = usec * 1000 + end + if method_defined?(:tv_nsec) + at(object['s'], Rational(object['n'], 1000)) + else + at(object['s'], object['n'] / 1000) + end + end + + # Returns a hash, that will be turned into a JSON object and represent this + # object. + def as_json(*) + nanoseconds = [ tv_usec * 1000 ] + respond_to?(:tv_nsec) and nanoseconds << tv_nsec + nanoseconds = nanoseconds.max + { + JSON.create_id => self.class.name, + 's' => tv_sec, + 'n' => nanoseconds, + } + end + + # Stores class name (Time) with number of seconds since epoch and number of + # microseconds for Time as JSON string + def to_json(*args) + as_json.to_json(*args) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/common.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/common.rb new file mode 100644 index 0000000..ea46896 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/common.rb @@ -0,0 +1,703 @@ +#frozen_string_literal: false +require 'json/version' +require 'json/generic_object' + +module JSON + class << self + # :call-seq: + # JSON[object] -> new_array or new_string + # + # If +object+ is a \String, + # calls JSON.parse with +object+ and +opts+ (see method #parse): + # json = '[0, 1, null]' + # JSON[json]# => [0, 1, nil] + # + # Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate): + # ruby = [0, 1, nil] + # JSON[ruby] # => '[0,1,null]' + def [](object, opts = {}) + if object.respond_to? :to_str + JSON.parse(object.to_str, opts) + else + JSON.generate(object, opts) + end + end + + # Returns the JSON parser class that is used by JSON. This is either + # JSON::Ext::Parser or JSON::Pure::Parser: + # JSON.parser # => JSON::Ext::Parser + attr_reader :parser + + # Set the JSON parser class _parser_ to be used by JSON. + def parser=(parser) # :nodoc: + @parser = parser + remove_const :Parser if const_defined?(:Parser, false) + const_set :Parser, parser + end + + # Return the constant located at _path_. The format of _path_ has to be + # either ::A::B::C or A::B::C. In any case, A has to be located at the top + # level (absolute namespace path?). If there doesn't exist a constant at + # the given path, an ArgumentError is raised. + def deep_const_get(path) # :nodoc: + path.to_s.split(/::/).inject(Object) do |p, c| + case + when c.empty? then p + when p.const_defined?(c, true) then p.const_get(c) + else + begin + p.const_missing(c) + rescue NameError => e + raise ArgumentError, "can't get const #{path}: #{e}" + end + end + end + end + + # Set the module _generator_ to be used by JSON. + def generator=(generator) # :nodoc: + old, $VERBOSE = $VERBOSE, nil + @generator = generator + generator_methods = generator::GeneratorMethods + for const in generator_methods.constants + klass = deep_const_get(const) + modul = generator_methods.const_get(const) + klass.class_eval do + instance_methods(false).each do |m| + m.to_s == 'to_json' and remove_method m + end + include modul + end + end + self.state = generator::State + const_set :State, self.state + const_set :SAFE_STATE_PROTOTYPE, State.new # for JRuby + const_set :FAST_STATE_PROTOTYPE, create_fast_state + const_set :PRETTY_STATE_PROTOTYPE, create_pretty_state + ensure + $VERBOSE = old + end + + def create_fast_state + State.new( + :indent => '', + :space => '', + :object_nl => "", + :array_nl => "", + :max_nesting => false + ) + end + + def create_pretty_state + State.new( + :indent => ' ', + :space => ' ', + :object_nl => "\n", + :array_nl => "\n" + ) + end + + # Returns the JSON generator module that is used by JSON. This is + # either JSON::Ext::Generator or JSON::Pure::Generator: + # JSON.generator # => JSON::Ext::Generator + attr_reader :generator + + # Sets or Returns the JSON generator state class that is used by JSON. This is + # either JSON::Ext::Generator::State or JSON::Pure::Generator::State: + # JSON.state # => JSON::Ext::Generator::State + attr_accessor :state + end + + DEFAULT_CREATE_ID = 'json_class'.freeze + private_constant :DEFAULT_CREATE_ID + + CREATE_ID_TLS_KEY = "JSON.create_id".freeze + private_constant :CREATE_ID_TLS_KEY + + # Sets create identifier, which is used to decide if the _json_create_ + # hook of a class should be called; initial value is +json_class+: + # JSON.create_id # => 'json_class' + def self.create_id=(new_value) + Thread.current[CREATE_ID_TLS_KEY] = new_value.dup.freeze + end + + # Returns the current create identifier. + # See also JSON.create_id=. + def self.create_id + Thread.current[CREATE_ID_TLS_KEY] || DEFAULT_CREATE_ID + end + + NaN = 0.0/0 + + Infinity = 1.0/0 + + MinusInfinity = -Infinity + + # The base exception for JSON errors. + class JSONError < StandardError + def self.wrap(exception) + obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}") + obj.set_backtrace exception.backtrace + obj + end + end + + # This exception is raised if a parser error occurs. + class ParserError < JSONError; end + + # This exception is raised if the nesting of parsed data structures is too + # deep. + class NestingError < ParserError; end + + # :stopdoc: + class CircularDatastructure < NestingError; end + # :startdoc: + + # This exception is raised if a generator or unparser error occurs. + class GeneratorError < JSONError; end + # For backwards compatibility + UnparserError = GeneratorError # :nodoc: + + # This exception is raised if the required unicode support is missing on the + # system. Usually this means that the iconv library is not installed. + class MissingUnicodeSupport < JSONError; end + + module_function + + # :call-seq: + # JSON.parse(source, opts) -> object + # + # Returns the Ruby objects created by parsing the given +source+. + # + # Argument +source+ contains the \String to be parsed. + # + # Argument +opts+, if given, contains a \Hash of options for the parsing. + # See {Parsing Options}[#module-JSON-label-Parsing+Options]. + # + # --- + # + # When +source+ is a \JSON array, returns a Ruby \Array: + # source = '["foo", 1.0, true, false, null]' + # ruby = JSON.parse(source) + # ruby # => ["foo", 1.0, true, false, nil] + # ruby.class # => Array + # + # When +source+ is a \JSON object, returns a Ruby \Hash: + # source = '{"a": "foo", "b": 1.0, "c": true, "d": false, "e": null}' + # ruby = JSON.parse(source) + # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil} + # ruby.class # => Hash + # + # For examples of parsing for all \JSON data types, see + # {Parsing \JSON}[#module-JSON-label-Parsing+JSON]. + # + # Parses nested JSON objects: + # source = <<-EOT + # { + # "name": "Dave", + # "age" :40, + # "hats": [ + # "Cattleman's", + # "Panama", + # "Tophat" + # ] + # } + # EOT + # ruby = JSON.parse(source) + # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} + # + # --- + # + # Raises an exception if +source+ is not valid JSON: + # # Raises JSON::ParserError (783: unexpected token at ''): + # JSON.parse('') + # + def parse(source, opts = {}) + Parser.new(source, **(opts||{})).parse + end + + # :call-seq: + # JSON.parse!(source, opts) -> object + # + # Calls + # parse(source, opts) + # with +source+ and possibly modified +opts+. + # + # Differences from JSON.parse: + # - Option +max_nesting+, if not provided, defaults to +false+, + # which disables checking for nesting depth. + # - Option +allow_nan+, if not provided, defaults to +true+. + def parse!(source, opts = {}) + opts = { + :max_nesting => false, + :allow_nan => true + }.merge(opts) + Parser.new(source, **(opts||{})).parse + end + + # :call-seq: + # JSON.load_file(path, opts={}) -> object + # + # Calls: + # parse(File.read(path), opts) + # + # See method #parse. + def load_file(filespec, opts = {}) + parse(File.read(filespec), opts) + end + + # :call-seq: + # JSON.load_file!(path, opts = {}) + # + # Calls: + # JSON.parse!(File.read(path, opts)) + # + # See method #parse! + def load_file!(filespec, opts = {}) + parse!(File.read(filespec), opts) + end + + # :call-seq: + # JSON.generate(obj, opts = nil) -> new_string + # + # Returns a \String containing the generated \JSON data. + # + # See also JSON.fast_generate, JSON.pretty_generate. + # + # Argument +obj+ is the Ruby object to be converted to \JSON. + # + # Argument +opts+, if given, contains a \Hash of options for the generation. + # See {Generating Options}[#module-JSON-label-Generating+Options]. + # + # --- + # + # When +obj+ is an \Array, returns a \String containing a \JSON array: + # obj = ["foo", 1.0, true, false, nil] + # json = JSON.generate(obj) + # json # => '["foo",1.0,true,false,null]' + # + # When +obj+ is a \Hash, returns a \String containing a \JSON object: + # obj = {foo: 0, bar: 's', baz: :bat} + # json = JSON.generate(obj) + # json # => '{"foo":0,"bar":"s","baz":"bat"}' + # + # For examples of generating from other Ruby objects, see + # {Generating \JSON from Other Objects}[#module-JSON-label-Generating+JSON+from+Other+Objects]. + # + # --- + # + # Raises an exception if any formatting option is not a \String. + # + # Raises an exception if +obj+ contains circular references: + # a = []; b = []; a.push(b); b.push(a) + # # Raises JSON::NestingError (nesting of 100 is too deep): + # JSON.generate(a) + # + def generate(obj, opts = nil) + if State === opts + state, opts = opts, nil + else + state = State.new + end + if opts + if opts.respond_to? :to_hash + opts = opts.to_hash + elsif opts.respond_to? :to_h + opts = opts.to_h + else + raise TypeError, "can't convert #{opts.class} into Hash" + end + state = state.configure(opts) + end + state.generate(obj) + end + + # :stopdoc: + # I want to deprecate these later, so I'll first be silent about them, and + # later delete them. + alias unparse generate + module_function :unparse + # :startdoc: + + # :call-seq: + # JSON.fast_generate(obj, opts) -> new_string + # + # Arguments +obj+ and +opts+ here are the same as + # arguments +obj+ and +opts+ in JSON.generate. + # + # By default, generates \JSON data without checking + # for circular references in +obj+ (option +max_nesting+ set to +false+, disabled). + # + # Raises an exception if +obj+ contains circular references: + # a = []; b = []; a.push(b); b.push(a) + # # Raises SystemStackError (stack level too deep): + # JSON.fast_generate(a) + def fast_generate(obj, opts = nil) + if State === opts + state, opts = opts, nil + else + state = JSON.create_fast_state + end + if opts + if opts.respond_to? :to_hash + opts = opts.to_hash + elsif opts.respond_to? :to_h + opts = opts.to_h + else + raise TypeError, "can't convert #{opts.class} into Hash" + end + state.configure(opts) + end + state.generate(obj) + end + + # :stopdoc: + # I want to deprecate these later, so I'll first be silent about them, and later delete them. + alias fast_unparse fast_generate + module_function :fast_unparse + # :startdoc: + + # :call-seq: + # JSON.pretty_generate(obj, opts = nil) -> new_string + # + # Arguments +obj+ and +opts+ here are the same as + # arguments +obj+ and +opts+ in JSON.generate. + # + # Default options are: + # { + # indent: ' ', # Two spaces + # space: ' ', # One space + # array_nl: "\n", # Newline + # object_nl: "\n" # Newline + # } + # + # Example: + # obj = {foo: [:bar, :baz], bat: {bam: 0, bad: 1}} + # json = JSON.pretty_generate(obj) + # puts json + # Output: + # { + # "foo": [ + # "bar", + # "baz" + # ], + # "bat": { + # "bam": 0, + # "bad": 1 + # } + # } + # + def pretty_generate(obj, opts = nil) + if State === opts + state, opts = opts, nil + else + state = JSON.create_pretty_state + end + if opts + if opts.respond_to? :to_hash + opts = opts.to_hash + elsif opts.respond_to? :to_h + opts = opts.to_h + else + raise TypeError, "can't convert #{opts.class} into Hash" + end + state.configure(opts) + end + state.generate(obj) + end + + # :stopdoc: + # I want to deprecate these later, so I'll first be silent about them, and later delete them. + alias pretty_unparse pretty_generate + module_function :pretty_unparse + # :startdoc: + + class << self + # Sets or returns default options for the JSON.load method. + # Initially: + # opts = JSON.load_default_options + # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true} + attr_accessor :load_default_options + end + self.load_default_options = { + :max_nesting => false, + :allow_nan => true, + :allow_blank => true, + :create_additions => true, + } + + # :call-seq: + # JSON.load(source, proc = nil, options = {}) -> object + # + # Returns the Ruby objects created by parsing the given +source+. + # + # - Argument +source+ must be, or be convertible to, a \String: + # - If +source+ responds to instance method +to_str+, + # source.to_str becomes the source. + # - If +source+ responds to instance method +to_io+, + # source.to_io.read becomes the source. + # - If +source+ responds to instance method +read+, + # source.read becomes the source. + # - If both of the following are true, source becomes the \String 'null': + # - Option +allow_blank+ specifies a truthy value. + # - The source, as defined above, is +nil+ or the empty \String ''. + # - Otherwise, +source+ remains the source. + # - Argument +proc+, if given, must be a \Proc that accepts one argument. + # It will be called recursively with each result (depth-first order). + # See details below. + # BEWARE: This method is meant to serialise data from trusted user input, + # like from your own database server or clients under your control, it could + # be dangerous to allow untrusted users to pass JSON sources into it. + # - Argument +opts+, if given, contains a \Hash of options for the parsing. + # See {Parsing Options}[#module-JSON-label-Parsing+Options]. + # The default options can be changed via method JSON.load_default_options=. + # + # --- + # + # When no +proc+ is given, modifies +source+ as above and returns the result of + # parse(source, opts); see #parse. + # + # Source for following examples: + # source = <<-EOT + # { + # "name": "Dave", + # "age" :40, + # "hats": [ + # "Cattleman's", + # "Panama", + # "Tophat" + # ] + # } + # EOT + # + # Load a \String: + # ruby = JSON.load(source) + # ruby # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} + # + # Load an \IO object: + # require 'stringio' + # object = JSON.load(StringIO.new(source)) + # object # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} + # + # Load a \File object: + # path = 't.json' + # File.write(path, source) + # File.open(path) do |file| + # JSON.load(file) + # end # => {"name"=>"Dave", "age"=>40, "hats"=>["Cattleman's", "Panama", "Tophat"]} + # + # --- + # + # When +proc+ is given: + # - Modifies +source+ as above. + # - Gets the +result+ from calling parse(source, opts). + # - Recursively calls proc(result). + # - Returns the final result. + # + # Example: + # require 'json' + # + # # Some classes for the example. + # class Base + # def initialize(attributes) + # @attributes = attributes + # end + # end + # class User < Base; end + # class Account < Base; end + # class Admin < Base; end + # # The JSON source. + # json = <<-EOF + # { + # "users": [ + # {"type": "User", "username": "jane", "email": "jane@example.com"}, + # {"type": "User", "username": "john", "email": "john@example.com"} + # ], + # "accounts": [ + # {"account": {"type": "Account", "paid": true, "account_id": "1234"}}, + # {"account": {"type": "Account", "paid": false, "account_id": "1235"}} + # ], + # "admins": {"type": "Admin", "password": "0wn3d"} + # } + # EOF + # # Deserializer method. + # def deserialize_obj(obj, safe_types = %w(User Account Admin)) + # type = obj.is_a?(Hash) && obj["type"] + # safe_types.include?(type) ? Object.const_get(type).new(obj) : obj + # end + # # Call to JSON.load + # ruby = JSON.load(json, proc {|obj| + # case obj + # when Hash + # obj.each {|k, v| obj[k] = deserialize_obj v } + # when Array + # obj.map! {|v| deserialize_obj v } + # end + # }) + # pp ruby + # Output: + # {"users"=> + # [#"User", "username"=>"jane", "email"=>"jane@example.com"}>, + # #"User", "username"=>"john", "email"=>"john@example.com"}>], + # "accounts"=> + # [{"account"=> + # #"Account", "paid"=>true, "account_id"=>"1234"}>}, + # {"account"=> + # #"Account", "paid"=>false, "account_id"=>"1235"}>}], + # "admins"=> + # #"Admin", "password"=>"0wn3d"}>} + # + def load(source, proc = nil, options = {}) + opts = load_default_options.merge options + if source.respond_to? :to_str + source = source.to_str + elsif source.respond_to? :to_io + source = source.to_io.read + elsif source.respond_to?(:read) + source = source.read + end + if opts[:allow_blank] && (source.nil? || source.empty?) + source = 'null' + end + result = parse(source, opts) + recurse_proc(result, &proc) if proc + result + end + + # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_ + def recurse_proc(result, &proc) # :nodoc: + case result + when Array + result.each { |x| recurse_proc x, &proc } + proc.call result + when Hash + result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc } + proc.call result + else + proc.call result + end + end + + alias restore load + module_function :restore + + class << self + # Sets or returns the default options for the JSON.dump method. + # Initially: + # opts = JSON.dump_default_options + # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false} + attr_accessor :dump_default_options + end + self.dump_default_options = { + :max_nesting => false, + :allow_nan => true, + :escape_slash => false, + } + + # :call-seq: + # JSON.dump(obj, io = nil, limit = nil) + # + # Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result. + # + # The default options can be changed via method JSON.dump_default_options. + # + # - Argument +io+, if given, should respond to method +write+; + # the \JSON \String is written to +io+, and +io+ is returned. + # If +io+ is not given, the \JSON \String is returned. + # - Argument +limit+, if given, is passed to JSON.generate as option +max_nesting+. + # + # --- + # + # When argument +io+ is not given, returns the \JSON \String generated from +obj+: + # obj = {foo: [0, 1], bar: {baz: 2, bat: 3}, bam: :bad} + # json = JSON.dump(obj) + # json # => "{\"foo\":[0,1],\"bar\":{\"baz\":2,\"bat\":3},\"bam\":\"bad\"}" + # + # When argument +io+ is given, writes the \JSON \String to +io+ and returns +io+: + # path = 't.json' + # File.open(path, 'w') do |file| + # JSON.dump(obj, file) + # end # => # + # puts File.read(path) + # Output: + # {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"} + def dump(obj, anIO = nil, limit = nil) + if anIO and limit.nil? + anIO = anIO.to_io if anIO.respond_to?(:to_io) + unless anIO.respond_to?(:write) + limit = anIO + anIO = nil + end + end + opts = JSON.dump_default_options + opts = opts.merge(:max_nesting => limit) if limit + result = generate(obj, opts) + if anIO + anIO.write result + anIO + else + result + end + rescue JSON::NestingError + raise ArgumentError, "exceed depth limit" + end + + # Encodes string using String.encode. + def self.iconv(to, from, string) + string.encode(to, from) + end +end + +module ::Kernel + private + + # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in + # one line. + def j(*objs) + objs.each do |obj| + puts JSON::generate(obj, :allow_nan => true, :max_nesting => false) + end + nil + end + + # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with + # indentation and over many lines. + def jj(*objs) + objs.each do |obj| + puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false) + end + nil + end + + # If _object_ is string-like, parse the string and return the parsed result as + # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data + # structure object and return it. + # + # The _opts_ argument is passed through to generate/parse respectively. See + # generate and parse for their documentation. + def JSON(object, *args) + if object.respond_to? :to_str + JSON.parse(object.to_str, args.first) + else + JSON.generate(object, args.first) + end + end +end + +# Extends any Class to include _json_creatable?_ method. +class ::Class + # Returns true if this class can be used to create an instance + # from a serialised JSON string. The class has to implement a class + # method _json_create_ that expects a hash as first parameter. The hash + # should include the required data. + def json_creatable? + respond_to?(:json_create) + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext.rb new file mode 100644 index 0000000..7264a85 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext.rb @@ -0,0 +1,15 @@ +require 'json/common' + +module JSON + # This module holds all the modules/classes that implement JSON's + # functionality as C extensions. + module Ext + require 'json/ext/parser' + require 'json/ext/generator' + $DEBUG and warn "Using Ext extension for JSON." + JSON.parser = Parser + JSON.generator = Generator + end + + JSON_LOADED = true unless defined?(::JSON::JSON_LOADED) +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext/generator.so b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext/generator.so new file mode 100755 index 0000000..d8731fc Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext/generator.so differ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext/parser.so b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext/parser.so new file mode 100755 index 0000000..0938a60 Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/ext/parser.so differ diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/generic_object.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/generic_object.rb new file mode 100644 index 0000000..108309d --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/generic_object.rb @@ -0,0 +1,71 @@ +#frozen_string_literal: false +require 'ostruct' + +module JSON + class GenericObject < OpenStruct + class << self + alias [] new + + def json_creatable? + @json_creatable + end + + attr_writer :json_creatable + + def json_create(data) + data = data.dup + data.delete JSON.create_id + self[data] + end + + def from_hash(object) + case + when object.respond_to?(:to_hash) + result = new + object.to_hash.each do |key, value| + result[key] = from_hash(value) + end + result + when object.respond_to?(:to_ary) + object.to_ary.map { |a| from_hash(a) } + else + object + end + end + + def load(source, proc = nil, opts = {}) + result = ::JSON.load(source, proc, opts.merge(:object_class => self)) + result.nil? ? new : result + end + + def dump(obj, *args) + ::JSON.dump(obj, *args) + end + end + self.json_creatable = false + + def to_hash + table + end + + def [](name) + __send__(name) + end unless method_defined?(:[]) + + def []=(name, value) + __send__("#{name}=", value) + end unless method_defined?(:[]=) + + def |(other) + self.class[other.to_hash.merge(to_hash)] + end + + def as_json(*) + { JSON.create_id => self.class.name }.merge to_hash + end + + def to_json(*a) + as_json.to_json(*a) + end + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure.rb new file mode 100644 index 0000000..53178b3 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure.rb @@ -0,0 +1,15 @@ +require 'json/common' + +module JSON + # This module holds all the modules/classes that implement JSON's + # functionality in pure ruby. + module Pure + require 'json/pure/parser' + require 'json/pure/generator' + $DEBUG and warn "Using Pure library for JSON." + JSON.parser = Parser + JSON.generator = Generator + end + + JSON_LOADED = true unless defined?(::JSON::JSON_LOADED) +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure/generator.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure/generator.rb new file mode 100644 index 0000000..2257ee3 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure/generator.rb @@ -0,0 +1,479 @@ +#frozen_string_literal: false +module JSON + MAP = { + "\x0" => '\u0000', + "\x1" => '\u0001', + "\x2" => '\u0002', + "\x3" => '\u0003', + "\x4" => '\u0004', + "\x5" => '\u0005', + "\x6" => '\u0006', + "\x7" => '\u0007', + "\b" => '\b', + "\t" => '\t', + "\n" => '\n', + "\xb" => '\u000b', + "\f" => '\f', + "\r" => '\r', + "\xe" => '\u000e', + "\xf" => '\u000f', + "\x10" => '\u0010', + "\x11" => '\u0011', + "\x12" => '\u0012', + "\x13" => '\u0013', + "\x14" => '\u0014', + "\x15" => '\u0015', + "\x16" => '\u0016', + "\x17" => '\u0017', + "\x18" => '\u0018', + "\x19" => '\u0019', + "\x1a" => '\u001a', + "\x1b" => '\u001b', + "\x1c" => '\u001c', + "\x1d" => '\u001d', + "\x1e" => '\u001e', + "\x1f" => '\u001f', + '"' => '\"', + '\\' => '\\\\', + } # :nodoc: + + ESCAPE_SLASH_MAP = MAP.merge( + '/' => '\\/', + ) + + # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with + # UTF16 big endian characters as \u????, and return it. + def utf8_to_json(string, escape_slash = false) # :nodoc: + string = string.dup + string.force_encoding(::Encoding::ASCII_8BIT) + map = escape_slash ? ESCAPE_SLASH_MAP : MAP + string.gsub!(/[\/"\\\x0-\x1f]/) { map[$&] || $& } + string.force_encoding(::Encoding::UTF_8) + string + end + + def utf8_to_json_ascii(string, escape_slash = false) # :nodoc: + string = string.dup + string.force_encoding(::Encoding::ASCII_8BIT) + map = escape_slash ? ESCAPE_SLASH_MAP : MAP + string.gsub!(/[\/"\\\x0-\x1f]/n) { map[$&] || $& } + string.gsub!(/( + (?: + [\xc2-\xdf][\x80-\xbf] | + [\xe0-\xef][\x80-\xbf]{2} | + [\xf0-\xf4][\x80-\xbf]{3} + )+ | + [\x80-\xc1\xf5-\xff] # invalid + )/nx) { |c| + c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'" + s = JSON.iconv('utf-16be', 'utf-8', c).unpack('H*')[0] + s.force_encoding(::Encoding::ASCII_8BIT) + s.gsub!(/.{4}/n, '\\\\u\&') + s.force_encoding(::Encoding::UTF_8) + } + string.force_encoding(::Encoding::UTF_8) + string + rescue => e + raise GeneratorError.wrap(e) + end + + def valid_utf8?(string) + encoding = string.encoding + (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII) && + string.valid_encoding? + end + module_function :utf8_to_json, :utf8_to_json_ascii, :valid_utf8? + + module Pure + module Generator + # This class is used to create State instances, that are use to hold data + # while generating a JSON text from a Ruby data structure. + class State + # Creates a State object from _opts_, which ought to be Hash to create + # a new State instance configured by _opts_, something else to create + # an unconfigured instance. If _opts_ is a State object, it is just + # returned. + def self.from_state(opts) + case + when self === opts + opts + when opts.respond_to?(:to_hash) + new(opts.to_hash) + when opts.respond_to?(:to_h) + new(opts.to_h) + else + SAFE_STATE_PROTOTYPE.dup + end + end + + # Instantiates a new State object, configured by _opts_. + # + # _opts_ can have the following keys: + # + # * *indent*: a string used to indent levels (default: ''), + # * *space*: a string that is put after, a : or , delimiter (default: ''), + # * *space_before*: a string that is put before a : pair delimiter (default: ''), + # * *object_nl*: a string that is put at the end of a JSON object (default: ''), + # * *array_nl*: a string that is put at the end of a JSON array (default: ''), + # * *escape_slash*: true if forward slash (/) should be escaped (default: false) + # * *check_circular*: is deprecated now, use the :max_nesting option instead, + # * *max_nesting*: sets the maximum level of data structure nesting in + # the generated JSON, max_nesting = 0 if no maximum should be checked. + # * *allow_nan*: true if NaN, Infinity, and -Infinity should be + # generated, otherwise an exception is thrown, if these values are + # encountered. This options defaults to false. + def initialize(opts = {}) + @indent = '' + @space = '' + @space_before = '' + @object_nl = '' + @array_nl = '' + @allow_nan = false + @ascii_only = false + @escape_slash = false + @buffer_initial_length = 1024 + configure opts + end + + # This string is used to indent levels in the JSON text. + attr_accessor :indent + + # This string is used to insert a space between the tokens in a JSON + # string. + attr_accessor :space + + # This string is used to insert a space before the ':' in JSON objects. + attr_accessor :space_before + + # This string is put at the end of a line that holds a JSON object (or + # Hash). + attr_accessor :object_nl + + # This string is put at the end of a line that holds a JSON array. + attr_accessor :array_nl + + # This integer returns the maximum level of data structure nesting in + # the generated JSON, max_nesting = 0 if no maximum is checked. + attr_accessor :max_nesting + + # If this attribute is set to true, forward slashes will be escaped in + # all json strings. + attr_accessor :escape_slash + + # :stopdoc: + attr_reader :buffer_initial_length + + def buffer_initial_length=(length) + if length > 0 + @buffer_initial_length = length + end + end + # :startdoc: + + # This integer returns the current depth data structure nesting in the + # generated JSON. + attr_accessor :depth + + def check_max_nesting # :nodoc: + return if @max_nesting.zero? + current_nesting = depth + 1 + current_nesting > @max_nesting and + raise NestingError, "nesting of #{current_nesting} is too deep" + end + + # Returns true, if circular data structures are checked, + # otherwise returns false. + def check_circular? + !@max_nesting.zero? + end + + # Returns true if NaN, Infinity, and -Infinity should be considered as + # valid JSON and output. + def allow_nan? + @allow_nan + end + + # Returns true, if only ASCII characters should be generated. Otherwise + # returns false. + def ascii_only? + @ascii_only + end + + # Returns true, if forward slashes are escaped. Otherwise returns false. + def escape_slash? + @escape_slash + end + + # Configure this State instance with the Hash _opts_, and return + # itself. + def configure(opts) + if opts.respond_to?(:to_hash) + opts = opts.to_hash + elsif opts.respond_to?(:to_h) + opts = opts.to_h + else + raise TypeError, "can't convert #{opts.class} into Hash" + end + for key, value in opts + instance_variable_set "@#{key}", value + end + @indent = opts[:indent] if opts.key?(:indent) + @space = opts[:space] if opts.key?(:space) + @space_before = opts[:space_before] if opts.key?(:space_before) + @object_nl = opts[:object_nl] if opts.key?(:object_nl) + @array_nl = opts[:array_nl] if opts.key?(:array_nl) + @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan) + @ascii_only = opts[:ascii_only] if opts.key?(:ascii_only) + @depth = opts[:depth] || 0 + @buffer_initial_length ||= opts[:buffer_initial_length] + @escape_slash = !!opts[:escape_slash] if opts.key?(:escape_slash) + + if !opts.key?(:max_nesting) # defaults to 100 + @max_nesting = 100 + elsif opts[:max_nesting] + @max_nesting = opts[:max_nesting] + else + @max_nesting = 0 + end + self + end + alias merge configure + + # Returns the configuration instance variables as a hash, that can be + # passed to the configure method. + def to_h + result = {} + for iv in instance_variables + iv = iv.to_s[1..-1] + result[iv.to_sym] = self[iv] + end + result + end + + alias to_hash to_h + + # Generates a valid JSON document from object +obj+ and + # returns the result. If no valid JSON document can be + # created this method raises a + # GeneratorError exception. + def generate(obj) + result = obj.to_json(self) + JSON.valid_utf8?(result) or raise GeneratorError, + "source sequence #{result.inspect} is illegal/malformed utf-8" + result + end + + # Return the value returned by method +name+. + def [](name) + if respond_to?(name) + __send__(name) + else + instance_variable_get("@#{name}") if + instance_variables.include?("@#{name}".to_sym) # avoid warning + end + end + + def []=(name, value) + if respond_to?(name_writer = "#{name}=") + __send__ name_writer, value + else + instance_variable_set "@#{name}", value + end + end + end + + module GeneratorMethods + module Object + # Converts this object to a string (calling #to_s), converts + # it to a JSON string, and returns the result. This is a fallback, if no + # special method #to_json was defined for some object. + def to_json(*) to_s.to_json end + end + + module Hash + # Returns a JSON string containing a JSON object, that is unparsed from + # this Hash instance. + # _state_ is a JSON::State object, that can also be used to configure the + # produced JSON string output further. + # _depth_ is used to find out nesting depth, to indent accordingly. + def to_json(state = nil, *) + state = State.from_state(state) + state.check_max_nesting + json_transform(state) + end + + private + + def json_shift(state) + state.object_nl.empty? or return '' + state.indent * state.depth + end + + def json_transform(state) + delim = ',' + delim << state.object_nl + result = '{' + result << state.object_nl + depth = state.depth += 1 + first = true + indent = !state.object_nl.empty? + each { |key,value| + result << delim unless first + result << state.indent * depth if indent + result << key.to_s.to_json(state) + result << state.space_before + result << ':' + result << state.space + if value.respond_to?(:to_json) + result << value.to_json(state) + else + result << %{"#{String(value)}"} + end + first = false + } + depth = state.depth -= 1 + unless first + result << state.object_nl + result << state.indent * depth if indent + end + result << '}' + result + end + end + + module Array + # Returns a JSON string containing a JSON array, that is unparsed from + # this Array instance. + # _state_ is a JSON::State object, that can also be used to configure the + # produced JSON string output further. + def to_json(state = nil, *) + state = State.from_state(state) + state.check_max_nesting + json_transform(state) + end + + private + + def json_transform(state) + delim = ',' + delim << state.array_nl + result = '[' + result << state.array_nl + depth = state.depth += 1 + first = true + indent = !state.array_nl.empty? + each { |value| + result << delim unless first + result << state.indent * depth if indent + if value.respond_to?(:to_json) + result << value.to_json(state) + else + result << %{"#{String(value)}"} + end + first = false + } + depth = state.depth -= 1 + result << state.array_nl + result << state.indent * depth if indent + result << ']' + end + end + + module Integer + # Returns a JSON string representation for this Integer number. + def to_json(*) to_s end + end + + module Float + # Returns a JSON string representation for this Float number. + def to_json(state = nil, *) + state = State.from_state(state) + case + when infinite? + if state.allow_nan? + to_s + else + raise GeneratorError, "#{self} not allowed in JSON" + end + when nan? + if state.allow_nan? + to_s + else + raise GeneratorError, "#{self} not allowed in JSON" + end + else + to_s + end + end + end + + module String + # This string should be encoded with UTF-8 A call to this method + # returns a JSON string encoded with UTF16 big endian characters as + # \u????. + def to_json(state = nil, *args) + state = State.from_state(state) + if encoding == ::Encoding::UTF_8 + string = self + else + string = encode(::Encoding::UTF_8) + end + if state.ascii_only? + '"' << JSON.utf8_to_json_ascii(string, state.escape_slash) << '"' + else + '"' << JSON.utf8_to_json(string, state.escape_slash) << '"' + end + end + + # Module that holds the extending methods if, the String module is + # included. + module Extend + # Raw Strings are JSON Objects (the raw bytes are stored in an + # array for the key "raw"). The Ruby String can be created by this + # module method. + def json_create(o) + o['raw'].pack('C*') + end + end + + # Extends _modul_ with the String::Extend module. + def self.included(modul) + modul.extend Extend + end + + # This method creates a raw object hash, that can be nested into + # other data structures and will be unparsed as a raw string. This + # method should be used, if you want to convert raw strings to JSON + # instead of UTF-8 strings, e. g. binary data. + def to_json_raw_object + { + JSON.create_id => self.class.name, + 'raw' => self.unpack('C*'), + } + end + + # This method creates a JSON text from the result of + # a call to to_json_raw_object of this String. + def to_json_raw(*args) + to_json_raw_object.to_json(*args) + end + end + + module TrueClass + # Returns a JSON string for true: 'true'. + def to_json(*) 'true' end + end + + module FalseClass + # Returns a JSON string for false: 'false'. + def to_json(*) 'false' end + end + + module NilClass + # Returns a JSON string for nil: 'null'. + def to_json(*) 'null' end + end + end + end + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure/parser.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure/parser.rb new file mode 100644 index 0000000..be48c60 --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/pure/parser.rb @@ -0,0 +1,337 @@ +#frozen_string_literal: false +require 'strscan' + +module JSON + module Pure + # This class implements the JSON parser that is used to parse a JSON string + # into a Ruby data structure. + class Parser < StringScanner + STRING = /" ((?:[^\x0-\x1f"\\] | + # escaped special characters: + \\["\\\/bfnrt] | + \\u[0-9a-fA-F]{4} | + # match all but escaped special characters: + \\[\x20-\x21\x23-\x2e\x30-\x5b\x5d-\x61\x63-\x65\x67-\x6d\x6f-\x71\x73\x75-\xff])*) + "/nx + INTEGER = /(-?0|-?[1-9]\d*)/ + FLOAT = /(-? + (?:0|[1-9]\d*) + (?: + \.\d+(?i:e[+-]?\d+) | + \.\d+ | + (?i:e[+-]?\d+) + ) + )/x + NAN = /NaN/ + INFINITY = /Infinity/ + MINUS_INFINITY = /-Infinity/ + OBJECT_OPEN = /\{/ + OBJECT_CLOSE = /\}/ + ARRAY_OPEN = /\[/ + ARRAY_CLOSE = /\]/ + PAIR_DELIMITER = /:/ + COLLECTION_DELIMITER = /,/ + TRUE = /true/ + FALSE = /false/ + NULL = /null/ + IGNORE = %r( + (?: + //[^\n\r]*[\n\r]| # line comments + /\* # c-style comments + (?: + [^*/]| # normal chars + /[^*]| # slashes that do not start a nested comment + \*[^/]| # asterisks that do not end this comment + /(?=\*/) # single slash before this comment's end + )* + \*/ # the End of this comment + |[ \t\r\n]+ # whitespaces: space, horizontal tab, lf, cr + )+ + )mx + + UNPARSED = Object.new.freeze + + # Creates a new JSON::Pure::Parser instance for the string _source_. + # + # It will be configured by the _opts_ hash. _opts_ can have the following + # keys: + # * *max_nesting*: The maximum depth of nesting allowed in the parsed data + # structures. Disable depth checking with :max_nesting => false|nil|0, + # it defaults to 100. + # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in + # defiance of RFC 7159 to be parsed by the Parser. This option defaults + # to false. + # * *freeze*: If set to true, all parsed objects will be frozen. Parsed + # string will be deduplicated if possible. + # * *symbolize_names*: If set to true, returns symbols for the names + # (keys) in a JSON object. Otherwise strings are returned, which is + # also the default. It's not possible to use this option in + # conjunction with the *create_additions* option. + # * *create_additions*: If set to true, the Parser creates + # additions when a matching class and create_id are found. This + # option defaults to false. + # * *object_class*: Defaults to Hash + # * *array_class*: Defaults to Array + # * *decimal_class*: Specifies which class to use instead of the default + # (Float) when parsing decimal numbers. This class must accept a single + # string argument in its constructor. + def initialize(source, opts = {}) + opts ||= {} + source = convert_encoding source + super source + if !opts.key?(:max_nesting) # defaults to 100 + @max_nesting = 100 + elsif opts[:max_nesting] + @max_nesting = opts[:max_nesting] + else + @max_nesting = 0 + end + @allow_nan = !!opts[:allow_nan] + @symbolize_names = !!opts[:symbolize_names] + @freeze = !!opts[:freeze] + if opts.key?(:create_additions) + @create_additions = !!opts[:create_additions] + else + @create_additions = false + end + @symbolize_names && @create_additions and raise ArgumentError, + 'options :symbolize_names and :create_additions cannot be used '\ + 'in conjunction' + @create_id = @create_additions ? JSON.create_id : nil + @object_class = opts[:object_class] || Hash + @array_class = opts[:array_class] || Array + @decimal_class = opts[:decimal_class] + @match_string = opts[:match_string] + end + + alias source string + + def reset + super + @current_nesting = 0 + end + + # Parses the current JSON string _source_ and returns the + # complete data structure as a result. + def parse + reset + obj = nil + while !eos? && skip(IGNORE) do end + if eos? + raise ParserError, "source is not valid JSON!" + else + obj = parse_value + UNPARSED.equal?(obj) and raise ParserError, + "source is not valid JSON!" + obj.freeze if @freeze + end + while !eos? && skip(IGNORE) do end + eos? or raise ParserError, "source is not valid JSON!" + obj + end + + private + + def convert_encoding(source) + if source.respond_to?(:to_str) + source = source.to_str + else + raise TypeError, + "#{source.inspect} is not like a string" + end + if source.encoding != ::Encoding::ASCII_8BIT + source = source.encode(::Encoding::UTF_8) + source.force_encoding(::Encoding::ASCII_8BIT) + end + source + end + + # Unescape characters in strings. + UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr } + UNESCAPE_MAP.update({ + ?" => '"', + ?\\ => '\\', + ?/ => '/', + ?b => "\b", + ?f => "\f", + ?n => "\n", + ?r => "\r", + ?t => "\t", + ?u => nil, + }) + + EMPTY_8BIT_STRING = '' + if ::String.method_defined?(:encode) + EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT + end + + STR_UMINUS = ''.respond_to?(:-@) + def parse_string + if scan(STRING) + return '' if self[1].empty? + string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c| + if u = UNESCAPE_MAP[$&[1]] + u + else # \uXXXX + bytes = EMPTY_8BIT_STRING.dup + i = 0 + while c[6 * i] == ?\\ && c[6 * i + 1] == ?u + bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16) + i += 1 + end + JSON.iconv('utf-8', 'utf-16be', bytes).force_encoding(::Encoding::ASCII_8BIT) + end + end + if string.respond_to?(:force_encoding) + string.force_encoding(::Encoding::UTF_8) + end + + if @freeze + if STR_UMINUS + string = -string + else + string.freeze + end + end + + if @create_additions and @match_string + for (regexp, klass) in @match_string + klass.json_creatable? or next + string =~ regexp and return klass.json_create(string) + end + end + string + else + UNPARSED + end + rescue => e + raise ParserError, "Caught #{e.class} at '#{peek(20)}': #{e}" + end + + def parse_value + case + when scan(FLOAT) + if @decimal_class then + if @decimal_class == BigDecimal then + BigDecimal(self[1]) + else + @decimal_class.new(self[1]) || Float(self[1]) + end + else + Float(self[1]) + end + when scan(INTEGER) + Integer(self[1]) + when scan(TRUE) + true + when scan(FALSE) + false + when scan(NULL) + nil + when !UNPARSED.equal?(string = parse_string) + string + when scan(ARRAY_OPEN) + @current_nesting += 1 + ary = parse_array + @current_nesting -= 1 + ary + when scan(OBJECT_OPEN) + @current_nesting += 1 + obj = parse_object + @current_nesting -= 1 + obj + when @allow_nan && scan(NAN) + NaN + when @allow_nan && scan(INFINITY) + Infinity + when @allow_nan && scan(MINUS_INFINITY) + MinusInfinity + else + UNPARSED + end + end + + def parse_array + raise NestingError, "nesting of #@current_nesting is too deep" if + @max_nesting.nonzero? && @current_nesting > @max_nesting + result = @array_class.new + delim = false + loop do + case + when eos? + raise ParserError, "unexpected end of string while parsing array" + when !UNPARSED.equal?(value = parse_value) + delim = false + result << value + skip(IGNORE) + if scan(COLLECTION_DELIMITER) + delim = true + elsif match?(ARRAY_CLOSE) + ; + else + raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!" + end + when scan(ARRAY_CLOSE) + if delim + raise ParserError, "expected next element in array at '#{peek(20)}'!" + end + break + when skip(IGNORE) + ; + else + raise ParserError, "unexpected token in array at '#{peek(20)}'!" + end + end + result + end + + def parse_object + raise NestingError, "nesting of #@current_nesting is too deep" if + @max_nesting.nonzero? && @current_nesting > @max_nesting + result = @object_class.new + delim = false + loop do + case + when eos? + raise ParserError, "unexpected end of string while parsing object" + when !UNPARSED.equal?(string = parse_string) + skip(IGNORE) + unless scan(PAIR_DELIMITER) + raise ParserError, "expected ':' in object at '#{peek(20)}'!" + end + skip(IGNORE) + unless UNPARSED.equal?(value = parse_value) + result[@symbolize_names ? string.to_sym : string] = value + delim = false + skip(IGNORE) + if scan(COLLECTION_DELIMITER) + delim = true + elsif match?(OBJECT_CLOSE) + ; + else + raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!" + end + else + raise ParserError, "expected value in object at '#{peek(20)}'!" + end + when scan(OBJECT_CLOSE) + if delim + raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!" + end + if @create_additions and klassname = result[@create_id] + klass = JSON.deep_const_get klassname + break unless klass and klass.json_creatable? + result = klass.json_create(result) + end + break + when skip(IGNORE) + ; + else + raise ParserError, "unexpected token in object at '#{peek(20)}'!" + end + end + result + end + end + end +end diff --git a/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/version.rb b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/version.rb new file mode 100644 index 0000000..3d4326d --- /dev/null +++ b/vendor/bundle/ruby/2.7.0/gems/json-2.6.3/lib/json/version.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: false +module JSON + # JSON version + VERSION = '2.6.3' + VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: + VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: + VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: + VERSION_BUILD = VERSION_ARRAY[2] # :nodoc: +end diff --git a/vendor/bundle/ruby/2.7.0/specifications/json-2.6.3.gemspec b/vendor/bundle/ruby/2.7.0/specifications/json-2.6.3.gemspec new file mode 100644 index 0000000..d41efd4 Binary files /dev/null and b/vendor/bundle/ruby/2.7.0/specifications/json-2.6.3.gemspec differ