json 1.0.0 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES.md +503 -0
  3. data/LICENSE +56 -0
  4. data/README.md +416 -0
  5. data/ext/json/ext/fbuffer/fbuffer.h +187 -0
  6. data/ext/json/ext/generator/depend +1 -0
  7. data/ext/json/ext/generator/extconf.rb +2 -7
  8. data/ext/json/ext/generator/generator.c +1312 -338
  9. data/ext/json/ext/generator/generator.h +177 -0
  10. data/ext/json/ext/parser/depend +1 -0
  11. data/ext/json/ext/parser/extconf.rb +28 -5
  12. data/ext/json/ext/parser/parser.c +1349 -689
  13. data/ext/json/ext/parser/parser.h +96 -0
  14. data/ext/json/ext/parser/parser.rl +644 -188
  15. data/ext/json/extconf.rb +3 -0
  16. data/json.gemspec +68 -0
  17. data/lib/json/add/bigdecimal.rb +58 -0
  18. data/lib/json/add/complex.rb +51 -0
  19. data/lib/json/add/core.rb +12 -0
  20. data/lib/json/add/date.rb +54 -0
  21. data/lib/json/add/date_time.rb +67 -0
  22. data/lib/json/add/exception.rb +49 -0
  23. data/lib/json/add/ostruct.rb +54 -0
  24. data/lib/json/add/range.rb +54 -0
  25. data/lib/json/add/rational.rb +49 -0
  26. data/lib/json/add/regexp.rb +48 -0
  27. data/lib/json/add/set.rb +48 -0
  28. data/lib/json/add/struct.rb +52 -0
  29. data/lib/json/add/symbol.rb +48 -0
  30. data/lib/json/add/time.rb +59 -0
  31. data/lib/json/common.rb +588 -74
  32. data/lib/json/ext.rb +3 -1
  33. data/lib/json/generic_object.rb +75 -0
  34. data/lib/json/pure/generator.rb +311 -119
  35. data/lib/json/pure/parser.rb +182 -55
  36. data/lib/json/pure.rb +5 -65
  37. data/lib/json/version.rb +2 -1
  38. data/lib/json.rb +583 -196
  39. metadata +78 -137
  40. data/CHANGES +0 -25
  41. data/GPL +0 -340
  42. data/README +0 -77
  43. data/Rakefile +0 -250
  44. data/TODO +0 -1
  45. data/VERSION +0 -1
  46. data/benchmarks/benchmark.txt +0 -133
  47. data/benchmarks/benchmark_generator.rb +0 -44
  48. data/benchmarks/benchmark_parser.rb +0 -22
  49. data/benchmarks/benchmark_rails.rb +0 -26
  50. data/bin/edit_json.rb +0 -11
  51. data/data/example.json +0 -1
  52. data/data/index.html +0 -37
  53. data/data/prototype.js +0 -2515
  54. data/ext/json/ext/generator/Makefile +0 -149
  55. data/ext/json/ext/generator/unicode.c +0 -184
  56. data/ext/json/ext/generator/unicode.h +0 -40
  57. data/ext/json/ext/parser/Makefile +0 -149
  58. data/ext/json/ext/parser/unicode.c +0 -156
  59. data/ext/json/ext/parser/unicode.h +0 -44
  60. data/install.rb +0 -26
  61. data/lib/json/Array.xpm +0 -21
  62. data/lib/json/FalseClass.xpm +0 -21
  63. data/lib/json/Hash.xpm +0 -21
  64. data/lib/json/Key.xpm +0 -73
  65. data/lib/json/NilClass.xpm +0 -21
  66. data/lib/json/Numeric.xpm +0 -28
  67. data/lib/json/String.xpm +0 -96
  68. data/lib/json/TrueClass.xpm +0 -21
  69. data/lib/json/editor.rb +0 -1207
  70. data/lib/json/json.xpm +0 -1499
  71. data/tests/fixtures/fail1.json +0 -1
  72. data/tests/fixtures/fail10.json +0 -1
  73. data/tests/fixtures/fail11.json +0 -1
  74. data/tests/fixtures/fail12.json +0 -1
  75. data/tests/fixtures/fail13.json +0 -1
  76. data/tests/fixtures/fail14.json +0 -1
  77. data/tests/fixtures/fail15.json +0 -1
  78. data/tests/fixtures/fail16.json +0 -1
  79. data/tests/fixtures/fail17.json +0 -1
  80. data/tests/fixtures/fail19.json +0 -1
  81. data/tests/fixtures/fail2.json +0 -1
  82. data/tests/fixtures/fail20.json +0 -1
  83. data/tests/fixtures/fail21.json +0 -1
  84. data/tests/fixtures/fail22.json +0 -1
  85. data/tests/fixtures/fail23.json +0 -1
  86. data/tests/fixtures/fail24.json +0 -1
  87. data/tests/fixtures/fail25.json +0 -1
  88. data/tests/fixtures/fail26.json +0 -1
  89. data/tests/fixtures/fail27.json +0 -2
  90. data/tests/fixtures/fail28.json +0 -2
  91. data/tests/fixtures/fail3.json +0 -1
  92. data/tests/fixtures/fail4.json +0 -1
  93. data/tests/fixtures/fail5.json +0 -1
  94. data/tests/fixtures/fail6.json +0 -1
  95. data/tests/fixtures/fail7.json +0 -1
  96. data/tests/fixtures/fail8.json +0 -1
  97. data/tests/fixtures/fail9.json +0 -1
  98. data/tests/fixtures/pass1.json +0 -56
  99. data/tests/fixtures/pass18.json +0 -1
  100. data/tests/fixtures/pass2.json +0 -1
  101. data/tests/fixtures/pass3.json +0 -6
  102. data/tests/runner.rb +0 -24
  103. data/tests/test_json.rb +0 -235
  104. data/tests/test_json_addition.rb +0 -94
  105. data/tests/test_json_fixtures.rb +0 -30
  106. data/tests/test_json_generate.rb +0 -81
  107. data/tests/test_json_unicode.rb +0 -55
  108. data/tools/fuzz.rb +0 -133
  109. data/tools/server.rb +0 -62
@@ -0,0 +1,96 @@
1
+ #ifndef _PARSER_H_
2
+ #define _PARSER_H_
3
+
4
+ #include "ruby.h"
5
+
6
+ #ifndef HAVE_RUBY_RE_H
7
+ #include "re.h"
8
+ #endif
9
+
10
+ #ifdef HAVE_RUBY_ST_H
11
+ #include "ruby/st.h"
12
+ #else
13
+ #include "st.h"
14
+ #endif
15
+
16
+ #ifndef MAYBE_UNUSED
17
+ # define MAYBE_UNUSED(x) x
18
+ #endif
19
+
20
+ #define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
21
+
22
+ /* unicode */
23
+
24
+ typedef unsigned long UTF32; /* at least 32 bits */
25
+ typedef unsigned short UTF16; /* at least 16 bits */
26
+ typedef unsigned char UTF8; /* typically 8 bits */
27
+
28
+ #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
29
+ #define UNI_SUR_HIGH_START (UTF32)0xD800
30
+ #define UNI_SUR_HIGH_END (UTF32)0xDBFF
31
+ #define UNI_SUR_LOW_START (UTF32)0xDC00
32
+ #define UNI_SUR_LOW_END (UTF32)0xDFFF
33
+
34
+ typedef struct JSON_ParserStruct {
35
+ VALUE Vsource;
36
+ char *source;
37
+ long len;
38
+ char *memo;
39
+ VALUE create_id;
40
+ int max_nesting;
41
+ int allow_nan;
42
+ int parsing_name;
43
+ int symbolize_names;
44
+ int freeze;
45
+ VALUE object_class;
46
+ VALUE array_class;
47
+ VALUE decimal_class;
48
+ int create_additions;
49
+ VALUE match_string;
50
+ FBuffer *fbuffer;
51
+ } JSON_Parser;
52
+
53
+ #define GET_PARSER \
54
+ GET_PARSER_INIT; \
55
+ if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
56
+ #define GET_PARSER_INIT \
57
+ JSON_Parser *json; \
58
+ TypedData_Get_Struct(self, JSON_Parser, &JSON_Parser_type, json)
59
+
60
+ #define MinusInfinity "-Infinity"
61
+ #define EVIL 0x666
62
+
63
+ static UTF32 unescape_unicode(const unsigned char *p);
64
+ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch);
65
+ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
66
+ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
67
+ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
68
+ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
69
+ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting);
70
+ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize);
71
+ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
72
+ static VALUE convert_encoding(VALUE source);
73
+ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
74
+ static VALUE cParser_parse(VALUE self);
75
+ static void JSON_mark(void *json);
76
+ static void JSON_free(void *json);
77
+ static VALUE cJSON_parser_s_allocate(VALUE klass);
78
+ static VALUE cParser_source(VALUE self);
79
+ #ifndef ZALLOC
80
+ #define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
81
+ static inline void *ruby_zalloc(size_t n)
82
+ {
83
+ void *p = ruby_xmalloc(n);
84
+ memset(p, 0, n);
85
+ return p;
86
+ }
87
+ #endif
88
+ #ifdef TypedData_Make_Struct
89
+ static const rb_data_type_t JSON_Parser_type;
90
+ #define NEW_TYPEDDATA_WRAPPER 1
91
+ #else
92
+ #define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, JSON_free, json)
93
+ #define TypedData_Get_Struct(self, JSON_Parser, ignore, json) Data_Get_Struct(self, JSON_Parser, json)
94
+ #endif
95
+
96
+ #endif