json 1.0.3-mswin32 → 1.0.4-mswin32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of json might be problematic. Click here for more details.

data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ 2007-05-09 (1.0.4)
2
+ * Applied a patch from Yui NARUSE <naruse@airemix.com> to make JSON compile
3
+ under Ruby 1.9. Thank you very much for mailing it to me!
4
+ * Made binary variants of JSON fail early, instead of falling back to the
5
+ pure version. This should avoid overshadowing of eventual problems while
6
+ loading of the binary.
1
7
  2007-03-24 (1.0.3)
2
8
  * Improved performance of pure variant a bit.
3
9
  * The ext variant of this release supports the mswin32 platform. Ugh!
data/Rakefile CHANGED
@@ -290,6 +290,7 @@ module JSON
290
290
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
291
291
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
292
292
  VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
293
+ VARIANT_BINARY = #{!!ON_WINDOWS}
293
294
  end
294
295
  EOT
295
296
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -22,7 +22,7 @@ def go(s, args = ARGV)
22
22
  until p == ''
23
23
  o = p.slice!(0, 1)
24
24
  if v.key?(o)
25
- v[o] = if p == '': args.shift or break 1 else p end
25
+ v[o] = if p == '' then args.shift or break 1 else p end
26
26
  break
27
27
  elsif b.key?(o)
28
28
  b[o] = true
Binary file
@@ -30,7 +30,6 @@ typedef struct JSON_Generator_StateStruct {
30
30
  #define GET_STATE(self) \
31
31
  JSON_Generator_State *state; \
32
32
  Data_Get_Struct(self, JSON_Generator_State, state);
33
- #define FUL(string) RSTRING(string)->len
34
33
 
35
34
  /*
36
35
  * Document-module: JSON::Ext::Generator
@@ -55,19 +54,19 @@ static int hash_to_json_state_i(VALUE key, VALUE value, VALUE Vstate)
55
54
  if (state->flag) {
56
55
  state->flag = 0;
57
56
  rb_str_buf_cat2(buf, ",");
58
- if (FUL(state->object_nl)) rb_str_buf_append(buf, state->object_nl);
57
+ if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(buf, state->object_nl);
59
58
  }
60
- if (FUL(state->object_nl)) {
59
+ if (RSTRING_LEN(state->object_nl)) {
61
60
  rb_str_buf_append(buf, rb_str_times(state->indent, Vdepth));
62
61
  }
63
62
  json = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 2, Vstate, Vdepth);
64
63
  rb_str_buf_append(buf, json);
65
64
  OBJ_INFECT(buf, json);
66
- if (FUL(state->space_before)) {
65
+ if (RSTRING_LEN(state->space_before)) {
67
66
  rb_str_buf_append(buf, state->space_before);
68
67
  }
69
68
  rb_str_buf_cat2(buf, ":");
70
- if (FUL(state->space)) rb_str_buf_append(buf, state->space);
69
+ if (RSTRING_LEN(state->space)) rb_str_buf_append(buf, state->space);
71
70
  json = rb_funcall(value, i_to_json, 2, Vstate, Vdepth);
72
71
  state->flag = 1;
73
72
  rb_str_buf_append(buf, json);
@@ -88,10 +87,10 @@ inline static VALUE mHash_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth)
88
87
  state->depth = LONG2FIX(depth);
89
88
  state->flag = 0;
90
89
  rb_str_buf_cat2(result, "{");
91
- if (FUL(state->object_nl)) rb_str_buf_append(result, state->object_nl);
90
+ if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
92
91
  rb_hash_foreach(self, hash_to_json_state_i, Vstate);
93
- if (FUL(state->object_nl)) rb_str_buf_append(result, state->object_nl);
94
- if (FUL(state->object_nl)) {
92
+ if (RSTRING_LEN(state->object_nl)) rb_str_buf_append(result, state->object_nl);
93
+ if (RSTRING_LEN(state->object_nl)) {
95
94
  rb_str_buf_append(result, rb_str_times(state->indent, Vdepth));
96
95
  }
97
96
  rb_str_buf_cat2(result, "}");
@@ -103,7 +102,7 @@ static int hash_to_json_i(VALUE key, VALUE value, VALUE buf)
103
102
  VALUE tmp;
104
103
 
105
104
  if (key == Qundef) return ST_CONTINUE;
106
- if (RSTRING(buf)->len > 1) rb_str_buf_cat2(buf, ",");
105
+ if (RSTRING_LEN(buf) > 1) rb_str_buf_cat2(buf, ",");
107
106
  tmp = rb_funcall(rb_funcall(key, i_to_s, 0), i_to_json, 0);
108
107
  rb_str_buf_append(buf, tmp);
109
108
  OBJ_INFECT(buf, tmp);
@@ -157,7 +156,7 @@ static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
157
156
  }
158
157
 
159
158
  inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth) {
160
- long i, len = RARRAY(self)->len;
159
+ long i, len = RARRAY_LEN(self);
161
160
  VALUE shift, result;
162
161
  long depth = NIL_P(Vdepth) ? 0 : FIX2LONG(Vdepth);
163
162
  VALUE delim = rb_str_new2(",");
@@ -167,13 +166,13 @@ inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth
167
166
  VALUE self_id = rb_obj_id(self);
168
167
  rb_hash_aset(state->seen, self_id, Qtrue);
169
168
  result = rb_str_buf_new(len);
170
- if (FUL(state->array_nl)) rb_str_append(delim, state->array_nl);
169
+ if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
171
170
  shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
172
171
 
173
172
  rb_str_buf_cat2(result, "[");
174
173
  rb_str_buf_append(result, state->array_nl);
175
174
  for (i = 0; i < len; i++) {
176
- VALUE element = RARRAY(self)->ptr[i];
175
+ VALUE element = RARRAY_PTR(self)[i];
177
176
  if (RTEST(rb_hash_aref(state->seen, rb_obj_id(element)))) {
178
177
  rb_raise(eCircularDatastructure,
179
178
  "circular data structures not supported!");
@@ -183,7 +182,7 @@ inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth
183
182
  rb_str_buf_append(result, shift);
184
183
  rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
185
184
  }
186
- if (FUL(state->array_nl)) {
185
+ if (RSTRING_LEN(state->array_nl)) {
187
186
  rb_str_buf_append(result, state->array_nl);
188
187
  rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
189
188
  }
@@ -191,20 +190,20 @@ inline static VALUE mArray_json_transfrom(VALUE self, VALUE Vstate, VALUE Vdepth
191
190
  rb_hash_delete(state->seen, self_id);
192
191
  } else {
193
192
  result = rb_str_buf_new(len);
194
- if (FUL(state->array_nl)) rb_str_append(delim, state->array_nl);
193
+ if (RSTRING_LEN(state->array_nl)) rb_str_append(delim, state->array_nl);
195
194
  shift = rb_str_times(state->indent, LONG2FIX(depth + 1));
196
195
 
197
196
  rb_str_buf_cat2(result, "[");
198
197
  rb_str_buf_append(result, state->array_nl);
199
198
  for (i = 0; i < len; i++) {
200
- VALUE element = RARRAY(self)->ptr[i];
199
+ VALUE element = RARRAY_PTR(self)[i];
201
200
  OBJ_INFECT(result, element);
202
201
  if (i > 0) rb_str_buf_append(result, delim);
203
202
  rb_str_buf_append(result, shift);
204
203
  rb_str_buf_append(result, rb_funcall(element, i_to_json, 2, Vstate, LONG2FIX(depth + 1)));
205
204
  }
206
205
  rb_str_buf_append(result, state->array_nl);
207
- if (FUL(state->array_nl)) {
206
+ if (RSTRING_LEN(state->array_nl)) {
208
207
  rb_str_buf_append(result, rb_str_times(state->indent, LONG2FIX(depth)));
209
208
  }
210
209
  rb_str_buf_cat2(result, "]");
@@ -226,11 +225,11 @@ static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
226
225
 
227
226
  rb_scan_args(argc, argv, "02", &Vstate, &Vdepth);
228
227
  if (NIL_P(Vstate)) {
229
- long i, len = RARRAY(self)->len;
228
+ long i, len = RARRAY_LEN(self);
230
229
  result = rb_str_buf_new(2 + 2 * len);
231
230
  rb_str_buf_cat2(result, "[");
232
231
  for (i = 0; i < len; i++) {
233
- VALUE element = RARRAY(self)->ptr[i];
232
+ VALUE element = RARRAY_PTR(self)[i];
234
233
  OBJ_INFECT(result, element);
235
234
  if (i > 0) rb_str_buf_cat2(result, ",");
236
235
  rb_str_buf_append(result, rb_funcall(element, i_to_json, 0));
@@ -281,7 +280,7 @@ static VALUE mString_included_s(VALUE self, VALUE modul) {
281
280
  */
282
281
  static VALUE mString_to_json(int argc, VALUE *argv, VALUE self)
283
282
  {
284
- VALUE result = rb_str_buf_new(RSTRING(self)->len);
283
+ VALUE result = rb_str_buf_new(RSTRING_LEN(self));
285
284
  rb_str_buf_cat2(result, "\"");
286
285
  JSON_convert_UTF8_to_JSON(result, self, strictConversion);
287
286
  rb_str_buf_cat2(result, "\"");
@@ -103,8 +103,8 @@ inline static unsigned char isLegalUTF8(const UTF8 *source, int length)
103
103
  void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags)
104
104
  {
105
105
  char buf[7];
106
- const UTF8* source = (UTF8 *) RSTRING(string)->ptr;
107
- const UTF8* sourceEnd = source + RSTRING(string)->len;
106
+ const UTF8* source = (UTF8 *) RSTRING_PTR(string);
107
+ const UTF8* sourceEnd = source + RSTRING_LEN(string);
108
108
 
109
109
  while (source < sourceEnd) {
110
110
  UTF32 ch = 0;
@@ -37,4 +37,17 @@ static const UTF32 halfMask = 0x3FFUL;
37
37
 
38
38
  void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags);
39
39
 
40
+ #ifndef RARRAY_PTR
41
+ #define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
42
+ #endif
43
+ #ifndef RARRAY_LEN
44
+ #define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
45
+ #endif
46
+ #ifndef RSTRING_PTR
47
+ #define RSTRING_PTR(string) RSTRING(string)->ptr
48
+ #endif
49
+ #ifndef RSTRING_LEN
50
+ #define RSTRING_LEN(string) RSTRING(string)->len
51
+ #endif
52
+
40
53
  #endif
Binary file
@@ -1317,8 +1317,8 @@ static VALUE cParser_initialize(VALUE self, VALUE source)
1317
1317
  long len;
1318
1318
  GET_STRUCT;
1319
1319
  source = StringValue(source);
1320
- ptr = RSTRING(source)->ptr;
1321
- len = RSTRING(source)->len;
1320
+ ptr = RSTRING_PTR(source);
1321
+ len = RSTRING_LEN(source);
1322
1322
  if (len < 2) {
1323
1323
  rb_raise(eParserError, "A JSON text must at least contain two octets!");
1324
1324
  }
@@ -412,8 +412,8 @@ static VALUE cParser_initialize(VALUE self, VALUE source)
412
412
  long len;
413
413
  GET_STRUCT;
414
414
  source = StringValue(source);
415
- ptr = RSTRING(source)->ptr;
416
- len = RSTRING(source)->len;
415
+ ptr = RSTRING_PTR(source);
416
+ len = RSTRING_LEN(source);
417
417
  if (len < 2) {
418
418
  rb_raise(eParserError, "A JSON text must at least contain two octets!");
419
419
  }
@@ -41,4 +41,18 @@ char *JSON_convert_UTF16_to_UTF8 (
41
41
  char *source,
42
42
  char *sourceEnd,
43
43
  ConversionFlags flags);
44
+
45
+ #ifndef RARRAY_PTR
46
+ #define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
47
+ #endif
48
+ #ifndef RARRAY_LEN
49
+ #define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
50
+ #endif
51
+ #ifndef RSTRING_PTR
52
+ #define RSTRING_PTR(string) RSTRING(string)->ptr
53
+ #endif
54
+ #ifndef RSTRING_LEN
55
+ #define RSTRING_LEN(string) RSTRING(string)->len
56
+ #endif
57
+
44
58
  #endif
@@ -197,9 +197,15 @@ require 'json/common'
197
197
  # javasript prototype library (http://www.prototypejs.org) works.
198
198
  #
199
199
  module JSON
200
- begin
200
+ require 'json/version'
201
+
202
+ if VARIANT_BINARY
201
203
  require 'json/ext'
202
- rescue LoadError
203
- require 'json/pure'
204
+ else
205
+ begin
206
+ require 'json/ext'
207
+ rescue LoadError
208
+ require 'json/pure'
209
+ end
204
210
  end
205
211
  end
@@ -29,11 +29,12 @@ module JSON
29
29
  # level (absolute namespace path?). If there doesn't exist a constant at
30
30
  # the given path, an ArgumentError is raised.
31
31
  def deep_const_get(path) # :nodoc:
32
+ path = path.to_s
32
33
  path.split(/::/).inject(Object) do |p, c|
33
34
  case
34
35
  when c.empty? then p
35
36
  when p.const_defined?(c) then p.const_get(c)
36
- else raise ArgumentError, "can't find #{path}"
37
+ else raise ArgumentError, "can't find const #{path}"
37
38
  end
38
39
  end
39
40
  end
@@ -1,8 +1,9 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.0.3'
3
+ VERSION = '1.0.4'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
7
7
  VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
8
+ VARIANT_BINARY = true
8
9
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: json
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.3
7
- date: 2007-04-27 00:00:00 +02:00
6
+ version: 1.0.4
7
+ date: 2007-05-10 00:00:00 +02:00
8
8
  summary: A JSON implementation as a Ruby extension
9
9
  require_paths:
10
10
  - ext/json/ext