WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 69156
Implicitly add toString and valueOf to prototype when convertToType callback is provided
https://bugs.webkit.org/show_bug.cgi?id=69156
Summary
Implicitly add toString and valueOf to prototype when convertToType callback ...
Mark Hahnenberg
Reported
2011-09-30 10:50:37 PDT
Due to the fact that JSCallbackObject overrides JSCell::toString, I don't believe we can do a simple refactoring to de-virtualize toString like we did with the other conversion methods. We'll just add it to the method table, at least for now. The first step in doing this is to create a static version of toString in the classes that override toString and have the virtual versions call it.
Attachments
Patch
(6.24 KB, patch)
2011-10-03 17:32 PDT
,
Mark Hahnenberg
no flags
Details
Formatted Diff
Diff
Test modification
(6.25 KB, patch)
2011-10-03 18:22 PDT
,
Mark Hahnenberg
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Gavin Barraclough
Comment 1
2011-09-30 15:07:42 PDT
I wonder if we really need to do this? ToString applied to Object (JSObject::toString) will try looking up a default value using the object's toString property, if one exists. For API objects that define a custom toString we could implicitly add a toString property to the object that is a host function that would call the API class's toString callback. This would allow us to retire the ability to override toString, and make API object behave more like normal objects.
Geoffrey Garen
Comment 2
2011-10-02 15:08:15 PDT
ggaren: mhahnenberg: i'd suggest a two-step process: [9:51pm] ggaren: mhahnenberg: (1) change API classes to supply a custom toString and valueOf on the class's prototype, which forwards to classDefinition.convertToType, if classDefinition.convertToType is supplied, and add tests to testapi verifying this behavior. [9:52pm] ggaren: mhahnenberg: (2) make toString non-virtual [9:53pm] ggaren: mhahnenberg: internally, you can reuse JSCallbackFunction to implement (1) [9:54pm] ggaren: mhahnenberg: you can have a shared JSObjectCallAsFunctionCallback for toString, and another for valueOf [9:54pm] ggaren: mhahnenberg: and they just take the 'this' object supplied, check that it inherits from JSCallbackObject, cast to JSCallbackObject, grab the convertToType function out of the JSCallbackObject's class, and call it, passing the right JSType parameter
Mark Hahnenberg
Comment 3
2011-10-03 17:32:57 PDT
Created
attachment 109561
[details]
Patch
Mark Hahnenberg
Comment 4
2011-10-03 18:22:45 PDT
Created
attachment 109566
[details]
Test modification
Geoffrey Garen
Comment 5
2011-10-03 18:24:50 PDT
Comment on
attachment 109566
[details]
Test modification r=me
WebKit Review Bot
Comment 6
2011-10-04 12:01:13 PDT
Comment on
attachment 109566
[details]
Test modification Clearing flags on attachment: 109566 Committed
r96627
: <
http://trac.webkit.org/changeset/96627
>
WebKit Review Bot
Comment 7
2011-10-04 12:01:18 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug