json 1.8.6 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +5 -5
  2. data/{CHANGES → CHANGES.md} +292 -96
  3. data/LICENSE +56 -0
  4. data/README.md +185 -114
  5. data/ext/json/ext/fbuffer/fbuffer.h +0 -3
  6. data/ext/json/ext/generator/generator.c +328 -117
  7. data/ext/json/ext/generator/generator.h +8 -8
  8. data/ext/json/ext/parser/extconf.rb +29 -0
  9. data/ext/json/ext/parser/parser.c +540 -569
  10. data/ext/json/ext/parser/parser.h +10 -6
  11. data/ext/json/ext/parser/parser.rl +269 -261
  12. data/ext/json/extconf.rb +1 -1
  13. data/json.gemspec +0 -0
  14. data/lib/json/add/bigdecimal.rb +40 -10
  15. data/lib/json/add/complex.rb +32 -9
  16. data/lib/json/add/core.rb +1 -0
  17. data/lib/json/add/date.rb +27 -7
  18. data/lib/json/add/date_time.rb +26 -9
  19. data/lib/json/add/exception.rb +25 -7
  20. data/lib/json/add/ostruct.rb +32 -9
  21. data/lib/json/add/range.rb +33 -8
  22. data/lib/json/add/rational.rb +30 -8
  23. data/lib/json/add/regexp.rb +28 -10
  24. data/lib/json/add/set.rb +48 -0
  25. data/lib/json/add/struct.rb +29 -7
  26. data/lib/json/add/symbol.rb +28 -5
  27. data/lib/json/add/time.rb +27 -6
  28. data/lib/json/common.rb +402 -188
  29. data/lib/json/ext.rb +0 -6
  30. data/lib/json/generic_object.rb +11 -6
  31. data/lib/json/pure/generator.rb +120 -137
  32. data/lib/json/pure/parser.rb +64 -86
  33. data/lib/json/pure.rb +2 -8
  34. data/lib/json/version.rb +2 -1
  35. data/lib/json.rb +559 -29
  36. metadata +18 -129
  37. data/.gitignore +0 -17
  38. data/.travis.yml +0 -18
  39. data/Gemfile +0 -7
  40. data/README-json-jruby.markdown +0 -33
  41. data/Rakefile +0 -402
  42. data/TODO +0 -1
  43. data/VERSION +0 -1
  44. data/data/example.json +0 -1
  45. data/data/index.html +0 -38
  46. data/data/prototype.js +0 -4184
  47. data/diagrams/.keep +0 -0
  48. data/install.rb +0 -23
  49. data/java/src/json/ext/ByteListTranscoder.java +0 -166
  50. data/java/src/json/ext/Generator.java +0 -446
  51. data/java/src/json/ext/GeneratorMethods.java +0 -231
  52. data/java/src/json/ext/GeneratorService.java +0 -42
  53. data/java/src/json/ext/GeneratorState.java +0 -542
  54. data/java/src/json/ext/OptionsReader.java +0 -113
  55. data/java/src/json/ext/Parser.java +0 -2644
  56. data/java/src/json/ext/Parser.rl +0 -968
  57. data/java/src/json/ext/ParserService.java +0 -34
  58. data/java/src/json/ext/RuntimeInfo.java +0 -120
  59. data/java/src/json/ext/StringDecoder.java +0 -166
  60. data/java/src/json/ext/StringEncoder.java +0 -111
  61. data/java/src/json/ext/Utils.java +0 -88
  62. data/json-java.gemspec +0 -38
  63. data/json_pure.gemspec +0 -37
  64. data/lib/json/ext/.keep +0 -0
  65. data/tests/fixtures/fail1.json +0 -1
  66. data/tests/fixtures/fail10.json +0 -1
  67. data/tests/fixtures/fail11.json +0 -1
  68. data/tests/fixtures/fail12.json +0 -1
  69. data/tests/fixtures/fail13.json +0 -1
  70. data/tests/fixtures/fail14.json +0 -1
  71. data/tests/fixtures/fail18.json +0 -1
  72. data/tests/fixtures/fail19.json +0 -1
  73. data/tests/fixtures/fail2.json +0 -1
  74. data/tests/fixtures/fail20.json +0 -1
  75. data/tests/fixtures/fail21.json +0 -1
  76. data/tests/fixtures/fail22.json +0 -1
  77. data/tests/fixtures/fail23.json +0 -1
  78. data/tests/fixtures/fail24.json +0 -1
  79. data/tests/fixtures/fail25.json +0 -1
  80. data/tests/fixtures/fail27.json +0 -2
  81. data/tests/fixtures/fail28.json +0 -2
  82. data/tests/fixtures/fail3.json +0 -1
  83. data/tests/fixtures/fail4.json +0 -1
  84. data/tests/fixtures/fail5.json +0 -1
  85. data/tests/fixtures/fail6.json +0 -1
  86. data/tests/fixtures/fail7.json +0 -1
  87. data/tests/fixtures/fail8.json +0 -1
  88. data/tests/fixtures/fail9.json +0 -1
  89. data/tests/fixtures/pass1.json +0 -56
  90. data/tests/fixtures/pass15.json +0 -1
  91. data/tests/fixtures/pass16.json +0 -1
  92. data/tests/fixtures/pass17.json +0 -1
  93. data/tests/fixtures/pass2.json +0 -1
  94. data/tests/fixtures/pass26.json +0 -1
  95. data/tests/fixtures/pass3.json +0 -6
  96. data/tests/setup_variant.rb +0 -11
  97. data/tests/test_json.rb +0 -519
  98. data/tests/test_json_addition.rb +0 -196
  99. data/tests/test_json_encoding.rb +0 -65
  100. data/tests/test_json_fixtures.rb +0 -35
  101. data/tests/test_json_generate.rb +0 -348
  102. data/tests/test_json_generic_object.rb +0 -75
  103. data/tests/test_json_string_matching.rb +0 -39
  104. data/tests/test_json_unicode.rb +0 -72
  105. data/tools/diff.sh +0 -18
  106. data/tools/fuzz.rb +0 -139
  107. data/tools/server.rb +0 -62
@@ -1,7 +1,6 @@
1
1
  #ifndef _GENERATOR_H_
2
2
  #define _GENERATOR_H_
3
3
 
4
- #include <string.h>
5
4
  #include <math.h>
6
5
  #include <ctype.h>
7
6
 
@@ -21,10 +20,6 @@
21
20
  #define rb_obj_instance_variables(object) rb_funcall(object, rb_intern("instance_variables"), 0)
22
21
  #endif
23
22
 
24
- #ifndef RB_TYPE_P
25
- #define RB_TYPE_P(obj, type) (rb_type(obj) == type)
26
- #endif
27
-
28
23
  #define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
29
24
 
30
25
  /* unicode definitions */
@@ -54,8 +49,8 @@ static const UTF32 halfMask = 0x3FFUL;
54
49
  static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length);
55
50
  static void unicode_escape(char *buf, UTF16 character);
56
51
  static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character);
57
- static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string);
58
- static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string);
52
+ static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char script_safe);
53
+ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char script_safe);
59
54
  static char *fstrndup(const char *ptr, unsigned long len);
60
55
 
61
56
  /* ruby api and some helpers */
@@ -77,7 +72,8 @@ typedef struct JSON_Generator_StateStruct {
77
72
  long max_nesting;
78
73
  char allow_nan;
79
74
  char ascii_only;
80
- char quirks_mode;
75
+ char script_safe;
76
+ char strict;
81
77
  long depth;
82
78
  long buffer_initial_length;
83
79
  } JSON_Generator_State;
@@ -156,6 +152,10 @@ static VALUE cState_allow_nan_p(VALUE self);
156
152
  static VALUE cState_ascii_only_p(VALUE self);
157
153
  static VALUE cState_depth(VALUE self);
158
154
  static VALUE cState_depth_set(VALUE self, VALUE depth);
155
+ static VALUE cState_script_safe(VALUE self);
156
+ static VALUE cState_script_safe_set(VALUE self, VALUE depth);
157
+ static VALUE cState_strict(VALUE self);
158
+ static VALUE cState_strict_set(VALUE self, VALUE strict);
159
159
  static FBuffer *cState_prepare_buffer(VALUE self);
160
160
  #ifndef ZALLOC
161
161
  #define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
@@ -1,3 +1,32 @@
1
+ # frozen_string_literal: false
1
2
  require 'mkmf'
2
3
 
4
+ have_func("rb_enc_raise", "ruby.h")
5
+ have_func("rb_enc_interned_str", "ruby.h")
6
+
7
+ # checking if String#-@ (str_uminus) dedupes... '
8
+ begin
9
+ a = -(%w(t e s t).join)
10
+ b = -(%w(t e s t).join)
11
+ if a.equal?(b)
12
+ $CFLAGS << ' -DSTR_UMINUS_DEDUPE=1 '
13
+ else
14
+ $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
15
+ end
16
+ rescue NoMethodError
17
+ $CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
18
+ end
19
+
20
+ # checking if String#-@ (str_uminus) directly interns frozen strings... '
21
+ begin
22
+ s = rand.to_s.freeze
23
+ if (-s).equal?(s) && (-s.dup).equal?(s)
24
+ $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
25
+ else
26
+ $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
27
+ end
28
+ rescue NoMethodError
29
+ $CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
30
+ end
31
+
3
32
  create_makefile 'json/ext/parser'