Conversation
| var object = #{allocate}; | ||
| var object; | ||
|
|
||
| if (self.$$bridge && self.$allocate == Opal.Class.prototype.$allocate) { |
There was a problem hiding this comment.
What if... we subclass a bridged class?
class Array < `Array`; end
class MyArray < Array; end
class YourArray < MyArray; end(The lack of awareness of that edge case caused in the past a hard-to-debug issue where we missed backtraces in Firefox - due to not launching a constructor - if Exception was subclassed more than once - see #2540 ).
There was a problem hiding this comment.
For comparison, we have something that's called pristine methods. This is an option for us to define a method to be unmodified from the default implementation. Perhaps this is a better idea.
There was a problem hiding this comment.
Alright, i will pay attention to that case, i still need to understand better whats going on
|
Also, take a look at the prior work on this matter: |
|
So the last patch makes bridge for subclasses work and no longer cuts of the prototype chain There are still issues though |
|
At this stage the following works: require 'engine'
# Engine now allow access to globalThis, so in the browser for example
Engine.history.length # -> 2manually in the browser console in js: #send is required, because method_missing is used |
|
further works: the last one in js: |
| message = message.chop | ||
| property_name = ::Engine.property_for_message(message, self) | ||
| arg = args[0] | ||
| arg = arg.to_n if `arg && typeof arg.$to_n === 'function'` |
There was a problem hiding this comment.
what if $to_n is a stub? It's still a function then.
|
I kind of fail to understand what Opal::Engine does. Is it yet another wrapping solution? Wouldn't it be a better idea to split that to another PR? |
|
Possibly, its handy for testing things, as its the goal to have automatic, easy and compact access to JS APIs and values. Once everything is working i may make that another PR or not, we will see |
|
For correctness when using Engine for testing the bridges proeprties must be accessed by [], eg: May work more or less, anymway |
No description provided.