msgpack 0.3.6-mswin32 → 0.3.7-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -220,15 +220,18 @@ static VALUE MessagePack_Unpacker_initialize(int argc, VALUE *argv, VALUE self)
220
220
  }
221
221
 
222
222
 
223
- static VALUE MessagePack_Unpacker_execute_impl(VALUE args)
223
+ static VALUE MessagePack_Unpacker_execute_do(VALUE argv)
224
224
  {
225
- VALUE self = ((VALUE*)args)[0];
226
- VALUE data = ((VALUE*)args)[1];
225
+ VALUE* args = (VALUE*)argv;
227
226
 
227
+ VALUE self = args[0];
228
228
  UNPACKER(self, mp);
229
- size_t from = NUM2UINT(((VALUE*)args)[2]);
229
+
230
+ VALUE data = args[1];
231
+
232
+ size_t from = (unsigned long)args[2];
230
233
  char* dptr = RSTRING_PTR(data);
231
- long dlen = FIX2LONG(((VALUE*)args)[3]);
234
+ size_t dlen = (unsigned long)args[3];
232
235
  int ret;
233
236
 
234
237
  if(from >= dlen) {
@@ -236,7 +239,7 @@ static VALUE MessagePack_Unpacker_execute_impl(VALUE args)
236
239
  }
237
240
 
238
241
  mp->user.source = data;
239
- ret = template_execute(mp, dptr, (size_t)dlen, &from);
242
+ ret = template_execute(mp, dptr, dlen, &from);
240
243
  mp->user.source = Qnil;
241
244
 
242
245
  if(ret < 0) {
@@ -260,22 +263,32 @@ static VALUE MessagePack_Unpacker_execute_rescue(VALUE nouse)
260
263
  #endif
261
264
  }
262
265
 
263
- static VALUE MessagePack_Unpacker_execute_limit(VALUE self, VALUE data,
264
- VALUE off, VALUE limit)
266
+ static inline VALUE MessagePack_Unpacker_execute_impl(VALUE self, VALUE data,
267
+ unsigned long off, unsigned long dlen)
265
268
  {
266
269
  // FIXME execute実行中はmp->topが更新されないのでGC markが機能しない
267
270
  rb_gc_disable();
268
- VALUE args[4] = {self, data, off, limit};
269
- VALUE ret = rb_rescue(MessagePack_Unpacker_execute_impl, (VALUE)args,
271
+ VALUE args[4] = {self, data, (VALUE)off, (VALUE)dlen};
272
+ VALUE ret = rb_rescue(MessagePack_Unpacker_execute_do, (VALUE)args,
270
273
  MessagePack_Unpacker_execute_rescue, Qnil);
271
274
  rb_gc_enable();
275
+
272
276
  return ret;
273
277
  }
274
278
 
279
+ static VALUE MessagePack_Unpacker_execute_limit(VALUE self, VALUE data,
280
+ VALUE off, VALUE limit)
281
+ {
282
+ CHECK_STRING_TYPE(data);
283
+ return MessagePack_Unpacker_execute_impl(self, data,
284
+ NUM2ULONG(off), NUM2ULONG(limit));
285
+ }
286
+
275
287
  static VALUE MessagePack_Unpacker_execute(VALUE self, VALUE data, VALUE off)
276
288
  {
277
- return MessagePack_Unpacker_execute_limit(self, data, off,
278
- LONG2FIX(RSTRING_LEN(data)));
289
+ CHECK_STRING_TYPE(data);
290
+ return MessagePack_Unpacker_execute_impl(self, data,
291
+ NUM2ULONG(off), RSTRING_LEN(data));
279
292
  }
280
293
 
281
294
  static VALUE MessagePack_Unpacker_finished_p(VALUE self)
@@ -379,18 +392,20 @@ static VALUE MessagePack_Unpacker_each(VALUE self)
379
392
  }
380
393
 
381
394
 
382
- static VALUE MessagePack_unpack_impl(VALUE args)
395
+ static VALUE MessagePack_unpack_do(VALUE argv)
383
396
  {
384
- msgpack_unpack_t* mp = (msgpack_unpack_t*)((VALUE*)args)[0];
385
- VALUE data = ((VALUE*)args)[1];
397
+ VALUE* args = (VALUE*)argv;
398
+
399
+ msgpack_unpack_t* mp = (msgpack_unpack_t*)args[0];
400
+ VALUE data = args[1];
386
401
 
387
402
  size_t from = 0;
388
403
  char* dptr = RSTRING_PTR(data);
389
- long dlen = FIX2LONG(((VALUE*)args)[2]);
404
+ size_t dlen = (unsigned long)args[2];
390
405
  int ret;
391
406
 
392
407
  mp->user.source = data;
393
- ret = template_execute(mp, dptr, (size_t)dlen, &from);
408
+ ret = template_execute(mp, dptr, dlen, &from);
394
409
  mp->user.source = Qnil;
395
410
 
396
411
  if(ret < 0) {
@@ -405,7 +420,7 @@ static VALUE MessagePack_unpack_impl(VALUE args)
405
420
  }
406
421
  }
407
422
 
408
- static VALUE MessagePack_unpack_rescue(VALUE args)
423
+ static VALUE MessagePack_unpack_rescue(VALUE nouse)
409
424
  {
410
425
  rb_gc_enable();
411
426
  #ifdef RUBY_VM
@@ -415,29 +430,34 @@ static VALUE MessagePack_unpack_rescue(VALUE args)
415
430
  #endif
416
431
  }
417
432
 
418
- static VALUE MessagePack_unpack_limit(VALUE self, VALUE data, VALUE limit)
433
+ static inline VALUE MessagePack_unpack_impl(VALUE self, VALUE data, unsigned long dlen)
419
434
  {
420
- CHECK_STRING_TYPE(data);
421
-
422
435
  msgpack_unpack_t mp;
423
436
  template_init(&mp);
424
437
  init_stack(&mp);
425
438
  unpack_user u = {0, Qnil, 0, 0, Qnil, Qnil, Qnil};
426
439
  mp.user = u;
427
440
 
441
+ // FIXME execute実行中はmp->topが更新されないのでGC markが機能しない
428
442
  rb_gc_disable();
429
- VALUE args[3] = {(VALUE)&mp, data, limit};
430
- VALUE ret = rb_rescue(MessagePack_unpack_impl, (VALUE)args,
443
+ VALUE args[3] = {(VALUE)&mp, data, (VALUE)dlen};
444
+ VALUE ret = rb_rescue(MessagePack_unpack_do, (VALUE)args,
431
445
  MessagePack_unpack_rescue, Qnil);
432
446
  rb_gc_enable();
433
447
 
434
448
  return ret;
435
449
  }
436
450
 
451
+ static VALUE MessagePack_unpack_limit(VALUE self, VALUE data, VALUE limit)
452
+ {
453
+ CHECK_STRING_TYPE(data);
454
+ return MessagePack_unpack_impl(self, data, NUM2ULONG(limit));
455
+ }
456
+
437
457
  static VALUE MessagePack_unpack(VALUE self, VALUE data)
438
458
  {
439
- return MessagePack_unpack_limit(self, data,
440
- LONG2FIX(RSTRING_LEN(data)));
459
+ CHECK_STRING_TYPE(data);
460
+ return MessagePack_unpack_impl(self, data, RSTRING_LEN(data));
441
461
  }
442
462
 
443
463
 
Binary file
Binary file
File without changes
@@ -1,3 +1,3 @@
1
1
  require 'test/unit'
2
- require File.dirname(__FILE__) + '/../ext/msgpack'
2
+ require File.dirname(__FILE__) + '/../lib/msgpack'
3
3
 
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  segments:
5
5
  - 0
6
6
  - 3
7
- - 6
8
- version: 0.3.6
7
+ - 7
8
+ version: 0.3.7
9
9
  platform: mswin32
10
10
  authors:
11
11
  - FURUHASHI Sadayuki
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-04-02 00:00:00 +09:00
16
+ date: 2010-04-06 00:00:00 +09:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
@@ -31,15 +31,15 @@ files:
31
31
  - AUTHORS
32
32
  - ChangeLog
33
33
  - README
34
- - ext/1.8/msgpack.so
35
- - ext/1.9/msgpack.so
36
34
  - ext/extconf.rb
37
- - ext/msgpack.rb
38
35
  - ext/pack.c
39
36
  - ext/pack.h
40
37
  - ext/rbinit.c
41
38
  - ext/unpack.c
42
39
  - ext/unpack.h
40
+ - lib/1.8/msgpack.so
41
+ - lib/1.9/msgpack.so
42
+ - lib/msgpack.rb
43
43
  - msgpack/pack_define.h
44
44
  - msgpack/pack_template.h
45
45
  - msgpack/sysdep.h
@@ -55,7 +55,7 @@ post_install_message:
55
55
  rdoc_options: []
56
56
 
57
57
  require_paths:
58
- - ext
58
+ - lib
59
59
  required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
Binary file
Binary file