summaryrefslogtreecommitdiff
path: root/ext/json/parser
AgeCommit message (Collapse)Author
2020-10-20Implement a freeze: parser optionJean Boussier
If set to true all parsed objects will be immediately frozen, and strings will be deduplicated if the Ruby implementation allows it.
2020-08-27sed -i '/rmodule.h/d'卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3347
2020-08-27sed -i '/r_cast.h/d'卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3346
2020-08-27sed -i '\,2/extern.h,d'卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3338
2020-07-01[flori/json] Use frozen string for hash keyWatson
When use non-frozen string for hash key with `rb_hash_aset()`, it will duplicate and freeze it internally. To avoid duplicate and freeze, this patch will give a frozen string in `rb_hash_aset()`. ``` Warming up -------------------------------------- json 14.000 i/100ms Calculating ------------------------------------- json 148.844 (± 1.3%) i/s - 756.000 in 5.079969s ``` ``` Warming up -------------------------------------- json 16.000 i/100ms Calculating ------------------------------------- json 165.608 (± 1.8%) i/s - 832.000 in 5.025367s ``` ``` require 'json' require 'securerandom' require 'benchmark/ips' obj = [] 1000.times do |i| obj << { "id": i, "uuid": SecureRandom.uuid, "created_at": Time.now } end json = obj.to_json Benchmark.ips do |x| x.report "json" do |iter| count = 0 while count < iter JSON.parse(json) count += 1 end end end ``` https://github.com/flori/json/commit/18292c0c1d
2020-05-14ext/json/parser/prereq.mk: remove type-limit warning if char is unsignedYusuke Endoh
Ragel generates a code `0 <= (*p)` where `*p` is char. As char is unsigned by default on arm and RISC-V, it is warned by gcc: ``` compiling parser.c parser.c: In function ‘JSON_parse_string’: parser.c:1566:2: warning: comparison is always true due to limited range of data type [-Wtype-limits] if ( 0 <= (*p) && (*p) <= 31 ) ^ parser.c:1596:2: warning: comparison is always true due to limited range of data type [-Wtype-limits] if ( 0 <= (*p) && (*p) <= 31 ) ^ ``` This change removes the warning by substituting the condition with `0 <= (signed char)(*p)`.
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2019-10-14[flori/json] Only attempt to resize strings not other objectsFlorian Frank
https://github.com/flori/json/commit/167ada8da7
2019-10-05ext/json/parser/prereq.mk: use `if $. == 1` instead of a hacky codeYusuke Endoh
2019-10-05ext/json/parser/prereq.mk: keep line numbers of ext/json/parser/parser.cYusuke Endoh
Follow up of 5717e55e9a7790c938afa694a9bf558c0e54bb83. Adding a header with newline broke linenos.
2019-10-05ext/json/parser/parser.rl: Use "signed" char to contain negative valuesYusuke Endoh
char is not always signed. In fact, it is unsigned in arm. https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-master/log/20191004T181708Z.log.html.gz ``` compiling parser.c parser.rl: In function ‘unescape_unicode’: parser.rl:50:5: warning: comparison is always false due to limited range of data type [-Wtype-limits] if (b < 0) return UNI_REPLACEMENT_CHAR; ^ ```
2019-10-05ext/json/parser/prereq.mk: Add a "automatically generated" headerYusuke Endoh
to parser.c.
2019-10-05ext/json/parser/parser.rl: Update the source code of parser.cYusuke Endoh
There have been some direct changes in parser.c which is automatically generated from parser.rl. This updates parser.rl to sync the changes: * 91793b8967e0531bd1159a8ff0cc7e50739c7620 * 79ead821dd4880725c9c6bb9645b3fad71715c5b * 80b5a0ff2a7709367178f29d4ebe1c54122b1c27
2019-09-25Make rb_scan_args handle keywords more similar to Ruby methods (#2460)Jeremy Evans
Cfuncs that use rb_scan_args with the : entry suffer similar keyword argument separation issues that Ruby methods suffer if the cfuncs accept optional or variable arguments. This makes the following changes to : handling. * Treats as **kw, prompting keyword argument separation warnings if called with a positional hash. * Do not look for an option hash if empty keywords are provided. For backwards compatibility, treat an empty keyword splat as a empty mandatory positional hash argument, but emit a a warning, as this behavior will be removed in Ruby 3. The argument number check needs to be moved lower so it can correctly handle an empty positional argument being added. * If the last argument is nil and it is necessary to treat it as an option hash in order to make sure all arguments are processed, continue to treat the last argument as the option hash. Emit a warning in this case, as this behavior will be removed in Ruby 3. * If splitting the keyword hash into two hashes, issue a warning, as we will not be splitting hashes in Ruby 3. * If the keyword argument is required to fill a mandatory positional argument, continue to do so, but emit a warning as this behavior will be going away in Ruby 3. * If keyword arguments are provided and the last argument is not a hash, that indicates something wrong. This can happen if a cfunc is calling rb_scan_args multiple times, and providing arguments that were not passed to it from Ruby. Callers need to switch to the new rb_scan_args_kw function, which allows passing of whether keywords were provided. This commit fixes all warnings caused by the changes above. It switches some function calls to *_kw versions with appropriate kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS is used. If creating new arguments, RB_PASS_KEYWORDS is used if the last argument is a hash to be treated as keywords. In open_key_args in io.c, use rb_scan_args_kw. In this case, the arguments provided come from another C function, not Ruby. The last argument may or may not be a hash, so we can't set keyword argument mode. However, if it is a hash, we don't want to warn when treating it as keywords. In Ruby files, make sure to appropriately use keyword splats or literal keywords when calling Cfuncs that now issue keyword argument separation warnings through rb_scan_args. Also, make sure not to pass nil in place of an option hash. Work around Kernel#warn warnings due to problems in the Rubygems override of the method. There is an open pull request to fix these issues in Rubygems, but part of the Rubygems tests for their override fail on ruby-head due to rb_scan_args not recognizing empty keyword splats, which this commit fixes. Implementation wise, adding rb_scan_args_kw is kind of a pain, because rb_scan_args takes a variable number of arguments. In order to not duplicate all the code, the function internals need to be split into two functions taking a va_list, and to avoid passing in a ton of arguments, a single struct argument is used to handle the variables previously local to the function. Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-07-14Include ruby/assert.h in ruby/ruby.h so that assertions can be thereNobuyoshi Nakada
2019-05-13Add NaN / Infinity / MinusInfinity to mark listAaron Patterson
This prevents the constants from moving.
2019-04-20Add `GC.compact` again.tenderlove
🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Reverting compaction for nowtenderlove
For some reason symbols (or classes) are being overridden in trunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Adding `GC.compact` and compacting GC support.tenderlove
This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10Reverting all commits from r67479 to r67496 because of CI failureskazu
Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09Add error globals to mark list so they don't movetenderlove
JSON gem is referencing constants defined in Ruby then keeping a reference as a global. We need to register these globals so they stay pinned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-23Merge json-2.2.0 from flori/json.hsbt
https://github.com/flori/json/releases/tag/v2.2.0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-14Prefer relative directory from srcdir to top_srcdirnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-11Use $(hdrdir) for include/ruby.h, as well as r67033nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-02Fix JSON::Parser against bigdecimal updatesmrkn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-03ext/json/parser/parser.c: do not call rb_str_resize() on Time objecteregon
* See https://github.com/flori/json/issues/342 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-03Fix missed update of parser source in r62429eregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16no ID cache in Init functionsnobu
Init functions are called only once, cache is useless. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-16Merge json-2.1.0 from https://github.com/flori/jsonhsbt
https://github.com/flori/json/blob/master/CHANGES.md#2017-04-18-210 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-12Merge json-2.0.4.hsbt
* https://github.com/flori/json/releases/tag/v2.0.4 * https://github.com/flori/json/blob/09fabeb03e73ed88dc8ce8f19d76ac59e51dae20/CHANGES.md#2017-03-23-204 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-22ruby tool/update-deps --fixshyouhei
Onigumo 6 (r57045) introduced new onigumo.h header file, which is required from quite much everywhere. This commit adds necessary dependencies. Note: ruby/oniguruma.h now includes onigumo.h, ruby/io.h includes oniguruma.h, ruby/encoding.h also includes oniguruma.h, and internal.h includes encoding.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-01* ext/json/*, test/json/json_parser_test.rb: Update json-2.0.2.hsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-06Revert ext/json/parser/prereq.mknobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-05* ext/json/*, test/json/*: Update json-2.0.1.hsbt
Changes of 2.0.0: https://github.com/flori/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2015-09-11-200 Changes of 2.0.1: https://github.com/flori/json/blob/f679ebd0c69a94e3e70a897ac9a229f5779c2ee1/CHANGES.md#2016-07-01-201 [Feature #12542][ruby-dev:49706][fix GH-1395] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-11Update dependencies.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16handle ext/ as r53141naruse
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&# frozen_string_literal: false\n");f.rewind;f.write s}}' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-25parser.c: updatenobu
* ext/json/parser/parser.c: update to r51946. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-25parser.rl: rb_scan_argsnobu
* ext/json/parser/parser.rl (cParser_initialize): use ':' in rb_scan_args. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-28parser.rl: allocate structs with wrappernobu
* ext/json/parser/parser.rl (cJSON_parser_s_allocate): allocate structs with making new wrapper objects and get rid of potential memory leak. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18parser.rl: define enc_raise iff necessarynobu
* ext/json/parser/parser.rl (enc_raise): no needs if rb_enc_raise is available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18parser.rl: rb_enc_raisenobu
* ext/json/parser/parser.rl: raise with messages in UTF-8 encoding. [ruby-core:67386] [Bug #10705] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18parser.rl: use rb_encodingnobu
* ext/json/parser/parser.rl (convert_encoding): use rb_encoding functions to compare and convert encodings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-18parser.rl: use StringValuenobu
* ext/json/parser/parser.rl (cParser_initialize): use StringValue instead of direct rb_convert_type and remove duplicate conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12* ext/json/*, test/json/*: Reverted r50231. Because it's not works withhsbt
cross-compile environment. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-11* ext/json/*, test/json/*, defs/default_gems: Gemify JSON library.hsbt
[fix GH-867][Feature #11057] * test/ruby/test_extlibs.rb: removed json gem from existence extentions. * gems/bundled_gems: added json gem into bundled gem. * lib/rdoc/rubygems_hook.rb: ignored no json environment. * lib/rubygems/test_case.rb, test/rubygems/*: ditto. * lib/rdoc/test_case.rb, test/rdoc/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-13* ext/json: merge upstream from flori/jsonhsbt
change usage of TypedData. [Feature #10739][ruby-core:67564] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-13* ext/json, test/json: merge JSON HEAD(259dee6)hsbt
separate imprementation of Typed_Data macro. https://github.com/flori/json/compare/v1.8.1...v1.8.2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-28* ext/json, test/json: merge JSON HEAD(17fe8e7)hsbt
https://github.com/flori/json/compare/v1.8.1...17fe8e7 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e