Skip to content

Commit c30c227

Browse files
committed
default to extension type of https://github.com/msgpack/msgpack-ruby for symbol packing
1 parent 37f0d8d commit c30c227

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/mrb_msgpack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static inline void mrb_msgpack_pack_string_value(mrb_state *mrb, mrb_value self,
7070
#ifdef MRB_MSGPACK_SYMBOLS
7171

7272
#ifndef MRB_MSGPACK_SYMBOLS_EXT
73-
#define MRB_MSGPACK_SYMBOLS_EXT 1
73+
#define MRB_MSGPACK_SYMBOLS_EXT 0
7474
#endif
7575

7676
template <typename Packer>

test/msgpack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mrb_mruby_simplemsgpack_gem_test(mrb_state *mrb)
3333

3434
#ifdef MRB_MSGPACK_SYMBOLS
3535
#ifndef MRB_MSGPACK_SYMBOLS_EXT
36-
#define MRB_MSGPACK_SYMBOLS_EXT 1
36+
#define MRB_MSGPACK_SYMBOLS_EXT 0
3737
#endif
3838
mrb_define_const(mrb, msgpack_test,
3939
"SYMBOLS_ENABLED",

test/msgpack.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ class TestClassFoo; end
150150
end
151151

152152
assert("Class#to_msgpack with registered ext type") do
153-
MessagePack.register_pack_type(0, Class) { |mod| mod.to_s }
154-
MessagePack.register_unpack_type(0) { |data| data.constantize }
153+
MessagePack.register_pack_type(1, Class) { |mod| mod.to_s }
154+
MessagePack.register_unpack_type(1) { |data| data.constantize }
155155
assert_equal(MessagePack::Error, MessagePack.unpack(MessagePack::Error.to_msgpack))
156156
end
157157

158158
assert("Registered ext type for one of the core types is ignored") do
159-
MessagePack.register_pack_type(0, Array) { |array| nil }
160-
MessagePack.register_unpack_type(0) { |data| nil }
159+
MessagePack.register_pack_type(1, Array) { |array| nil }
160+
MessagePack.register_unpack_type(1) { |data| nil }
161161
assert_equal(['item'], MessagePack.unpack(['item'].to_msgpack))
162162
end
163163

@@ -177,8 +177,8 @@ def ==(other)
177177

178178
class InheritsTest < Test; end
179179

180-
MessagePack.register_pack_type(0, Test) { |test| test.class.to_s + '#' + test.id }
181-
MessagePack.register_unpack_type(0) do |data|
180+
MessagePack.register_pack_type(1, Test) { |test| test.class.to_s + '#' + test.id }
181+
MessagePack.register_unpack_type(1) do |data|
182182
class_name, id = data.split('#')
183183
class_name.constantize.new(id)
184184
end
@@ -189,12 +189,12 @@ class InheritsTest < Test; end
189189

190190
assert("Extension types for modules") do
191191
module Mod; end
192-
MessagePack.register_pack_type(0, Mod) { |obj| 'packed' }
192+
MessagePack.register_pack_type(1, Mod) { |obj| 'packed' }
193193

194194
class Cls; include Mod end
195-
assert_equal(Cls.new.to_msgpack, "\xc7\x06\x00packed")
195+
assert_equal(Cls.new.to_msgpack, "\xc7\x06\x01packed")
196196

197-
assert_equal(Object.new.extend(Mod).to_msgpack, "\xc7\x06\x00packed")
197+
assert_equal(Object.new.extend(Mod).to_msgpack, "\xc7\x06\x01packed")
198198
end
199199

200200
assert("C Packing and unpacking") do

0 commit comments

Comments
 (0)