Bug 105892 - Objective-C API: Objective-C functions exposed to JavaScript have the wrong type (object instead of function)
Summary: Objective-C API: Objective-C functions exposed to JavaScript have the wrong t...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-31 23:45 PST by Gavin Barraclough
Modified: 2013-03-14 14:40 PDT (History)
4 users (show)

See Also:


Attachments
Patch (20.80 KB, patch)
2013-03-11 16:26 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (22.34 KB, patch)
2013-03-11 16:42 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (22.38 KB, patch)
2013-03-11 16:59 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (22.37 KB, patch)
2013-03-11 17:36 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin Barraclough 2012-12-31 23:45:40 PST
The current implementation ttys to implement a JavaScript Function object via the C-API - it does so imperfectly.
Comment 1 Geoffrey Garen 2013-01-03 15:58:51 PST
ObjCCallbackFunction should subclass JSFunction or InternalFunction.
Comment 2 Mark Hahnenberg 2013-03-11 16:26:20 PDT
Created attachment 192590 [details]
Patch
Comment 3 Early Warning System Bot 2013-03-11 16:36:28 PDT
Comment on attachment 192590 [details]
Patch

Attachment 192590 [details] did not pass qt-ews (qt):
Output: http://webkit-commit-queue.appspot.com/results/17121421
Comment 4 Early Warning System Bot 2013-03-11 16:38:44 PDT
Comment on attachment 192590 [details]
Patch

Attachment 192590 [details] did not pass qt-wk2-ews (qt):
Output: http://webkit-commit-queue.appspot.com/results/17178092
Comment 5 Mark Hahnenberg 2013-03-11 16:42:18 PDT
Created attachment 192592 [details]
Patch
Comment 6 Early Warning System Bot 2013-03-11 16:53:27 PDT
Comment on attachment 192592 [details]
Patch

Attachment 192592 [details] did not pass qt-ews (qt):
Output: http://webkit-commit-queue.appspot.com/results/17013883
Comment 7 Early Warning System Bot 2013-03-11 16:54:14 PDT
Comment on attachment 192592 [details]
Patch

Attachment 192592 [details] did not pass qt-wk2-ews (qt):
Output: http://webkit-commit-queue.appspot.com/results/17177390
Comment 8 Mark Hahnenberg 2013-03-11 16:59:10 PDT
Created attachment 192596 [details]
Patch
Comment 9 Early Warning System Bot 2013-03-11 17:13:14 PDT
Comment on attachment 192596 [details]
Patch

Attachment 192596 [details] did not pass qt-ews (qt):
Output: http://webkit-commit-queue.appspot.com/results/17149383
Comment 10 Early Warning System Bot 2013-03-11 17:18:38 PDT
Comment on attachment 192596 [details]
Patch

Attachment 192596 [details] did not pass qt-wk2-ews (qt):
Output: http://webkit-commit-queue.appspot.com/results/17024541
Comment 11 Mark Hahnenberg 2013-03-11 17:36:00 PDT
Created attachment 192606 [details]
Patch
Comment 12 Mark Hahnenberg 2013-03-11 18:05:16 PDT
<rdar://problem/12954243>
Comment 13 Geoffrey Garen 2013-03-12 09:06:03 PDT
Comment on attachment 192606 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=192606&action=review

r=me

> Source/JavaScriptCore/API/ObjCCallbackFunction.mm:586
> +    return toRef(JSC::ObjCCallbackFunction::create(exec, exec->lexicalGlobalObject(), "Objective-C", impl.release()));

Should we just leave the function anonymous, instead? I agree that at the JS-mangled selector name would be better, but I don't think "Objective-C" adds all that much.

> Source/JavaScriptCore/API/tests/testapi.mm:526
> +        JSValue *result = [context evaluateScript:@"Function.prototype.toString.call(testObject.callback)"];
> +        checkResult(@"callback function typeof", !context.exception && ![result isUndefined]);

This test doesn't actually test typeof. You should name this test "toString', and write a separate test line for typeof that shows it's "Function".
Comment 14 Mark Hahnenberg 2013-03-14 14:16:14 PDT
Committed r145848: <http://trac.webkit.org/changeset/145848>
Comment 15 Mark Hahnenberg 2013-03-14 14:40:09 PDT
Comment on attachment 192606 [details]
Patch

Clearing flags.