Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package rubygem-msgpack for openSUSE:Factory
checked in at 2022-01-28 22:12:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-msgpack (Old)
and /work/SRC/openSUSE:Factory/.rubygem-msgpack.new.1898 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-msgpack"
Fri Jan 28 22:12:29 2022 rev:14 rq:949578 version:1.4.4
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-msgpack/rubygem-msgpack.changes
2021-02-20 22:12:13.535034951 +0100
+++
/work/SRC/openSUSE:Factory/.rubygem-msgpack.new.1898/rubygem-msgpack.changes
2022-01-28 22:12:41.458826366 +0100
@@ -1,0 +2,19 @@
+Tue Jan 25 07:13:34 UTC 2022 - Stephan Kulow <[email protected]>
+
+updated to version 1.4.4
+ see installed ChangeLog
+
+ 2022-01-22 version 1.4.4:
+
+ * Specify the build option --platform=8 for older Java platforms
+
+ 2022-01-20 version 1.4.3:
+
+ * Optimize serialization/deserialization of Symbols
+ * Support registering ext types for objects of subclasses of primitive types
(like Hash)
+ * Add optimized_symbols_parsing option to Factory#register_type on MRI
implementation
+ * Optimize to deduplicate Hash keys on JRuby
+ * Support JRuby 9.3 (and drop 9.1)
+
+
+-------------------------------------------------------------------
Old:
----
msgpack-1.4.2.gem
New:
----
msgpack-1.4.4.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-msgpack.spec ++++++
--- /var/tmp/diff_new_pack.PhUmKB/_old 2022-01-28 22:12:41.962822917 +0100
+++ /var/tmp/diff_new_pack.PhUmKB/_new 2022-01-28 22:12:41.966822889 +0100
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-msgpack
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
#
Name: rubygem-msgpack
-Version: 1.4.2
+Version: 1.4.4
Release: 0
%define mod_name msgpack
%define mod_full_name %{mod_name}-%{version}
++++++ msgpack-1.4.2.gem -> msgpack-1.4.4.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.github/workflows/ci.yaml
new/.github/workflows/ci.yaml
--- old/.github/workflows/ci.yaml 1970-01-01 01:00:00.000000000 +0100
+++ new/.github/workflows/ci.yaml 2022-01-22 10:08:54.000000000 +0100
@@ -0,0 +1,56 @@
+name: ci
+
+on:
+ pull_request:
+ branches: '*'
+ push:
+ branches:
+ - master
+ - main
+ - 'release-*'
+
+jobs:
+ mri:
+ strategy:
+ matrix:
+ os: [ubuntu, macos, windows]
+ ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
+ runs-on: ${{ matrix.os }}-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: ${{ matrix.ruby }}
+ bundler-cache: true # 'bundle install' and cache
+ - run: bundle exec rake
+
+ jruby:
+ strategy:
+ matrix:
+ os: [ubuntu]
+ # TODO: update to 9.3.3.0 once supported
+ # https://github.com/ruby/setup-ruby#supported-versions
+ ruby: ['jruby-9.2.19.0', 'jruby-9.3.2.0']
+ runs-on: ${{ matrix.os }}-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: ${{ matrix.ruby }}
+ bundler-cache: true # 'bundle install' and cache
+ - run: bundle exec rake
+
+ head-versions:
+ continue-on-error: true
+ strategy:
+ matrix:
+ os: [ubuntu]
+ ruby: ['ruby-head', 'jruby-head', 'truffleruby']
+ runs-on: ${{ matrix.os }}-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: ${{ matrix.ruby }}
+ bundler-cache: true # 'bundle install' and cache
+ - run: bundle exec rake || echo "failed, but ignore it"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml 2021-02-01 04:16:37.000000000 +0100
+++ new/.travis.yml 1970-01-01 01:00:00.000000000 +0100
@@ -1,39 +0,0 @@
-language: ruby
-
-branches:
- only:
- - master
-
-gemfile:
- - Gemfile
-
-before_install:
- # This is only for Ruby 2.5.0, Bundler 1.16.1 and rubygems 2.7.3
- # See https://github.com/travis-ci/travis-ci/issues/8969
- - "[ \"x2.7.3\" = \"x\"$(gem --version) ] && gem update --system
--no-document || echo \"no need to update rubygem\""
-
-# http://rubies.travis-ci.org/
-matrix:
- include:
- - rvm: 2.4.5
- os: linux
- - rvm: 2.5.8
- os: linux
- - rvm: 2.6.6
- os: linux
- - rvm: 2.6.6
- os: osx
- - rvm: 2.7.1
- os: linux
- - rvm: ruby-head
- os: linux
- - rvm: jruby-head
- os: linux
- - rvm: jruby-19mode
- os: linux
- allow_failures:
- - rvm: 2.6.1
- os: osx
- - rvm: ruby-head
- - rvm: jruby-head
- - rvm: jruby-19mode
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ChangeLog new/ChangeLog
--- old/ChangeLog 2021-02-01 04:16:37.000000000 +0100
+++ new/ChangeLog 2022-01-22 10:08:54.000000000 +0100
@@ -1,3 +1,15 @@
+2022-01-22 version 1.4.4:
+
+* Specify the build option --platform=8 for older Java platforms
+
+2022-01-20 version 1.4.3:
+
+* Optimize serialization/deserialization of Symbols
+* Support registering ext types for objects of subclasses of primitive types
(like Hash)
+* Add optimized_symbols_parsing option to Factory#register_type on MRI
implementation
+* Optimize to deduplicate Hash keys on JRuby
+* Support JRuby 9.3 (and drop 9.1)
+
2021-02-01 version 1.4.2:
* Add the required Ruby version (>= 2.4) to avoid compilation errors on older
Ruby runtimes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Rakefile new/Rakefile
--- old/Rakefile 2021-02-01 04:16:37.000000000 +0100
+++ new/Rakefile 2022-01-22 10:08:54.000000000 +0100
@@ -34,8 +34,7 @@
jars = ["#{jruby_home}/lib/jruby.jar"]
ext.classpath = jars.map { |x| File.expand_path(x) }.join(':')
ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
- ext.source_version = '1.6'
- ext.target_version = '1.6'
+ ext.release = '8'
end
else
require 'rake/extensiontask'
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/doclib/msgpack/factory.rb
new/doclib/msgpack/factory.rb
--- old/doclib/msgpack/factory.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/doclib/msgpack/factory.rb 2022-01-22 10:08:54.000000000 +0100
@@ -75,6 +75,7 @@
#
# * *:packer* specify symbol or proc object for packer
# * *:unpacker* specify symbol or proc object for unpacker
+ # * *:optimized_symbols_parsing* specify true to use the optimized symbols
parsing (not supported on JRuby now)
#
def register_type(type, klass, options={})
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/Buffer.java
new/ext/java/org/msgpack/jruby/Buffer.java
--- old/ext/java/org/msgpack/jruby/Buffer.java 2021-02-01 04:16:37.000000000
+0100
+++ new/ext/java/org/msgpack/jruby/Buffer.java 2022-01-22 10:08:54.000000000
+0100
@@ -21,6 +21,7 @@
@JRubyClass(name="MessagePack::Buffer")
public class Buffer extends RubyObject {
+ private static final long serialVersionUID = 8441244627425629412L;
private IRubyObject io;
private ByteBuffer buffer;
private boolean writeMode;
@@ -49,7 +50,7 @@
}
this.buffer = ByteBuffer.allocate(CACHE_LINE_SIZE - ARRAY_HEADER_SIZE);
this.writeMode = true;
- this.binaryEncoding =
ctx.getRuntime().getEncodingService().getAscii8bitEncoding();
+ this.binaryEncoding =
ctx.runtime.getEncodingService().getAscii8bitEncoding();
return this;
}
@@ -87,17 +88,17 @@
writeMode = true;
}
buffer.clear();
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
}
@JRubyMethod(name = "size")
public IRubyObject size(ThreadContext ctx) {
- return ctx.getRuntime().newFixnum(rawSize());
+ return ctx.runtime.newFixnum(rawSize());
}
@JRubyMethod(name = "empty?")
public IRubyObject isEmpty(ThreadContext ctx) {
- return rawSize() == 0 ? ctx.getRuntime().getTrue() :
ctx.getRuntime().getFalse();
+ return rawSize() == 0 ? ctx.runtime.getTrue() : ctx.runtime.getFalse();
}
private IRubyObject bufferWrite(ThreadContext ctx, IRubyObject str) {
@@ -105,7 +106,7 @@
int length = bytes.length();
ensureRemainingCapacity(length);
buffer.put(bytes.unsafeBytes(), bytes.begin(), length);
- return ctx.getRuntime().newFixnum(length);
+ return ctx.runtime.newFixnum(length);
}
@@ -131,19 +132,19 @@
length = (int) args[0].convertToInteger().getLongValue();
}
if (raiseOnUnderflow && rawSize() < length) {
- throw ctx.getRuntime().newEOFError();
+ throw ctx.runtime.newEOFError();
}
int readLength = Math.min(length, rawSize());
if (readLength == 0 && length > 0) {
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
} else if (readLength == 0) {
- return ctx.getRuntime().newString();
+ return ctx.runtime.newString();
} else {
ensureReadMode();
byte[] bytes = new byte[readLength];
buffer.get(bytes);
ByteList byteList = new ByteList(bytes, binaryEncoding);
- return ctx.getRuntime().newString(byteList);
+ return ctx.runtime.newString(byteList);
}
}
@@ -161,12 +162,12 @@
feed(ctx);
int length = (int) _length.convertToInteger().getLongValue();
if (raiseOnUnderflow && rawSize() < length) {
- throw ctx.getRuntime().newEOFError();
+ throw ctx.runtime.newEOFError();
}
ensureReadMode();
int skipLength = Math.min(length, rawSize());
buffer.position(buffer.position() + skipLength);
- return ctx.getRuntime().newFixnum(skipLength);
+ return ctx.runtime.newFixnum(skipLength);
}
@JRubyMethod(name = "skip")
@@ -188,23 +189,23 @@
ensureReadMode();
int length = buffer.limit() - buffer.position();
ByteList str = new ByteList(buffer.array(), buffer.position(), length,
binaryEncoding, true);
- return ctx.getRuntime().newString(str);
+ return ctx.runtime.newString(str);
}
@JRubyMethod(name = "to_a")
public IRubyObject toA(ThreadContext ctx) {
- return ctx.getRuntime().newArray(toS(ctx));
+ return ctx.runtime.newArray(toS(ctx));
}
@JRubyMethod(name = "io")
public IRubyObject getIo(ThreadContext ctx) {
- return io == null ? ctx.getRuntime().getNil() : io;
+ return io == null ? ctx.runtime.getNil() : io;
}
@JRubyMethod(name = "flush")
public IRubyObject flush(ThreadContext ctx) {
if (io == null) {
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
} else {
return io.callMethod(ctx, "flush");
}
@@ -213,7 +214,7 @@
@JRubyMethod(name = "close")
public IRubyObject close(ThreadContext ctx) {
if (io == null) {
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
} else {
return io.callMethod(ctx, "close");
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/Decoder.java
new/ext/java/org/msgpack/jruby/Decoder.java
--- old/ext/java/org/msgpack/jruby/Decoder.java 2021-02-01 04:16:37.000000000
+0100
+++ new/ext/java/org/msgpack/jruby/Decoder.java 2022-01-22 10:08:54.000000000
+0100
@@ -122,7 +122,6 @@
ByteList byteList = new ByteList(bytes, encoding);
RubyString string = runtime.newString(byteList);
if (this.freeze) {
- string.setFrozen(true);
string = runtime.freezeAndDedupString(string);
}
return string;
@@ -140,9 +139,14 @@
RubyHash hash = RubyHash.newHash(runtime);
for (int i = 0; i < size; i++) {
IRubyObject key = next();
- if (this.symbolizeKeys && key instanceof RubyString) {
+ if (key instanceof RubyString) {
+ if (this.symbolizeKeys) {
key = ((RubyString) key).intern();
+ } else {
+ key = runtime.freezeAndDedupString((RubyString) key);
+ }
}
+
hash.fastASet(key, next());
}
return hash;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/Encoder.java
new/ext/java/org/msgpack/jruby/Encoder.java
--- old/ext/java/org/msgpack/jruby/Encoder.java 2021-02-01 04:16:37.000000000
+0100
+++ new/ext/java/org/msgpack/jruby/Encoder.java 2022-01-22 10:08:54.000000000
+0100
@@ -119,7 +119,9 @@
} else if (object instanceof RubyFloat) {
appendFloat((RubyFloat) object);
} else if (object instanceof RubyString) {
- appendString((RubyString) object);
+ if (object.getType() == runtime.getString() ||
!tryAppendWithExtTypeLookup(object)) {
+ appendString((RubyString) object);
+ }
} else if (object instanceof RubySymbol) {
if (hasSymbolExtType) {
appendOther(object, destination);
@@ -127,9 +129,13 @@
appendString(((RubySymbol) object).asString());
}
} else if (object instanceof RubyArray) {
- appendArray((RubyArray) object);
+ if (object.getType() == runtime.getArray() ||
!tryAppendWithExtTypeLookup(object)) {
+ appendArray((RubyArray) object);
+ }
} else if (object instanceof RubyHash) {
- appendHash((RubyHash) object);
+ if (object.getType() == runtime.getHash() ||
!tryAppendWithExtTypeLookup(object)) {
+ appendHash((RubyHash) object);
+ }
} else if (object instanceof ExtensionValue) {
appendExtensionValue((ExtensionValue) object);
} else {
@@ -153,7 +159,7 @@
}
private void appendInteger(RubyInteger object) {
- long value = ((RubyInteger) object).getLongValue();
+ long value = object.getLongValue();
if (value < 0) {
if (value < Short.MIN_VALUE) {
if (value < Integer.MIN_VALUE) {
@@ -241,7 +247,7 @@
} else {
ensureRemainingCapacity(5 + length);
buffer.put(binary ? BIN32 : STR32);
- buffer.putInt((int) length);
+ buffer.putInt(length);
}
}
@@ -249,7 +255,7 @@
Encoding encoding = object.getEncoding();
boolean binary = !compatibilityMode && encoding == binaryEncoding;
if (encoding != utf8Encoding && encoding != binaryEncoding) {
- object = (RubyString) ((RubyString)
object).encode(runtime.getCurrentContext(),
runtime.getEncodingService().getEncoding(utf8Encoding));
+ object = (RubyString)(object).encode(runtime.getCurrentContext(),
runtime.getEncodingService().getEncoding(utf8Encoding));
}
ByteList bytes = object.getByteList();
int length = bytes.length();
@@ -257,12 +263,12 @@
buffer.put(bytes.unsafeBytes(), bytes.begin(), length);
}
- private void appendArray(RubyArray object) {
+ private void appendArray(RubyArray<?> object) {
appendArrayHeader(object);
appendArrayElements(object);
}
- private void appendArrayHeader(RubyArray object) {
+ private void appendArrayHeader(RubyArray<?> object) {
appendArrayHeader(object.size());
}
@@ -281,7 +287,7 @@
}
}
- private void appendArrayElements(RubyArray object) {
+ private void appendArrayElements(RubyArray<?> object) {
int size = object.size();
for (int i = 0; i < size; i++) {
appendObject(object.eltOk(i));
@@ -383,7 +389,7 @@
appendExt((int) type, payloadBytes);
}
- private void appendOther(IRubyObject object, IRubyObject destination) {
+ private boolean tryAppendWithExtTypeLookup(IRubyObject object) {
if (registry != null) {
RubyModule lookupClass;
@@ -398,10 +404,14 @@
RubyString bytes = pair[0].callMethod(runtime.getCurrentContext(),
"call", object).asString();
int type = (int) ((RubyFixnum) pair[1]).getLongValue();
appendExt(type, bytes.getByteList());
- return;
+ return true;
}
}
- appendCustom(object, destination);
+ return false;
+ }
+
+ private void appendOther(IRubyObject object, IRubyObject destination) {
+ if (!tryAppendWithExtTypeLookup(object)) { appendCustom(object,
destination); }
}
private void appendCustom(IRubyObject object, IRubyObject destination) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/ExtensionRegistry.java
new/ext/java/org/msgpack/jruby/ExtensionRegistry.java
--- old/ext/java/org/msgpack/jruby/ExtensionRegistry.java 2021-02-01
04:16:37.000000000 +0100
+++ new/ext/java/org/msgpack/jruby/ExtensionRegistry.java 2022-01-22
10:08:54.000000000 +0100
@@ -37,7 +37,7 @@
}
public IRubyObject toInternalPackerRegistry(ThreadContext ctx) {
- RubyHash hash = RubyHash.newHash(ctx.getRuntime());
+ RubyHash hash = RubyHash.newHash(ctx.runtime);
for (RubyModule extensionModule : extensionsByModule.keySet()) {
ExtensionEntry entry = extensionsByModule.get(extensionModule);
if (entry.hasPacker()) {
@@ -48,11 +48,11 @@
}
public IRubyObject toInternalUnpackerRegistry(ThreadContext ctx) {
- RubyHash hash = RubyHash.newHash(ctx.getRuntime());
+ RubyHash hash = RubyHash.newHash(ctx.runtime);
for (int typeIdIndex = 0 ; typeIdIndex < 256 ; typeIdIndex++) {
ExtensionEntry entry = extensionsByTypeId[typeIdIndex];
if (entry != null && entry.hasUnpacker()) {
- IRubyObject typeId = RubyFixnum.newFixnum(ctx.getRuntime(),
typeIdIndex - 128);
+ IRubyObject typeId = RubyFixnum.newFixnum(ctx.runtime, typeIdIndex -
128);
hash.put(typeId, entry.toUnpackerTuple(ctx));
}
}
@@ -124,7 +124,7 @@
private ExtensionEntry findEntryByModuleOrAncestor(final RubyModule mod) {
ThreadContext ctx = mod.getRuntime().getCurrentContext();
for (RubyModule extensionModule : extensionsByModule.keySet()) {
- RubyArray ancestors = (RubyArray) mod.callMethod(ctx, "ancestors");
+ RubyArray<?> ancestors = (RubyArray)mod.callMethod(ctx, "ancestors");
if (ancestors.callMethod(ctx, "include?", extensionModule).isTrue()) {
return extensionsByModule.get(extensionModule);
}
@@ -173,16 +173,16 @@
return unpackerProc;
}
- public RubyArray toPackerTuple(ThreadContext ctx) {
- return RubyArray.newArray(ctx.getRuntime(), new IRubyObject[]
{RubyFixnum.newFixnum(ctx.getRuntime(), typeId), packerProc, packerArg});
+ public RubyArray<?> toPackerTuple(ThreadContext ctx) {
+ return ctx.runtime.newArray(new IRubyObject[]
{ctx.runtime.newFixnum(typeId), packerProc, packerArg});
}
- public RubyArray toUnpackerTuple(ThreadContext ctx) {
- return RubyArray.newArray(ctx.getRuntime(), new IRubyObject[] {mod,
unpackerProc, unpackerArg});
+ public RubyArray<?> toUnpackerTuple(ThreadContext ctx) {
+ return ctx.runtime.newArray(new IRubyObject[] {mod, unpackerProc,
unpackerArg});
}
public IRubyObject[] toPackerProcTypeIdPair(ThreadContext ctx) {
- return new IRubyObject[] {packerProc,
RubyFixnum.newFixnum(ctx.getRuntime(), typeId)};
+ return new IRubyObject[] {packerProc, ctx.runtime.newFixnum(typeId)};
}
}
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/ExtensionValue.java
new/ext/java/org/msgpack/jruby/ExtensionValue.java
--- old/ext/java/org/msgpack/jruby/ExtensionValue.java 2021-02-01
04:16:37.000000000 +0100
+++ new/ext/java/org/msgpack/jruby/ExtensionValue.java 2022-01-22
10:08:54.000000000 +0100
@@ -25,6 +25,7 @@
@JRubyClass(name="MessagePack::ExtensionValue")
public class ExtensionValue extends RubyObject {
+ private static final long serialVersionUID = 8451274621449322492L;
private final Encoding binaryEncoding;
private RubyFixnum type;
@@ -77,12 +78,10 @@
}
if (o instanceof ExtensionValue) {
ExtensionValue other = (ExtensionValue) o;
- if (!this.type.eql_p(other.type).isTrue())
+ if (!this.type.eql_p(other.type).isTrue()) {
return runtime.getFalse();
- if (runtime.is1_8()) {
- return this.payload.str_eql_p(ctx, other.payload);
} else {
- return this.payload.str_eql_p19(ctx, other.payload);
+ return this.payload.str_eql_p(ctx, other.payload);
}
}
return runtime.getFalse();
@@ -96,12 +95,10 @@
}
if (o instanceof ExtensionValue) {
ExtensionValue other = (ExtensionValue) o;
- if (!this.type.op_equal(ctx, other.type).isTrue())
+ if (!this.type.op_equal(ctx, other.type).isTrue()) {
return runtime.getFalse();
- if (runtime.is1_8()) {
- return this.payload.op_equal(ctx, other.payload);
} else {
- return this.payload.op_equal19(ctx, other.payload);
+ return this.payload.op_equal(ctx, other.payload);
}
}
return runtime.getFalse();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/Factory.java
new/ext/java/org/msgpack/jruby/Factory.java
--- old/ext/java/org/msgpack/jruby/Factory.java 2021-02-01 04:16:37.000000000
+0100
+++ new/ext/java/org/msgpack/jruby/Factory.java 2022-01-22 10:08:54.000000000
+0100
@@ -23,6 +23,7 @@
@JRubyClass(name="MessagePack::Factory")
public class Factory extends RubyObject {
+ private static final long serialVersionUID = 8441284623445322492L;
private final Ruby runtime;
private final ExtensionRegistry extensionRegistry;
private boolean hasSymbolExtType;
@@ -61,7 +62,7 @@
@JRubyMethod(name = "registered_types_internal", visibility = PRIVATE)
public IRubyObject registeredTypesInternal(ThreadContext ctx) {
- return RubyArray.newArray(ctx.getRuntime(), new IRubyObject[] {
+ return RubyArray.newArray(ctx.runtime, new IRubyObject[] {
extensionRegistry.toInternalPackerRegistry(ctx),
extensionRegistry.toInternalUnpackerRegistry(ctx)
});
@@ -69,7 +70,7 @@
@JRubyMethod(name = "register_type", required = 2, optional = 1)
public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args) {
- Ruby runtime = ctx.getRuntime();
+ Ruby runtime = ctx.runtime;
IRubyObject type = args[0];
IRubyObject mod = args[1];
@@ -88,6 +89,10 @@
RubyHash options = (RubyHash) args[args.length - 1];
packerArg = options.fastARef(runtime.newSymbol("packer"));
unpackerArg = options.fastARef(runtime.newSymbol("unpacker"));
+ IRubyObject optimizedSymbolsParsingArg =
options.fastARef(runtime.newSymbol("optimized_symbols_parsing"));
+ if (optimizedSymbolsParsingArg != null &&
optimizedSymbolsParsingArg.isTrue()) {
+ throw runtime.newArgumentError("JRuby implementation does not
support the optimized_symbols_parsing option");
+ }
} else {
throw runtime.newArgumentError(String.format("expected Hash but found
%s.", args[args.length - 1].getType().getName()));
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/Packer.java
new/ext/java/org/msgpack/jruby/Packer.java
--- old/ext/java/org/msgpack/jruby/Packer.java 2021-02-01 04:16:37.000000000
+0100
+++ new/ext/java/org/msgpack/jruby/Packer.java 2022-01-22 10:08:54.000000000
+0100
@@ -27,6 +27,7 @@
@JRubyClass(name="MessagePack::Packer")
public class Packer extends RubyObject {
+ private static final long serialVersionUID = 8451274621499362492L;
public ExtensionRegistry registry;
private Buffer buffer;
private Encoder encoder;
@@ -48,9 +49,10 @@
@JRubyMethod(name = "initialize", optional = 2)
public IRubyObject initialize(ThreadContext ctx, IRubyObject[] args) {
boolean compatibilityMode = false;
+ Ruby runtime = ctx.runtime;
if (args.length > 0 && args[args.length - 1] instanceof RubyHash) {
RubyHash options = (RubyHash) args[args.length - 1];
- IRubyObject mode =
options.fastARef(ctx.getRuntime().newSymbol("compatibility_mode"));
+ IRubyObject mode =
options.fastARef(runtime.newSymbol("compatibility_mode"));
compatibilityMode = (mode != null) && mode.isTrue();
}
if (registry == null) {
@@ -58,22 +60,22 @@
// registry is already initialized (and somthing might be registered)
when newPacker from Factory
this.registry = new ExtensionRegistry();
}
- this.encoder = new Encoder(ctx.getRuntime(), compatibilityMode, registry,
hasSymbolExtType);
- this.buffer = new Buffer(ctx.getRuntime(),
ctx.getRuntime().getModule("MessagePack").getClass("Buffer"));
+ this.encoder = new Encoder(runtime, compatibilityMode, registry,
hasSymbolExtType);
+ this.buffer = new Buffer(runtime,
runtime.getModule("MessagePack").getClass("Buffer"));
this.buffer.initialize(ctx, args);
- this.binaryEncoding =
ctx.getRuntime().getEncodingService().getAscii8bitEncoding();
+ this.binaryEncoding = runtime.getEncodingService().getAscii8bitEncoding();
return this;
}
public static Packer newPacker(ThreadContext ctx, ExtensionRegistry
extRegistry, boolean hasSymbolExtType, IRubyObject[] args) {
- Packer packer = new Packer(ctx.getRuntime(),
ctx.getRuntime().getModule("MessagePack").getClass("Packer"), extRegistry,
hasSymbolExtType);
+ Packer packer = new Packer(ctx.runtime,
ctx.runtime.getModule("MessagePack").getClass("Packer"), extRegistry,
hasSymbolExtType);
packer.initialize(ctx, args);
return packer;
}
@JRubyMethod(name = "compatibility_mode?")
public IRubyObject isCompatibilityMode(ThreadContext ctx) {
- return encoder.isCompatibilityMode() ? ctx.getRuntime().getTrue() :
ctx.getRuntime().getFalse();
+ return encoder.isCompatibilityMode() ? ctx.runtime.getTrue() :
ctx.runtime.getFalse();
}
@JRubyMethod(name = "registered_types_internal", visibility = PRIVATE)
@@ -83,7 +85,7 @@
@JRubyMethod(name = "register_type", required = 2, optional = 1)
public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args, final
Block block) {
- Ruby runtime = ctx.getRuntime();
+ Ruby runtime = ctx.runtime;
IRubyObject type = args[0];
IRubyObject mod = args[1];
@@ -182,12 +184,12 @@
@JRubyMethod(name = "write_true")
public IRubyObject writeTrue(ThreadContext ctx) {
- return write(ctx, ctx.getRuntime().getTrue());
+ return write(ctx, ctx.runtime.getTrue());
}
@JRubyMethod(name = "write_false")
public IRubyObject writeFalse(ThreadContext ctx) {
- return write(ctx, ctx.getRuntime().getFalse());
+ return write(ctx, ctx.runtime.getFalse());
}
@JRubyMethod(name = "write_nil")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/java/org/msgpack/jruby/Unpacker.java
new/ext/java/org/msgpack/jruby/Unpacker.java
--- old/ext/java/org/msgpack/jruby/Unpacker.java 2021-02-01
04:16:37.000000000 +0100
+++ new/ext/java/org/msgpack/jruby/Unpacker.java 2022-01-22
10:08:54.000000000 +0100
@@ -27,6 +27,7 @@
@JRubyClass(name="MessagePack::Unpacker")
public class Unpacker extends RubyObject {
+ private static final long serialVersionUID = 8451264671199362492L;
private final ExtensionRegistry registry;
private IRubyObject stream;
@@ -59,22 +60,23 @@
allowUnknownExt = false;
freeze = false;
if (args.length > 0) {
+ Ruby runtime = ctx.runtime;
if (args[args.length - 1] instanceof RubyHash) {
RubyHash options = (RubyHash) args[args.length - 1];
- IRubyObject sk =
options.fastARef(ctx.getRuntime().newSymbol("symbolize_keys"));
+ IRubyObject sk = options.fastARef(runtime.newSymbol("symbolize_keys"));
if (sk != null) {
symbolizeKeys = sk.isTrue();
}
- IRubyObject f = options.fastARef(ctx.getRuntime().newSymbol("freeze"));
+ IRubyObject f = options.fastARef(runtime.newSymbol("freeze"));
if (f != null) {
freeze = f.isTrue();
}
- IRubyObject au =
options.fastARef(ctx.getRuntime().newSymbol("allow_unknown_ext"));
+ IRubyObject au =
options.fastARef(runtime.newSymbol("allow_unknown_ext"));
if (au != null) {
allowUnknownExt = au.isTrue();
}
}
- if (args[0] != ctx.getRuntime().getNil() && !(args[0] instanceof
RubyHash)) {
+ if (args[0] != runtime.getNil() && !(args[0] instanceof RubyHash)) {
setStream(ctx, args[0]);
}
}
@@ -82,24 +84,24 @@
}
public static Unpacker newUnpacker(ThreadContext ctx, ExtensionRegistry
extRegistry, IRubyObject[] args) {
- Unpacker unpacker = new Unpacker(ctx.getRuntime(),
ctx.getRuntime().getModule("MessagePack").getClass("Unpacker"), extRegistry);
+ Unpacker unpacker = new Unpacker(ctx.runtime,
ctx.runtime.getModule("MessagePack").getClass("Unpacker"), extRegistry);
unpacker.initialize(ctx, args);
return unpacker;
}
@JRubyMethod(name = "symbolize_keys?")
public IRubyObject isSymbolizeKeys(ThreadContext ctx) {
- return symbolizeKeys ? ctx.getRuntime().getTrue() :
ctx.getRuntime().getFalse();
+ return symbolizeKeys ? ctx.runtime.getTrue() : ctx.runtime.getFalse();
}
@JRubyMethod(name = "freeze?")
public IRubyObject isFreeze(ThreadContext ctx) {
- return freeze ? ctx.getRuntime().getTrue() : ctx.getRuntime().getFalse();
+ return freeze ? ctx.runtime.getTrue() : ctx.runtime.getFalse();
}
@JRubyMethod(name = "allow_unknown_ext?")
public IRubyObject isAllowUnknownExt(ThreadContext ctx) {
- return allowUnknownExt ? ctx.getRuntime().getTrue() :
ctx.getRuntime().getFalse();
+ return allowUnknownExt ? ctx.runtime.getTrue() : ctx.runtime.getFalse();
}
@JRubyMethod(name = "registered_types_internal", visibility = PRIVATE)
@@ -109,7 +111,7 @@
@JRubyMethod(name = "register_type", required = 1, optional = 2)
public IRubyObject registerType(ThreadContext ctx, IRubyObject[] args, final
Block block) {
- Ruby runtime = ctx.getRuntime();
+ Ruby runtime = ctx.runtime;
IRubyObject type = args[0];
RubyModule extModule;
@@ -155,7 +157,7 @@
if (limit == -1) {
limit = byteList.length() - offset;
}
- Decoder decoder = new Decoder(ctx.getRuntime(), registry,
byteList.unsafeBytes(), byteList.begin() + offset, limit, symbolizeKeys,
freeze, allowUnknownExt);
+ Decoder decoder = new Decoder(ctx.runtime, registry,
byteList.unsafeBytes(), byteList.begin() + offset, limit, symbolizeKeys,
freeze, allowUnknownExt);
try {
data = null;
data = decoder.next();
@@ -164,13 +166,13 @@
throw re;
}
}
- return ctx.getRuntime().newFixnum(decoder.offset());
+ return ctx.runtime.newFixnum(decoder.offset());
}
@JRubyMethod(name = "data")
public IRubyObject getData(ThreadContext ctx) {
if (data == null) {
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
} else {
return data;
}
@@ -178,14 +180,14 @@
@JRubyMethod(name = "finished?")
public IRubyObject finished_p(ThreadContext ctx) {
- return data == null ? ctx.getRuntime().getFalse() :
ctx.getRuntime().getTrue();
+ return data == null ? ctx.runtime.getFalse() : ctx.runtime.getTrue();
}
@JRubyMethod(required = 1, name = "feed", alias = { "feed_reference" })
public IRubyObject feed(ThreadContext ctx, IRubyObject data) {
ByteList byteList = data.asString().getByteList();
if (decoder == null) {
- decoder = new Decoder(ctx.getRuntime(), registry,
byteList.unsafeBytes(), byteList.begin(), byteList.length(), symbolizeKeys,
freeze, allowUnknownExt);
+ decoder = new Decoder(ctx.runtime, registry, byteList.unsafeBytes(),
byteList.begin(), byteList.length(), symbolizeKeys, freeze, allowUnknownExt);
} else {
decoder.feed(byteList.unsafeBytes(), byteList.begin(),
byteList.length());
}
@@ -202,7 +204,7 @@
feed(ctx, data);
if (block.isGiven()) {
each(ctx, block);
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
} else {
return callMethod(ctx, "to_enum");
}
@@ -230,7 +232,7 @@
@JRubyMethod
public IRubyObject fill(ThreadContext ctx) {
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
}
@JRubyMethod
@@ -238,13 +240,13 @@
if (decoder != null) {
decoder.reset();
}
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
}
@JRubyMethod(name = "read", alias = { "unpack" })
public IRubyObject read(ThreadContext ctx) {
if (decoder == null) {
- throw ctx.getRuntime().newEOFError();
+ throw ctx.runtime.newEOFError();
}
try {
return decoder.next();
@@ -252,19 +254,19 @@
if (re.getException().getType() != underflowErrorClass) {
throw re;
} else {
- throw ctx.getRuntime().newEOFError();
+ throw ctx.runtime.newEOFError();
}
}
}
@JRubyMethod(name = "skip")
public IRubyObject skip(ThreadContext ctx) {
- throw ctx.getRuntime().newNotImplementedError("Not supported yet in JRuby
implementation");
+ throw ctx.runtime.newNotImplementedError("Not supported yet in JRuby
implementation");
}
@JRubyMethod(name = "skip_nil")
public IRubyObject skipNil(ThreadContext ctx) {
- throw ctx.getRuntime().newNotImplementedError("Not supported yet in JRuby
implementation");
+ throw ctx.runtime.newNotImplementedError("Not supported yet in JRuby
implementation");
}
@JRubyMethod
@@ -276,11 +278,11 @@
if (re.getException().getType() != underflowErrorClass) {
throw re;
} else {
- throw ctx.getRuntime().newEOFError();
+ throw ctx.runtime.newEOFError();
}
}
}
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
}
@JRubyMethod
@@ -292,17 +294,17 @@
if (re.getException().getType() != underflowErrorClass) {
throw re;
} else {
- throw ctx.getRuntime().newEOFError();
+ throw ctx.runtime.newEOFError();
}
}
}
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
}
@JRubyMethod(name = "stream")
public IRubyObject getStream(ThreadContext ctx) {
if (stream == null) {
- return ctx.getRuntime().getNil();
+ return ctx.runtime.getNil();
} else {
return stream;
}
@@ -318,12 +320,12 @@
} else if (stream.respondsTo("read")) {
str = stream.callMethod(ctx, "read").asString();
} else {
- throw ctx.getRuntime().newTypeError(stream, "IO");
+ throw ctx.runtime.newTypeError(stream, "IO");
}
ByteList byteList = str.getByteList();
this.stream = stream;
this.decoder = null;
- this.decoder = new Decoder(ctx.getRuntime(), registry,
byteList.unsafeBytes(), byteList.begin(), byteList.length(), symbolizeKeys,
freeze, allowUnknownExt);
+ this.decoder = new Decoder(ctx.runtime, registry, byteList.unsafeBytes(),
byteList.begin(), byteList.length(), symbolizeKeys, freeze, allowUnknownExt);
return getStream(ctx);
}
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/buffer.c new/ext/msgpack/buffer.c
--- old/ext/msgpack/buffer.c 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/buffer.c 2022-01-22 10:08:54.000000000 +0100
@@ -164,12 +164,7 @@
b->head->mapped_string != NO_MAPPED_STRING &&
length >= b->read_reference_threshold) {
VALUE s = _msgpack_buffer_refer_head_mapped_string(b, length);
-#ifndef HAVE_RB_STR_REPLACE
- /* TODO MRI 1.8 */
- rb_funcall(string, s_replace, 1, s);
-#else
rb_str_replace(string, s);
-#endif
/* here doesn't have to call ENCODING_SET because
* encoding of s is always ASCII-8BIT */
_msgpack_buffer_consumed(b, length);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/buffer.h new/ext/msgpack/buffer.h
--- old/ext/msgpack/buffer.h 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/buffer.h 2022-01-22 10:08:54.000000000 +0100
@@ -494,4 +494,9 @@
#endif // HAVE_RB_ENC_INTERNED_STR
}
+static inline VALUE msgpack_buffer_read_top_as_symbol(msgpack_buffer_t* b,
size_t length)
+{
+ return rb_str_intern(msgpack_buffer_read_top_as_string(b, length, true,
false));
+}
+
#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/extconf.rb new/ext/msgpack/extconf.rb
--- old/ext/msgpack/extconf.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/extconf.rb 2022-01-22 10:08:54.000000000 +0100
@@ -2,14 +2,7 @@
have_header("ruby/st.h")
have_header("st.h")
-have_func("rb_str_replace", ["ruby.h"])
-have_func("rb_intern_str", ["ruby.h"])
have_func("rb_enc_interned_str", "ruby.h")
-have_func("rb_sym2str", ["ruby.h"])
-have_func("rb_str_intern", ["ruby.h"])
-have_func("rb_block_lambda", ["ruby.h"])
-have_func("rb_hash_dup", ["ruby.h"])
-have_func("rb_hash_clear", ["ruby.h"])
unless RUBY_PLATFORM.include? 'mswin'
$CFLAGS << %[ -I.. -Wall -O3 -g -std=gnu99]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/factory_class.c
new/ext/msgpack/factory_class.c
--- old/ext/msgpack/factory_class.c 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/factory_class.c 2022-01-22 10:08:54.000000000 +0100
@@ -32,6 +32,8 @@
msgpack_packer_ext_registry_t pkrg;
msgpack_unpacker_ext_registry_t ukrg;
bool has_symbol_ext_type;
+ bool optimized_symbol_ext_type;
+ int symbol_ext_type;
};
#define FACTORY(from, name) \
@@ -114,6 +116,8 @@
msgpack_unpacker_ext_registry_destroy(&uk->ext_registry);
msgpack_unpacker_ext_registry_dup(&fc->ukrg, &uk->ext_registry);
+ uk->optimized_symbol_ext_type = fc->optimized_symbol_ext_type;
+ uk->symbol_ext_type = fc->symbol_ext_type;
return unpacker;
}
@@ -128,11 +132,7 @@
rb_hash_aset(uk_mapping, INT2FIX(i - 128), fc->ukrg.array[i]);
}
}
-#ifdef HAVE_RB_HASH_DUP
return rb_ary_new3(2, rb_hash_dup(fc->pkrg.hash), uk_mapping);
-#else
- return rb_ary_new3(2, rb_funcall(fc->pkrg.hash, rb_intern("dup"), 0),
uk_mapping);
-#endif
}
static VALUE Factory_register_type(int argc, VALUE* argv, VALUE self)
@@ -141,7 +141,7 @@
int ext_type;
VALUE ext_module;
- VALUE options;
+ VALUE options = Qnil;
VALUE packer_arg, unpacker_arg;
VALUE packer_proc, unpacker_proc;
@@ -188,6 +188,8 @@
if(unpacker_arg != Qnil) {
if(rb_type(unpacker_arg) == T_SYMBOL || rb_type(unpacker_arg) ==
T_STRING) {
unpacker_proc = rb_obj_method(ext_module, unpacker_arg);
+ } else if (rb_respond_to(unpacker_arg, rb_intern("call"))) {
+ unpacker_proc = unpacker_arg;
} else {
unpacker_proc = rb_funcall(unpacker_arg, rb_intern("method"), 1,
ID2SYM(rb_intern("call")));
}
@@ -197,6 +199,9 @@
if (ext_module == rb_cSymbol) {
fc->has_symbol_ext_type = true;
+ if(RB_TEST(options) && RB_TEST(rb_hash_aref(options,
ID2SYM(rb_intern("optimized_symbols_parsing"))))) {
+ fc->optimized_symbol_ext_type = true;
+ }
}
msgpack_unpacker_ext_registry_put(&fc->ukrg, ext_module, ext_type,
unpacker_proc, unpacker_arg);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/packer.c new/ext/msgpack/packer.c
--- old/ext/msgpack/packer.c 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/packer.c 2022-01-22 10:08:54.000000000 +0100
@@ -121,7 +121,7 @@
#endif
}
-void msgpack_packer_write_other_value(msgpack_packer_t* pk, VALUE v)
+bool msgpack_packer_try_write_with_ext_type_lookup(msgpack_packer_t* pk, VALUE
v)
{
int ext_type;
@@ -131,7 +131,14 @@
VALUE payload = rb_funcall(proc, s_call, 1, v);
StringValue(payload);
msgpack_packer_write_ext(pk, ext_type, payload);
- } else {
+ return true;
+ }
+ return false;
+}
+
+void msgpack_packer_write_other_value(msgpack_packer_t* pk, VALUE v)
+{
+ if(!(msgpack_packer_try_write_with_ext_type_lookup(pk, v))) {
rb_funcall(v, pk->to_msgpack_method, 1, pk->to_msgpack_arg);
}
}
@@ -155,13 +162,19 @@
msgpack_packer_write_symbol_value(pk, v);
break;
case T_STRING:
- msgpack_packer_write_string_value(pk, v);
+ if(rb_class_of(v) == rb_cString ||
!msgpack_packer_try_write_with_ext_type_lookup(pk, v)) {
+ msgpack_packer_write_string_value(pk, v);
+ }
break;
case T_ARRAY:
- msgpack_packer_write_array_value(pk, v);
+ if(rb_class_of(v) == rb_cArray ||
!msgpack_packer_try_write_with_ext_type_lookup(pk, v)) {
+ msgpack_packer_write_array_value(pk, v);
+ }
break;
case T_HASH:
- msgpack_packer_write_hash_value(pk, v);
+ if(rb_class_of(v) == rb_cHash ||
!msgpack_packer_try_write_with_ext_type_lookup(pk, v)) {
+ msgpack_packer_write_hash_value(pk, v);
+ }
break;
case T_BIGNUM:
msgpack_packer_write_bignum_value(pk, v);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/packer.h new/ext/msgpack/packer.h
--- old/ext/msgpack/packer.h 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/packer.h 2022-01-22 10:08:54.000000000 +0100
@@ -444,16 +444,7 @@
static inline void msgpack_packer_write_symbol_string_value(msgpack_packer_t*
pk, VALUE v)
{
-#ifdef HAVE_RB_SYM2STR
- /* rb_sym2str is added since MRI 2.2.0 */
msgpack_packer_write_string_value(pk, rb_sym2str(v));
-#else
- VALUE str = rb_id2str(SYM2ID(v));
- if (!str) {
- rb_raise(rb_eRuntimeError, "could not convert a symbol to string");
- }
- msgpack_packer_write_string_value(pk, str);
-#endif
}
void msgpack_packer_write_other_value(msgpack_packer_t* pk, VALUE v);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/packer_class.c
new/ext/msgpack/packer_class.c
--- old/ext/msgpack/packer_class.c 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/packer_class.c 2022-01-22 10:08:54.000000000 +0100
@@ -339,11 +339,7 @@
static VALUE Packer_registered_types_internal(VALUE self)
{
PACKER(self, pk);
-#ifdef HAVE_RB_HASH_DUP
return rb_hash_dup(pk->ext_registry.hash);
-#else
- return rb_funcall(pk->ext_registry.hash, rb_intern("dup"), 0);
-#endif
}
static VALUE Packer_register_type(int argc, VALUE* argv, VALUE self)
@@ -359,12 +355,7 @@
case 2:
/* register_type(0x7f, Time) {|obj| block... } */
rb_need_block();
-#ifdef HAVE_RB_BLOCK_LAMBDA
proc = rb_block_lambda();
-#else
- /* MRI 1.8 */
- proc = rb_block_proc();
-#endif
arg = proc;
break;
case 3:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/packer_ext_registry.c
new/ext/msgpack/packer_ext_registry.c
--- old/ext/msgpack/packer_ext_registry.c 2021-02-01 04:16:37.000000000
+0100
+++ new/ext/msgpack/packer_ext_registry.c 2022-01-22 10:08:54.000000000
+0100
@@ -43,37 +43,15 @@
void msgpack_packer_ext_registry_dup(msgpack_packer_ext_registry_t* src,
msgpack_packer_ext_registry_t* dst)
{
-#ifdef HAVE_RB_HASH_DUP
dst->hash = rb_hash_dup(src->hash);
dst->cache = rb_hash_dup(src->cache);
-#else
- dst->hash = rb_funcall(src->hash, rb_intern("dup"), 0);
- dst->cache = rb_funcall(src->cache, rb_intern("dup"), 0);
-#endif
}
-#ifndef HAVE_RB_HASH_CLEAR
-
-static int
-__rb_hash_clear_clear_i(key, value, dummy)
- VALUE key, value, dummy;
-{
- return ST_DELETE;
-}
-
-#endif
-
VALUE msgpack_packer_ext_registry_put(msgpack_packer_ext_registry_t* pkrg,
VALUE ext_module, int ext_type, VALUE proc, VALUE arg)
{
VALUE e = rb_ary_new3(3, INT2FIX(ext_type), proc, arg);
/* clear lookup cache not to miss added type */
-#ifdef HAVE_RB_HASH_CLEAR
rb_hash_clear(pkrg->cache);
-#else
- if(FIX2INT(rb_funcall(pkrg->cache, rb_intern("size"), 0)) > 0) {
- rb_hash_foreach(pkrg->cache, __rb_hash_clear_clear_i, 0);
- }
-#endif
return rb_hash_aset(pkrg->hash, ext_module, e);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/unpacker.c new/ext/msgpack/unpacker.c
--- old/ext/msgpack/unpacker.c 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/unpacker.c 2022-01-22 10:08:54.000000000 +0100
@@ -151,8 +151,19 @@
return PRIMITIVE_OBJECT_COMPLETE;
}
+static inline int object_complete_symbol(msgpack_unpacker_t* uk, VALUE object)
+{
+ uk->last_object = object;
+ reset_head_byte(uk);
+ return PRIMITIVE_OBJECT_COMPLETE;
+}
+
static inline int object_complete_ext(msgpack_unpacker_t* uk, int ext_type,
VALUE str)
{
+ if (uk->optimized_symbol_ext_type && ext_type == uk->symbol_ext_type) {
+ return object_complete_symbol(uk, rb_str_intern(str));
+ }
+
VALUE proc = msgpack_unpacker_ext_registry_lookup(&uk->ext_registry,
ext_type);
if(proc != Qnil) {
VALUE obj = rb_funcall(proc, s_call, 1, str);
@@ -273,22 +284,27 @@
/* try optimized read */
size_t length = uk->reading_raw_remaining;
if(length <= msgpack_buffer_top_readable_size(UNPACKER_BUFFER_(uk))) {
- /* don't use zerocopy for hash keys but get a frozen string directly
- * because rb_hash_aset freezes keys and it causes copying */
- bool will_freeze = uk->freeze || is_reading_map_key(uk);
- VALUE string = msgpack_buffer_read_top_as_string(UNPACKER_BUFFER_(uk),
length, will_freeze, raw_type == RAW_TYPE_STRING);
int ret;
- if(raw_type == RAW_TYPE_STRING || raw_type == RAW_TYPE_BINARY) {
- ret = object_complete(uk, string);
+ if ((uk->optimized_symbol_ext_type && uk->symbol_ext_type == raw_type)
|| (uk->symbolize_keys && is_reading_map_key(uk))) {
+ VALUE symbol =
msgpack_buffer_read_top_as_symbol(UNPACKER_BUFFER_(uk), length);
+ ret = object_complete_symbol(uk, symbol);
} else {
- ret = object_complete_ext(uk, raw_type, string);
- }
+ /* don't use zerocopy for hash keys but get a frozen string
directly
+ * because rb_hash_aset freezes keys and it causes copying */
+ bool will_freeze = uk->freeze || is_reading_map_key(uk);
+ VALUE string =
msgpack_buffer_read_top_as_string(UNPACKER_BUFFER_(uk), length, will_freeze,
raw_type == RAW_TYPE_STRING);
+ if(raw_type == RAW_TYPE_STRING || raw_type == RAW_TYPE_BINARY) {
+ ret = object_complete(uk, string);
+ } else {
+ ret = object_complete_ext(uk, raw_type, string);
+ }
# if !HASH_ASET_DEDUPE
- if(will_freeze) {
- rb_obj_freeze(string);
- }
+ if(will_freeze) {
+ rb_obj_freeze(string);
+ }
# endif
+ }
uk->reading_raw_remaining = 0;
return ret;
}
@@ -705,18 +721,8 @@
break;
case STACK_TYPE_MAP_VALUE:
if(uk->symbolize_keys && rb_type(top->key) == T_STRING) {
- /* here uses rb_intern_str instead of rb_intern so that
Ruby VM can GC unused symbols */
-#ifdef HAVE_RB_STR_INTERN
- /* rb_str_intern is added since MRI 2.2.0 */
+ /* here uses rb_str_intern instead of rb_intern so that
Ruby VM can GC unused symbols */
rb_hash_aset(top->object, rb_str_intern(top->key),
uk->last_object);
-#else
-#ifndef HAVE_RB_INTERN_STR
- /* MRI 1.8 doesn't have rb_intern_str or rb_intern2 */
- rb_hash_aset(top->object,
ID2SYM(rb_intern(RSTRING_PTR(top->key))), uk->last_object);
-#else
- rb_hash_aset(top->object, ID2SYM(rb_intern_str(top->key)),
uk->last_object);
-#endif
-#endif
} else {
rb_hash_aset(top->object, top->key, uk->last_object);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/unpacker.h new/ext/msgpack/unpacker.h
--- old/ext/msgpack/unpacker.h 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/unpacker.h 2022-01-22 10:08:54.000000000 +0100
@@ -66,6 +66,8 @@
bool symbolize_keys;
bool freeze;
bool allow_unknown_ext;
+ bool optimized_symbol_ext_type;
+ int symbol_ext_type;
};
#define UNPACKER_BUFFER_(uk) (&(uk)->buffer)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/ext/msgpack/unpacker_class.c
new/ext/msgpack/unpacker_class.c
--- old/ext/msgpack/unpacker_class.c 2021-02-01 04:16:37.000000000 +0100
+++ new/ext/msgpack/unpacker_class.c 2022-01-22 10:08:54.000000000 +0100
@@ -369,12 +369,7 @@
case 1:
/* register_type(0x7f) {|data| block... } */
rb_need_block();
-#ifdef HAVE_RB_BLOCK_LAMBDA
proc = rb_block_lambda();
-#else
- /* MRI 1.8 */
- proc = rb_block_proc();
-#endif
arg = proc;
ext_module = Qnil;
break;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/msgpack/symbol.rb new/lib/msgpack/symbol.rb
--- old/lib/msgpack/symbol.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/lib/msgpack/symbol.rb 2022-01-22 10:08:54.000000000 +0100
@@ -1,9 +1,19 @@
class Symbol
- def to_msgpack_ext
- [to_s].pack('A*')
+ # to_msgpack_ext is supposed to return a binary string.
+ # The canonical way to do it for symbols would be:
+ # [to_s].pack('A*')
+ # However in this instance we can take a shortcut
+ if method_defined?(:name)
+ alias_method :to_msgpack_ext, :name
+ else
+ alias_method :to_msgpack_ext, :to_s
end
def self.from_msgpack_ext(data)
- data.unpack('A*').first.to_sym
+ # from_msgpack_ext is supposed to parse a binary string.
+ # The canonical way to do it for symbols would be:
+ # data.unpack1('A*').to_sym
+ # However in this instance we can take a shortcut
+ data.to_sym
end
-end
\ No newline at end of file
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/msgpack/time.rb new/lib/msgpack/time.rb
--- old/lib/msgpack/time.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/lib/msgpack/time.rb 2022-01-22 10:08:54.000000000 +0100
@@ -18,7 +18,7 @@
else
lambda do |payload|
tv = MessagePack::Timestamp.from_msgpack_ext(payload)
- ::Time.at(tv.sec, tv.nsec / 1000.0)
+ ::Time.at(tv.sec, tv.nsec / 1000.0r)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/msgpack/version.rb new/lib/msgpack/version.rb
--- old/lib/msgpack/version.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/lib/msgpack/version.rb 2022-01-22 10:08:54.000000000 +0100
@@ -1,5 +1,5 @@
module MessagePack
- VERSION = "1.4.2"
+ VERSION = "1.4.4"
# Note for maintainers:
# Don't miss building/releasing the JRuby version (rake buld:java)
# See "How to build -java rubygems" in README for more details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/msgpack.rb new/lib/msgpack.rb
--- old/lib/msgpack.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/lib/msgpack.rb 2022-01-22 10:08:54.000000000 +0100
@@ -1,9 +1,8 @@
require "msgpack/version"
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" # This is same with `/java/
=~ RUBY_VERSION`
- require "java"
require "msgpack/msgpack.jar"
- org.msgpack.jruby.MessagePackLibrary.new.load(JRuby.runtime, false)
+ JRuby::Util.load_ext("org.msgpack.jruby.MessagePackLibrary")
else
require "msgpack/msgpack"
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2021-02-01 04:16:37.000000000 +0100
+++ new/metadata 2022-01-22 10:08:54.000000000 +0100
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: msgpack
version: !ruby/object:Gem::Version
- version: 1.4.2
+ version: 1.4.4
platform: ruby
authors:
- Sadayuki Furuhashi
@@ -10,7 +10,7 @@
autorequire:
bindir: bin
cert_chain: []
-date: 2021-02-01 00:00:00.000000000 Z
+date: 2022-01-22 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: bundler
@@ -46,14 +46,14 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '0'
+ version: 1.1.9
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: '0'
+ version: 1.1.9
- !ruby/object:Gem::Dependency
name: rspec
requirement: !ruby/object:Gem::Requirement
@@ -108,9 +108,9 @@
- ext/msgpack/extconf.rb
extra_rdoc_files: []
files:
+- ".github/workflows/ci.yaml"
- ".gitignore"
- ".rubocop.yml"
-- ".travis.yml"
- ChangeLog
- Gemfile
- LICENSE
@@ -229,32 +229,8 @@
- !ruby/object:Gem::Version
version: '0'
requirements: []
-rubygems_version: 3.2.3
+rubygems_version: 3.3.3
signing_key:
specification_version: 4
summary: MessagePack, a binary-based efficient data interchange format.
-test_files:
-- spec/cases.json
-- spec/cases.msg
-- spec/cases_compact.msg
-- spec/cases_spec.rb
-- spec/cruby/buffer_io_spec.rb
-- spec/cruby/buffer_packer.rb
-- spec/cruby/buffer_spec.rb
-- spec/cruby/buffer_unpacker.rb
-- spec/cruby/unpacker_spec.rb
-- spec/ext_value_spec.rb
-- spec/exttypes.rb
-- spec/factory_spec.rb
-- spec/format_spec.rb
-- spec/jruby/benchmarks/shootout_bm.rb
-- spec/jruby/benchmarks/symbolize_keys_bm.rb
-- spec/jruby/unpacker_spec.rb
-- spec/msgpack_spec.rb
-- spec/pack_spec.rb
-- spec/packer_spec.rb
-- spec/random_compat.rb
-- spec/spec_helper.rb
-- spec/timestamp_spec.rb
-- spec/unpack_spec.rb
-- spec/unpacker_spec.rb
+test_files: []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/msgpack.gemspec new/msgpack.gemspec
--- old/msgpack.gemspec 2021-02-01 04:16:37.000000000 +0100
+++ new/msgpack.gemspec 2022-01-22 10:08:54.000000000 +0100
@@ -18,13 +18,12 @@
s.files = `git ls-files`.split("\n")
s.extensions = ["ext/msgpack/extconf.rb"]
end
- s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
s.required_ruby_version = ">= 2.4"
s.add_development_dependency 'bundler'
s.add_development_dependency 'rake'
- s.add_development_dependency 'rake-compiler'
+ s.add_development_dependency 'rake-compiler', ['>= 1.1.9']
s.add_development_dependency 'rspec', ['~> 3.3']
s.add_development_dependency 'yard'
s.add_development_dependency 'json'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/factory_spec.rb new/spec/factory_spec.rb
--- old/spec/factory_spec.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/spec/factory_spec.rb 2022-01-22 10:08:54.000000000 +0100
@@ -280,6 +280,23 @@
unpacker.feed(packed_symbol).unpack
end
+ context 'using the optimized symbol unpacker' do
+ before do
+ skip if IS_JRUBY # JRuby implementation doesn't support the optimized
symbols unpacker for now
+ subject.register_type(
+ 0x00,
+ ::Symbol,
+ packer: :to_msgpack_ext,
+ unpacker: :from_msgpack_ext,
+ optimized_symbols_parsing: true,
+ )
+ end
+
+ it 'lets symbols survive a roundtrip' do
+ expect(symbol_after_roundtrip).to be :symbol
+ end
+ end
+
context 'if no ext type is registered for symbols' do
it 'converts symbols to string' do
expect(symbol_after_roundtrip).to eq 'symbol'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/msgpack_spec.rb new/spec/msgpack_spec.rb
--- old/spec/msgpack_spec.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/spec/msgpack_spec.rb 2022-01-22 10:08:54.000000000 +0100
@@ -115,7 +115,7 @@
expect { MessagePack.pack(self) }.to raise_error(NoMethodError,
/^undefined method `to_msgpack'/)
end
- it 'rasies an error on #unpack with garbage' do
+ it 'raises an error on #unpack with garbage' do
skip "but nothing was raised. why?"
expect { MessagePack.unpack('asdka;sd') }.to
raise_error(MessagePack::UnpackError)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/packer_spec.rb new/spec/packer_spec.rb
--- old/spec/packer_spec.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/spec/packer_spec.rb 2022-01-22 10:08:54.000000000 +0100
@@ -488,6 +488,24 @@
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
end
+ shared_examples_for 'extension subclasses core type' do |klass|
+ before { stub_const('Value', Class.new(klass)) }
+ let(:object) { Value.new }
+ subject { packer.pack(object).to_s }
+
+ it "defaults to #{klass.name} packer if no extension is present" do
+ expect(subject).to eq(MessagePack.dump(klass.new))
+ end
+
+ it "uses core type extension for #{klass.name}" do
+ packer.register_type(0x01, Value, ->(_) { 'value_msgpacked' })
+ expect(subject).to eq("\xC7\x0F\x01value_msgpacked")
+ end
+ end
+ it_behaves_like 'extension subclasses core type', Hash
+ it_behaves_like 'extension subclasses core type', Array
+ it_behaves_like 'extension subclasses core type', String
+
context 'when registering a type for symbols' do
before { packer.register_type(0x00, ::Symbol, :to_msgpack_ext) }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/spec/spec_helper.rb 2022-01-22 10:08:54.000000000 +0100
@@ -15,6 +15,16 @@
require 'msgpack'
+if GC.respond_to?(:verify_compaction_references)
+ # This method was added in Ruby 3.0.0. Calling it this way asks the GC to
+ # move objects around, helping to find object movement bugs.
+ GC.verify_compaction_references(double_heap: true, toward: :empty)
+end
+
+if GC.respond_to?(:auto_compact=)
+ GC.auto_compact = true
+end
+
def java?
/java/ =~ RUBY_PLATFORM
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/timestamp_spec.rb new/spec/timestamp_spec.rb
--- old/spec/timestamp_spec.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/spec/timestamp_spec.rb 2022-01-22 10:08:54.000000000 +0100
@@ -2,6 +2,8 @@
require 'spec_helper'
+IS_JRUBY = Kernel.const_defined?(:JRUBY_VERSION)
+
describe MessagePack::Timestamp do
describe 'malformed format' do
it do
@@ -60,6 +62,44 @@
it 'runs correctly (regression)' do
expect(factory.unpack(factory.pack(Time.utc(2200)))).to
eq(Time.utc(2200))
end
+
+ let(:time32_max) { Time.new(2106, 2, 7, 6, 28, 15, "+00:00") }
+ it 'is serialized into timestamp32' do
+ expect(factory.pack(time32_max).size).to be 6
+ expect(factory.unpack(factory.pack(time32_max)).utc).to eq(time32_max)
+ end
+
+ let(:time64_min) { Time.new(2106, 2, 7, 6, 28, 16, "+00:00") }
+ it 'is serialized into timestamp64' do
+ expect(factory.pack(time64_min).size).to be 10
+ expect(factory.unpack(factory.pack(time64_min)).utc).to eq(time64_min)
+ end
+
+ let(:time64_max) { Time.at(Time.new(2514, 5, 30, 1, 53, 3, "+00:00").to_i,
999999999 / 1000.0r).utc } # TODO: use Time.at(sec, nsec, :nsec) when removing
Ruby 2.4 from the list
+ it 'is serialized into timestamp64' do
+ expect(factory.pack(time64_max).size).to be 10
+ expect(factory.unpack(factory.pack(time64_max)).utc).to eq(time64_max)
+ end
+
+ let(:time96_positive_min) { Time.new(2514, 5, 30, 1, 53, 4, "+00:00") }
+ it 'is serialized into timestamp96' do
+ expect(factory.pack(time96_positive_min).size).to be 15
+ expect(factory.unpack(factory.pack(time96_positive_min)).utc).to
eq(time96_positive_min)
+ end
+
+ let(:time96_min) { Time.at(-2**63).utc }
+ it 'is serialized into timestamp96' do
+ skip if IS_JRUBY # JRuby cannot handle numerics larger than long
+ expect(factory.pack(time96_min).size).to be 15
+ expect(factory.unpack(factory.pack(time96_min)).utc).to eq(time96_min)
+ end
+
+ let(:time96_max) { Time.at(2**63 - 1).utc }
+ it 'is serialized into timestamp96' do
+ skip if IS_JRUBY # JRuby cannot handle numerics larger than long
+ expect(factory.pack(time96_max).size).to be 15
+ expect(factory.unpack(factory.pack(time96_max)).utc).to eq(time96_max)
+ end
end
describe 'register_type with MessagePack::Timestamp' do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unpacker_spec.rb new/spec/unpacker_spec.rb
--- old/spec/unpacker_spec.rb 2021-02-01 04:16:37.000000000 +0100
+++ new/spec/unpacker_spec.rb 2022-01-22 10:08:54.000000000 +0100
@@ -36,6 +36,15 @@
unpacker.each { |obj| hashes = obj }
expect(hashes[0].keys.first).to equal(hashes[1].keys.first)
end
+
+ it 'ensure strings are not deduplicated' do
+ sample_data = ["foo"]
+ sample_packed =
MessagePack.pack(sample_data).force_encoding('ASCII-8BIT')
+ unpacker.feed(sample_packed)
+ ary = nil
+ unpacker.each { |obj| ary = obj }
+ expect(ary.first.frozen?).to eq(false)
+ end
end
it 'gets IO or object which has #read to read data from it' do
@@ -635,7 +644,7 @@
MessagePack.unpack(MessagePack.pack(array)).size.should == 10_000
end
- it 'preserve string encoding (issue #200)' do
+ it 'preserves string encoding (issue #200)' do
string = 'a'.force_encoding(Encoding::UTF_8)
MessagePack.unpack(MessagePack.pack(string)).encoding.should ==
string.encoding