-
Notifications
You must be signed in to change notification settings - Fork 810
Module#prepend #2885
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
Module#prepend #2885
Conversation
Currently kind_of fails miserably, still looking for the reason
And of course, some of them fail miserably
Not sure if this apart of the ISO standard, so make sure its not misrepresented
Prepended modules would include their origin ICLASS
Also tried to fix it, however the problem lies with how aliased methods are done and their internal structure. mruby simply aliases methods by grabbing the RProc and giving it a new name, super then determines the original method to call by using the name so a method called m, aliased as m2, will call the m2 super method instead of m
Based on the gc patch by ko1 ruby/ruby@5922c95
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)(c->flags & 0xff) | ||
// TODO: figure out where to put user flags | ||
#define MRB_FLAG_IS_ORIGIN (1 << 20) | ||
#define MRB_FLAG_IS_INSTANCE (0xFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think MRB_FLAG_IS_INSTANCE
should be renamed to MRB_INSTANCE_TT_MASK
since it's a mask for instance type tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@take-cheeze Ah, right, okay, I've changed it, can you review again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IceDragon200 LGTM
Thank you for the implementation. I will merge this. But I need at least a few days to review the patch, sinch the change is huge. |
} | ||
|
||
MRB_API void | ||
mrb_prepend_module(mrb_state *mrb, struct RClass *c, struct RClass *m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static
or declare it in a header: mruby.h
like mrb_include_module()
or maybe even mruby/class.h
because it won't be used that often.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, we missed that one, thanks!
Since I can't forsee any reason to use it directly inplace of using prepend/include
Hi @matz, sorry for the bother, any updates on this? |
Finally I took time to review this pull request. Sorry for being so late. The PR seems fine except for on thing. You have added If you are willing to address this issue, I'd love to wait. If you are not, I will take time to fix, but you may have to wait longer in this case. |
Hi @matz, in the original pull request description we pointed out "RClass struct size is now bigger, because we needed to add origin, but that seems unavoidable." I'd be happy to try and implement an alternative, however I have no idea how that would look like. |
A golden opportunity to remove |
🎉 🎈 🎉 thanks matz! |
@matz, sure, but segregating into a small number of object types, say, |
Hi, we requested Module#prepend, so about a year later we figured what the heck and went ahead and implemented it.
We've gone and ported over the original ruby commits by ko1 and nobu over to mruby, all tests currently pass. RClass struct size is now bigger, because we needed to add
origin
, but that seems unavoidable./cc @matz @cremno @zzak
Closes #2082.