nutshell-crm 0.0.5 → 0.0.6.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.rbenv-version +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/README.md +37 -0
- data/Rakefile +14 -3
- data/lib/nutshell-crm.rb +92 -5
- data/lib/nutshell-crm/version.rb +1 -1
- data/nutshell-crm.gemspec +1 -0
- data/spec/nutshell-crm_spec.rb +17 -8
- data/vendor/bundle/bin/rake +19 -0
- data/vendor/bundle/gems/json-1.6.4/.gitignore +8 -0
- data/vendor/bundle/gems/json-1.6.4/.travis.yml +15 -0
- data/vendor/bundle/gems/json-1.6.4/CHANGES +227 -0
- data/vendor/bundle/gems/json-1.6.4/COPYING +58 -0
- data/vendor/bundle/gems/json-1.6.4/COPYING-json-jruby +57 -0
- data/vendor/bundle/gems/json-1.6.4/GPL +340 -0
- data/vendor/bundle/gems/json-1.6.4/Gemfile +11 -0
- data/vendor/bundle/gems/json-1.6.4/README-json-jruby.markdown +33 -0
- data/vendor/bundle/gems/json-1.6.4/README.rdoc +358 -0
- data/vendor/bundle/gems/json-1.6.4/Rakefile +408 -0
- data/vendor/bundle/gems/json-1.6.4/TODO +1 -0
- data/vendor/bundle/gems/json-1.6.4/VERSION +1 -0
- data/{README → vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/.keep} +0 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/data/.keep +0 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/generator2_benchmark.rb +222 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/generator_benchmark.rb +224 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/ohai.json +1216 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/ohai.ruby +1 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/parser2_benchmark.rb +251 -0
- data/vendor/bundle/gems/json-1.6.4/benchmarks/parser_benchmark.rb +259 -0
- data/vendor/bundle/gems/json-1.6.4/data/example.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/data/index.html +38 -0
- data/vendor/bundle/gems/json-1.6.4/data/prototype.js +4184 -0
- data/vendor/bundle/gems/json-1.6.4/diagrams/.keep +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/fbuffer/fbuffer.h +156 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/Makefile +187 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/extconf.rb +13 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.c +1384 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.h +161 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/generator/generator.o +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/json/ext/generator.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/json/ext/parser.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/Makefile +187 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/extconf.rb +13 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.bundle +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.c +2203 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.h +77 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.o +0 -0
- data/vendor/bundle/gems/json-1.6.4/ext/json/ext/parser/parser.rl +926 -0
- data/vendor/bundle/gems/json-1.6.4/install.rb +19 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/ByteListTranscoder.java +167 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Generator.java +437 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/GeneratorMethods.java +232 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/GeneratorService.java +43 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/GeneratorState.java +522 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/OptionsReader.java +113 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Parser.java +2640 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Parser.rl +964 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/ParserService.java +35 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/RuntimeInfo.java +121 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/StringDecoder.java +166 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/StringEncoder.java +106 -0
- data/vendor/bundle/gems/json-1.6.4/java/src/json/ext/Utils.java +89 -0
- data/vendor/bundle/gems/json-1.6.4/json-java.gemspec +22 -0
- data/vendor/bundle/gems/json-1.6.4/json.gemspec +40 -0
- data/vendor/bundle/gems/json-1.6.4/json_pure.gemspec +42 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json.rb +62 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/bigdecimal.rb +21 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/complex.rb +22 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/core.rb +11 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/date.rb +34 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/date_time.rb +50 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/exception.rb +31 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/ostruct.rb +31 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/range.rb +29 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/rational.rb +22 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/regexp.rb +30 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/struct.rb +30 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/symbol.rb +25 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/add/time.rb +35 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/common.rb +470 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/ext.rb +21 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/ext/.keep +0 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/pure.rb +21 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/pure/generator.rb +468 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/pure/parser.rb +359 -0
- data/vendor/bundle/gems/json-1.6.4/lib/json/version.rb +8 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail1.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail10.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail11.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail12.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail13.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail14.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail18.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail19.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail2.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail20.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail21.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail22.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail23.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail24.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail25.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail27.json +2 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail28.json +2 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail3.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail4.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail5.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail6.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail7.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail8.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/fail9.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass1.json +56 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass15.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass16.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass17.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass2.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass26.json +1 -0
- data/vendor/bundle/gems/json-1.6.4/tests/fixtures/pass3.json +6 -0
- data/vendor/bundle/gems/json-1.6.4/tests/setup_variant.rb +11 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json.rb +527 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_addition.rb +188 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_encoding.rb +65 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_fixtures.rb +35 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_generate.rb +249 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_string_matching.rb +40 -0
- data/vendor/bundle/gems/json-1.6.4/tests/test_json_unicode.rb +72 -0
- data/vendor/bundle/gems/json-1.6.4/tools/fuzz.rb +139 -0
- data/vendor/bundle/gems/json-1.6.4/tools/server.rb +62 -0
- data/vendor/bundle/gems/rake-0.9.2.2/.gemtest +0 -0
- data/vendor/bundle/gems/rake-0.9.2.2/CHANGES +522 -0
- data/vendor/bundle/gems/rake-0.9.2.2/MIT-LICENSE +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/README.rdoc +197 -0
- data/vendor/bundle/gems/rake-0.9.2.2/Rakefile +369 -0
- data/vendor/bundle/gems/rake-0.9.2.2/TODO +20 -0
- data/vendor/bundle/gems/rake-0.9.2.2/bin/rake +33 -0
- data/vendor/bundle/gems/rake-0.9.2.2/install.rb +90 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake.rb +69 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/alt_system.rb +109 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/application.rb +595 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/classic_namespace.rb +11 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/clean.rb +32 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/cloneable.rb +25 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/compositepublisher.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/ftptools.rb +150 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/publisher.rb +73 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/rubyforgepublisher.rb +16 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/sshpublisher.rb +50 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/contrib/sys.rb +191 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/default_loader.rb +10 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/dsl_definition.rb +176 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/early_time.rb +18 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/core.rb +27 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/module.rb +39 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/string.rb +167 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ext/time.rb +14 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_creation_task.rb +24 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_list.rb +403 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_task.rb +47 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_utils.rb +114 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb +145 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/gempackagetask.rb +15 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/invocation_chain.rb +51 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/invocation_exception_mixin.rb +16 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/loaders/makefile.rb +40 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/multi_task.rb +16 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/name_space.rb +25 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/packagetask.rb +185 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/pathmap.rb +1 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/pseudo_status.rb +24 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rake_module.rb +29 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb +22 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rdoctask.rb +234 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/ruby182_test_unit_fix.rb +25 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/runtest.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task.rb +327 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task_argument_error.rb +7 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task_arguments.rb +78 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/task_manager.rb +307 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/tasklib.rb +22 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/testtask.rb +191 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/version.rb +8 -0
- data/vendor/bundle/gems/rake-0.9.2.2/lib/rake/win32.rb +55 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/file_creation.rb +34 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/helper.rb +492 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake.rb +40 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_application.rb +489 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_application_options.rb +335 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_clean.rb +14 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_definitions.rb +80 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_directory_task.rb +46 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_dsl.rb +77 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_early_time.rb +31 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_extension.rb +59 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_creation_task.rb +56 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_list.rb +628 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_list_path_map.rb +8 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_task.rb +102 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_file_utils.rb +305 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_ftp_file.rb +59 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_functional.rb +450 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_invocation_chain.rb +52 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_makefile_loader.rb +44 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_multi_task.rb +51 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_name_space.rb +43 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_package_task.rb +79 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_path_map.rb +157 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_path_map_explode.rb +34 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_path_map_partial.rb +18 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_pseudo_status.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_rake_test_loader.rb +21 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_rdoc_task.rb +83 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_require.rb +40 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_rules.rb +327 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task.rb +267 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_argument_parsing.rb +103 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_arguments.rb +88 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_lib.rb +9 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_manager.rb +157 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_manager_argument_resolution.rb +36 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_task_with_arguments.rb +173 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_test_task.rb +120 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_top_level_functions.rb +111 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_rake_win32.rb +72 -0
- data/vendor/bundle/gems/rake-0.9.2.2/test/test_sys.rb +20 -0
- data/vendor/bundle/specifications/json-1.6.4.gemspec +39 -0
- data/vendor/bundle/specifications/rake-0.9.2.2.gemspec +34 -0
- metadata +285 -18
File without changes
|
@@ -0,0 +1,156 @@
|
|
1
|
+
|
2
|
+
#ifndef _FBUFFER_H_
|
3
|
+
#define _FBUFFER_H_
|
4
|
+
|
5
|
+
#include <assert.h>
|
6
|
+
#include "ruby.h"
|
7
|
+
|
8
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
9
|
+
#include "ruby/encoding.h"
|
10
|
+
#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
|
11
|
+
#else
|
12
|
+
#define FORCE_UTF8(obj)
|
13
|
+
#endif
|
14
|
+
|
15
|
+
/* We don't need to guard objects for rbx, so let's do nothing at all. */
|
16
|
+
#ifndef RB_GC_GUARD
|
17
|
+
#define RB_GC_GUARD(object)
|
18
|
+
#endif
|
19
|
+
|
20
|
+
typedef struct FBufferStruct {
|
21
|
+
unsigned long initial_length;
|
22
|
+
char *ptr;
|
23
|
+
unsigned long len;
|
24
|
+
unsigned long capa;
|
25
|
+
} FBuffer;
|
26
|
+
|
27
|
+
#define FBUFFER_INITIAL_LENGTH_DEFAULT 1024
|
28
|
+
|
29
|
+
#define FBUFFER_PTR(fb) (fb->ptr)
|
30
|
+
#define FBUFFER_LEN(fb) (fb->len)
|
31
|
+
#define FBUFFER_CAPA(fb) (fb->capa)
|
32
|
+
#define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb)
|
33
|
+
|
34
|
+
static FBuffer *fbuffer_alloc(unsigned long initial_length);
|
35
|
+
static void fbuffer_free(FBuffer *fb);
|
36
|
+
static void fbuffer_clear(FBuffer *fb);
|
37
|
+
static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len);
|
38
|
+
static void fbuffer_append_long(FBuffer *fb, long number);
|
39
|
+
static void fbuffer_append_char(FBuffer *fb, char newchr);
|
40
|
+
static FBuffer *fbuffer_dup(FBuffer *fb);
|
41
|
+
static VALUE fbuffer_to_s(FBuffer *fb);
|
42
|
+
|
43
|
+
static FBuffer *fbuffer_alloc(unsigned long initial_length)
|
44
|
+
{
|
45
|
+
FBuffer *fb;
|
46
|
+
if (initial_length <= 0) initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
|
47
|
+
fb = ALLOC(FBuffer);
|
48
|
+
memset((void *) fb, 0, sizeof(FBuffer));
|
49
|
+
fb->initial_length = initial_length;
|
50
|
+
return fb;
|
51
|
+
}
|
52
|
+
|
53
|
+
static void fbuffer_free(FBuffer *fb)
|
54
|
+
{
|
55
|
+
if (fb->ptr) ruby_xfree(fb->ptr);
|
56
|
+
ruby_xfree(fb);
|
57
|
+
}
|
58
|
+
|
59
|
+
static void fbuffer_clear(FBuffer *fb)
|
60
|
+
{
|
61
|
+
fb->len = 0;
|
62
|
+
}
|
63
|
+
|
64
|
+
static void fbuffer_inc_capa(FBuffer *fb, unsigned long requested)
|
65
|
+
{
|
66
|
+
unsigned long required;
|
67
|
+
|
68
|
+
if (!fb->ptr) {
|
69
|
+
fb->ptr = ALLOC_N(char, fb->initial_length);
|
70
|
+
fb->capa = fb->initial_length;
|
71
|
+
}
|
72
|
+
|
73
|
+
for (required = fb->capa; requested > required - fb->len; required <<= 1);
|
74
|
+
|
75
|
+
if (required > fb->capa) {
|
76
|
+
REALLOC_N(fb->ptr, char, required);
|
77
|
+
fb->capa = required;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len)
|
82
|
+
{
|
83
|
+
if (len > 0) {
|
84
|
+
fbuffer_inc_capa(fb, len);
|
85
|
+
MEMCPY(fb->ptr + fb->len, newstr, char, len);
|
86
|
+
fb->len += len;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
static void fbuffer_append_str(FBuffer *fb, VALUE str)
|
91
|
+
{
|
92
|
+
const char *newstr = StringValuePtr(str);
|
93
|
+
unsigned long len = RSTRING_LEN(str);
|
94
|
+
|
95
|
+
RB_GC_GUARD(str);
|
96
|
+
|
97
|
+
fbuffer_append(fb, newstr, len);
|
98
|
+
}
|
99
|
+
|
100
|
+
static void fbuffer_append_char(FBuffer *fb, char newchr)
|
101
|
+
{
|
102
|
+
fbuffer_inc_capa(fb, 1);
|
103
|
+
*(fb->ptr + fb->len) = newchr;
|
104
|
+
fb->len++;
|
105
|
+
}
|
106
|
+
|
107
|
+
static void freverse(char *start, char *end)
|
108
|
+
{
|
109
|
+
char c;
|
110
|
+
|
111
|
+
while (end > start) {
|
112
|
+
c = *end, *end-- = *start, *start++ = c;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
static long fltoa(long number, char *buf)
|
117
|
+
{
|
118
|
+
static char digits[] = "0123456789";
|
119
|
+
long sign = number;
|
120
|
+
char* tmp = buf;
|
121
|
+
|
122
|
+
if (sign < 0) number = -number;
|
123
|
+
do *tmp++ = digits[number % 10]; while (number /= 10);
|
124
|
+
if (sign < 0) *tmp++ = '-';
|
125
|
+
freverse(buf, tmp - 1);
|
126
|
+
return tmp - buf;
|
127
|
+
}
|
128
|
+
|
129
|
+
static void fbuffer_append_long(FBuffer *fb, long number)
|
130
|
+
{
|
131
|
+
char buf[20];
|
132
|
+
unsigned long len = fltoa(number, buf);
|
133
|
+
fbuffer_append(fb, buf, len);
|
134
|
+
}
|
135
|
+
|
136
|
+
static FBuffer *fbuffer_dup(FBuffer *fb)
|
137
|
+
{
|
138
|
+
unsigned long len = fb->len;
|
139
|
+
FBuffer *result;
|
140
|
+
|
141
|
+
assert(len > 0);
|
142
|
+
if (len > 0) {
|
143
|
+
result = fbuffer_alloc(len);
|
144
|
+
fbuffer_append(result, FBUFFER_PAIR(fb));
|
145
|
+
}
|
146
|
+
return result;
|
147
|
+
}
|
148
|
+
|
149
|
+
static VALUE fbuffer_to_s(FBuffer *fb)
|
150
|
+
{
|
151
|
+
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
|
152
|
+
fbuffer_free(fb);
|
153
|
+
FORCE_UTF8(result);
|
154
|
+
return result;
|
155
|
+
}
|
156
|
+
#endif
|
@@ -0,0 +1,187 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = .
|
7
|
+
topdir = /Users/mshafrir/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1
|
8
|
+
hdrdir = /Users/mshafrir/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1
|
9
|
+
arch_hdrdir = /Users/mshafrir/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/$(arch)
|
10
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
11
|
+
prefix = $(DESTDIR)/Users/mshafrir/.rbenv/versions/1.9.2-p290
|
12
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
13
|
+
exec_prefix = $(prefix)
|
14
|
+
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
15
|
+
sitehdrdir = $(rubyhdrdir)/site_ruby
|
16
|
+
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
|
17
|
+
vendordir = $(rubylibprefix)/vendor_ruby
|
18
|
+
sitedir = $(rubylibprefix)/site_ruby
|
19
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
20
|
+
mandir = $(datarootdir)/man
|
21
|
+
localedir = $(datarootdir)/locale
|
22
|
+
libdir = $(exec_prefix)/lib
|
23
|
+
psdir = $(docdir)
|
24
|
+
pdfdir = $(docdir)
|
25
|
+
dvidir = $(docdir)
|
26
|
+
htmldir = $(docdir)
|
27
|
+
infodir = $(datarootdir)/info
|
28
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
29
|
+
oldincludedir = $(DESTDIR)/usr/include
|
30
|
+
includedir = $(prefix)/include
|
31
|
+
localstatedir = $(prefix)/var
|
32
|
+
sharedstatedir = $(prefix)/com
|
33
|
+
sysconfdir = $(prefix)/etc
|
34
|
+
datadir = $(datarootdir)
|
35
|
+
datarootdir = $(prefix)/share
|
36
|
+
libexecdir = $(exec_prefix)/libexec
|
37
|
+
sbindir = $(exec_prefix)/sbin
|
38
|
+
bindir = $(exec_prefix)/bin
|
39
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
40
|
+
archdir = $(rubylibdir)/$(arch)
|
41
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
42
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
43
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
44
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
45
|
+
|
46
|
+
CC = gcc
|
47
|
+
CXX = g++
|
48
|
+
LIBRUBY = $(LIBRUBY_A)
|
49
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
50
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
51
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
52
|
+
OUTFLAG = -o
|
53
|
+
COUTFLAG = -o
|
54
|
+
|
55
|
+
RUBY_EXTCONF_H =
|
56
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
57
|
+
optflags = -O3
|
58
|
+
debugflags = -ggdb
|
59
|
+
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long
|
60
|
+
CFLAGS = -fno-common $(cflags) -pipe -O3 -Wall -O0 -ggdb
|
61
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
62
|
+
DEFS =
|
63
|
+
CPPFLAGS = -I'/Users/mshafrir/.rbenv/versions/1.9.2-p290/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
|
64
|
+
CXXFLAGS = $(CFLAGS) $(cxxflags)
|
65
|
+
ldflags = -L. -L'/Users/mshafrir/.rbenv/versions/1.9.2-p290/lib' -L/usr/local/lib
|
66
|
+
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
|
67
|
+
ARCH_FLAG =
|
68
|
+
DLDFLAGS = $(ldflags) $(dldflags)
|
69
|
+
LDSHARED = $(CC) -dynamic -bundle
|
70
|
+
LDSHAREDXX = $(CXX) -dynamic -bundle
|
71
|
+
AR = ar
|
72
|
+
EXEEXT =
|
73
|
+
|
74
|
+
RUBY_BASE_NAME = ruby
|
75
|
+
RUBY_INSTALL_NAME = ruby
|
76
|
+
RUBY_SO_NAME = ruby
|
77
|
+
arch = x86_64-darwin11.1.0
|
78
|
+
sitearch = $(arch)
|
79
|
+
ruby_version = 1.9.1
|
80
|
+
ruby = /Users/mshafrir/.rbenv/versions/1.9.2-p290/bin/ruby
|
81
|
+
RUBY = $(ruby)
|
82
|
+
RM = rm -f
|
83
|
+
RM_RF = $(RUBY) -run -e rm -- -rf
|
84
|
+
RMDIRS = $(RUBY) -run -e rmdir -- -p
|
85
|
+
MAKEDIRS = mkdir -p
|
86
|
+
INSTALL = /usr/bin/install -c
|
87
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
88
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
89
|
+
COPY = cp
|
90
|
+
|
91
|
+
#### End of system configuration section. ####
|
92
|
+
|
93
|
+
preload =
|
94
|
+
|
95
|
+
libpath = . $(libdir)
|
96
|
+
LIBPATH = -L. -L$(libdir)
|
97
|
+
DEFFILE =
|
98
|
+
|
99
|
+
CLEANFILES = mkmf.log
|
100
|
+
DISTCLEANFILES =
|
101
|
+
DISTCLEANDIRS =
|
102
|
+
|
103
|
+
extout =
|
104
|
+
extout_prefix =
|
105
|
+
target_prefix = /json/ext
|
106
|
+
LOCAL_LIBS =
|
107
|
+
LIBS = -lpthread -ldl -lobjc
|
108
|
+
SRCS = generator.c
|
109
|
+
OBJS = generator.o
|
110
|
+
TARGET = generator
|
111
|
+
DLLIB = $(TARGET).bundle
|
112
|
+
EXTSTATIC =
|
113
|
+
STATIC_LIB =
|
114
|
+
|
115
|
+
BINDIR = $(bindir)
|
116
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
117
|
+
RUBYLIBDIR = /Users/mshafrir/Dev/nutshell-crm/vendor/bundle/gems/json-1.6.4/ext/json/ext$(target_prefix)
|
118
|
+
RUBYARCHDIR = /Users/mshafrir/Dev/nutshell-crm/vendor/bundle/gems/json-1.6.4/ext/json/ext$(target_prefix)
|
119
|
+
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
120
|
+
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
121
|
+
|
122
|
+
TARGET_SO = $(DLLIB)
|
123
|
+
CLEANLIBS = $(TARGET).bundle
|
124
|
+
CLEANOBJS = *.o *.bak
|
125
|
+
|
126
|
+
all: $(DLLIB)
|
127
|
+
static: $(STATIC_LIB)
|
128
|
+
.PHONY: all install static install-so install-rb
|
129
|
+
.PHONY: clean clean-so clean-rb
|
130
|
+
|
131
|
+
clean-rb-default::
|
132
|
+
clean-rb::
|
133
|
+
clean-so::
|
134
|
+
clean: clean-so clean-rb-default clean-rb
|
135
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
136
|
+
|
137
|
+
distclean-rb-default::
|
138
|
+
distclean-rb::
|
139
|
+
distclean-so::
|
140
|
+
distclean: clean distclean-so distclean-rb-default distclean-rb
|
141
|
+
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
142
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
143
|
+
@-$(RMDIRS) $(DISTCLEANDIRS)
|
144
|
+
|
145
|
+
realclean: distclean
|
146
|
+
install: install-so install-rb
|
147
|
+
|
148
|
+
install-so: $(RUBYARCHDIR)
|
149
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
150
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
151
|
+
@-$(MAKEDIRS) $(@D)
|
152
|
+
$(INSTALL_PROG) $(DLLIB) $(@D)
|
153
|
+
install-rb: pre-install-rb install-rb-default
|
154
|
+
install-rb-default: pre-install-rb-default
|
155
|
+
pre-install-rb: Makefile
|
156
|
+
pre-install-rb-default: Makefile
|
157
|
+
$(RUBYARCHDIR):
|
158
|
+
$(MAKEDIRS) $@
|
159
|
+
|
160
|
+
site-install: site-install-so site-install-rb
|
161
|
+
site-install-so: install-so
|
162
|
+
site-install-rb: install-rb
|
163
|
+
|
164
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
165
|
+
|
166
|
+
.cc.o:
|
167
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
168
|
+
|
169
|
+
.cxx.o:
|
170
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
171
|
+
|
172
|
+
.cpp.o:
|
173
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
174
|
+
|
175
|
+
.C.o:
|
176
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
177
|
+
|
178
|
+
.c.o:
|
179
|
+
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
180
|
+
|
181
|
+
$(DLLIB): $(OBJS) Makefile
|
182
|
+
@-$(RM) $(@)
|
183
|
+
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
unless $CFLAGS.gsub!(/ -O[\dsz]?/, ' -O3')
|
4
|
+
$CFLAGS << ' -O3'
|
5
|
+
end
|
6
|
+
if CONFIG['CC'] =~ /gcc/
|
7
|
+
$CFLAGS << ' -Wall'
|
8
|
+
unless $DEBUG && !$CFLAGS.gsub!(/ -O[\dsz]?/, ' -O0 -ggdb')
|
9
|
+
$CFLAGS << ' -O0 -ggdb'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
create_makefile 'json/ext/generator'
|
@@ -0,0 +1,1384 @@
|
|
1
|
+
#include "../fbuffer/fbuffer.h"
|
2
|
+
#include "generator.h"
|
3
|
+
|
4
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
5
|
+
static VALUE CEncoding_UTF_8;
|
6
|
+
static ID i_encoding, i_encode;
|
7
|
+
#endif
|
8
|
+
|
9
|
+
static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
|
10
|
+
mHash, mArray, mFixnum, mBignum, mFloat, mString, mString_Extend,
|
11
|
+
mTrueClass, mFalseClass, mNilClass, eGeneratorError,
|
12
|
+
eNestingError, CRegexp_MULTILINE, CJSON_SAFE_STATE_PROTOTYPE,
|
13
|
+
i_SAFE_STATE_PROTOTYPE;
|
14
|
+
|
15
|
+
static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
|
16
|
+
i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only,
|
17
|
+
i_quirks_mode, i_pack, i_unpack, i_create_id, i_extend, i_key_p,
|
18
|
+
i_aref, i_send, i_respond_to_p, i_match, i_keys, i_depth,
|
19
|
+
i_buffer_initial_length, i_dup;
|
20
|
+
|
21
|
+
/*
|
22
|
+
* Copyright 2001-2004 Unicode, Inc.
|
23
|
+
*
|
24
|
+
* Disclaimer
|
25
|
+
*
|
26
|
+
* This source code is provided as is by Unicode, Inc. No claims are
|
27
|
+
* made as to fitness for any particular purpose. No warranties of any
|
28
|
+
* kind are expressed or implied. The recipient agrees to determine
|
29
|
+
* applicability of information provided. If this file has been
|
30
|
+
* purchased on magnetic or optical media from Unicode, Inc., the
|
31
|
+
* sole remedy for any claim will be exchange of defective media
|
32
|
+
* within 90 days of receipt.
|
33
|
+
*
|
34
|
+
* Limitations on Rights to Redistribute This Code
|
35
|
+
*
|
36
|
+
* Unicode, Inc. hereby grants the right to freely use the information
|
37
|
+
* supplied in this file in the creation of products supporting the
|
38
|
+
* Unicode Standard, and to make copies of this file in any form
|
39
|
+
* for internal or external distribution as long as this notice
|
40
|
+
* remains attached.
|
41
|
+
*/
|
42
|
+
|
43
|
+
/*
|
44
|
+
* Index into the table below with the first byte of a UTF-8 sequence to
|
45
|
+
* get the number of trailing bytes that are supposed to follow it.
|
46
|
+
* Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
|
47
|
+
* left as-is for anyone who may want to do such conversion, which was
|
48
|
+
* allowed in earlier algorithms.
|
49
|
+
*/
|
50
|
+
static const char trailingBytesForUTF8[256] = {
|
51
|
+
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,
|
52
|
+
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,
|
53
|
+
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,
|
54
|
+
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,
|
55
|
+
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,
|
56
|
+
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,
|
57
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
58
|
+
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
|
59
|
+
};
|
60
|
+
|
61
|
+
/*
|
62
|
+
* Magic values subtracted from a buffer value during UTF8 conversion.
|
63
|
+
* This table contains as many values as there might be trailing bytes
|
64
|
+
* in a UTF-8 sequence.
|
65
|
+
*/
|
66
|
+
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
|
67
|
+
0x03C82080UL, 0xFA082080UL, 0x82082080UL };
|
68
|
+
|
69
|
+
/*
|
70
|
+
* Utility routine to tell whether a sequence of bytes is legal UTF-8.
|
71
|
+
* This must be called with the length pre-determined by the first byte.
|
72
|
+
* If not calling this from ConvertUTF8to*, then the length can be set by:
|
73
|
+
* length = trailingBytesForUTF8[*source]+1;
|
74
|
+
* and the sequence is illegal right away if there aren't that many bytes
|
75
|
+
* available.
|
76
|
+
* If presented with a length > 4, this returns 0. The Unicode
|
77
|
+
* definition of UTF-8 goes up to 4-byte sequences.
|
78
|
+
*/
|
79
|
+
static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length)
|
80
|
+
{
|
81
|
+
UTF8 a;
|
82
|
+
const UTF8 *srcptr = source+length;
|
83
|
+
switch (length) {
|
84
|
+
default: return 0;
|
85
|
+
/* Everything else falls through when "1"... */
|
86
|
+
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
|
87
|
+
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
|
88
|
+
case 2: if ((a = (*--srcptr)) > 0xBF) return 0;
|
89
|
+
|
90
|
+
switch (*source) {
|
91
|
+
/* no fall-through in this inner switch */
|
92
|
+
case 0xE0: if (a < 0xA0) return 0; break;
|
93
|
+
case 0xED: if (a > 0x9F) return 0; break;
|
94
|
+
case 0xF0: if (a < 0x90) return 0; break;
|
95
|
+
case 0xF4: if (a > 0x8F) return 0; break;
|
96
|
+
default: if (a < 0x80) return 0;
|
97
|
+
}
|
98
|
+
|
99
|
+
case 1: if (*source >= 0x80 && *source < 0xC2) return 0;
|
100
|
+
}
|
101
|
+
if (*source > 0xF4) return 0;
|
102
|
+
return 1;
|
103
|
+
}
|
104
|
+
|
105
|
+
/* Escapes the UTF16 character and stores the result in the buffer buf. */
|
106
|
+
static void unicode_escape(char *buf, UTF16 character)
|
107
|
+
{
|
108
|
+
const char *digits = "0123456789abcdef";
|
109
|
+
|
110
|
+
buf[2] = digits[character >> 12];
|
111
|
+
buf[3] = digits[(character >> 8) & 0xf];
|
112
|
+
buf[4] = digits[(character >> 4) & 0xf];
|
113
|
+
buf[5] = digits[character & 0xf];
|
114
|
+
}
|
115
|
+
|
116
|
+
/* Escapes the UTF16 character and stores the result in the buffer buf, then
|
117
|
+
* the buffer buf is appended to the FBuffer buffer. */
|
118
|
+
static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16
|
119
|
+
character)
|
120
|
+
{
|
121
|
+
unicode_escape(buf, character);
|
122
|
+
fbuffer_append(buffer, buf, 6);
|
123
|
+
}
|
124
|
+
|
125
|
+
/* Converts string to a JSON string in FBuffer buffer, where all but the ASCII
|
126
|
+
* and control characters are JSON escaped. */
|
127
|
+
static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string)
|
128
|
+
{
|
129
|
+
const UTF8 *source = (UTF8 *) RSTRING_PTR(string);
|
130
|
+
const UTF8 *sourceEnd = source + RSTRING_LEN(string);
|
131
|
+
char buf[6] = { '\\', 'u' };
|
132
|
+
|
133
|
+
while (source < sourceEnd) {
|
134
|
+
UTF32 ch = 0;
|
135
|
+
unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
|
136
|
+
if (source + extraBytesToRead >= sourceEnd) {
|
137
|
+
rb_raise(rb_path2class("JSON::GeneratorError"),
|
138
|
+
"partial character in source, but hit end");
|
139
|
+
}
|
140
|
+
if (!isLegalUTF8(source, extraBytesToRead+1)) {
|
141
|
+
rb_raise(rb_path2class("JSON::GeneratorError"),
|
142
|
+
"source sequence is illegal/malformed utf-8");
|
143
|
+
}
|
144
|
+
/*
|
145
|
+
* The cases all fall through. See "Note A" below.
|
146
|
+
*/
|
147
|
+
switch (extraBytesToRead) {
|
148
|
+
case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
|
149
|
+
case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
|
150
|
+
case 3: ch += *source++; ch <<= 6;
|
151
|
+
case 2: ch += *source++; ch <<= 6;
|
152
|
+
case 1: ch += *source++; ch <<= 6;
|
153
|
+
case 0: ch += *source++;
|
154
|
+
}
|
155
|
+
ch -= offsetsFromUTF8[extraBytesToRead];
|
156
|
+
|
157
|
+
if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
|
158
|
+
/* UTF-16 surrogate values are illegal in UTF-32 */
|
159
|
+
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
|
160
|
+
#if UNI_STRICT_CONVERSION
|
161
|
+
source -= (extraBytesToRead+1); /* return to the illegal value itself */
|
162
|
+
rb_raise(rb_path2class("JSON::GeneratorError"),
|
163
|
+
"source sequence is illegal/malformed utf-8");
|
164
|
+
#else
|
165
|
+
unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR);
|
166
|
+
#endif
|
167
|
+
} else {
|
168
|
+
/* normal case */
|
169
|
+
if (ch >= 0x20 && ch <= 0x7f) {
|
170
|
+
switch (ch) {
|
171
|
+
case '\\':
|
172
|
+
fbuffer_append(buffer, "\\\\", 2);
|
173
|
+
break;
|
174
|
+
case '"':
|
175
|
+
fbuffer_append(buffer, "\\\"", 2);
|
176
|
+
break;
|
177
|
+
default:
|
178
|
+
fbuffer_append_char(buffer, (char)ch);
|
179
|
+
break;
|
180
|
+
}
|
181
|
+
} else {
|
182
|
+
switch (ch) {
|
183
|
+
case '\n':
|
184
|
+
fbuffer_append(buffer, "\\n", 2);
|
185
|
+
break;
|
186
|
+
case '\r':
|
187
|
+
fbuffer_append(buffer, "\\r", 2);
|
188
|
+
break;
|
189
|
+
case '\t':
|
190
|
+
fbuffer_append(buffer, "\\t", 2);
|
191
|
+
break;
|
192
|
+
case '\f':
|
193
|
+
fbuffer_append(buffer, "\\f", 2);
|
194
|
+
break;
|
195
|
+
case '\b':
|
196
|
+
fbuffer_append(buffer, "\\b", 2);
|
197
|
+
break;
|
198
|
+
default:
|
199
|
+
unicode_escape_to_buffer(buffer, buf, (UTF16) ch);
|
200
|
+
break;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}
|
204
|
+
} else if (ch > UNI_MAX_UTF16) {
|
205
|
+
#if UNI_STRICT_CONVERSION
|
206
|
+
source -= (extraBytesToRead+1); /* return to the start */
|
207
|
+
rb_raise(rb_path2class("JSON::GeneratorError"),
|
208
|
+
"source sequence is illegal/malformed utf8");
|
209
|
+
#else
|
210
|
+
unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR);
|
211
|
+
#endif
|
212
|
+
} else {
|
213
|
+
/* target is a character in range 0xFFFF - 0x10FFFF. */
|
214
|
+
ch -= halfBase;
|
215
|
+
unicode_escape_to_buffer(buffer, buf, (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START));
|
216
|
+
unicode_escape_to_buffer(buffer, buf, (UTF16)((ch & halfMask) + UNI_SUR_LOW_START));
|
217
|
+
}
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
/* Converts string to a JSON string in FBuffer buffer, where only the
|
222
|
+
* characters required by the JSON standard are JSON escaped. The remaining
|
223
|
+
* characters (should be UTF8) are just passed through and appended to the
|
224
|
+
* result. */
|
225
|
+
static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
|
226
|
+
{
|
227
|
+
const char *ptr = RSTRING_PTR(string), *p;
|
228
|
+
unsigned long len = RSTRING_LEN(string), start = 0, end = 0;
|
229
|
+
const char *escape = NULL;
|
230
|
+
int escape_len;
|
231
|
+
unsigned char c;
|
232
|
+
char buf[6] = { '\\', 'u' };
|
233
|
+
|
234
|
+
for (start = 0, end = 0; end < len;) {
|
235
|
+
p = ptr + end;
|
236
|
+
c = (unsigned char) *p;
|
237
|
+
if (c < 0x20) {
|
238
|
+
switch (c) {
|
239
|
+
case '\n':
|
240
|
+
escape = "\\n";
|
241
|
+
escape_len = 2;
|
242
|
+
break;
|
243
|
+
case '\r':
|
244
|
+
escape = "\\r";
|
245
|
+
escape_len = 2;
|
246
|
+
break;
|
247
|
+
case '\t':
|
248
|
+
escape = "\\t";
|
249
|
+
escape_len = 2;
|
250
|
+
break;
|
251
|
+
case '\f':
|
252
|
+
escape = "\\f";
|
253
|
+
escape_len = 2;
|
254
|
+
break;
|
255
|
+
case '\b':
|
256
|
+
escape = "\\b";
|
257
|
+
escape_len = 2;
|
258
|
+
break;
|
259
|
+
default:
|
260
|
+
unicode_escape(buf, (UTF16) *p);
|
261
|
+
escape = buf;
|
262
|
+
escape_len = 6;
|
263
|
+
break;
|
264
|
+
}
|
265
|
+
} else {
|
266
|
+
switch (c) {
|
267
|
+
case '\\':
|
268
|
+
escape = "\\\\";
|
269
|
+
escape_len = 2;
|
270
|
+
break;
|
271
|
+
case '"':
|
272
|
+
escape = "\\\"";
|
273
|
+
escape_len = 2;
|
274
|
+
break;
|
275
|
+
default:
|
276
|
+
end++;
|
277
|
+
continue;
|
278
|
+
break;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
fbuffer_append(buffer, ptr + start, end - start);
|
282
|
+
fbuffer_append(buffer, escape, escape_len);
|
283
|
+
start = ++end;
|
284
|
+
escape = NULL;
|
285
|
+
}
|
286
|
+
fbuffer_append(buffer, ptr + start, end - start);
|
287
|
+
}
|
288
|
+
|
289
|
+
static char *fstrndup(const char *ptr, unsigned long len) {
|
290
|
+
char *result;
|
291
|
+
if (len <= 0) return NULL;
|
292
|
+
result = ALLOC_N(char, len);
|
293
|
+
memccpy(result, ptr, 0, len);
|
294
|
+
return result;
|
295
|
+
}
|
296
|
+
|
297
|
+
/*
|
298
|
+
* Document-module: JSON::Ext::Generator
|
299
|
+
*
|
300
|
+
* This is the JSON generator implemented as a C extension. It can be
|
301
|
+
* configured to be used by setting
|
302
|
+
*
|
303
|
+
* JSON.generator = JSON::Ext::Generator
|
304
|
+
*
|
305
|
+
* with the method generator= in JSON.
|
306
|
+
*
|
307
|
+
*/
|
308
|
+
|
309
|
+
/*
|
310
|
+
* call-seq: to_json(state = nil)
|
311
|
+
*
|
312
|
+
* Returns a JSON string containing a JSON object, that is generated from
|
313
|
+
* this Hash instance.
|
314
|
+
* _state_ is a JSON::State object, that can also be used to configure the
|
315
|
+
* produced JSON string output further.
|
316
|
+
*/
|
317
|
+
static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
|
318
|
+
{
|
319
|
+
GENERATE_JSON(object);
|
320
|
+
}
|
321
|
+
|
322
|
+
/*
|
323
|
+
* call-seq: to_json(state = nil)
|
324
|
+
*
|
325
|
+
* Returns a JSON string containing a JSON array, that is generated from
|
326
|
+
* this Array instance.
|
327
|
+
* _state_ is a JSON::State object, that can also be used to configure the
|
328
|
+
* produced JSON string output further.
|
329
|
+
*/
|
330
|
+
static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
|
331
|
+
GENERATE_JSON(array);
|
332
|
+
}
|
333
|
+
|
334
|
+
/*
|
335
|
+
* call-seq: to_json(*)
|
336
|
+
*
|
337
|
+
* Returns a JSON string representation for this Integer number.
|
338
|
+
*/
|
339
|
+
static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self)
|
340
|
+
{
|
341
|
+
GENERATE_JSON(fixnum);
|
342
|
+
}
|
343
|
+
|
344
|
+
/*
|
345
|
+
* call-seq: to_json(*)
|
346
|
+
*
|
347
|
+
* Returns a JSON string representation for this Integer number.
|
348
|
+
*/
|
349
|
+
static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self)
|
350
|
+
{
|
351
|
+
GENERATE_JSON(bignum);
|
352
|
+
}
|
353
|
+
|
354
|
+
/*
|
355
|
+
* call-seq: to_json(*)
|
356
|
+
*
|
357
|
+
* Returns a JSON string representation for this Float number.
|
358
|
+
*/
|
359
|
+
static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
|
360
|
+
{
|
361
|
+
GENERATE_JSON(float);
|
362
|
+
}
|
363
|
+
|
364
|
+
/*
|
365
|
+
* call-seq: String.included(modul)
|
366
|
+
*
|
367
|
+
* Extends _modul_ with the String::Extend module.
|
368
|
+
*/
|
369
|
+
static VALUE mString_included_s(VALUE self, VALUE modul) {
|
370
|
+
VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
|
371
|
+
return result;
|
372
|
+
}
|
373
|
+
|
374
|
+
/*
|
375
|
+
* call-seq: to_json(*)
|
376
|
+
*
|
377
|
+
* This string should be encoded with UTF-8 A call to this method
|
378
|
+
* returns a JSON string encoded with UTF16 big endian characters as
|
379
|
+
* \u????.
|
380
|
+
*/
|
381
|
+
static VALUE mString_to_json(int argc, VALUE *argv, VALUE self)
|
382
|
+
{
|
383
|
+
GENERATE_JSON(string);
|
384
|
+
}
|
385
|
+
|
386
|
+
/*
|
387
|
+
* call-seq: to_json_raw_object()
|
388
|
+
*
|
389
|
+
* This method creates a raw object hash, that can be nested into
|
390
|
+
* other data structures and will be generated as a raw string. This
|
391
|
+
* method should be used, if you want to convert raw strings to JSON
|
392
|
+
* instead of UTF-8 strings, e. g. binary data.
|
393
|
+
*/
|
394
|
+
static VALUE mString_to_json_raw_object(VALUE self)
|
395
|
+
{
|
396
|
+
VALUE ary;
|
397
|
+
VALUE result = rb_hash_new();
|
398
|
+
rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self)));
|
399
|
+
ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*"));
|
400
|
+
rb_hash_aset(result, rb_str_new2("raw"), ary);
|
401
|
+
return result;
|
402
|
+
}
|
403
|
+
|
404
|
+
/*
|
405
|
+
* call-seq: to_json_raw(*args)
|
406
|
+
*
|
407
|
+
* This method creates a JSON text from the result of a call to
|
408
|
+
* to_json_raw_object of this String.
|
409
|
+
*/
|
410
|
+
static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self)
|
411
|
+
{
|
412
|
+
VALUE obj = mString_to_json_raw_object(self);
|
413
|
+
Check_Type(obj, T_HASH);
|
414
|
+
return mHash_to_json(argc, argv, obj);
|
415
|
+
}
|
416
|
+
|
417
|
+
/*
|
418
|
+
* call-seq: json_create(o)
|
419
|
+
*
|
420
|
+
* Raw Strings are JSON Objects (the raw bytes are stored in an array for the
|
421
|
+
* key "raw"). The Ruby String can be created by this module method.
|
422
|
+
*/
|
423
|
+
static VALUE mString_Extend_json_create(VALUE self, VALUE o)
|
424
|
+
{
|
425
|
+
VALUE ary;
|
426
|
+
Check_Type(o, T_HASH);
|
427
|
+
ary = rb_hash_aref(o, rb_str_new2("raw"));
|
428
|
+
return rb_funcall(ary, i_pack, 1, rb_str_new2("C*"));
|
429
|
+
}
|
430
|
+
|
431
|
+
/*
|
432
|
+
* call-seq: to_json(*)
|
433
|
+
*
|
434
|
+
* Returns a JSON string for true: 'true'.
|
435
|
+
*/
|
436
|
+
static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self)
|
437
|
+
{
|
438
|
+
GENERATE_JSON(true);
|
439
|
+
}
|
440
|
+
|
441
|
+
/*
|
442
|
+
* call-seq: to_json(*)
|
443
|
+
*
|
444
|
+
* Returns a JSON string for false: 'false'.
|
445
|
+
*/
|
446
|
+
static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self)
|
447
|
+
{
|
448
|
+
GENERATE_JSON(false);
|
449
|
+
}
|
450
|
+
|
451
|
+
/*
|
452
|
+
* call-seq: to_json(*)
|
453
|
+
*
|
454
|
+
* Returns a JSON string for nil: 'null'.
|
455
|
+
*/
|
456
|
+
static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self)
|
457
|
+
{
|
458
|
+
GENERATE_JSON(null);
|
459
|
+
}
|
460
|
+
|
461
|
+
/*
|
462
|
+
* call-seq: to_json(*)
|
463
|
+
*
|
464
|
+
* Converts this object to a string (calling #to_s), converts
|
465
|
+
* it to a JSON string, and returns the result. This is a fallback, if no
|
466
|
+
* special method #to_json was defined for some object.
|
467
|
+
*/
|
468
|
+
static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self)
|
469
|
+
{
|
470
|
+
VALUE state;
|
471
|
+
VALUE string = rb_funcall(self, i_to_s, 0);
|
472
|
+
rb_scan_args(argc, argv, "01", &state);
|
473
|
+
Check_Type(string, T_STRING);
|
474
|
+
state = cState_from_state_s(cState, state);
|
475
|
+
return cState_partial_generate(state, string);
|
476
|
+
}
|
477
|
+
|
478
|
+
static void State_free(JSON_Generator_State *state)
|
479
|
+
{
|
480
|
+
if (state->indent) ruby_xfree(state->indent);
|
481
|
+
if (state->space) ruby_xfree(state->space);
|
482
|
+
if (state->space_before) ruby_xfree(state->space_before);
|
483
|
+
if (state->object_nl) ruby_xfree(state->object_nl);
|
484
|
+
if (state->array_nl) ruby_xfree(state->array_nl);
|
485
|
+
if (state->array_delim) fbuffer_free(state->array_delim);
|
486
|
+
if (state->object_delim) fbuffer_free(state->object_delim);
|
487
|
+
if (state->object_delim2) fbuffer_free(state->object_delim2);
|
488
|
+
ruby_xfree(state);
|
489
|
+
}
|
490
|
+
|
491
|
+
static JSON_Generator_State *State_allocate()
|
492
|
+
{
|
493
|
+
JSON_Generator_State *state = ALLOC(JSON_Generator_State);
|
494
|
+
MEMZERO(state, JSON_Generator_State, 1);
|
495
|
+
return state;
|
496
|
+
}
|
497
|
+
|
498
|
+
static VALUE cState_s_allocate(VALUE klass)
|
499
|
+
{
|
500
|
+
JSON_Generator_State *state = State_allocate();
|
501
|
+
return Data_Wrap_Struct(klass, NULL, State_free, state);
|
502
|
+
}
|
503
|
+
|
504
|
+
/*
|
505
|
+
* call-seq: configure(opts)
|
506
|
+
*
|
507
|
+
* Configure this State instance with the Hash _opts_, and return
|
508
|
+
* itself.
|
509
|
+
*/
|
510
|
+
static VALUE cState_configure(VALUE self, VALUE opts)
|
511
|
+
{
|
512
|
+
VALUE tmp;
|
513
|
+
GET_STATE(self);
|
514
|
+
tmp = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
|
515
|
+
if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
|
516
|
+
if (NIL_P(tmp)) {
|
517
|
+
rb_raise(rb_eArgError, "opts has to be hash like or convertable into a hash");
|
518
|
+
}
|
519
|
+
opts = tmp;
|
520
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_indent));
|
521
|
+
if (RTEST(tmp)) {
|
522
|
+
unsigned long len;
|
523
|
+
Check_Type(tmp, T_STRING);
|
524
|
+
len = RSTRING_LEN(tmp);
|
525
|
+
state->indent = fstrndup(RSTRING_PTR(tmp), len);
|
526
|
+
state->indent_len = len;
|
527
|
+
}
|
528
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_space));
|
529
|
+
if (RTEST(tmp)) {
|
530
|
+
unsigned long len;
|
531
|
+
Check_Type(tmp, T_STRING);
|
532
|
+
len = RSTRING_LEN(tmp);
|
533
|
+
state->space = fstrndup(RSTRING_PTR(tmp), len);
|
534
|
+
state->space_len = len;
|
535
|
+
}
|
536
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
|
537
|
+
if (RTEST(tmp)) {
|
538
|
+
unsigned long len;
|
539
|
+
Check_Type(tmp, T_STRING);
|
540
|
+
len = RSTRING_LEN(tmp);
|
541
|
+
state->space_before = fstrndup(RSTRING_PTR(tmp), len);
|
542
|
+
state->space_before_len = len;
|
543
|
+
}
|
544
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
|
545
|
+
if (RTEST(tmp)) {
|
546
|
+
unsigned long len;
|
547
|
+
Check_Type(tmp, T_STRING);
|
548
|
+
len = RSTRING_LEN(tmp);
|
549
|
+
state->array_nl = fstrndup(RSTRING_PTR(tmp), len);
|
550
|
+
state->array_nl_len = len;
|
551
|
+
}
|
552
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
|
553
|
+
if (RTEST(tmp)) {
|
554
|
+
unsigned long len;
|
555
|
+
Check_Type(tmp, T_STRING);
|
556
|
+
len = RSTRING_LEN(tmp);
|
557
|
+
state->object_nl = fstrndup(RSTRING_PTR(tmp), len);
|
558
|
+
state->object_nl_len = len;
|
559
|
+
}
|
560
|
+
tmp = ID2SYM(i_max_nesting);
|
561
|
+
state->max_nesting = 19;
|
562
|
+
if (option_given_p(opts, tmp)) {
|
563
|
+
VALUE max_nesting = rb_hash_aref(opts, tmp);
|
564
|
+
if (RTEST(max_nesting)) {
|
565
|
+
Check_Type(max_nesting, T_FIXNUM);
|
566
|
+
state->max_nesting = FIX2LONG(max_nesting);
|
567
|
+
} else {
|
568
|
+
state->max_nesting = 0;
|
569
|
+
}
|
570
|
+
}
|
571
|
+
tmp = ID2SYM(i_depth);
|
572
|
+
state->depth = 0;
|
573
|
+
if (option_given_p(opts, tmp)) {
|
574
|
+
VALUE depth = rb_hash_aref(opts, tmp);
|
575
|
+
if (RTEST(depth)) {
|
576
|
+
Check_Type(depth, T_FIXNUM);
|
577
|
+
state->depth = FIX2LONG(depth);
|
578
|
+
} else {
|
579
|
+
state->depth = 0;
|
580
|
+
}
|
581
|
+
}
|
582
|
+
tmp = ID2SYM(i_buffer_initial_length);
|
583
|
+
if (option_given_p(opts, tmp)) {
|
584
|
+
VALUE buffer_initial_length = rb_hash_aref(opts, tmp);
|
585
|
+
if (RTEST(buffer_initial_length)) {
|
586
|
+
long initial_length;
|
587
|
+
Check_Type(buffer_initial_length, T_FIXNUM);
|
588
|
+
initial_length = FIX2LONG(buffer_initial_length);
|
589
|
+
if (initial_length > 0) state->buffer_initial_length = initial_length;
|
590
|
+
}
|
591
|
+
}
|
592
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan));
|
593
|
+
state->allow_nan = RTEST(tmp);
|
594
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only));
|
595
|
+
state->ascii_only = RTEST(tmp);
|
596
|
+
tmp = rb_hash_aref(opts, ID2SYM(i_quirks_mode));
|
597
|
+
state->quirks_mode = RTEST(tmp);
|
598
|
+
return self;
|
599
|
+
}
|
600
|
+
|
601
|
+
/*
|
602
|
+
* call-seq: to_h
|
603
|
+
*
|
604
|
+
* Returns the configuration instance variables as a hash, that can be
|
605
|
+
* passed to the configure method.
|
606
|
+
*/
|
607
|
+
static VALUE cState_to_h(VALUE self)
|
608
|
+
{
|
609
|
+
VALUE result = rb_hash_new();
|
610
|
+
GET_STATE(self);
|
611
|
+
rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state->indent, state->indent_len));
|
612
|
+
rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state->space, state->space_len));
|
613
|
+
rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state->space_before, state->space_before_len));
|
614
|
+
rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state->object_nl, state->object_nl_len));
|
615
|
+
rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len));
|
616
|
+
rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
|
617
|
+
rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse);
|
618
|
+
rb_hash_aset(result, ID2SYM(i_quirks_mode), state->quirks_mode ? Qtrue : Qfalse);
|
619
|
+
rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
|
620
|
+
rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth));
|
621
|
+
rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length));
|
622
|
+
return result;
|
623
|
+
}
|
624
|
+
|
625
|
+
/*
|
626
|
+
* call-seq: [](name)
|
627
|
+
*
|
628
|
+
* Return the value returned by method +name+.
|
629
|
+
*/
|
630
|
+
static VALUE cState_aref(VALUE self, VALUE name)
|
631
|
+
{
|
632
|
+
GET_STATE(self);
|
633
|
+
if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
|
634
|
+
return rb_funcall(self, i_send, 1, name);
|
635
|
+
} else {
|
636
|
+
return Qnil;
|
637
|
+
}
|
638
|
+
}
|
639
|
+
|
640
|
+
static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
641
|
+
{
|
642
|
+
char *object_nl = state->object_nl;
|
643
|
+
long object_nl_len = state->object_nl_len;
|
644
|
+
char *indent = state->indent;
|
645
|
+
long indent_len = state->indent_len;
|
646
|
+
long max_nesting = state->max_nesting;
|
647
|
+
char *delim = FBUFFER_PTR(state->object_delim);
|
648
|
+
long delim_len = FBUFFER_LEN(state->object_delim);
|
649
|
+
char *delim2 = FBUFFER_PTR(state->object_delim2);
|
650
|
+
long delim2_len = FBUFFER_LEN(state->object_delim2);
|
651
|
+
long depth = ++state->depth;
|
652
|
+
int i, j;
|
653
|
+
VALUE key, key_to_s, keys;
|
654
|
+
if (max_nesting != 0 && depth > max_nesting) {
|
655
|
+
fbuffer_free(buffer);
|
656
|
+
rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
|
657
|
+
}
|
658
|
+
fbuffer_append_char(buffer, '{');
|
659
|
+
keys = rb_funcall(obj, i_keys, 0);
|
660
|
+
for(i = 0; i < RARRAY_LEN(keys); i++) {
|
661
|
+
if (i > 0) fbuffer_append(buffer, delim, delim_len);
|
662
|
+
if (object_nl) {
|
663
|
+
fbuffer_append(buffer, object_nl, object_nl_len);
|
664
|
+
}
|
665
|
+
if (indent) {
|
666
|
+
for (j = 0; j < depth; j++) {
|
667
|
+
fbuffer_append(buffer, indent, indent_len);
|
668
|
+
}
|
669
|
+
}
|
670
|
+
key = rb_ary_entry(keys, i);
|
671
|
+
key_to_s = rb_funcall(key, i_to_s, 0);
|
672
|
+
Check_Type(key_to_s, T_STRING);
|
673
|
+
generate_json(buffer, Vstate, state, key_to_s);
|
674
|
+
fbuffer_append(buffer, delim2, delim2_len);
|
675
|
+
generate_json(buffer, Vstate, state, rb_hash_aref(obj, key));
|
676
|
+
}
|
677
|
+
depth = --state->depth;
|
678
|
+
if (object_nl) {
|
679
|
+
fbuffer_append(buffer, object_nl, object_nl_len);
|
680
|
+
if (indent) {
|
681
|
+
for (j = 0; j < depth; j++) {
|
682
|
+
fbuffer_append(buffer, indent, indent_len);
|
683
|
+
}
|
684
|
+
}
|
685
|
+
}
|
686
|
+
fbuffer_append_char(buffer, '}');
|
687
|
+
}
|
688
|
+
|
689
|
+
static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
690
|
+
{
|
691
|
+
char *array_nl = state->array_nl;
|
692
|
+
long array_nl_len = state->array_nl_len;
|
693
|
+
char *indent = state->indent;
|
694
|
+
long indent_len = state->indent_len;
|
695
|
+
long max_nesting = state->max_nesting;
|
696
|
+
char *delim = FBUFFER_PTR(state->array_delim);
|
697
|
+
long delim_len = FBUFFER_LEN(state->array_delim);
|
698
|
+
long depth = ++state->depth;
|
699
|
+
int i, j;
|
700
|
+
if (max_nesting != 0 && depth > max_nesting) {
|
701
|
+
fbuffer_free(buffer);
|
702
|
+
rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
|
703
|
+
}
|
704
|
+
fbuffer_append_char(buffer, '[');
|
705
|
+
if (array_nl) fbuffer_append(buffer, array_nl, array_nl_len);
|
706
|
+
for(i = 0; i < RARRAY_LEN(obj); i++) {
|
707
|
+
if (i > 0) fbuffer_append(buffer, delim, delim_len);
|
708
|
+
if (indent) {
|
709
|
+
for (j = 0; j < depth; j++) {
|
710
|
+
fbuffer_append(buffer, indent, indent_len);
|
711
|
+
}
|
712
|
+
}
|
713
|
+
generate_json(buffer, Vstate, state, rb_ary_entry(obj, i));
|
714
|
+
}
|
715
|
+
state->depth = --depth;
|
716
|
+
if (array_nl) {
|
717
|
+
fbuffer_append(buffer, array_nl, array_nl_len);
|
718
|
+
if (indent) {
|
719
|
+
for (j = 0; j < depth; j++) {
|
720
|
+
fbuffer_append(buffer, indent, indent_len);
|
721
|
+
}
|
722
|
+
}
|
723
|
+
}
|
724
|
+
fbuffer_append_char(buffer, ']');
|
725
|
+
}
|
726
|
+
|
727
|
+
static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
728
|
+
{
|
729
|
+
fbuffer_append_char(buffer, '"');
|
730
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
731
|
+
obj = rb_funcall(obj, i_encode, 1, CEncoding_UTF_8);
|
732
|
+
#endif
|
733
|
+
if (state->ascii_only) {
|
734
|
+
convert_UTF8_to_JSON_ASCII(buffer, obj);
|
735
|
+
} else {
|
736
|
+
convert_UTF8_to_JSON(buffer, obj);
|
737
|
+
}
|
738
|
+
fbuffer_append_char(buffer, '"');
|
739
|
+
}
|
740
|
+
|
741
|
+
static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
742
|
+
{
|
743
|
+
fbuffer_append(buffer, "null", 4);
|
744
|
+
}
|
745
|
+
|
746
|
+
static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
747
|
+
{
|
748
|
+
fbuffer_append(buffer, "false", 5);
|
749
|
+
}
|
750
|
+
|
751
|
+
static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
752
|
+
{
|
753
|
+
fbuffer_append(buffer, "true", 4);
|
754
|
+
}
|
755
|
+
|
756
|
+
static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
757
|
+
{
|
758
|
+
fbuffer_append_long(buffer, FIX2LONG(obj));
|
759
|
+
}
|
760
|
+
|
761
|
+
static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
762
|
+
{
|
763
|
+
VALUE tmp = rb_funcall(obj, i_to_s, 0);
|
764
|
+
fbuffer_append_str(buffer, tmp);
|
765
|
+
}
|
766
|
+
|
767
|
+
static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
768
|
+
{
|
769
|
+
double value = RFLOAT_VALUE(obj);
|
770
|
+
char allow_nan = state->allow_nan;
|
771
|
+
VALUE tmp = rb_funcall(obj, i_to_s, 0);
|
772
|
+
if (!allow_nan) {
|
773
|
+
if (isinf(value)) {
|
774
|
+
fbuffer_free(buffer);
|
775
|
+
rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
|
776
|
+
} else if (isnan(value)) {
|
777
|
+
fbuffer_free(buffer);
|
778
|
+
rb_raise(eGeneratorError, "%u: %s not allowed in JSON", __LINE__, StringValueCStr(tmp));
|
779
|
+
}
|
780
|
+
}
|
781
|
+
fbuffer_append_str(buffer, tmp);
|
782
|
+
}
|
783
|
+
|
784
|
+
static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
785
|
+
{
|
786
|
+
VALUE tmp;
|
787
|
+
VALUE klass = CLASS_OF(obj);
|
788
|
+
if (klass == rb_cHash) {
|
789
|
+
generate_json_object(buffer, Vstate, state, obj);
|
790
|
+
} else if (klass == rb_cArray) {
|
791
|
+
generate_json_array(buffer, Vstate, state, obj);
|
792
|
+
} else if (klass == rb_cString) {
|
793
|
+
generate_json_string(buffer, Vstate, state, obj);
|
794
|
+
} else if (obj == Qnil) {
|
795
|
+
generate_json_null(buffer, Vstate, state, obj);
|
796
|
+
} else if (obj == Qfalse) {
|
797
|
+
generate_json_false(buffer, Vstate, state, obj);
|
798
|
+
} else if (obj == Qtrue) {
|
799
|
+
generate_json_true(buffer, Vstate, state, obj);
|
800
|
+
} else if (klass == rb_cFixnum) {
|
801
|
+
generate_json_fixnum(buffer, Vstate, state, obj);
|
802
|
+
} else if (klass == rb_cBignum) {
|
803
|
+
generate_json_bignum(buffer, Vstate, state, obj);
|
804
|
+
} else if (klass == rb_cFloat) {
|
805
|
+
generate_json_float(buffer, Vstate, state, obj);
|
806
|
+
} else if (rb_respond_to(obj, i_to_json)) {
|
807
|
+
tmp = rb_funcall(obj, i_to_json, 1, Vstate);
|
808
|
+
Check_Type(tmp, T_STRING);
|
809
|
+
fbuffer_append_str(buffer, tmp);
|
810
|
+
} else {
|
811
|
+
tmp = rb_funcall(obj, i_to_s, 0);
|
812
|
+
Check_Type(tmp, T_STRING);
|
813
|
+
generate_json(buffer, Vstate, state, tmp);
|
814
|
+
}
|
815
|
+
}
|
816
|
+
|
817
|
+
static FBuffer *cState_prepare_buffer(VALUE self)
|
818
|
+
{
|
819
|
+
FBuffer *buffer;
|
820
|
+
GET_STATE(self);
|
821
|
+
buffer = fbuffer_alloc(state->buffer_initial_length);
|
822
|
+
|
823
|
+
if (state->object_delim) {
|
824
|
+
fbuffer_clear(state->object_delim);
|
825
|
+
} else {
|
826
|
+
state->object_delim = fbuffer_alloc(16);
|
827
|
+
}
|
828
|
+
fbuffer_append_char(state->object_delim, ',');
|
829
|
+
if (state->object_delim2) {
|
830
|
+
fbuffer_clear(state->object_delim2);
|
831
|
+
} else {
|
832
|
+
state->object_delim2 = fbuffer_alloc(16);
|
833
|
+
}
|
834
|
+
fbuffer_append_char(state->object_delim2, ':');
|
835
|
+
if (state->space) fbuffer_append(state->object_delim2, state->space, state->space_len);
|
836
|
+
|
837
|
+
if (state->array_delim) {
|
838
|
+
fbuffer_clear(state->array_delim);
|
839
|
+
} else {
|
840
|
+
state->array_delim = fbuffer_alloc(16);
|
841
|
+
}
|
842
|
+
fbuffer_append_char(state->array_delim, ',');
|
843
|
+
if (state->array_nl) fbuffer_append(state->array_delim, state->array_nl, state->array_nl_len);
|
844
|
+
return buffer;
|
845
|
+
}
|
846
|
+
|
847
|
+
static VALUE cState_partial_generate(VALUE self, VALUE obj)
|
848
|
+
{
|
849
|
+
FBuffer *buffer = cState_prepare_buffer(self);
|
850
|
+
GET_STATE(self);
|
851
|
+
generate_json(buffer, self, state, obj);
|
852
|
+
return fbuffer_to_s(buffer);
|
853
|
+
}
|
854
|
+
|
855
|
+
/*
|
856
|
+
* call-seq: generate(obj)
|
857
|
+
*
|
858
|
+
* Generates a valid JSON document from object +obj+ and returns the
|
859
|
+
* result. If no valid JSON document can be created this method raises a
|
860
|
+
* GeneratorError exception.
|
861
|
+
*/
|
862
|
+
static VALUE cState_generate(VALUE self, VALUE obj)
|
863
|
+
{
|
864
|
+
VALUE result = cState_partial_generate(self, obj);
|
865
|
+
VALUE re, args[2];
|
866
|
+
GET_STATE(self);
|
867
|
+
if (!state->quirks_mode) {
|
868
|
+
args[0] = rb_str_new2("\\A\\s*(?:\\[.*\\]|\\{.*\\})\\s*\\Z");
|
869
|
+
args[1] = CRegexp_MULTILINE;
|
870
|
+
re = rb_class_new_instance(2, args, rb_cRegexp);
|
871
|
+
if (NIL_P(rb_funcall(re, i_match, 1, result))) {
|
872
|
+
rb_raise(eGeneratorError, "only generation of JSON objects or arrays allowed");
|
873
|
+
}
|
874
|
+
}
|
875
|
+
return result;
|
876
|
+
}
|
877
|
+
|
878
|
+
/*
|
879
|
+
* call-seq: new(opts = {})
|
880
|
+
*
|
881
|
+
* Instantiates a new State object, configured by _opts_.
|
882
|
+
*
|
883
|
+
* _opts_ can have the following keys:
|
884
|
+
*
|
885
|
+
* * *indent*: a string used to indent levels (default: ''),
|
886
|
+
* * *space*: a string that is put after, a : or , delimiter (default: ''),
|
887
|
+
* * *space_before*: a string that is put before a : pair delimiter (default: ''),
|
888
|
+
* * *object_nl*: a string that is put at the end of a JSON object (default: ''),
|
889
|
+
* * *array_nl*: a string that is put at the end of a JSON array (default: ''),
|
890
|
+
* * *allow_nan*: true if NaN, Infinity, and -Infinity should be
|
891
|
+
* generated, otherwise an exception is thrown, if these values are
|
892
|
+
* encountered. This options defaults to false.
|
893
|
+
* * *quirks_mode*: Enables quirks_mode for parser, that is for example
|
894
|
+
* generating single JSON values instead of documents is possible.
|
895
|
+
* * *buffer_initial_length*: sets the initial length of the generator's
|
896
|
+
* internal buffer.
|
897
|
+
*/
|
898
|
+
static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
|
899
|
+
{
|
900
|
+
VALUE opts;
|
901
|
+
GET_STATE(self);
|
902
|
+
state->max_nesting = 19;
|
903
|
+
state->buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
|
904
|
+
rb_scan_args(argc, argv, "01", &opts);
|
905
|
+
if (!NIL_P(opts)) cState_configure(self, opts);
|
906
|
+
return self;
|
907
|
+
}
|
908
|
+
|
909
|
+
/*
|
910
|
+
* call-seq: initialize_copy(orig)
|
911
|
+
*
|
912
|
+
* Initializes this object from orig if it to be duplicated/cloned and returns
|
913
|
+
* it.
|
914
|
+
*/
|
915
|
+
static VALUE cState_init_copy(VALUE obj, VALUE orig)
|
916
|
+
{
|
917
|
+
JSON_Generator_State *objState, *origState;
|
918
|
+
|
919
|
+
Data_Get_Struct(obj, JSON_Generator_State, objState);
|
920
|
+
Data_Get_Struct(orig, JSON_Generator_State, origState);
|
921
|
+
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
|
922
|
+
|
923
|
+
MEMCPY(objState, origState, JSON_Generator_State, 1);
|
924
|
+
objState->indent = fstrndup(origState->indent, origState->indent_len);
|
925
|
+
objState->space = fstrndup(origState->space, origState->space_len);
|
926
|
+
objState->space_before = fstrndup(origState->space_before, origState->space_before_len);
|
927
|
+
objState->object_nl = fstrndup(origState->object_nl, origState->object_nl_len);
|
928
|
+
objState->array_nl = fstrndup(origState->array_nl, origState->array_nl_len);
|
929
|
+
if (origState->array_delim) objState->array_delim = fbuffer_dup(origState->array_delim);
|
930
|
+
if (origState->object_delim) objState->object_delim = fbuffer_dup(origState->object_delim);
|
931
|
+
if (origState->object_delim2) objState->object_delim2 = fbuffer_dup(origState->object_delim2);
|
932
|
+
return obj;
|
933
|
+
}
|
934
|
+
|
935
|
+
/*
|
936
|
+
* call-seq: from_state(opts)
|
937
|
+
*
|
938
|
+
* Creates a State object from _opts_, which ought to be Hash to create a
|
939
|
+
* new State instance configured by _opts_, something else to create an
|
940
|
+
* unconfigured instance. If _opts_ is a State object, it is just returned.
|
941
|
+
*/
|
942
|
+
static VALUE cState_from_state_s(VALUE self, VALUE opts)
|
943
|
+
{
|
944
|
+
if (rb_obj_is_kind_of(opts, self)) {
|
945
|
+
return opts;
|
946
|
+
} else if (rb_obj_is_kind_of(opts, rb_cHash)) {
|
947
|
+
return rb_funcall(self, i_new, 1, opts);
|
948
|
+
} else {
|
949
|
+
if (NIL_P(CJSON_SAFE_STATE_PROTOTYPE)) {
|
950
|
+
CJSON_SAFE_STATE_PROTOTYPE = rb_const_get(mJSON, i_SAFE_STATE_PROTOTYPE);
|
951
|
+
}
|
952
|
+
return rb_funcall(CJSON_SAFE_STATE_PROTOTYPE, i_dup, 0);
|
953
|
+
}
|
954
|
+
}
|
955
|
+
|
956
|
+
/*
|
957
|
+
* call-seq: indent()
|
958
|
+
*
|
959
|
+
* This string is used to indent levels in the JSON text.
|
960
|
+
*/
|
961
|
+
static VALUE cState_indent(VALUE self)
|
962
|
+
{
|
963
|
+
GET_STATE(self);
|
964
|
+
return state->indent ? rb_str_new2(state->indent) : rb_str_new2("");
|
965
|
+
}
|
966
|
+
|
967
|
+
/*
|
968
|
+
* call-seq: indent=(indent)
|
969
|
+
*
|
970
|
+
* This string is used to indent levels in the JSON text.
|
971
|
+
*/
|
972
|
+
static VALUE cState_indent_set(VALUE self, VALUE indent)
|
973
|
+
{
|
974
|
+
unsigned long len;
|
975
|
+
GET_STATE(self);
|
976
|
+
Check_Type(indent, T_STRING);
|
977
|
+
len = RSTRING_LEN(indent);
|
978
|
+
if (len == 0) {
|
979
|
+
if (state->indent) {
|
980
|
+
ruby_xfree(state->indent);
|
981
|
+
state->indent = NULL;
|
982
|
+
state->indent_len = 0;
|
983
|
+
}
|
984
|
+
} else {
|
985
|
+
if (state->indent) ruby_xfree(state->indent);
|
986
|
+
state->indent = strdup(RSTRING_PTR(indent));
|
987
|
+
state->indent_len = len;
|
988
|
+
}
|
989
|
+
return Qnil;
|
990
|
+
}
|
991
|
+
|
992
|
+
/*
|
993
|
+
* call-seq: space()
|
994
|
+
*
|
995
|
+
* This string is used to insert a space between the tokens in a JSON
|
996
|
+
* string.
|
997
|
+
*/
|
998
|
+
static VALUE cState_space(VALUE self)
|
999
|
+
{
|
1000
|
+
GET_STATE(self);
|
1001
|
+
return state->space ? rb_str_new2(state->space) : rb_str_new2("");
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
/*
|
1005
|
+
* call-seq: space=(space)
|
1006
|
+
*
|
1007
|
+
* This string is used to insert a space between the tokens in a JSON
|
1008
|
+
* string.
|
1009
|
+
*/
|
1010
|
+
static VALUE cState_space_set(VALUE self, VALUE space)
|
1011
|
+
{
|
1012
|
+
unsigned long len;
|
1013
|
+
GET_STATE(self);
|
1014
|
+
Check_Type(space, T_STRING);
|
1015
|
+
len = RSTRING_LEN(space);
|
1016
|
+
if (len == 0) {
|
1017
|
+
if (state->space) {
|
1018
|
+
ruby_xfree(state->space);
|
1019
|
+
state->space = NULL;
|
1020
|
+
state->space_len = 0;
|
1021
|
+
}
|
1022
|
+
} else {
|
1023
|
+
if (state->space) ruby_xfree(state->space);
|
1024
|
+
state->space = strdup(RSTRING_PTR(space));
|
1025
|
+
state->space_len = len;
|
1026
|
+
}
|
1027
|
+
return Qnil;
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
/*
|
1031
|
+
* call-seq: space_before()
|
1032
|
+
*
|
1033
|
+
* This string is used to insert a space before the ':' in JSON objects.
|
1034
|
+
*/
|
1035
|
+
static VALUE cState_space_before(VALUE self)
|
1036
|
+
{
|
1037
|
+
GET_STATE(self);
|
1038
|
+
return state->space_before ? rb_str_new2(state->space_before) : rb_str_new2("");
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
/*
|
1042
|
+
* call-seq: space_before=(space_before)
|
1043
|
+
*
|
1044
|
+
* This string is used to insert a space before the ':' in JSON objects.
|
1045
|
+
*/
|
1046
|
+
static VALUE cState_space_before_set(VALUE self, VALUE space_before)
|
1047
|
+
{
|
1048
|
+
unsigned long len;
|
1049
|
+
GET_STATE(self);
|
1050
|
+
Check_Type(space_before, T_STRING);
|
1051
|
+
len = RSTRING_LEN(space_before);
|
1052
|
+
if (len == 0) {
|
1053
|
+
if (state->space_before) {
|
1054
|
+
ruby_xfree(state->space_before);
|
1055
|
+
state->space_before = NULL;
|
1056
|
+
state->space_before_len = 0;
|
1057
|
+
}
|
1058
|
+
} else {
|
1059
|
+
if (state->space_before) ruby_xfree(state->space_before);
|
1060
|
+
state->space_before = strdup(RSTRING_PTR(space_before));
|
1061
|
+
state->space_before_len = len;
|
1062
|
+
}
|
1063
|
+
return Qnil;
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
/*
|
1067
|
+
* call-seq: object_nl()
|
1068
|
+
*
|
1069
|
+
* This string is put at the end of a line that holds a JSON object (or
|
1070
|
+
* Hash).
|
1071
|
+
*/
|
1072
|
+
static VALUE cState_object_nl(VALUE self)
|
1073
|
+
{
|
1074
|
+
GET_STATE(self);
|
1075
|
+
return state->object_nl ? rb_str_new2(state->object_nl) : rb_str_new2("");
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
/*
|
1079
|
+
* call-seq: object_nl=(object_nl)
|
1080
|
+
*
|
1081
|
+
* This string is put at the end of a line that holds a JSON object (or
|
1082
|
+
* Hash).
|
1083
|
+
*/
|
1084
|
+
static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
|
1085
|
+
{
|
1086
|
+
unsigned long len;
|
1087
|
+
GET_STATE(self);
|
1088
|
+
Check_Type(object_nl, T_STRING);
|
1089
|
+
len = RSTRING_LEN(object_nl);
|
1090
|
+
if (len == 0) {
|
1091
|
+
if (state->object_nl) {
|
1092
|
+
ruby_xfree(state->object_nl);
|
1093
|
+
state->object_nl = NULL;
|
1094
|
+
}
|
1095
|
+
} else {
|
1096
|
+
if (state->object_nl) ruby_xfree(state->object_nl);
|
1097
|
+
state->object_nl = strdup(RSTRING_PTR(object_nl));
|
1098
|
+
state->object_nl_len = len;
|
1099
|
+
}
|
1100
|
+
return Qnil;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
/*
|
1104
|
+
* call-seq: array_nl()
|
1105
|
+
*
|
1106
|
+
* This string is put at the end of a line that holds a JSON array.
|
1107
|
+
*/
|
1108
|
+
static VALUE cState_array_nl(VALUE self)
|
1109
|
+
{
|
1110
|
+
GET_STATE(self);
|
1111
|
+
return state->array_nl ? rb_str_new2(state->array_nl) : rb_str_new2("");
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
/*
|
1115
|
+
* call-seq: array_nl=(array_nl)
|
1116
|
+
*
|
1117
|
+
* This string is put at the end of a line that holds a JSON array.
|
1118
|
+
*/
|
1119
|
+
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
|
1120
|
+
{
|
1121
|
+
unsigned long len;
|
1122
|
+
GET_STATE(self);
|
1123
|
+
Check_Type(array_nl, T_STRING);
|
1124
|
+
len = RSTRING_LEN(array_nl);
|
1125
|
+
if (len == 0) {
|
1126
|
+
if (state->array_nl) {
|
1127
|
+
ruby_xfree(state->array_nl);
|
1128
|
+
state->array_nl = NULL;
|
1129
|
+
}
|
1130
|
+
} else {
|
1131
|
+
if (state->array_nl) ruby_xfree(state->array_nl);
|
1132
|
+
state->array_nl = strdup(RSTRING_PTR(array_nl));
|
1133
|
+
state->array_nl_len = len;
|
1134
|
+
}
|
1135
|
+
return Qnil;
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
|
1139
|
+
/*
|
1140
|
+
* call-seq: check_circular?
|
1141
|
+
*
|
1142
|
+
* Returns true, if circular data structures should be checked,
|
1143
|
+
* otherwise returns false.
|
1144
|
+
*/
|
1145
|
+
static VALUE cState_check_circular_p(VALUE self)
|
1146
|
+
{
|
1147
|
+
GET_STATE(self);
|
1148
|
+
return state->max_nesting ? Qtrue : Qfalse;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
/*
|
1152
|
+
* call-seq: max_nesting
|
1153
|
+
*
|
1154
|
+
* This integer returns the maximum level of data structure nesting in
|
1155
|
+
* the generated JSON, max_nesting = 0 if no maximum is checked.
|
1156
|
+
*/
|
1157
|
+
static VALUE cState_max_nesting(VALUE self)
|
1158
|
+
{
|
1159
|
+
GET_STATE(self);
|
1160
|
+
return LONG2FIX(state->max_nesting);
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
/*
|
1164
|
+
* call-seq: max_nesting=(depth)
|
1165
|
+
*
|
1166
|
+
* This sets the maximum level of data structure nesting in the generated JSON
|
1167
|
+
* to the integer depth, max_nesting = 0 if no maximum should be checked.
|
1168
|
+
*/
|
1169
|
+
static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
|
1170
|
+
{
|
1171
|
+
GET_STATE(self);
|
1172
|
+
Check_Type(depth, T_FIXNUM);
|
1173
|
+
return state->max_nesting = FIX2LONG(depth);
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
/*
|
1177
|
+
* call-seq: allow_nan?
|
1178
|
+
*
|
1179
|
+
* Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
|
1180
|
+
* returns false.
|
1181
|
+
*/
|
1182
|
+
static VALUE cState_allow_nan_p(VALUE self)
|
1183
|
+
{
|
1184
|
+
GET_STATE(self);
|
1185
|
+
return state->allow_nan ? Qtrue : Qfalse;
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
/*
|
1189
|
+
* call-seq: ascii_only?
|
1190
|
+
*
|
1191
|
+
* Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
|
1192
|
+
* returns false.
|
1193
|
+
*/
|
1194
|
+
static VALUE cState_ascii_only_p(VALUE self)
|
1195
|
+
{
|
1196
|
+
GET_STATE(self);
|
1197
|
+
return state->ascii_only ? Qtrue : Qfalse;
|
1198
|
+
}
|
1199
|
+
|
1200
|
+
/*
|
1201
|
+
* call-seq: quirks_mode?
|
1202
|
+
*
|
1203
|
+
* Returns true, if quirks mode is enabled. Otherwise returns false.
|
1204
|
+
*/
|
1205
|
+
static VALUE cState_quirks_mode_p(VALUE self)
|
1206
|
+
{
|
1207
|
+
GET_STATE(self);
|
1208
|
+
return state->quirks_mode ? Qtrue : Qfalse;
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
/*
|
1212
|
+
* call-seq: quirks_mode=(enable)
|
1213
|
+
*
|
1214
|
+
* If set to true, enables the quirks_mode mode.
|
1215
|
+
*/
|
1216
|
+
static VALUE cState_quirks_mode_set(VALUE self, VALUE enable)
|
1217
|
+
{
|
1218
|
+
GET_STATE(self);
|
1219
|
+
state->quirks_mode = RTEST(enable);
|
1220
|
+
return Qnil;
|
1221
|
+
}
|
1222
|
+
|
1223
|
+
/*
|
1224
|
+
* call-seq: depth
|
1225
|
+
*
|
1226
|
+
* This integer returns the current depth of data structure nesting.
|
1227
|
+
*/
|
1228
|
+
static VALUE cState_depth(VALUE self)
|
1229
|
+
{
|
1230
|
+
GET_STATE(self);
|
1231
|
+
return LONG2FIX(state->depth);
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
/*
|
1235
|
+
* call-seq: depth=(depth)
|
1236
|
+
*
|
1237
|
+
* This sets the maximum level of data structure nesting in the generated JSON
|
1238
|
+
* to the integer depth, max_nesting = 0 if no maximum should be checked.
|
1239
|
+
*/
|
1240
|
+
static VALUE cState_depth_set(VALUE self, VALUE depth)
|
1241
|
+
{
|
1242
|
+
GET_STATE(self);
|
1243
|
+
Check_Type(depth, T_FIXNUM);
|
1244
|
+
state->depth = FIX2LONG(depth);
|
1245
|
+
return Qnil;
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
/*
|
1249
|
+
* call-seq: buffer_initial_length
|
1250
|
+
*
|
1251
|
+
* This integer returns the current inital length of the buffer.
|
1252
|
+
*/
|
1253
|
+
static VALUE cState_buffer_initial_length(VALUE self)
|
1254
|
+
{
|
1255
|
+
GET_STATE(self);
|
1256
|
+
return LONG2FIX(state->buffer_initial_length);
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
/*
|
1260
|
+
* call-seq: buffer_initial_length=(length)
|
1261
|
+
*
|
1262
|
+
* This sets the initial length of the buffer to +length+, if +length+ > 0,
|
1263
|
+
* otherwise its value isn't changed.
|
1264
|
+
*/
|
1265
|
+
static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_length)
|
1266
|
+
{
|
1267
|
+
long initial_length;
|
1268
|
+
GET_STATE(self);
|
1269
|
+
Check_Type(buffer_initial_length, T_FIXNUM);
|
1270
|
+
initial_length = FIX2LONG(buffer_initial_length);
|
1271
|
+
if (initial_length > 0) {
|
1272
|
+
state->buffer_initial_length = initial_length;
|
1273
|
+
}
|
1274
|
+
return Qnil;
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
/*
|
1278
|
+
*
|
1279
|
+
*/
|
1280
|
+
void Init_generator()
|
1281
|
+
{
|
1282
|
+
rb_require("json/common");
|
1283
|
+
|
1284
|
+
mJSON = rb_define_module("JSON");
|
1285
|
+
mExt = rb_define_module_under(mJSON, "Ext");
|
1286
|
+
mGenerator = rb_define_module_under(mExt, "Generator");
|
1287
|
+
|
1288
|
+
eGeneratorError = rb_path2class("JSON::GeneratorError");
|
1289
|
+
eNestingError = rb_path2class("JSON::NestingError");
|
1290
|
+
|
1291
|
+
cState = rb_define_class_under(mGenerator, "State", rb_cObject);
|
1292
|
+
rb_define_alloc_func(cState, cState_s_allocate);
|
1293
|
+
rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1);
|
1294
|
+
rb_define_method(cState, "initialize", cState_initialize, -1);
|
1295
|
+
rb_define_method(cState, "initialize_copy", cState_init_copy, 1);
|
1296
|
+
rb_define_method(cState, "indent", cState_indent, 0);
|
1297
|
+
rb_define_method(cState, "indent=", cState_indent_set, 1);
|
1298
|
+
rb_define_method(cState, "space", cState_space, 0);
|
1299
|
+
rb_define_method(cState, "space=", cState_space_set, 1);
|
1300
|
+
rb_define_method(cState, "space_before", cState_space_before, 0);
|
1301
|
+
rb_define_method(cState, "space_before=", cState_space_before_set, 1);
|
1302
|
+
rb_define_method(cState, "object_nl", cState_object_nl, 0);
|
1303
|
+
rb_define_method(cState, "object_nl=", cState_object_nl_set, 1);
|
1304
|
+
rb_define_method(cState, "array_nl", cState_array_nl, 0);
|
1305
|
+
rb_define_method(cState, "array_nl=", cState_array_nl_set, 1);
|
1306
|
+
rb_define_method(cState, "max_nesting", cState_max_nesting, 0);
|
1307
|
+
rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1);
|
1308
|
+
rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
|
1309
|
+
rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
|
1310
|
+
rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0);
|
1311
|
+
rb_define_method(cState, "quirks_mode?", cState_quirks_mode_p, 0);
|
1312
|
+
rb_define_method(cState, "quirks_mode", cState_quirks_mode_p, 0);
|
1313
|
+
rb_define_method(cState, "quirks_mode=", cState_quirks_mode_set, 1);
|
1314
|
+
rb_define_method(cState, "depth", cState_depth, 0);
|
1315
|
+
rb_define_method(cState, "depth=", cState_depth_set, 1);
|
1316
|
+
rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0);
|
1317
|
+
rb_define_method(cState, "buffer_initial_length=", cState_buffer_initial_length_set, 1);
|
1318
|
+
rb_define_method(cState, "configure", cState_configure, 1);
|
1319
|
+
rb_define_alias(cState, "merge", "configure");
|
1320
|
+
rb_define_method(cState, "to_h", cState_to_h, 0);
|
1321
|
+
rb_define_method(cState, "[]", cState_aref, 1);
|
1322
|
+
rb_define_method(cState, "generate", cState_generate, 1);
|
1323
|
+
|
1324
|
+
mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
|
1325
|
+
mObject = rb_define_module_under(mGeneratorMethods, "Object");
|
1326
|
+
rb_define_method(mObject, "to_json", mObject_to_json, -1);
|
1327
|
+
mHash = rb_define_module_under(mGeneratorMethods, "Hash");
|
1328
|
+
rb_define_method(mHash, "to_json", mHash_to_json, -1);
|
1329
|
+
mArray = rb_define_module_under(mGeneratorMethods, "Array");
|
1330
|
+
rb_define_method(mArray, "to_json", mArray_to_json, -1);
|
1331
|
+
mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum");
|
1332
|
+
rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1);
|
1333
|
+
mBignum = rb_define_module_under(mGeneratorMethods, "Bignum");
|
1334
|
+
rb_define_method(mBignum, "to_json", mBignum_to_json, -1);
|
1335
|
+
mFloat = rb_define_module_under(mGeneratorMethods, "Float");
|
1336
|
+
rb_define_method(mFloat, "to_json", mFloat_to_json, -1);
|
1337
|
+
mString = rb_define_module_under(mGeneratorMethods, "String");
|
1338
|
+
rb_define_singleton_method(mString, "included", mString_included_s, 1);
|
1339
|
+
rb_define_method(mString, "to_json", mString_to_json, -1);
|
1340
|
+
rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1);
|
1341
|
+
rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0);
|
1342
|
+
mString_Extend = rb_define_module_under(mString, "Extend");
|
1343
|
+
rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1);
|
1344
|
+
mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass");
|
1345
|
+
rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1);
|
1346
|
+
mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass");
|
1347
|
+
rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1);
|
1348
|
+
mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
|
1349
|
+
rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);
|
1350
|
+
|
1351
|
+
CRegexp_MULTILINE = rb_const_get(rb_cRegexp, rb_intern("MULTILINE"));
|
1352
|
+
i_to_s = rb_intern("to_s");
|
1353
|
+
i_to_json = rb_intern("to_json");
|
1354
|
+
i_new = rb_intern("new");
|
1355
|
+
i_indent = rb_intern("indent");
|
1356
|
+
i_space = rb_intern("space");
|
1357
|
+
i_space_before = rb_intern("space_before");
|
1358
|
+
i_object_nl = rb_intern("object_nl");
|
1359
|
+
i_array_nl = rb_intern("array_nl");
|
1360
|
+
i_max_nesting = rb_intern("max_nesting");
|
1361
|
+
i_allow_nan = rb_intern("allow_nan");
|
1362
|
+
i_ascii_only = rb_intern("ascii_only");
|
1363
|
+
i_quirks_mode = rb_intern("quirks_mode");
|
1364
|
+
i_depth = rb_intern("depth");
|
1365
|
+
i_buffer_initial_length = rb_intern("buffer_initial_length");
|
1366
|
+
i_pack = rb_intern("pack");
|
1367
|
+
i_unpack = rb_intern("unpack");
|
1368
|
+
i_create_id = rb_intern("create_id");
|
1369
|
+
i_extend = rb_intern("extend");
|
1370
|
+
i_key_p = rb_intern("key?");
|
1371
|
+
i_aref = rb_intern("[]");
|
1372
|
+
i_send = rb_intern("__send__");
|
1373
|
+
i_respond_to_p = rb_intern("respond_to?");
|
1374
|
+
i_match = rb_intern("match");
|
1375
|
+
i_keys = rb_intern("keys");
|
1376
|
+
i_dup = rb_intern("dup");
|
1377
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
1378
|
+
CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
|
1379
|
+
i_encoding = rb_intern("encoding");
|
1380
|
+
i_encode = rb_intern("encode");
|
1381
|
+
#endif
|
1382
|
+
i_SAFE_STATE_PROTOTYPE = rb_intern("SAFE_STATE_PROTOTYPE");
|
1383
|
+
CJSON_SAFE_STATE_PROTOTYPE = Qnil;
|
1384
|
+
}
|