msgpack 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ 2013-09-23 version 0.5.6:
3
+
4
+ * Fixed "can't modify frozen String" exception in Unpacker with ruby 2.1.0-dev
5
+ * Getting work with Ruby v2.0 on Windows (Thank you @thegreendroid)
6
+ * Fixed EOFError handling in Unpacker
7
+
8
+
2
9
  2013-05-12 version 0.5.5:
3
10
 
4
11
  * Fixed SEGV problem in to_msgpack
@@ -17,6 +17,12 @@ Use RubyGems to install:
17
17
 
18
18
  gem install msgpack
19
19
 
20
+ or build msgpack-ruby and install:
21
+
22
+ bundle
23
+ rake
24
+ gem install --local pkg/msgpack
25
+
20
26
 
21
27
  = Use cases
22
28
 
@@ -93,10 +99,30 @@ MessagePack for Ruby provides a buffer API so that you can read or write data by
93
99
  This {MessagePack::Buffer}[http://ruby.msgpack.org/MessagePack/Buffer.html] is backed with a fixed-length shared memory pool which is very fast for small data (<= 4KB),
94
100
  and has zero-copy capability which significantly affects performance to handle large binary data.
95
101
 
102
+ = How to build and run tests
103
+
104
+ Before building msgpack, you need to install bundler and dependencies.
105
+
106
+ gem install bundler
107
+ bundle install
108
+
109
+ Then, you can run the tasks as follows:
110
+
111
+ * Build
112
+
113
+ bundle exec rake build
114
+
115
+ * Run tests
116
+
117
+ bundle exec rake spec
118
+
119
+ * Generating docs
120
+
121
+ bundle exec rake doc
96
122
 
97
123
  = Copyright
98
124
 
99
- Author:: FURUHASHI Sadayuki <frsyuki@gmail.com>
100
- Copyright:: Copyright (c) 2008-2012 FURUHASHI Sadayuki
125
+ Author:: Sadayuki Furuhashi <frsyuki@gmail.com>
126
+ Copyright:: Copyright (c) 2008-2013 Sadayuki Furuhashi
101
127
  License:: Apache License, Version 2.0
102
128
 
data/Rakefile CHANGED
@@ -61,8 +61,9 @@ task :default => :build
61
61
  ## Ubuntu Ubuntu 10.04.1 LTS
62
62
  ##
63
63
  #
64
- ### install mingw32 cross compiler
64
+ ### install mingw32 cross compiler with w64 support
65
65
  # sudo apt-get install gcc-mingw32
66
+ # sudo apt-get install mingw-w64
66
67
  #
67
68
  ### install rbenv
68
69
  # git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -165,6 +165,8 @@ size_t msgpack_buffer_read_to_string_nonblock(msgpack_buffer_t* b, VALUE string,
165
165
  #else
166
166
  rb_str_replace(string, s);
167
167
  #endif
168
+ /* here doesn't have to call ENCODING_SET because
169
+ * encoding of s is always ASCII-8BIT */
168
170
  _msgpack_buffer_consumed(b, length);
169
171
  return length;
170
172
  }
@@ -307,8 +309,8 @@ static inline void _msgpack_buffer_append_reference(msgpack_buffer_t* b, VALUE s
307
309
 
308
310
  _msgpack_buffer_add_new_chunk(b);
309
311
 
310
- char* data = RSTRING_PTR(string);
311
- size_t length = RSTRING_LEN(string);
312
+ char* data = RSTRING_PTR(mapped_string);
313
+ size_t length = RSTRING_LEN(mapped_string);
312
314
 
313
315
  b->tail.first = (char*) data;
314
316
  b->tail.last = (char*) data + length;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -418,11 +418,11 @@ static inline VALUE _msgpack_buffer_refer_head_mapped_string(msgpack_buffer_t* b
418
418
  return rb_str_substr(b->head->mapped_string, offset, length);
419
419
  }
420
420
 
421
- static inline VALUE msgpack_buffer_read_top_as_string(msgpack_buffer_t* b, size_t length, bool frozen)
421
+ static inline VALUE msgpack_buffer_read_top_as_string(msgpack_buffer_t* b, size_t length, bool will_be_frozen)
422
422
  {
423
423
  #ifndef DISABLE_BUFFER_READ_REFERENCE_OPTIMIZE
424
424
  /* optimize */
425
- if(!frozen &&
425
+ if(!will_be_frozen &&
426
426
  b->head->mapped_string != NO_MAPPED_STRING &&
427
427
  length >= b->read_reference_threshold) {
428
428
  VALUE result = _msgpack_buffer_refer_head_mapped_string(b, length);
@@ -432,9 +432,6 @@ static inline VALUE msgpack_buffer_read_top_as_string(msgpack_buffer_t* b, size_
432
432
  #endif
433
433
 
434
434
  VALUE result = rb_str_new(b->read_buffer, length);
435
- if(frozen) {
436
- rb_obj_freeze(result);
437
- }
438
435
  _msgpack_buffer_consumed(b, length);
439
436
  return result;
440
437
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -149,9 +149,8 @@ static inline int object_complete(msgpack_unpacker_t* uk, VALUE object)
149
149
 
150
150
  static inline int object_complete_string(msgpack_unpacker_t* uk, VALUE str)
151
151
  {
152
- // TODO ruby 2.0 has String#b method
153
152
  #ifdef COMPAT_HAVE_ENCODING
154
- //str_modifiable(str);
153
+ // TODO ruby 2.0 has String#b method
155
154
  ENCODING_SET(str, s_enc_utf8);
156
155
  #endif
157
156
  return object_complete(uk, str);
@@ -257,9 +256,12 @@ static inline int read_raw_body_begin(msgpack_unpacker_t* uk)
257
256
  if(length <= msgpack_buffer_top_readable_size(UNPACKER_BUFFER_(uk))) {
258
257
  /* don't use zerocopy for hash keys but get a frozen string directly
259
258
  * because rb_hash_aset freezes keys and it causes copying */
260
- bool frozen = is_reading_map_key(uk);
261
- VALUE string = msgpack_buffer_read_top_as_string(UNPACKER_BUFFER_(uk), length, frozen);
259
+ bool will_freeze = is_reading_map_key(uk);
260
+ VALUE string = msgpack_buffer_read_top_as_string(UNPACKER_BUFFER_(uk), length, will_freeze);
262
261
  object_complete_string(uk, string);
262
+ if(will_freeze) {
263
+ rb_obj_freeze(string);
264
+ }
263
265
  uk->reading_raw_remaining = 0;
264
266
  return PRIMITIVE_OBJECT_COMPLETE;
265
267
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -260,12 +260,12 @@ static VALUE Unpacker_each(VALUE self)
260
260
  #endif
261
261
 
262
262
  if(msgpack_buffer_has_io(UNPACKER_BUFFER_(uk))) {
263
- return Unpacker_each_impl(self);
264
- } else {
265
263
  /* rescue EOFError only if io is set */
266
264
  return rb_rescue2(Unpacker_each_impl, self,
267
265
  Unpacker_rescue_EOFError, self,
268
266
  rb_eEOFError, NULL);
267
+ } else {
268
+ return Unpacker_each_impl(self);
269
269
  }
270
270
  }
271
271
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack for Ruby
3
3
  *
4
- * Copyright (C) 2008-2012 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2013 Sadayuki Furuhashi
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -3,7 +3,6 @@ require File.join(here, 'msgpack', 'version')
3
3
  begin
4
4
  m = /(\d+.\d+)/.match(RUBY_VERSION)
5
5
  ver = m[1]
6
- ver = '1.9' if ver == '2.0'
7
6
  require File.join(here, 'msgpack', ver, 'msgpack')
8
7
  rescue LoadError
9
8
  require File.join(here, 'msgpack', 'msgpack')
@@ -1,3 +1,3 @@
1
1
  module MessagePack
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
@@ -6,8 +6,9 @@ Gem::Specification.new do |s|
6
6
  s.version = MessagePack::VERSION
7
7
  s.summary = "MessagePack, a binary-based efficient data interchange format."
8
8
  s.description = %q{MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.}
9
- s.author = "FURUHASHI Sadayuki"
9
+ s.author = "Sadayuki Furuhashi"
10
10
  s.email = "frsyuki@gmail.com"
11
+ s.license = "Apache 2.0"
11
12
  s.homepage = "http://msgpack.org/"
12
13
  s.rubyforge_project = "msgpack"
13
14
  s.has_rdoc = false
@@ -138,6 +138,20 @@ describe Unpacker do
138
138
  unpacker.buffer.object_id.should == o1
139
139
  end
140
140
 
141
+ it 'frozen short strings' do
142
+ raw = sample_object.to_msgpack.to_s.force_encoding('UTF-8')
143
+ lambda {
144
+ unpacker.feed_each(raw.freeze) { }
145
+ }.should_not raise_error
146
+ end
147
+
148
+ it 'frozen long strings' do
149
+ raw = (sample_object.to_msgpack.to_s * 10240).force_encoding('UTF-8')
150
+ lambda {
151
+ unpacker.feed_each(raw.freeze) { }
152
+ }.should_not raise_error
153
+ end
154
+
141
155
  it 'read raises level stack too deep error' do
142
156
  512.times { packer.write_array_header(1) }
143
157
  packer.write(nil)
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - FURUHASHI Sadayuki
8
+ - Sadayuki Furuhashi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-13 00:00:00.000000000 Z
12
+ date: 2013-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -164,7 +164,8 @@ files:
164
164
  - spec/spec_helper.rb
165
165
  - spec/unpacker_spec.rb
166
166
  homepage: http://msgpack.org/
167
- licenses: []
167
+ licenses:
168
+ - Apache 2.0
168
169
  post_install_message:
169
170
  rdoc_options: []
170
171
  require_paths: