Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does two things for defining modules and classes:
The new API itself is intended to allow composition through method functions in a builder style. For this old code:
Now looks like:
So by chaining in a builder style we remove a lot of repetition and the need to debate on variable names (at least a good portion of the time).
In doing this I realized someone had started the tradition of making the variable name match the Ruby name. So instead of
objectClassit would beObject. This convention is not 100% possible but it is pretty close. This PR adopts this when possible and changes the name when it isn't. It makes the reading of these definition feel more DSLish.Another thing I changed was create functions tend to pass in what they use in the definition. So passing in, for example, Enumerable module as a parameter:
runtime.getObjectorobjectClass(context)in new API terms).The main risk here is largely that I did change non-private signatures related to creating our types internally. I cannot think of a possible reason anyone would be trying to call our bootstrapping methods. I think this is safe.
There are a couple of methods which accept ThreadContext but do not use them. The intention here is that I know beneath the covers we are using context or runtime. These should be pushed through where possible. The primal uses might force us to always have runtime very deep in some methods but we need to keep pushing runtime out in favor of thread context.
Speaking of ThreadContext we need to figure out a way of reducing the few classes above to get closer to being runtime free for all definition. I am not sure it is possible but I think we can get so close perhaps we have some duplicated logic only for them and the rest of the system happily is using context-based APIs.
I am certain there are more methods in module,class,irubyobject,basicobject which should be marked as @JRubyAPI and possibly replaced with the composable style. I did get almost everything in this massive PR