json_pure 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 2011-05-11 (1.5.2)
2
+ * Apply documentation patch by Cory Monty <cory.monty@gmail.com>.
3
+ * Add gemspecs for json and json_pure.
4
+ * Fix bug in jruby pretty printing.
5
+ * Fix bug in object_class and array_class when inheriting from Hash or Array.
1
6
  2011-01-24 (1.5.1)
2
7
  * Made rake-compiler build a fat binary gem. This should fix issue
3
8
  https://github.com/flori/json/issues#issue/54.
File without changes
data/Rakefile CHANGED
@@ -1,22 +1,16 @@
1
1
  begin
2
- require 'rake/gempackagetask'
2
+ require 'rubygems/package_task'
3
3
  rescue LoadError
4
4
  end
5
5
 
6
- begin
7
- require 'rake/extensiontask'
8
- rescue LoadError
9
- warn "WARNING: rake-compiler is not installed. You will not be able to build the json gem until you install it."
10
- end
11
-
12
6
  require 'rbconfig'
13
7
  include Config
14
8
 
15
9
  require 'rake/clean'
16
- CLOBBER.include Dir['benchmarks/data/*.{dat,log}']
10
+ CLOBBER.include Dir['benchmarks/data/*.{dat,log}'], 'doc'
17
11
  CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp',
18
12
  FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'],
19
- FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class}"],
13
+ FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class,dSYM}"],
20
14
  FileList['java/src/**/*.class']
21
15
 
22
16
  MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
@@ -73,7 +67,7 @@ task :install_ext_really do
73
67
  end
74
68
 
75
69
  desc "Installing library (extension)"
76
- task :install_ext => [ :compile_ext, :install_pure, :install_ext_really ]
70
+ task :install_ext => [ :compile, :install_pure, :install_ext_really ]
77
71
 
78
72
  desc "Installing library (extension)"
79
73
  if RUBY_PLATFORM =~ /java/
@@ -82,7 +76,7 @@ else
82
76
  task :install => :install_ext
83
77
  end
84
78
 
85
- if defined?(Gem) and defined?(Rake::GemPackageTask)
79
+ if defined?(Gem) and defined?(Gem::PackageTask)
86
80
  spec_pure = Gem::Specification.new do |s|
87
81
  s.name = 'json_pure'
88
82
  s.version = PKG_VERSION
@@ -92,15 +86,16 @@ if defined?(Gem) and defined?(Rake::GemPackageTask)
92
86
  s.files = PKG_FILES
93
87
 
94
88
  s.require_path = 'lib'
89
+ s.add_development_dependency 'permutation'
90
+ s.add_development_dependency 'bullshit'
91
+ s.add_development_dependency 'sdoc'
95
92
 
96
93
  s.bindir = "bin"
97
94
  s.executables = [ "edit_json.rb", "prettify_json.rb" ]
98
- s.default_executable = "edit_json.rb"
99
95
 
100
- s.has_rdoc = true
101
- s.extra_rdoc_files << 'README'
96
+ s.extra_rdoc_files << 'README.rdoc'
102
97
  s.rdoc_options <<
103
- '--title' << 'JSON implemention for ruby' << '--main' << 'README'
98
+ '--title' << 'JSON implemention for ruby' << '--main' << 'README.rdoc'
104
99
  s.test_files.concat Dir['./tests/test_*.rb']
105
100
 
106
101
  s.author = "Florian Frank"
@@ -109,13 +104,18 @@ if defined?(Gem) and defined?(Rake::GemPackageTask)
109
104
  s.rubyforge_project = "json"
110
105
  end
111
106
 
112
- Rake::GemPackageTask.new(spec_pure) do |pkg|
107
+ desc 'Creates a json_pure.gemspec file'
108
+ task :gemspec_pure => :version do
109
+ File.open('json_pure.gemspec', 'w') do |gemspec|
110
+ gemspec.write spec_pure.to_ruby
111
+ end
112
+ end
113
+
114
+ Gem::PackageTask.new(spec_pure) do |pkg|
113
115
  pkg.need_tar = true
114
116
  pkg.package_files = PKG_FILES
115
117
  end
116
- end
117
118
 
118
- if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask)
119
119
  spec_ext = Gem::Specification.new do |s|
120
120
  s.name = 'json'
121
121
  s.version = PKG_VERSION
@@ -129,15 +129,16 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
129
129
  s.require_path = EXT_ROOT_DIR
130
130
  s.require_paths << 'ext'
131
131
  s.require_paths << 'lib'
132
+ s.add_development_dependency 'permutation'
133
+ s.add_development_dependency 'bullshit'
134
+ s.add_development_dependency 'sdoc'
132
135
 
133
136
  s.bindir = "bin"
134
137
  s.executables = [ "edit_json.rb", "prettify_json.rb" ]
135
- s.default_executable = "edit_json.rb"
136
138
 
137
- s.has_rdoc = true
138
- s.extra_rdoc_files << 'README'
139
+ s.extra_rdoc_files << 'README.rdoc'
139
140
  s.rdoc_options <<
140
- '--title' << 'JSON implemention for Ruby' << '--main' << 'README'
141
+ '--title' << 'JSON implemention for Ruby' << '--main' << 'README.rdoc'
141
142
  s.test_files.concat Dir['./tests/test_*.rb']
142
143
 
143
144
  s.author = "Florian Frank"
@@ -146,28 +147,21 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
146
147
  s.rubyforge_project = "json"
147
148
  end
148
149
 
149
- Rake::GemPackageTask.new(spec_ext) do |pkg|
150
+ desc 'Creates a json.gemspec file'
151
+ task :gemspec_ext => :version do
152
+ File.open('json.gemspec', 'w') do |gemspec|
153
+ gemspec.write spec_ext.to_ruby
154
+ end
155
+ end
156
+
157
+ Gem::PackageTask.new(spec_ext) do |pkg|
150
158
  pkg.need_tar = true
151
159
  pkg.package_files = PKG_FILES
152
160
  end
153
161
 
154
- Rake::ExtensionTask.new do |ext|
155
- ext.name = 'parser'
156
- ext.gem_spec = spec_ext
157
- ext.cross_compile = true
158
- ext.cross_platform = %w[i386-mswin32 i386-mingw32]
159
- ext.ext_dir = 'ext/json/ext/parser'
160
- ext.lib_dir = 'lib/json/ext'
161
- end
162
162
 
163
- Rake::ExtensionTask.new do |ext|
164
- ext.name = 'generator'
165
- ext.gem_spec = spec_ext
166
- ext.cross_compile = true
167
- ext.cross_platform = %w[i386-mswin32 i386-mingw32]
168
- ext.ext_dir = 'ext/json/ext/generator'
169
- ext.lib_dir = 'lib/json/ext'
170
- end
163
+ desc 'Create all gemspec files'
164
+ task :gemspec => [ :gemspec_pure, :gemspec_ext ]
171
165
  end
172
166
 
173
167
  desc m = "Writing version information for #{PKG_VERSION}"
@@ -197,7 +191,6 @@ end
197
191
  desc "Testing library (pure ruby and extension)"
198
192
  task :test => [ :test_pure, :test_ext ]
199
193
 
200
-
201
194
  if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
202
195
  file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do
203
196
  cd JAVA_DIR do
@@ -232,7 +225,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
232
225
  end
233
226
 
234
227
  desc "Compiling jruby extension"
235
- task :compile_ext => JAVA_CLASSES
228
+ task :compile => JAVA_CLASSES
236
229
 
237
230
  desc "Package the jruby gem"
238
231
  task :jruby_gem => :create_jar do
@@ -247,7 +240,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
247
240
  myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb']
248
241
  end
249
242
 
250
- file JRUBY_PARSER_JAR => :compile_ext do
243
+ file JRUBY_PARSER_JAR => :compile do
251
244
  cd 'java/src' do
252
245
  parser_classes = FileList[
253
246
  "json/ext/ByteListTranscoder*.class",
@@ -265,7 +258,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
265
258
  desc "Create parser jar"
266
259
  task :create_parser_jar => JRUBY_PARSER_JAR
267
260
 
268
- file JRUBY_GENERATOR_JAR => :compile_ext do
261
+ file JRUBY_GENERATOR_JAR => :compile do
269
262
  cd 'java/src' do
270
263
  generator_classes = FileList[
271
264
  "json/ext/ByteListTranscoder*.class",
@@ -290,7 +283,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
290
283
  task :release => [ :clean, :version, :jruby_gem ]
291
284
  else
292
285
  desc "Compiling extension"
293
- task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
286
+ task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
294
287
 
295
288
  file EXT_PARSER_DL => EXT_PARSER_SRC do
296
289
  cd EXT_PARSER_DIR do
@@ -309,7 +302,7 @@ else
309
302
  end
310
303
 
311
304
  desc "Testing library (extension)"
312
- task :test_ext => :compile_ext do
305
+ task :test_ext => :compile do
313
306
  ENV['JSON'] = 'ext'
314
307
  ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
315
308
  myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
@@ -334,7 +327,7 @@ else
334
327
 
335
328
  desc "Create RDOC documentation"
336
329
  task :doc => [ :version, EXT_PARSER_SRC ] do
337
- sh "sdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
330
+ sh "sdoc -o doc -t '#{PKG_TITLE}' -m README.rdoc README.rdoc lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
338
331
  end
339
332
 
340
333
  desc "Generate parser with ragel"
@@ -386,16 +379,9 @@ else
386
379
  desc "Generate diagrams of ragel parser"
387
380
  task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
388
381
 
389
- task :environment do
390
- ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2'
391
- end
392
-
393
382
  desc "Build all gems and archives for a new release of json and json_pure."
394
- task :release => [ :clean, :version, :environment, :cross, :native, :gem, ] do
395
- sh "#$0 clean native gem"
396
- sh "#$0 clean package"
397
- end
383
+ task :release => [ :clean, :gemspec, :package ]
398
384
  end
399
385
 
400
386
  desc "Compile in the the source directory"
401
- task :default => [ :version ]
387
+ task :default => [ :clean, :gemspec, :compile ]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.1
1
+ 1.5.2
@@ -62,7 +62,7 @@ static const char trailingBytesForUTF8[256] = {
62
62
  * in a UTF-8 sequence.
63
63
  */
64
64
  static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
65
- 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
65
+ 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
66
66
 
67
67
  /*
68
68
  * Utility routine to tell whether a sequence of bytes is legal UTF-8.
@@ -363,23 +363,23 @@ static void fbuffer_append_char(FBuffer *fb, char newchr)
363
363
 
364
364
  static void freverse(char *start, char *end)
365
365
  {
366
- char c;
366
+ char c;
367
367
 
368
- while (end > start) {
369
- c = *end, *end-- = *start, *start++ = c;
368
+ while (end > start) {
369
+ c = *end, *end-- = *start, *start++ = c;
370
370
  }
371
371
  }
372
372
 
373
373
  static long fltoa(long number, char *buf)
374
374
  {
375
- static char digits[] = "0123456789";
376
- long sign = number;
377
- char* tmp = buf;
375
+ static char digits[] = "0123456789";
376
+ long sign = number;
377
+ char* tmp = buf;
378
378
 
379
- if (sign < 0) number = -number;
379
+ if (sign < 0) number = -number;
380
380
  do *tmp++ = digits[number % 10]; while (number /= 10);
381
- if (sign < 0) *tmp++ = '-';
382
- freverse(buf, tmp - 1);
381
+ if (sign < 0) *tmp++ = '-';
382
+ freverse(buf, tmp - 1);
383
383
  return tmp - buf;
384
384
  }
385
385
 
@@ -561,6 +561,7 @@ static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self)
561
561
  /*
562
562
  * call-seq: to_json(*)
563
563
  *
564
+ * Returns a JSON string for nil: 'null'.
564
565
  */
565
566
  static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self)
566
567
  {
@@ -79,9 +79,9 @@ static VALUE fbuffer_to_s(FBuffer *fb);
79
79
 
80
80
  #define UNI_STRICT_CONVERSION 1
81
81
 
82
- typedef unsigned long UTF32; /* at least 32 bits */
83
- typedef unsigned short UTF16; /* at least 16 bits */
84
- typedef unsigned char UTF8; /* typically 8 bits */
82
+ typedef unsigned long UTF32; /* at least 32 bits */
83
+ typedef unsigned short UTF16; /* at least 16 bits */
84
+ typedef unsigned char UTF8; /* typically 8 bits */
85
85
 
86
86
  #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
87
87
  #define UNI_MAX_BMP (UTF32)0x0000FFFF
@@ -79,7 +79,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity;
79
79
 
80
80
  static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
81
81
  i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
82
- i_array_class, i_key_p, i_deep_const_get, i_match, i_match_string;
82
+ i_array_class, i_key_p, i_deep_const_get, i_match, i_match_string, i_aset, i_leftshift;
83
83
 
84
84
 
85
85
  #line 108 "parser.rl"
@@ -94,7 +94,7 @@ static const int JSON_object_error = 0;
94
94
  static const int JSON_object_en_main = 1;
95
95
 
96
96
 
97
- #line 144 "parser.rl"
97
+ #line 148 "parser.rl"
98
98
 
99
99
 
100
100
  static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -115,7 +115,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
115
115
  cs = JSON_object_start;
116
116
  }
117
117
 
118
- #line 159 "parser.rl"
118
+ #line 163 "parser.rl"
119
119
 
120
120
  #line 121 "parser.c"
121
121
  {
@@ -145,7 +145,7 @@ case 2:
145
145
  goto st2;
146
146
  goto st0;
147
147
  tr2:
148
- #line 127 "parser.rl"
148
+ #line 131 "parser.rl"
149
149
  {
150
150
  char *np;
151
151
  json->parsing_name = 1;
@@ -232,7 +232,11 @@ tr11:
232
232
  if (np == NULL) {
233
233
  p--; {p++; cs = 9; goto _out;}
234
234
  } else {
235
- rb_hash_aset(*result, last_name, v);
235
+ if (NIL_P(json->object_class)) {
236
+ rb_hash_aset(*result, last_name, v);
237
+ } else {
238
+ rb_funcall(*result, i_aset, 2, last_name, v);
239
+ }
236
240
  {p = (( np))-1;}
237
241
  }
238
242
  }
@@ -241,7 +245,7 @@ st9:
241
245
  if ( ++p == pe )
242
246
  goto _test_eof9;
243
247
  case 9:
244
- #line 245 "parser.c"
248
+ #line 249 "parser.c"
245
249
  switch( (*p) ) {
246
250
  case 13: goto st9;
247
251
  case 32: goto st9;
@@ -330,14 +334,14 @@ case 18:
330
334
  goto st9;
331
335
  goto st18;
332
336
  tr4:
333
- #line 135 "parser.rl"
337
+ #line 139 "parser.rl"
334
338
  { p--; {p++; cs = 27; goto _out;} }
335
339
  goto st27;
336
340
  st27:
337
341
  if ( ++p == pe )
338
342
  goto _test_eof27;
339
343
  case 27:
340
- #line 341 "parser.c"
344
+ #line 345 "parser.c"
341
345
  goto st0;
342
346
  st19:
343
347
  if ( ++p == pe )
@@ -435,7 +439,7 @@ case 26:
435
439
  _out: {}
436
440
  }
437
441
 
438
- #line 160 "parser.rl"
442
+ #line 164 "parser.rl"
439
443
 
440
444
  if (cs >= JSON_object_first_final) {
441
445
  if (json->create_additions) {
@@ -454,7 +458,7 @@ case 26:
454
458
  }
455
459
 
456
460
 
457
- #line 458 "parser.c"
461
+ #line 462 "parser.c"
458
462
  static const int JSON_value_start = 1;
459
463
  static const int JSON_value_first_final = 21;
460
464
  static const int JSON_value_error = 0;
@@ -462,7 +466,7 @@ static const int JSON_value_error = 0;
462
466
  static const int JSON_value_en_main = 1;
463
467
 
464
468
 
465
- #line 258 "parser.rl"
469
+ #line 262 "parser.rl"
466
470
 
467
471
 
468
472
  static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -470,14 +474,14 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
470
474
  int cs = EVIL;
471
475
 
472
476
 
473
- #line 474 "parser.c"
477
+ #line 478 "parser.c"
474
478
  {
475
479
  cs = JSON_value_start;
476
480
  }
477
481
 
478
- #line 265 "parser.rl"
482
+ #line 269 "parser.rl"
479
483
 
480
- #line 481 "parser.c"
484
+ #line 485 "parser.c"
481
485
  {
482
486
  if ( p == pe )
483
487
  goto _test_eof;
@@ -502,14 +506,14 @@ st0:
502
506
  cs = 0;
503
507
  goto _out;
504
508
  tr0:
505
- #line 206 "parser.rl"
509
+ #line 210 "parser.rl"
506
510
  {
507
511
  char *np = JSON_parse_string(json, p, pe, result);
508
512
  if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
509
513
  }
510
514
  goto st21;
511
515
  tr2:
512
- #line 211 "parser.rl"
516
+ #line 215 "parser.rl"
513
517
  {
514
518
  char *np;
515
519
  if(pe > p + 9 && !strncmp(MinusInfinity, p, 9)) {
@@ -529,7 +533,7 @@ tr2:
529
533
  }
530
534
  goto st21;
531
535
  tr5:
532
- #line 229 "parser.rl"
536
+ #line 233 "parser.rl"
533
537
  {
534
538
  char *np;
535
539
  json->current_nesting++;
@@ -539,7 +543,7 @@ tr5:
539
543
  }
540
544
  goto st21;
541
545
  tr9:
542
- #line 237 "parser.rl"
546
+ #line 241 "parser.rl"
543
547
  {
544
548
  char *np;
545
549
  json->current_nesting++;
@@ -549,7 +553,7 @@ tr9:
549
553
  }
550
554
  goto st21;
551
555
  tr16:
552
- #line 199 "parser.rl"
556
+ #line 203 "parser.rl"
553
557
  {
554
558
  if (json->allow_nan) {
555
559
  *result = CInfinity;
@@ -559,7 +563,7 @@ tr16:
559
563
  }
560
564
  goto st21;
561
565
  tr18:
562
- #line 192 "parser.rl"
566
+ #line 196 "parser.rl"
563
567
  {
564
568
  if (json->allow_nan) {
565
569
  *result = CNaN;
@@ -569,19 +573,19 @@ tr18:
569
573
  }
570
574
  goto st21;
571
575
  tr22:
572
- #line 186 "parser.rl"
576
+ #line 190 "parser.rl"
573
577
  {
574
578
  *result = Qfalse;
575
579
  }
576
580
  goto st21;
577
581
  tr25:
578
- #line 183 "parser.rl"
582
+ #line 187 "parser.rl"
579
583
  {
580
584
  *result = Qnil;
581
585
  }
582
586
  goto st21;
583
587
  tr28:
584
- #line 189 "parser.rl"
588
+ #line 193 "parser.rl"
585
589
  {
586
590
  *result = Qtrue;
587
591
  }
@@ -590,9 +594,9 @@ st21:
590
594
  if ( ++p == pe )
591
595
  goto _test_eof21;
592
596
  case 21:
593
- #line 245 "parser.rl"
597
+ #line 249 "parser.rl"
594
598
  { p--; {p++; cs = 21; goto _out;} }
595
- #line 596 "parser.c"
599
+ #line 600 "parser.c"
596
600
  goto st0;
597
601
  st2:
598
602
  if ( ++p == pe )
@@ -753,7 +757,7 @@ case 20:
753
757
  _out: {}
754
758
  }
755
759
 
756
- #line 266 "parser.rl"
760
+ #line 270 "parser.rl"
757
761
 
758
762
  if (cs >= JSON_value_first_final) {
759
763
  return p;
@@ -763,7 +767,7 @@ case 20:
763
767
  }
764
768
 
765
769
 
766
- #line 767 "parser.c"
770
+ #line 771 "parser.c"
767
771
  static const int JSON_integer_start = 1;
768
772
  static const int JSON_integer_first_final = 5;
769
773
  static const int JSON_integer_error = 0;
@@ -771,7 +775,7 @@ static const int JSON_integer_error = 0;
771
775
  static const int JSON_integer_en_main = 1;
772
776
 
773
777
 
774
- #line 282 "parser.rl"
778
+ #line 286 "parser.rl"
775
779
 
776
780
 
777
781
  static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -779,15 +783,15 @@ static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *res
779
783
  int cs = EVIL;
780
784
 
781
785
 
782
- #line 783 "parser.c"
786
+ #line 787 "parser.c"
783
787
  {
784
788
  cs = JSON_integer_start;
785
789
  }
786
790
 
787
- #line 289 "parser.rl"
791
+ #line 293 "parser.rl"
788
792
  json->memo = p;
789
793
 
790
- #line 791 "parser.c"
794
+ #line 795 "parser.c"
791
795
  {
792
796
  if ( p == pe )
793
797
  goto _test_eof;
@@ -821,14 +825,14 @@ case 3:
821
825
  goto st0;
822
826
  goto tr4;
823
827
  tr4:
824
- #line 279 "parser.rl"
828
+ #line 283 "parser.rl"
825
829
  { p--; {p++; cs = 5; goto _out;} }
826
830
  goto st5;
827
831
  st5:
828
832
  if ( ++p == pe )
829
833
  goto _test_eof5;
830
834
  case 5:
831
- #line 832 "parser.c"
835
+ #line 836 "parser.c"
832
836
  goto st0;
833
837
  st4:
834
838
  if ( ++p == pe )
@@ -847,7 +851,7 @@ case 4:
847
851
  _out: {}
848
852
  }
849
853
 
850
- #line 291 "parser.rl"
854
+ #line 295 "parser.rl"
851
855
 
852
856
  if (cs >= JSON_integer_first_final) {
853
857
  long len = p - json->memo;
@@ -859,7 +863,7 @@ case 4:
859
863
  }
860
864
 
861
865
 
862
- #line 863 "parser.c"
866
+ #line 867 "parser.c"
863
867
  static const int JSON_float_start = 1;
864
868
  static const int JSON_float_first_final = 10;
865
869
  static const int JSON_float_error = 0;
@@ -867,7 +871,7 @@ static const int JSON_float_error = 0;
867
871
  static const int JSON_float_en_main = 1;
868
872
 
869
873
 
870
- #line 313 "parser.rl"
874
+ #line 317 "parser.rl"
871
875
 
872
876
 
873
877
  static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -875,15 +879,15 @@ static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *resul
875
879
  int cs = EVIL;
876
880
 
877
881
 
878
- #line 879 "parser.c"
882
+ #line 883 "parser.c"
879
883
  {
880
884
  cs = JSON_float_start;
881
885
  }
882
886
 
883
- #line 320 "parser.rl"
887
+ #line 324 "parser.rl"
884
888
  json->memo = p;
885
889
 
886
- #line 887 "parser.c"
890
+ #line 891 "parser.c"
887
891
  {
888
892
  if ( p == pe )
889
893
  goto _test_eof;
@@ -941,14 +945,14 @@ case 5:
941
945
  goto st0;
942
946
  goto tr7;
943
947
  tr7:
944
- #line 307 "parser.rl"
948
+ #line 311 "parser.rl"
945
949
  { p--; {p++; cs = 10; goto _out;} }
946
950
  goto st10;
947
951
  st10:
948
952
  if ( ++p == pe )
949
953
  goto _test_eof10;
950
954
  case 10:
951
- #line 952 "parser.c"
955
+ #line 956 "parser.c"
952
956
  goto st0;
953
957
  st6:
954
958
  if ( ++p == pe )
@@ -1009,7 +1013,7 @@ case 9:
1009
1013
  _out: {}
1010
1014
  }
1011
1015
 
1012
- #line 322 "parser.rl"
1016
+ #line 326 "parser.rl"
1013
1017
 
1014
1018
  if (cs >= JSON_float_first_final) {
1015
1019
  long len = p - json->memo;
@@ -1022,7 +1026,7 @@ case 9:
1022
1026
 
1023
1027
 
1024
1028
 
1025
- #line 1026 "parser.c"
1029
+ #line 1030 "parser.c"
1026
1030
  static const int JSON_array_start = 1;
1027
1031
  static const int JSON_array_first_final = 17;
1028
1032
  static const int JSON_array_error = 0;
@@ -1030,7 +1034,7 @@ static const int JSON_array_error = 0;
1030
1034
  static const int JSON_array_en_main = 1;
1031
1035
 
1032
1036
 
1033
- #line 358 "parser.rl"
1037
+ #line 366 "parser.rl"
1034
1038
 
1035
1039
 
1036
1040
  static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -1044,14 +1048,14 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
1044
1048
  *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
1045
1049
 
1046
1050
 
1047
- #line 1048 "parser.c"
1051
+ #line 1052 "parser.c"
1048
1052
  {
1049
1053
  cs = JSON_array_start;
1050
1054
  }
1051
1055
 
1052
- #line 371 "parser.rl"
1056
+ #line 379 "parser.rl"
1053
1057
 
1054
- #line 1055 "parser.c"
1058
+ #line 1059 "parser.c"
1055
1059
  {
1056
1060
  if ( p == pe )
1057
1061
  goto _test_eof;
@@ -1090,14 +1094,18 @@ case 2:
1090
1094
  goto st2;
1091
1095
  goto st0;
1092
1096
  tr2:
1093
- #line 339 "parser.rl"
1097
+ #line 343 "parser.rl"
1094
1098
  {
1095
1099
  VALUE v = Qnil;
1096
1100
  char *np = JSON_parse_value(json, p, pe, &v);
1097
1101
  if (np == NULL) {
1098
1102
  p--; {p++; cs = 3; goto _out;}
1099
1103
  } else {
1100
- rb_ary_push(*result, v);
1104
+ if (NIL_P(json->array_class)) {
1105
+ rb_ary_push(*result, v);
1106
+ } else {
1107
+ rb_funcall(*result, i_leftshift, 1, v);
1108
+ }
1101
1109
  {p = (( np))-1;}
1102
1110
  }
1103
1111
  }
@@ -1106,7 +1114,7 @@ st3:
1106
1114
  if ( ++p == pe )
1107
1115
  goto _test_eof3;
1108
1116
  case 3:
1109
- #line 1110 "parser.c"
1117
+ #line 1118 "parser.c"
1110
1118
  switch( (*p) ) {
1111
1119
  case 13: goto st3;
1112
1120
  case 32: goto st3;
@@ -1206,14 +1214,14 @@ case 12:
1206
1214
  goto st3;
1207
1215
  goto st12;
1208
1216
  tr4:
1209
- #line 350 "parser.rl"
1217
+ #line 358 "parser.rl"
1210
1218
  { p--; {p++; cs = 17; goto _out;} }
1211
1219
  goto st17;
1212
1220
  st17:
1213
1221
  if ( ++p == pe )
1214
1222
  goto _test_eof17;
1215
1223
  case 17:
1216
- #line 1217 "parser.c"
1224
+ #line 1225 "parser.c"
1217
1225
  goto st0;
1218
1226
  st13:
1219
1227
  if ( ++p == pe )
@@ -1269,7 +1277,7 @@ case 16:
1269
1277
  _out: {}
1270
1278
  }
1271
1279
 
1272
- #line 372 "parser.rl"
1280
+ #line 380 "parser.rl"
1273
1281
 
1274
1282
  if(cs >= JSON_array_first_final) {
1275
1283
  return p + 1;
@@ -1350,7 +1358,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
1350
1358
  }
1351
1359
 
1352
1360
 
1353
- #line 1354 "parser.c"
1361
+ #line 1362 "parser.c"
1354
1362
  static const int JSON_string_start = 1;
1355
1363
  static const int JSON_string_first_final = 8;
1356
1364
  static const int JSON_string_error = 0;
@@ -1358,7 +1366,7 @@ static const int JSON_string_error = 0;
1358
1366
  static const int JSON_string_en_main = 1;
1359
1367
 
1360
1368
 
1361
- #line 471 "parser.rl"
1369
+ #line 479 "parser.rl"
1362
1370
 
1363
1371
 
1364
1372
  static int
@@ -1380,15 +1388,15 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
1380
1388
 
1381
1389
  *result = rb_str_buf_new(0);
1382
1390
 
1383
- #line 1384 "parser.c"
1391
+ #line 1392 "parser.c"
1384
1392
  {
1385
1393
  cs = JSON_string_start;
1386
1394
  }
1387
1395
 
1388
- #line 492 "parser.rl"
1396
+ #line 500 "parser.rl"
1389
1397
  json->memo = p;
1390
1398
 
1391
- #line 1392 "parser.c"
1399
+ #line 1400 "parser.c"
1392
1400
  {
1393
1401
  if ( p == pe )
1394
1402
  goto _test_eof;
@@ -1413,7 +1421,7 @@ case 2:
1413
1421
  goto st0;
1414
1422
  goto st2;
1415
1423
  tr2:
1416
- #line 457 "parser.rl"
1424
+ #line 465 "parser.rl"
1417
1425
  {
1418
1426
  *result = json_string_unescape(*result, json->memo + 1, p);
1419
1427
  if (NIL_P(*result)) {
@@ -1424,14 +1432,14 @@ tr2:
1424
1432
  {p = (( p + 1))-1;}
1425
1433
  }
1426
1434
  }
1427
- #line 468 "parser.rl"
1435
+ #line 476 "parser.rl"
1428
1436
  { p--; {p++; cs = 8; goto _out;} }
1429
1437
  goto st8;
1430
1438
  st8:
1431
1439
  if ( ++p == pe )
1432
1440
  goto _test_eof8;
1433
1441
  case 8:
1434
- #line 1435 "parser.c"
1442
+ #line 1443 "parser.c"
1435
1443
  goto st0;
1436
1444
  st3:
1437
1445
  if ( ++p == pe )
@@ -1507,7 +1515,7 @@ case 7:
1507
1515
  _out: {}
1508
1516
  }
1509
1517
 
1510
- #line 494 "parser.rl"
1518
+ #line 502 "parser.rl"
1511
1519
 
1512
1520
  if (json->create_additions && RTEST(match_string = json->match_string)) {
1513
1521
  VALUE klass;
@@ -1532,7 +1540,7 @@ case 7:
1532
1540
 
1533
1541
 
1534
1542
 
1535
- #line 1536 "parser.c"
1543
+ #line 1544 "parser.c"
1536
1544
  static const int JSON_start = 1;
1537
1545
  static const int JSON_first_final = 10;
1538
1546
  static const int JSON_error = 0;
@@ -1540,7 +1548,7 @@ static const int JSON_error = 0;
1540
1548
  static const int JSON_en_main = 1;
1541
1549
 
1542
1550
 
1543
- #line 542 "parser.rl"
1551
+ #line 550 "parser.rl"
1544
1552
 
1545
1553
 
1546
1554
  /*
@@ -1729,16 +1737,16 @@ static VALUE cParser_parse(VALUE self)
1729
1737
  GET_PARSER;
1730
1738
 
1731
1739
 
1732
- #line 1733 "parser.c"
1740
+ #line 1741 "parser.c"
1733
1741
  {
1734
1742
  cs = JSON_start;
1735
1743
  }
1736
1744
 
1737
- #line 730 "parser.rl"
1745
+ #line 738 "parser.rl"
1738
1746
  p = json->source;
1739
1747
  pe = p + json->len;
1740
1748
 
1741
- #line 1742 "parser.c"
1749
+ #line 1750 "parser.c"
1742
1750
  {
1743
1751
  if ( p == pe )
1744
1752
  goto _test_eof;
@@ -1794,7 +1802,7 @@ case 5:
1794
1802
  goto st1;
1795
1803
  goto st5;
1796
1804
  tr3:
1797
- #line 531 "parser.rl"
1805
+ #line 539 "parser.rl"
1798
1806
  {
1799
1807
  char *np;
1800
1808
  json->current_nesting = 1;
@@ -1803,7 +1811,7 @@ tr3:
1803
1811
  }
1804
1812
  goto st10;
1805
1813
  tr4:
1806
- #line 524 "parser.rl"
1814
+ #line 532 "parser.rl"
1807
1815
  {
1808
1816
  char *np;
1809
1817
  json->current_nesting = 1;
@@ -1815,7 +1823,7 @@ st10:
1815
1823
  if ( ++p == pe )
1816
1824
  goto _test_eof10;
1817
1825
  case 10:
1818
- #line 1819 "parser.c"
1826
+ #line 1827 "parser.c"
1819
1827
  switch( (*p) ) {
1820
1828
  case 13: goto st10;
1821
1829
  case 32: goto st10;
@@ -1872,7 +1880,7 @@ case 9:
1872
1880
  _out: {}
1873
1881
  }
1874
1882
 
1875
- #line 733 "parser.rl"
1883
+ #line 741 "parser.rl"
1876
1884
 
1877
1885
  if (cs >= JSON_first_final && p == pe) {
1878
1886
  return result;
@@ -1952,6 +1960,8 @@ void Init_parser()
1952
1960
  i_match_string = rb_intern("match_string");
1953
1961
  i_key_p = rb_intern("key?");
1954
1962
  i_deep_const_get = rb_intern("deep_const_get");
1963
+ i_aset = rb_intern("[]=");
1964
+ i_leftshift = rb_intern("<<");
1955
1965
  #ifdef HAVE_RUBY_ENCODING_H
1956
1966
  CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
1957
1967
  CEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be"));