Bug 115447 - Objective-C JavaScriptCore API should publicly support bridging to C
Summary: Objective-C JavaScriptCore API should publicly support bridging to C
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Geoffrey Garen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-30 14:37 PDT by Geoffrey Garen
Modified: 2013-05-14 13:46 PDT (History)
1 user (show)

See Also:


Attachments
patch (50.57 KB, patch)
2013-04-30 14:43 PDT, Geoffrey Garen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2013-04-30 14:37:23 PDT
Objective-C JavaScriptCore API should publicly support bridging to C
Comment 1 Geoffrey Garen 2013-04-30 14:43:16 PDT
Created attachment 200150 [details]
patch
Comment 2 Mark Hahnenberg 2013-04-30 14:49:56 PDT
Comment on attachment 200150 [details]
patch

r=me
Comment 3 Geoffrey Garen 2013-04-30 14:54:41 PDT
Committed r149401: <http://trac.webkit.org/changeset/149401>
Comment 4 Timothy Hatcher 2013-04-30 18:48:19 PDT
Comment on attachment 200150 [details]
patch

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

> Source/JavaScriptCore/API/JSContext.h:124
> +// Creates a JSContext, wrapping its C API counterpart.
> ++ (JSContext *)contextWithJSGlobalContextRef:(JSGlobalContextRef)jsGlobalContextRef;
> +// Returns the C API counterpart wrapped by a JSContext.
> +- (JSGlobalContextRef)JSGlobalContextRef;

I'm not sure I like these method names. globalContextRef and contextWithGlobalContextRef: are more ObjC-like.

> Source/JavaScriptCore/API/JSContext.mm:52
> -- (JSGlobalContextRef)globalContextRef
> +- (JSGlobalContextRef)JSGlobalContextRef

Keep it like you had before!

> Source/JavaScriptCore/API/JSContext.mm:100
> -    return [JSValue valueWithValue:result inContext:self];
> +    return [JSValue valueWithJSValueRef:result inContext:self];

No…!
Comment 5 Geoffrey Garen 2013-04-30 19:44:03 PDT
Here are the four functions we're considering in context:

@interface JSValue(JSValueRefSupport)
+ (JSValue *)valueWithJSValueRef:(JSValueRef)value inContext:(JSContext *)context;
- (JSValueRef)JSValueRef;
@end

@interface JSContext(JSContextRefSupport)
+ (JSContext *)contextWithJSGlobalContextRef:(JSGlobalContextRef)jsGlobalContextRef;
- (JSGlobalContextRef)JSGlobalContextRef;
@end

If we switched away from type names for functions, what would we name the up-conversion and down-conversion functions in JSValue?
Comment 6 Mark Hahnenberg 2013-05-14 11:39:48 PDT
Comment on attachment 200150 [details]
patch

Clearing flags.
Comment 7 Geoffrey Garen 2013-05-14 13:46:07 PDT
We discussed this in IRC and decided to keep the names as-is, since bare words "value" and "context" alone would probably be too terse, to the point of conflicting with things like NSValue and CGContext.