Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add full spec ext type support to JRuby implementation #91

Merged
merged 40 commits into from
Oct 23, 2015

Conversation

tagomoris
Copy link
Member

This WIP branch is for #87 and #55.
msgpack-ruby v0.7.0 will be released after this branch merged.

@tagomoris
Copy link
Member Author

Almost implementation is already done.
Now I'm merging specs between cruby and jruby, but some of these are failing.

@tagomoris
Copy link
Member Author

Mission accomplished! Almost all specs are merged into spec/*.rb, except for Buffer APIs of CRuby implementation, or Unpacker#execute of JRuby implementation. These are left on spec/cruby and spec/jruby.

Tests are failing with jruby-19mode on mac environment because of Travis-CI's any troubles, and with jruby-head for unidentified error.

I changed the behavior of JRuby implementation below:

  • removed Unpacker.new(encoding: "ENCODING_NAME") to decode strings as utf8, and binaries as ascii-8bit
  • added Unpacker.new(allow_unknown_ext: bool) to specify to allow using Extension objects for unknown ext types, and make that default as false (changed from v0.6 jruby implementation behavior)

@iconara How do you think about this change? Could you review this?

return ExtensionValue.newExtensionValue(runtime, type, payload);

if (this.registry != null) {
IRubyObject proc = this.registry.lookup(type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to prefix all instance variable accesses with this.. It's not that it matters if you do, just that it breaks the style of the rest of the Java code.

@tagomoris
Copy link
Member Author

I've pushed commits against reviews.
JRuby 9.0.1.0 is still failing for tests about encoding...

@tagomoris
Copy link
Member Author

Failure on JRuby 9.0.1.0 is from this bug: jruby/jruby#3405

@tagomoris tagomoris changed the title [WIP] add full spec ext type support to JRuby implementation add full spec ext type support to JRuby implementation Oct 22, 2015
@tagomoris tagomoris mentioned this pull request Oct 22, 2015
3 tasks
@tagomoris
Copy link
Member Author

@iconara Could you review this change once more?

I didn't change ExtensionRegistry internal classes. These are similar but different from each other.
Of course we can create a registry classes for both of Packer and Unpacker, but it will have 2 different member and accessor for Packer and Unpacker. It looks nonsense for me.

public void allowUnknownExt(boolean allow) {
this.allowUnknownExt = allow;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a constructor argument (same goes for #symbolizeKeys).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with review, and pushing

iconara and others added 7 commits October 23, 2015 08:59
Comments are at best outdated, but most of the time they confuse more than they help. Whenever you feel the urge to write a comment, think about how you can rewrite the code to make it not need a comment to explain what it does.
By extracting the code below a comment to a method that explains what the code does the comment is not needed and the code is self-explaining.
What this comment says is better explained by the exception thrown by the method.
@iconara
Copy link
Member

iconara commented Oct 23, 2015

I think it's harder to explain than show, so I'm going to push up some code in a separate branch showing you what I mean. I'll try to get it done within the next hour or two.

…ternals

Use Java collections for the registry and cache, and use a class for the four-tuple containing the registered entries.
Make it possible to look up extensions in ExtensionRegistry by type ID, and add the features needed to make it work for the unpacking side of things.

Eliminate duplicated code in Factory#registered_types_internal and Unpacker#registered_types_internal by moving it to ExtensionRegistry.

There are a few tests that fail because of this change. The reason is that Factory#registered_types_internal, Packer#registered_types_internal and Unpacker#registered_types_internal have inconsistent interfaces. The consumers of these methods expect slightly different things in the returned values. I consider this a bug, but I can't change it without changing the C code, something I'm not comfortable with.
@iconara
Copy link
Member

iconara commented Oct 23, 2015

My opinion on how this should work is now in #92

@tagomoris
Copy link
Member Author

@iconara Thank you! I'm checking it.

* class is lookup key for Packer (and also key for Hash from registered_types_internal)
* typeId is lookup key for Unpacker (and also key for Hash from registered_types_internal)
Because ext types for unpacker may be registered without class (just only with proc)
@tagomoris
Copy link
Member Author

@iconara Your code looks fine for me too.
And I've added just few changes to return compatible objects for registered_types_internal to make tests to pass. It doesn't requires so large patches.

I'll merge this branch into master, and then execute re-indentation with 4 spaces for 1 indent level (same with many Java code, like JRuby). Is it ok for you?

tagomoris added a commit that referenced this pull request Oct 23, 2015
add full spec ext type support to JRuby implementation
@tagomoris tagomoris merged commit 540fdb9 into master Oct 23, 2015
@tagomoris
Copy link
Member Author

Anyway, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants